/* ksformat pkgdown site theme — "the site is the output"
 * Adapted from the ksTFL site theme: the documentation reads like the
 * formatted outputs the package produces — numbered report sections, serif
 * headings, booktabs-style tables, a footer page-band — wearing the ksformat
 * brand palette: navy #173147 with gold #d59b3d / amber #f1a340 accents,
 * taken from the logo and the hero animation.
 * Auto-loaded by pkgdown BS5 from pkgdown/extra.css
 */

/* ── Brand accent strip (top of every page) ────────────── */
body::before {
    content: "";
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(to right, #173147 0%, #d59b3d 60%, #d0d0d0 100%);
    z-index: 9999;
}

/* ── Navbar refinements ─────────────────────────────────── */
.navbar {
    border-bottom: 1px solid rgba(23, 49, 71, 0.15);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

/* ── Code blocks ────────────────────────────────────────── */
pre {
    /* quiet paper look: hairline frame, no accent stripe */
    border: 1px solid #dfe3e8;
    border-radius: 6px;
    font-variant-ligatures: none;
    box-shadow: none;
}

code {
    font-family: "Consolas", "SFMono-Regular", "Menlo", monospace;
    font-variant-ligatures: none;
}

/* code blocks: compact across the whole site (anchored + code element, because
   pkgdown/bslib set pre/code font-size with id-level specificity) */
main#main pre,
main#main pre code,
div.sourceCode pre,
div.sourceCode pre code {
    font-size: 0.82rem;
}

/* ── Document identity: serif headings + numbered sections ─
 * Articles read like a report: H2 gets "n.", H3 gets "n.m" via CSS
 * counters. Articles that carry their OWN numbering in the headings
 * opt out with a .self-numbered marker element at the top of the body. */
main#main h2,
main#main h3,
main#main h4 {
    font-family: "Source Serif 4", "Crimson Pro", Georgia, "Times New Roman", serif;
}

main#main {
    counter-reset: ksec;
}

main#main h2 {
    font-weight: 600;
    font-size: clamp(1.45rem, 2.2vw, 1.8rem);
    counter-increment: ksec;
    counter-reset: ksub;
    border-bottom: 1px solid rgba(23, 49, 71, 0.35);
    padding-bottom: 0.35em;
    margin-top: 3.4em;
    margin-bottom: 1.3em;
}

main#main h2::before {
    content: counter(ksec) ". ";
    color: #173147;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

main#main h3 {
    font-weight: 600;
    counter-increment: ksub;
    color: #264760;
}

main#main h3::before {
    content: counter(ksec) "." counter(ksub) "  ";
    color: rgba(23, 49, 71, 0.65);
    font-size: 0.85em;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

main#main h4 {
    color: #173147;
}

/* Reference topics keep their own structure: no section numbers there. */
.template-reference-topic main#main h2::before,
.template-reference-topic main#main h3::before {
    content: none;
}

/* Reference index / article index pages are listings, not reports. */
.template-reference-index main#main h2::before,
.template-article-index main#main h2::before,
.template-news main#main h2::before {
    content: none;
}

/* The changelog is not a report: no numbering at all on news pages. */
.template-news main#main h3::before {
    content: none;
}

.template-news main#main h2 {
    counter-increment: none;
}

.template-news main#main h3 {
    counter-increment: none;
}

/* Pages whose sources number their own headings: no CSS prefixes.
 * Specificity must reach main#main (id) to beat the base ::before rules. */
main#main:has(.self-numbered) h2::before,
main#main:has(.self-numbered) h3::before {
    content: none;
}

/* ── Sidebar TOC ────────────────────────────────────────── */

/* Move sidebar to the left on all pages that have one */
.template-article>.row>aside,
.template-article-index>.row>aside,
.template-reference-topic>.row>aside {
    order: -1;
}

/* Smaller, refined TOC text */
aside nav#toc {
    font-size: 0.84rem;
    line-height: 1.5;
}

aside nav#toc h2 {
    font-size: 0.92rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #666;
    margin-bottom: 0.5em;
}

aside nav#toc a {
    color: #444;
    transition: color 0.15s;
}

aside nav#toc a:hover {
    color: #b57f2a;
}

aside nav#toc a.active {
    border-left-color: #d59b3d;
    color: #173147;
    font-weight: 600;
}

/* ── Blockquotes: "note" boxes of a report ──────────────── */
blockquote {
    border-left: 4px solid #d59b3d;
    background: #faf6ee;
    border-radius: 0 6px 6px 0;
    padding: 0.6em 1em;
    font-family: "Source Serif 4", "Crimson Pro", Georgia, "Times New Roman", serif;
}

/* ── Tables: the package's booktabs grammar ───────────────
 * No vertical rules, no fill; a strong top rule, a mid rule
 * under the header, a bottom rule. Small-caps column labels,
 * tabular figures — like a TFL page. */
.table,
main#main table {
    border: none;
    border-radius: 0;
    overflow: visible;
    border-collapse: collapse;
    border-spacing: 0;
    font-size: 0.92em;
    font-variant-numeric: tabular-nums lining-nums;
    border-top: 2px solid #173147;
    border-bottom: 2px solid #173147;
}

.table>thead>tr>th,
main#main table thead th {
    background: transparent;
    color: #173147;
    font-weight: 700;
    font-size: 0.88em;
    letter-spacing: 0.03em;
    font-variant-caps: all-small-caps;
    padding: 0.5em 0.9em 0.4em;
    border: none;
    border-bottom: 1px solid #173147;
}

.table>tbody>tr>td,
main#main table tbody td {
    padding: 0.45em 0.9em;
    border: none;
    color: #24292f;
}

/* zebra removed on purpose: booktabs relies on whitespace, not shading */
.table>tbody>tr:nth-child(even) {
    background: transparent;
}

.table>tbody>tr:hover {
    background: rgba(213, 155, 61, 0.08);
}

.table>tbody>tr>td:first-child {
    font-weight: 500;
}

.table>tbody>tr>td code {
    font-size: 0.85em;
    background: #eef1f4;
    padding: 0.1em 0.35em;
    border-radius: 3px;
}

/* ── Article images ─────────────────────────────────────── */
main#main img {
    display: block;
    margin: 1em auto;
    max-width: 100%;
    border-radius: 6px;
    border: 1px solid #e1e4e8;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

main#main img[src*="logo"] {
    border: none;
    box-shadow: none;
}

/* ── Home hero (pkgdown/index.md) ───────────────────────
 * Dark "cover page" band: echoes the logo animation's background
 * and makes the hero GIF read as intentional rather than floating. */
.kshero {
    background: radial-gradient(120% 140% at 50% 0%, #1c3a4f 0%, #0c1a28 70%);
    color: #dce7f2;
    margin: -1rem -1rem 1.6rem;
    padding: 2.6rem 1.5rem 2.2rem;
    text-align: center;
    border-radius: 10px;
}

/* narrow screens: the container has no gutters to bleed into - avoid overflow */
@media (max-width: 575.98px) {
    .kshero {
        margin: 0 0 1.4rem;
        padding: 2rem 1rem 1.7rem;
    }
}

.kshero img {
    margin: 0 auto;
    border: none;
    box-shadow: none;
}

.kshero-logo {
    max-width: min(560px, 100%);
    height: auto;
    border-radius: 8px;
}

.kshero-tag {
    font-family: "Source Serif 4", "Crimson Pro", Georgia, "Times New Roman", serif;
    font-size: 1.25rem;
    line-height: 1.45;
    margin: 1.1rem auto 1.4rem;
    max-width: 34em;
    color: #eaf1f8;
}

.kshero-cta .btn {
    margin: 0 0.35rem;
    font-weight: 600;
    border-radius: 999px;
    padding: 0.5rem 1.35rem;
}

.btn-ksformat {
    background: #d59b3d;
    color: #173147;
    border: 1px solid #d59b3d;
}

.btn-ksformat:hover {
    background: #e2b055;
    color: #10233a;
}

.btn-ksformat-ghost {
    background: transparent;
    color: #f0e3c8;
    border: 1px solid rgba(240, 227, 200, 0.5);
}

.btn-ksformat-ghost:hover {
    border-color: #fff;
    color: #fff;
}

/* ── Footer: page band like a running footer ────────────── */
footer {
    border-top: 2px solid rgba(23, 49, 71, 0.4);
    font-variant-numeric: tabular-nums;
}

footer p {
    letter-spacing: 0.02em;
}

/* ── Selection highlight ────────────────────────────────── */
::selection {
    background: rgba(213, 155, 61, 0.18);
}

/* ── Scrollbar in code blocks ───────────────────────────── */
pre::-webkit-scrollbar {
    height: 6px;
}

pre::-webkit-scrollbar-thumb {
    background: #c0c8d0;
    border-radius: 3px;
}

pre::-webkit-scrollbar-thumb:hover {
    background: #173147;
}

/* ── Dark mode ──────────────────────────────────────────── */
/* Mirrors the light theme but brightens the brand accents
 * (#f1a340 gold, #7FB3D5 steel) and darkens surfaces. Applies only when
 * the pkgdown page is in dark mode (BS5 sets data-bs-theme="dark"). */
[data-bs-theme="dark"] main#main h2 {
    border-bottom-color: rgba(241, 163, 64, 0.4);
}

[data-bs-theme="dark"] main#main h3 {
    color: #cfe2f5;
}

[data-bs-theme="dark"] main#main h2::before,
[data-bs-theme="dark"] main#main h3::before {
    color: #f1a340;
}

[data-bs-theme="dark"] .table,
[data-bs-theme="dark"] main#main table {
    border-top-color: #f1a340;
    border-bottom-color: #f1a340;
}

[data-bs-theme="dark"] .table>thead>tr>th,
[data-bs-theme="dark"] main#main table thead th {
    background: transparent;
    color: #cfe2f5;
    border-bottom-color: #f1a340;
}

[data-bs-theme="dark"] .table>tbody>tr>td {
    color: #d6d9e0;
}

/* Same rules in the higher-specificity (ID-anchored) form, otherwise the
   light-mode `main#main table ...` declarations win in dark mode. */
[data-bs-theme="dark"] main#main table {
    border-top-color: #f1a340;
    border-bottom-color: #f1a340;
}

[data-bs-theme="dark"] main#main table thead th {
    background: transparent;
    color: #cfe2f5;
    border-bottom-color: #f1a340;
}

[data-bs-theme="dark"] main#main table tbody td {
    color: #d6d9e0;
}

[data-bs-theme="dark"] .table>tbody>tr:nth-child(even) {
    background: transparent;
}

[data-bs-theme="dark"] .table>tbody>tr:hover {
    background: rgba(241, 163, 64, 0.12);
}

[data-bs-theme="dark"] .table>tbody>tr>td code {
    background: #2c333d;
}

[data-bs-theme="dark"] pre {
    border-color: #3a3f4b;
}

[data-bs-theme="dark"] blockquote {
    border-left-color: #f1a340;
    background: rgba(48, 41, 28, 0.5);
}

[data-bs-theme="dark"] main#main img {
    border-color: #3a3f4b;
}

[data-bs-theme="dark"] .kshero {
    border: 1px solid rgba(241, 163, 64, 0.25);
}

[data-bs-theme="dark"] aside nav#toc h2 {
    color: #aab0bc;
}

[data-bs-theme="dark"] aside nav#toc a {
    color: #aab0bc;
}

[data-bs-theme="dark"] aside nav#toc a:hover,
[data-bs-theme="dark"] aside nav#toc a.active {
    color: #f1a340;
    border-left-color: #f1a340;
}

[data-bs-theme="dark"] pre::-webkit-scrollbar-thumb {
    background: #4a4f5b;
}

[data-bs-theme="dark"] pre::-webkit-scrollbar-thumb:hover {
    background: #f1a340;
}

[data-bs-theme="dark"] footer {
    border-top-color: rgba(241, 163, 64, 0.45);
}
