/* The docs pages (rendered by scripts/build-docs.mjs). Colors and type match index.html. */

:root {
    color-scheme: light dark;
    --bg: #f5f4f0;
    --surface: #ffffff;
    --surface-2: #f4f5f7;
    --text: #1d2635;
    --text-muted: #5d6879;
    --border: #e2e4e9;
    --accent: #2f5aa8;
    --accent-hover: #264b8f;
    --accent-soft: #e9effa;
    --accent-text: #ffffff;
    --code-bg: #f4f5f7;
    --shadow: 0 1px 2px rgba(29, 38, 53, 0.04), 0 8px 24px rgba(29, 38, 53, 0.06);
    --radius: 16px;
    --font-sans: ui-sans-serif, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, 'Liberation Mono', monospace;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #12151a;
        --surface: #191d24;
        --surface-2: #20252e;
        --text: #e5e9f0;
        --text-muted: #9aa4b4;
        --border: #2b313b;
        --accent: #7ea3f7;
        --accent-hover: #9ab7fa;
        --accent-soft: rgba(126, 163, 247, 0.12);
        --accent-text: #0f1626;
        --code-bg: #20252e;
        --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.25);
    }
}

*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-sans);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
}

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 6px;
}

.skip-link {
    position: absolute;
    left: 12px;
    top: -48px;
    z-index: 200;
    padding: 8px 12px;
    border-radius: 8px;
    background: var(--accent);
    color: var(--accent-text);
    text-decoration: none;
}

.skip-link:focus {
    top: 12px;
}

/* ---------- Top bar ---------- */

.topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    height: 60px;
    padding: 0 24px;
    background: color-mix(in srgb, var(--bg) 82%, transparent);
    backdrop-filter: saturate(160%) blur(12px);
    -webkit-backdrop-filter: saturate(160%) blur(12px);
    border-bottom: 1px solid var(--border);
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: -0.01em;
    color: inherit;
    text-decoration: none;
}

.brand-mark {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--accent-soft);
    object-fit: contain;
    padding: 2px;
}

.topbar-nav {
    display: flex;
    align-items: center;
    gap: 4px;
}

.topbar-nav a:not(.btn) {
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-muted);
    text-decoration: none;
}

.topbar-nav a:not(.btn):hover,
.topbar-nav a.current-section,
.topbar-nav a[aria-current] {
    color: var(--text);
}

.btn {
    display: inline-flex;
    align-items: center;
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1;
    border-radius: 10px;
    padding: 10px 16px;
    margin-left: 8px;
    text-decoration: none;
    transition: background-color 0.15s ease;
}

.btn-primary {
    background: var(--accent);
    color: var(--accent-text);
}

.btn-primary:hover {
    background: var(--accent-hover);
}

/* ---------- Layout ---------- */

.docs-layout {
    flex: 1;
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr);
    gap: 32px;
    width: 100%;
    max-width: 1140px;
    margin: 0 auto;
    padding: 32px 24px 48px;
}

.docs-nav ul {
    position: sticky;
    top: 92px;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.docs-nav a {
    display: block;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.92rem;
    color: var(--text-muted);
    text-decoration: none;
}

.docs-nav a:hover {
    color: var(--text);
    background: var(--surface-2);
}

.docs-nav a[aria-current="page"] {
    color: var(--accent);
    background: var(--accent-soft);
    font-weight: 600;
}

/* ---------- Content ---------- */

.docs-content {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 48px 56px;
    font-size: 1.0625rem;
    line-height: 1.7;
    overflow-wrap: break-word;
}

.docs-content h1,
.docs-content h2,
.docs-content h3,
.docs-content h4 {
    line-height: 1.25;
    letter-spacing: -0.02em;
    margin: 1.8em 0 0.6em;
    scroll-margin-top: 80px;
}

.docs-content h1 {
    font-size: 2.25rem;
    letter-spacing: -0.03em;
    margin-top: 0;
}

.docs-content h2 {
    font-size: 1.5rem;
    padding-bottom: 0.35em;
    border-bottom: 1px solid var(--border);
}

.docs-content h3 { font-size: 1.2rem; }
.docs-content h4 { font-size: 1.05rem; }

.heading-anchor {
    float: left;
    margin-left: -1em;
    width: 1em;
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 400;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.docs-content :is(h2, h3, h4):hover .heading-anchor,
.heading-anchor:focus-visible {
    opacity: 1;
}

.docs-content p,
.docs-content ul,
.docs-content ol,
.docs-content blockquote,
.docs-content pre,
.docs-content table {
    margin-bottom: 1.1em;
}

.docs-content ul,
.docs-content ol {
    padding-left: 1.5em;
}

.docs-content li + li {
    margin-top: 0.3em;
}

.docs-content li > ul,
.docs-content li > ol {
    margin: 0.3em 0 0;
}

.docs-content a {
    color: var(--accent);
    text-decoration: underline;
    text-decoration-color: color-mix(in srgb, var(--accent) 35%, transparent);
    text-underline-offset: 3px;
}

.docs-content a:hover {
    text-decoration-color: currentColor;
}

.docs-content code {
    font-family: var(--font-mono);
    font-size: 0.86em;
    background: var(--code-bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.12em 0.4em;
}

.docs-content pre {
    background: var(--code-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px 20px;
    overflow-x: auto;
    line-height: 1.5;
}

.docs-content pre code {
    font-size: 0.85rem;
    background: none;
    border: 0;
    padding: 0;
}

.docs-content kbd {
    font-family: var(--font-sans);
    font-size: 0.85em;
    padding: 0.1em 0.45em;
    border: 1px solid var(--border);
    border-bottom-width: 2px;
    border-radius: 6px;
    background: var(--surface-2);
    white-space: nowrap;
}

.docs-content blockquote {
    padding: 12px 18px;
    border-left: 4px solid var(--accent);
    border-radius: 0 10px 10px 0;
    background: var(--accent-soft);
}

.docs-content blockquote > :last-child {
    margin-bottom: 0;
}

.docs-content table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
    display: block;
    overflow-x: auto;
}

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

.docs-content th {
    font-weight: 650;
    background: var(--surface-2);
}

.docs-content img {
    max-width: 100%;
    height: auto;
    border: 1px solid var(--border);
    border-radius: 12px;
}

.docs-content .docs-video {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
    margin: 1.5em 0;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface-2);
}

.docs-content hr {
    border: 0;
    border-top: 1px solid var(--border);
    margin: 2em 0;
}

/* ---------- Footer ---------- */

.footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    width: 100%;
    max-width: 1140px;
    margin: 0 auto;
    padding: 20px 24px 28px;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.footer-credit a {
    color: inherit;
    font-weight: 600;
    text-decoration: none;
}

.footer-links {
    display: flex;
    gap: 4px;
}

.footer-links a {
    display: flex;
    padding: 8px;
    border-radius: 8px;
    opacity: 0.7;
    transition: opacity 0.15s ease, background-color 0.15s ease;
}

.footer-links a:hover {
    opacity: 1;
    background: var(--surface-2);
}

.footer-icon {
    width: 18px;
    height: 18px;
}

@media (prefers-color-scheme: dark) {
    .footer-icon {
        filter: invert(1);
    }
}

/* ---------- Narrow screens ---------- */

@media (max-width: 760px) {
    .topbar {
        padding: 0 14px;
        gap: 8px;
    }

    .brand span {
        display: none;
    }

    .topbar-nav a:not(.btn) {
        padding: 8px;
    }

    .btn {
        padding: 9px 12px;
        margin-left: 4px;
    }

    .docs-layout {
        grid-template-columns: minmax(0, 1fr);
        gap: 16px;
        padding: 16px 12px 32px;
    }

    /* The page list becomes a row that scrolls sideways above the page. */
    .docs-nav ul {
        position: static;
        flex-direction: row;
        overflow-x: auto;
        gap: 4px;
        padding-bottom: 4px;
    }

    .docs-nav a {
        white-space: nowrap;
        border: 1px solid var(--border);
    }

    .docs-content {
        padding: 28px 20px;
        font-size: 1rem;
    }

    .docs-content h1 {
        font-size: 1.8rem;
    }

    .heading-anchor {
        display: none;
    }

    .footer {
        justify-content: center;
        text-align: center;
    }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        transition: none !important;
    }
}
