/* docs.css — layout and typography for docs.html (everything inside main.docs).
   The nav bar, logo, footer, body background and base font belong to site.css /
   chrome.js. Colours come only from the tokens in tokens.css, so the dark and
   light themes both follow. */

.docs {
    --docs-top: 5.25rem;                 /* clearance under the site nav for sticky / anchors */
    --docs-mono: var(--font-m, ui-monospace, "JetBrains Mono", Consolas, monospace);
    --docs-head: var(--font-d, var(--font-b, system-ui, sans-serif));
    --docs-r: var(--radius, 10px);
    --docs-r-lg: var(--radius-lg, 14px);

    box-sizing: border-box;
    max-width: 1180px;
    margin: 0 auto;
    padding: 2.5rem 1.5rem 5rem;
    display: grid;
    grid-template-columns: 232px minmax(0, 1fr);
    gap: 3.5rem;
    align-items: start;
    color: var(--text);
    font-family: var(--font-b, system-ui, sans-serif);
    font-size: 16px;
    line-height: 1.7;
}

.docs *,
.docs *::before,
.docs *::after { box-sizing: border-box; }

/* ── Sidebar table of contents ───────────────────────────── */

.docs-toc {
    position: sticky;
    top: var(--docs-top);
    max-height: calc(100vh - var(--docs-top) - 1.5rem);
    overflow-y: auto;
    padding-right: 0.5rem;
    scrollbar-width: thin;
    scrollbar-color: var(--border2) transparent;
}

.docs-toc-title,
.docs-eyebrow {
    font-family: var(--docs-mono);
    font-size: 0.6875rem;
    font-weight: 500;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--muted);
}

.docs-toc-title { margin: 0 0 0.75rem; padding-left: 0.875rem; }

.docs-toc ol {
    list-style: none;
    margin: 0;
    padding: 0;
    border-left: 1px solid var(--border);
}

.docs-toc ol ol {
    border-left: 0;
    margin: 0 0 0.25rem;
}

.docs-toc a {
    display: block;
    margin-left: -1px;
    padding: 0.3rem 0 0.3rem 0.875rem;
    border-left: 1px solid transparent;
    color: var(--muted);
    font-size: 0.875rem;
    line-height: 1.4;
    text-decoration: none;
    transition: color 0.15s ease, border-color 0.15s ease;
}

.docs-toc ol ol a {
    padding-left: 1.625rem;
    font-size: 0.8125rem;
    color: var(--muted2);
}

.docs-toc a:hover { color: var(--text); }

.docs-toc a.is-active {
    color: var(--text);
    border-left-color: var(--accent);
}

/* ── Article ─────────────────────────────────────────────── */

.docs-article { min-width: 0; }

.docs-article > header { margin-bottom: 3rem; }

.docs-article h1 {
    margin: 0.5rem 0 1rem;
    font-family: var(--docs-head);
    font-size: clamp(2rem, 4.5vw, 2.75rem);
    font-weight: 600;
    line-height: 1.1;
    letter-spacing: -0.02em;
}

.docs-lede {
    max-width: 62ch;
    margin: 0;
    font-size: 1.125rem;
    line-height: 1.6;
    color: var(--muted);
}

.docs-article section {
    padding-top: 2.75rem;
    margin-top: 2.75rem;
    border-top: 1px solid var(--border);
}

.docs-article section,
.docs-article h3[id] { scroll-margin-top: var(--docs-top); }

.docs-article h2 {
    margin: 0.375rem 0 1rem;
    font-family: var(--docs-head);
    font-size: 1.625rem;
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: -0.015em;
}

.docs-article h3 {
    margin: 2.25rem 0 0.625rem;
    font-family: var(--docs-head);
    font-size: 1.1875rem;
    font-weight: 600;
    line-height: 1.3;
    letter-spacing: -0.01em;
}

.docs-article h4 {
    margin: 1.75rem 0 0.5rem;
    font-family: var(--docs-mono);
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--muted);
}

.docs-article p,
.docs-article ul,
.docs-article ol,
.docs-article dl { max-width: 72ch; margin: 0 0 1rem; }

.docs-article ul,
.docs-article ol { padding-left: 1.25rem; }

.docs-article li { margin: 0.3rem 0; }
.docs-article li::marker { color: var(--muted2); }

.docs-article strong { font-weight: 600; color: var(--text); }

.docs-article a {
    color: var(--text);
    text-decoration: underline;
    text-decoration-color: var(--accent);
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
}

.docs-article a:hover { color: var(--accent); }

.docs a:focus-visible,
.docs-table-wrap:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 3px;
}

/* ── Code, keys, pills ───────────────────────────────────── */

.docs code,
.docs kbd {
    font-family: var(--docs-mono);
    font-size: 0.8125em;
    padding: 0.125em 0.4em;
    border: 1px solid var(--border);
    border-radius: 5px;
    background: var(--card2);
    color: var(--text);
    white-space: nowrap;
}

.docs kbd { border-bottom-width: 2px; }

.docs pre {
    max-width: 72ch;
    margin: 0 0 1rem;
    padding: 0.875rem 1rem;
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--docs-r);
    background: var(--card2);
    font-family: var(--docs-mono);
    font-size: 0.8125rem;
    line-height: 1.6;
}

.docs pre code { padding: 0; border: 0; background: none; font-size: inherit; white-space: pre; }

.pill {
    display: inline-block;
    padding: 0.1em 0.55em;
    border: 1px solid var(--border2);
    border-radius: 999px;
    background: var(--card);
    color: var(--muted);
    font-family: var(--docs-mono);
    font-size: 0.6875rem;
    font-weight: 500;
    letter-spacing: 0.06em;
    line-height: 1.6;
    white-space: nowrap;
    vertical-align: 0.08em;
}

.pill--ok   { color: var(--ok);   border-color: color-mix(in srgb, var(--ok) 45%, transparent); }
.pill--warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 45%, transparent); }
.pill--err  { color: var(--err);  border-color: color-mix(in srgb, var(--err) 45%, transparent); }

/* ── Callouts ────────────────────────────────────────────── */

.callout {
    max-width: 72ch;
    margin: 1.25rem 0;
    padding: 0.875rem 1.125rem;
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    border-radius: 0 var(--docs-r) var(--docs-r) 0;
    background: var(--card);
    font-size: 0.9375rem;
    line-height: 1.6;
}

.callout > :last-child { margin-bottom: 0; }

.callout-title {
    display: block;
    margin-bottom: 0.25rem;
    font-family: var(--docs-mono);
    font-size: 0.6875rem;
    font-weight: 500;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--accent);
}

.callout--caution { border-left-color: var(--warn); }
.callout--caution .callout-title { color: var(--warn); }
.callout--note { border-left-color: var(--border2); }
.callout--note .callout-title { color: var(--muted); }

/* ── Tables ──────────────────────────────────────────────── */

.docs-table-wrap {
    margin: 1.25rem 0 1.5rem;
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--docs-r);
    background: var(--card);
}

.docs table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
    line-height: 1.5;
}

.docs th,
.docs td {
    padding: 0.625rem 0.875rem;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: top;
}

.docs tbody tr:last-child > * { border-bottom: 0; }

.docs thead th {
    background: var(--card2);
    font-family: var(--docs-mono);
    font-size: 0.6875rem;
    font-weight: 500;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--muted);
    white-space: nowrap;
}

.docs tbody th { font-weight: 600; white-space: nowrap; }

.docs td.num,
.docs th.num {
    font-family: var(--docs-mono);
    font-size: 0.8125rem;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.docs tr.group > th {
    padding-top: 0.875rem;
    background: transparent;
    font-family: var(--docs-mono);
    font-size: 0.6875rem;
    font-weight: 500;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--accent);
}

.table-params { min-width: 780px; }
.table-params td:last-child { min-width: 18rem; color: var(--muted); }
.table-wide { min-width: 620px; }

/* ── Cards, steps, figures ───────────────────────────────── */

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.875rem;
    margin: 1.25rem 0 1.5rem;
}

.card-grid > div {
    padding: 1rem 1.125rem;
    border: 1px solid var(--border);
    border-radius: var(--docs-r-lg);
    background: var(--card);
}

.card-grid h3 { margin: 0.25rem 0 0.375rem; font-size: 1.0625rem; }
.card-grid p  { margin: 0; font-size: 0.9375rem; line-height: 1.55; color: var(--muted); }

.steps {
    list-style: none;
    counter-reset: step;
    padding-left: 0 !important;
}

.steps > li {
    counter-increment: step;
    position: relative;
    margin: 0;
    padding: 0 0 1rem 2.75rem;
}

.steps > li::before {
    content: counter(step);
    position: absolute;
    left: 0;
    top: 0.1rem;
    width: 1.75rem;
    height: 1.75rem;
    display: grid;
    place-items: center;
    border: 1px solid var(--border2);
    border-radius: 50%;
    font-family: var(--docs-mono);
    font-size: 0.75rem;
    color: var(--accent);
}

/* Power path figure */
.flow {
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
    gap: 0.5rem;
    margin: 1.25rem 0 0.5rem;
    padding: 1.125rem;
    border: 1px solid var(--border);
    border-radius: var(--docs-r-lg);
    background: var(--card2);
}

.flow > div {
    flex: 1 1 140px;
    padding: 0.75rem 0.875rem;
    border: 1px solid var(--border);
    border-radius: var(--docs-r);
    background: var(--card);
    font-size: 0.875rem;
    line-height: 1.45;
    color: var(--muted);
}

.flow > div.flow-core { border-color: var(--accent); background: var(--glow); }

.flow b {
    display: block;
    margin-bottom: 0.125rem;
    font-family: var(--docs-mono);
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text);
}

.flow > span {
    flex: 0 0 auto;
    align-self: center;
    font-family: var(--docs-mono);
    color: var(--muted2);
}

.docs figcaption,
.docs-caption {
    max-width: 72ch;
    margin: 0 0 1.25rem;
    font-size: 0.8125rem;
    color: var(--muted);
}

.docs figure { margin: 0; }

.docs dl { display: grid; grid-template-columns: max-content 1fr; gap: 0.375rem 1.25rem; }
.docs dt { font-weight: 600; }
.docs dd { margin: 0; color: var(--muted); }

.faq h3 { margin-top: 1.75rem; font-size: 1.0625rem; }

/* ── Narrow screens ──────────────────────────────────────── */

@media (max-width: 900px) {
    .docs {
        grid-template-columns: minmax(0, 1fr);
        gap: 2rem;
        padding: 1.5rem 1rem 4rem;
    }

    .docs-toc {
        position: static;
        max-height: none;
        padding: 1rem 1.125rem;
        border: 1px solid var(--border);
        border-radius: var(--docs-r-lg);
        background: var(--card);
    }

    .docs-toc-title { padding-left: 0; }
    .docs-toc > ol { border-left: 0; columns: 2; column-gap: 1.5rem; }
    .docs-toc ol ol { display: none; }
    .docs-toc a { margin-left: 0; padding-left: 0; border-left: 0; }
    .docs-toc a.is-active { color: var(--muted); }

    .docs dl { grid-template-columns: 1fr; gap: 0; }
    .docs dd { margin-bottom: 0.625rem; }
}

@media (max-width: 480px) {
    .docs-toc > ol { columns: 1; }
    .docs { font-size: 15px; }
}

@media (prefers-reduced-motion: reduce) {
    .docs-toc a { transition: none; }
}

@media (prefers-reduced-motion: no-preference) {
    html:has(main.docs) { scroll-behavior: smooth; }
}

@media print {
    .docs { display: block; }
    .docs-toc { display: none; }
}
