/* FluxOS — Docs design tokens. Brand-level tokens (--accent + family) mirror
 * the canonical values in landing.css. Anything docs-specific (sidebar
 * width, table-of-contents styling) stays here. */

:root {
    --bg-base:      #050608;
    --bg-surface:   #0B0D11;
    --bg-overlay:   #1D2127;
    --bg-highlight: #1E2228;
    --bg-hover:     #1E2228;

    --text:         #F2F4F7;
    --text-dim:     #C7CCD3;
    --text-muted:   #8A929E;

    /* Electric green brand accent (canonical) */
    --accent:       #10F590;
    --accent-hover: #34FFA5;
    --accent-deep:  #00C275;
    --accent-soft:  rgba(16, 245, 144, 0.08);
    --accent-glow:  rgba(16, 245, 144, 0.22);

    /* Semantic colors — kept distinct from brand accent */
    --green:        #34d399;
    --red:          #fb7185;
    --yellow:       #fbbf24;
    --peach:        #fb923c;
    --mauve:        #a78bfa;
    --pink:         #f472b6;
    --teal:         #2dd4bf;

    --border:        #1F242C;
    --border-subtle: #14171C;

    --font-mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

    --radius:    8px;
    --radius-sm: 6px;
    --transition: 0.2s ease;

    --sidebar-width: 260px;
    --toc-width: 200px;
    --header-height: 52px;

    --glass-bg: rgba(12, 14, 20, 0.85);
    --glass-border: rgba(255, 255, 255, 0.06);

    /* Flux gradient */
    --gradient-flux: linear-gradient(135deg, var(--accent-deep), #8b5cf6, #a78bfa);
}

/* ── Light Mode ────────────────────────────────────────── */

[data-theme="light"] {
    --bg-base: #f8fafc;
    --bg-surface: #ffffff;
    --bg-overlay: #e2e8f0;
    --bg-highlight: #f1f5f9;
    --bg-hover: #e2e8f0;

    --text: #0f172a;
    --text-dim: #475569;
    --text-muted: #94a3b8;

    /* Light-mode accent — deeper electric green for AA contrast on white */
    --accent: #00B86F;
    --accent-hover: #00D67F;
    --accent-deep: #008A53;
    --accent-soft: rgba(0, 184, 111, 0.07);
    --accent-glow: rgba(0, 184, 111, 0.18);
    --green: #059669;
    --red: #e11d48;
    --yellow: #d97706;
    --peach: #ea580c;
    --mauve: #7c3aed;
    --pink: #db2777;
    --teal: #0d9488;

    --border: #e2e8f0;
    --border-subtle: #f1f5f9;

    --glass-bg: rgba(255, 255, 255, 0.9);
    --glass-border: rgba(0, 0, 0, 0.08);
}

/* ── Inline SVG icon base ─────────────────────────────────────────── */

.icon {
    display: inline-block;
    vertical-align: middle;
    flex-shrink: 0;
}

/* ── Reset ────────────────────────────────────────────────────────── */

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

html, body {
    height: 100%;
    overflow: hidden;
    font-family: var(--font-sans);
    font-size: 15px;
    line-height: 1.65;
    color: var(--text);
    background: var(--bg-base);
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--accent);
    text-decoration: none;
    transition: color var(--transition);
}
a:hover { color: var(--accent-hover); }

/* ── Scrollbar ────────────────────────────────────────────────────── */

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-highlight); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── Header ───────────────────────────────────────────────────────── */

#docs-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    height: var(--header-height);
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    gap: 16px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 20px;
    cursor: pointer;
    padding: 4px;
}

.header-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
}

.logo-star {
    color: var(--accent);
    width: 24px;
    height: 24px;
    filter: drop-shadow(0 0 6px rgba(16, 245, 144, 0.4));
}

.logo-text {
    font-weight: 700;
    font-size: 16px;
    letter-spacing: -0.3px;
    background: var(--gradient-flux);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.logo-label {
    background: var(--gradient-flux);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 4px;
    letter-spacing: 1px;
}

.header-center {
    flex: 1;
    max-width: 480px;
}

.search-box {
    display: flex;
    align-items: center;
    background: var(--bg-overlay);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 6px 12px;
    gap: 8px;
    cursor: text;
    transition: border-color var(--transition);
}
.search-box:focus-within {
    border-color: var(--accent);
}

.search-icon {
    display: inline-flex;
    align-items: center;
    color: var(--text-muted);
}

.search-box input {
    flex: 1;
    background: none;
    border: none;
    color: var(--text);
    font-family: var(--font-sans);
    font-size: 14px;
    outline: none;
}
.search-box input::placeholder { color: var(--text-muted); }

.search-shortcut, kbd {
    background: var(--bg-highlight);
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: 1px 6px;
    font-size: 11px;
    font-family: var(--font-mono);
    color: var(--text-muted);
    line-height: 1.4;
}

.header-right {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.theme-toggle-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    background: none;
    border: none;
    border-radius: 50%;
    color: var(--text-dim);
    cursor: pointer;
    transition: color var(--transition), background var(--transition);
}
.theme-toggle-btn:hover {
    color: var(--text);
    background: var(--bg-hover);
}
.theme-toggle-btn svg { overflow: visible; }

.header-link {
    color: var(--text-dim);
    font-size: 13px;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
}
.header-link:hover {
    color: var(--accent);
    background: var(--bg-overlay);
}

/* ── Layout ───────────────────────────────────────────────────────── */

#docs-layout {
    display: flex;
    margin-top: var(--header-height);
    height: calc(100vh - var(--header-height));
}

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

#docs-sidebar {
    width: var(--sidebar-width);
    flex-shrink: 0;
    background: var(--bg-surface);
    border-right: 1px solid var(--glass-border);
    overflow-y: auto;
    padding: 16px 0;
}

.nav-section {
    margin-bottom: 4px;
}

.nav-section-title {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 16px 6px 12px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-dim);
    cursor: pointer;
    user-select: none;
    transition: color var(--transition);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.nav-section-title:hover {
    color: var(--text);
}

.nav-chevron {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    transition: transform var(--transition);
    width: 14px;
}
.nav-section.expanded > .nav-section-title > .nav-chevron {
    transform: rotate(90deg);
}

.nav-children {
    display: none;
    padding-left: 8px;
}
.nav-section.expanded > .nav-children {
    display: block;
}

.nav-item {
    display: block;
    padding: 5px 16px 5px 28px;
    font-size: 13px;
    color: var(--text-dim);
    cursor: pointer;
    border-left: 2px solid transparent;
    transition: all var(--transition);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.nav-item:hover {
    color: var(--text);
    background: rgba(16, 245, 144, 0.06);
}
.nav-item.active {
    color: var(--accent);
    border-left-color: var(--accent);
    background: rgba(16, 245, 144, 0.1);
    font-weight: 500;
}

/* Nested sub-sections */
.nav-sub-section {
    margin-bottom: 2px;
}
.nav-sub-title {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 16px 5px 24px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-dim);
    cursor: pointer;
    transition: color var(--transition), background var(--transition);
    user-select: none;
    border-radius: 4px;
}
.nav-sub-title:hover { color: var(--text); background: rgba(16, 245, 144, 0.06); }

.nav-sub-children {
    display: none;
    padding-left: 8px;
}
.nav-sub-section.expanded > .nav-sub-children {
    display: block;
}
.nav-sub-section.expanded > .nav-sub-title > .nav-chevron {
    transform: rotate(90deg);
}

/* 3rd-level nav items (individual functions) */
.nav-sub-children .nav-sub-children .nav-item {
    padding-left: 36px;
    font-size: 12.5px;
    font-family: 'JetBrains Mono', monospace;
}
.nav-sub-children .nav-sub-children .nav-sub-title {
    padding-left: 32px;
    font-size: 12.5px;
}

/* Clickable function names in overview tables */
.fn-table a.fn-name-link {
    color: var(--accent);
    text-decoration: none;
    cursor: pointer;
    font-weight: 500;
}
.fn-table a.fn-name-link:hover {
    text-decoration: underline;
}

/* ── Main content ─────────────────────────────────────────────────── */

#docs-content {
    flex: 1;
    overflow-y: auto;
    padding: 24px 40px 80px;
    min-width: 0;
}

/* Breadcrumbs */
#docs-breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.breadcrumb-sep {
    color: var(--text-muted);
    font-size: 11px;
}
.breadcrumb-link {
    color: var(--text-dim);
    cursor: pointer;
    transition: color var(--transition);
}
.breadcrumb-link:hover { color: var(--accent); }
.breadcrumb-current {
    color: var(--text-dim);
}

/* Page content wrapper */
#docs-page {
    max-width: 800px;
}

/* ── Typography ───────────────────────────────────────────────────── */

.doc-h1 {
    font-size: 32px;
    font-weight: 700;
    color: var(--text);
    line-height: 1.3;
    margin-bottom: 16px;
}

.doc-h2 {
    font-size: 22px;
    font-weight: 600;
    color: var(--text);
    line-height: 1.35;
    margin-top: 40px;
    margin-bottom: 12px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border-subtle);
    scroll-margin-top: calc(var(--header-height) + 16px);
}

.doc-h3 {
    font-size: 17px;
    font-weight: 600;
    color: var(--text);
    line-height: 1.4;
    margin-top: 28px;
    margin-bottom: 8px;
    scroll-margin-top: calc(var(--header-height) + 16px);
}

.doc-text {
    color: var(--text);
    margin-bottom: 16px;
    line-height: 1.7;
}
.doc-text code {
    background: var(--bg-overlay);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 1px 5px;
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--accent-hover);
}

/* ── Syntax blocks ────────────────────────────────────────────────── */

.code-block {
    position: relative;
    background: var(--bg-overlay);
    border-radius: var(--radius);
    margin-bottom: 20px;
    overflow: hidden;
}

.code-block-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 14px;
    background: rgba(0, 0, 0, 0.15);
    border-bottom: 1px solid var(--border-subtle);
    font-size: 12px;
    color: var(--text-muted);
}

.code-block pre {
    padding: 16px 18px;
    overflow-x: auto;
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.6;
    tab-size: 4;
    color: var(--text);
}

.code-block.example-block {
    border-left: 3px solid;
    border-image: linear-gradient(180deg, var(--accent-deep), #8b5cf6) 1;
}

.copy-btn {
    position: absolute;
    top: 8px;
    right: 10px;
    background: var(--bg-highlight);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 12px;
    padding: 3px 8px;
    cursor: pointer;
    opacity: 0;
    transition: all var(--transition);
    z-index: 2;
}
.code-block:hover .copy-btn {
    opacity: 1;
}
.copy-btn:hover {
    background: var(--bg-overlay);
    color: var(--text);
}
.copy-btn.copied {
    color: var(--green);
}

/* Syntax highlighting tokens */
.tok-keyword   { color: var(--accent); font-weight: 600; }
.tok-type      { color: var(--mauve); }
.tok-function  { color: var(--green); }
.tok-string    { color: var(--pink); }
.tok-number    { color: var(--peach); }
.tok-comment   { color: var(--text-muted); font-style: italic; }
.tok-punct     { color: var(--peach); }
.tok-placeholder { color: var(--teal); }
.tok-operator  { color: var(--text); }

/* ── Callout boxes ────────────────────────────────────────────────── */

.callout {
    border-radius: var(--radius);
    padding: 14px 18px;
    margin-bottom: 20px;
    font-size: 14px;
    line-height: 1.65;
}
.callout code {
    background: rgba(0,0,0,0.15);
    border-radius: var(--radius-sm);
    padding: 1px 4px;
    font-family: var(--font-mono);
    font-size: 12px;
}

.callout-title {
    font-weight: 700;
    margin-bottom: 4px;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.callout.note {
    background: var(--bg-overlay);
    border: 1px solid var(--border);
}
.callout.note .callout-title { color: var(--text-dim); }

.callout.tip {
    background: rgba(16, 245, 144, 0.08);
    border: 1px solid rgba(16, 245, 144, 0.2);
}
.callout.tip .callout-title { color: var(--accent); }

.callout.important {
    background: rgba(251, 113, 133, 0.08);
    border: 1px solid rgba(251, 113, 133, 0.2);
}
.callout.important .callout-title { color: var(--red); }

.callout.warning {
    background: rgba(251, 146, 60, 0.08);
    border: 1px solid rgba(251, 146, 60, 0.2);
}
.callout.warning .callout-title { color: var(--peach); }

/* ── Parameter tables ─────────────────────────────────────────────── */

.params-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
    font-size: 14px;
}

.params-table th {
    text-align: left;
    padding: 10px 14px;
    background: var(--bg-surface);
    border-bottom: 2px solid var(--border);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-dim);
}

.params-table td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-subtle);
    vertical-align: top;
}

.params-table tr:last-child td {
    border-bottom: none;
}

.param-name {
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--accent-hover);
    font-weight: 500;
    white-space: nowrap;
}

.param-type {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--mauve);
    white-space: nowrap;
}

.param-required {
    font-size: 11px;
    color: var(--red);
    font-weight: 600;
}

.param-optional {
    font-size: 11px;
    color: var(--text-muted);
}

/* ── Function signature table ─────────────────────────────────────── */

.fn-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
    font-size: 14px;
}

.fn-table th {
    text-align: left;
    padding: 8px 12px;
    background: var(--bg-surface);
    border-bottom: 2px solid var(--border);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-dim);
}

.fn-table td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-subtle);
}

.fn-table tr:last-child td { border-bottom: none; }

.fn-table .fn-name {
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--green);
    font-weight: 500;
}

.fn-table .fn-sig {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-dim);
}

/* ── See also ─────────────────────────────────────────────────────── */

.see-also {
    margin-top: 28px;
    padding-top: 16px;
    border-top: 1px solid var(--border-subtle);
    font-size: 14px;
    color: var(--text-dim);
}
.see-also-label {
    font-weight: 600;
    margin-right: 8px;
}
.see-also a {
    margin-right: 6px;
}
.see-also a::after {
    content: ',';
    color: var(--text-muted);
}
.see-also a:last-child::after {
    content: '';
}

/* ── Lists ────────────────────────────────────────────────────────── */

.doc-list {
    margin-bottom: 16px;
    padding-left: 24px;
}
.doc-list li {
    margin-bottom: 6px;
    color: var(--text);
    line-height: 1.65;
}
.doc-list li code {
    background: var(--bg-overlay);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 1px 5px;
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--accent-hover);
}

/* ── Right TOC ────────────────────────────────────────────────────── */

#docs-toc {
    width: var(--toc-width);
    flex-shrink: 0;
    padding: 20px 16px;
    overflow-y: auto;
    position: sticky;
    top: var(--header-height);
    height: calc(100vh - var(--header-height));
    border-left: 1px solid var(--border-subtle);
}

.toc-header {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.toc-link {
    display: block;
    padding: 3px 0 3px 10px;
    font-size: 12px;
    color: var(--text-muted);
    border-left: 2px solid transparent;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.toc-link:hover {
    color: var(--text-dim);
}
.toc-link.active {
    color: var(--accent);
    border-left-color: var(--accent);
}
.toc-link.toc-h3 {
    padding-left: 20px;
    font-size: 12px;
}

/* ── Search overlay ───────────────────────────────────────────────── */

#search-overlay {
    position: fixed;
    inset: 0;
    z-index: 200;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    padding-top: 15vh;
    backdrop-filter: blur(4px);
}
#search-overlay.hidden { display: none; }

.search-modal {
    width: 560px;
    max-height: 480px;
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.search-modal-header {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    gap: 10px;
    border-bottom: 1px solid var(--border);
}

.search-modal-header input {
    flex: 1;
    background: none;
    border: none;
    color: var(--text);
    font-family: var(--font-sans);
    font-size: 16px;
    outline: none;
    caret-color: var(--accent, var(--accent-deep));
    -webkit-user-select: text;
    user-select: text;
    pointer-events: auto;
}
.search-modal-header input:focus {
    outline: none;
}
.search-modal-header input::placeholder { color: var(--text-muted); }

.search-dismiss {
    cursor: pointer;
}

#search-results {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.search-result {
    display: block;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition);
}
.search-result:hover, .search-result.selected {
    background: var(--bg-overlay);
}
.search-result-title {
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
    margin-bottom: 2px;
}
.search-result-breadcrumb {
    font-size: 12px;
    color: var(--text-muted);
}
.search-result-snippet {
    font-size: 12px;
    color: var(--text-dim);
    margin-top: 2px;
}
.search-result-snippet mark {
    background: rgba(16, 245, 144, 0.25);
    color: var(--accent);
    border-radius: 3px;
    padding: 0 3px;
}

.search-no-results {
    padding: 24px;
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
}

.search-footer {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 8px 16px;
    border-top: 1px solid var(--border);
    font-size: 12px;
    color: var(--text-muted);
}
.search-footer kbd {
    font-size: 10px;
    margin-right: 2px;
}

/* ── Responsive ───────────────────────────────────────────────────── */

@media (max-width: 1280px) {
    #docs-toc { display: none; }
}

@media (max-width: 1024px) {
    .sidebar-toggle { display: block; }

    #docs-sidebar {
        position: fixed;
        top: var(--header-height);
        left: 0;
        bottom: 0;
        z-index: 50;
        transform: translateX(-100%);
        transition: transform 0.2s ease;
        box-shadow: none;
    }
    #docs-sidebar.open {
        transform: translateX(0);
        box-shadow: 4px 0 16px rgba(0, 0, 0, 0.4);
    }

    #docs-content {
        padding: 20px 24px 80px;
    }
}

@media (max-width: 640px) {
    .header-center { display: none; }
    #docs-content { padding: 16px 16px 60px; }
    .doc-h1 { font-size: 24px; }
    .doc-h2 { font-size: 18px; }
    .search-modal { width: 95vw; }
}

/* ── Utility ──────────────────────────────────────────────────────── */

.hidden { display: none !important; }

.doc-hr {
    border: none;
    border-top: 1px solid var(--border-subtle);
    margin: 32px 0;
}

/* Inline definition list for short params */
.def-list {
    margin-bottom: 16px;
}
.def-item {
    margin-bottom: 10px;
    padding-left: 16px;
}
.def-term {
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--accent-hover);
    font-weight: 500;
}
.def-desc {
    color: var(--text);
    font-size: 14px;
    margin-top: 2px;
}
.def-desc code {
    background: var(--bg-overlay);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 1px 5px;
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--accent-hover);
}
