/* ───────────────────────────────────────────────────────────────
   FluxLang Docs — stylesheet (multi-page)
   ─────────────────────────────────────────────────────────────── */

:root {
    --bg: #0b1020;
    --panel: #111a33;
    --panel2: #0f1730;
    --text: #e8eefc;
    --muted: #9fb0d0;
    --line: #263656;
    --brand: #7c9cff;
    --brand2: #9df0d0;
    --warn: #ffd166;
    --danger: #ff6b6b;
    --code: #0a0f1f;
    --shadow: 0 18px 60px rgba(0, 0, 0, .35);
    --radius: 18px;
    --radius-sm: 12px;
    --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    --topbar-h: 64px;
}
[data-theme="light"] {
    --bg: #f6f8ff;
    --panel: #ffffff;
    --panel2: #eef3ff;
    --text: #17203a;
    --muted: #5b6b8c;
    --line: #d8e1f7;
    --brand: #3457d5;
    --brand2: #087f8c;
    --warn: #9a6700;
    --danger: #b42318;
    --code: #f1f5ff;
    --shadow: 0 18px 50px rgba(42, 64, 120, .16);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 84px; }
body {
    margin: 0;
    font-family: var(--font-sans);
    background:
            radial-gradient(circle at top left, rgba(124, 156, 255, .18), transparent 32rem),
            var(--bg);
    color: var(--text);
    line-height: 1.65;
    -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre { font-family: var(--font-mono); }
code { font-size: .92em; }
svg { display: block; }

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        transition-duration: 0.001ms !important;
    }
}

/* Top bar */
.topbar {
    position: sticky; top: 0; z-index: 40;
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 16px; align-items: center;
    height: var(--topbar-h);
    padding: 0 18px;
    border-bottom: 1px solid var(--line);
    background: color-mix(in srgb, var(--bg) 82%, transparent);
    backdrop-filter: blur(14px);
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 10px; }
.topbar-center { display: flex; justify-content: center; }
.brand {
    display: flex; align-items: center; gap: 10px;
    font-weight: 800; color: var(--text);
}
.brand small { color: var(--muted); font-weight: 500; margin-left: 4px; }
.logo {
    width: 32px; height: 32px; border-radius: 10px;
    background: linear-gradient(135deg, var(--brand), var(--brand2));
    box-shadow: 0 8px 30px rgba(124, 156, 255, .35);
}

/* Search */
.search-wrap {
    display: flex; align-items: center; gap: 8px;
    padding: 0 10px;
    min-width: min(480px, 44vw);
    height: 40px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--panel);
    color: var(--muted);
}
.search-wrap:focus-within {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 25%, transparent);
    color: var(--text);
}
.search {
    flex: 1; min-width: 0;
    border: 0; outline: 0; background: transparent;
    color: var(--text); font: inherit;
}
.search-kbd {
    font-family: var(--font-mono);
    font-size: 11px; color: var(--muted);
    border: 1px solid var(--line);
    border-radius: 6px; padding: 1px 6px;
}

/* Search results popover */
.search-results {
    position: absolute;
    top: calc(var(--topbar-h) - 8px);
    left: 50%;
    transform: translateX(-50%);
    width: min(560px, 90vw);
    max-height: 60vh;
    overflow: auto;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    padding: 6px;
    display: none;
    z-index: 50;
}
.search-results.show { display: block; }
.search-results a {
    display: block;
    padding: 9px 12px;
    border-radius: 8px;
    color: var(--text);
}
.search-results a:hover,
.search-results a.active { background: var(--panel2); text-decoration: none; }
.search-results .sr-title { font-weight: 600; }
.search-results .sr-path { font-size: 12px; color: var(--muted); }
.search-results .sr-empty { padding: 12px; color: var(--muted); text-align: center; }

/* Buttons */
.icon-btn {
    display: inline-grid; place-items: center;
    width: 38px; height: 38px;
    border: 1px solid var(--line);
    background: var(--panel);
    border-radius: var(--radius-sm);
    color: inherit; cursor: pointer;
    transition: border-color .15s, color .15s;
}
.icon-btn:hover { border-color: var(--brand); color: var(--brand); }
.menu-btn { display: none; }

/* Breadcrumb */
.breadcrumb { font-size: 13px; color: var(--muted); }
.breadcrumb strong { color: var(--text); font-weight: 600; }

/* Layout */
.layout {
    display: grid;
    grid-template-columns: 290px minmax(0, 1fr);
    max-width: 1440px;
    margin: 0 auto;
}

/* Sidebar */
.sidebar {
    position: sticky;
    top: var(--topbar-h);
    height: calc(100vh - var(--topbar-h));
    overflow: auto;
    padding: 18px 14px;
    border-right: 1px solid var(--line);
    scrollbar-width: thin;
}
.nav-title {
    font-size: 11px; text-transform: uppercase;
    letter-spacing: .14em; color: var(--muted);
    margin: 8px 10px;
}
.nav { display: flex; flex-direction: column; }
.nav a {
    display: flex; justify-content: space-between; align-items: baseline;
    gap: 8px; padding: 8px 10px;
    border-radius: 10px; color: var(--muted);
    margin: 1px 0; font-size: 14px;
    transition: background .15s, color .15s;
}
.nav a:hover { background: var(--panel2); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--panel2); color: var(--text); font-weight: 600; }
.nav a small { font-size: 11px; opacity: .7; }

/* Content */
.content { padding: 32px min(5vw, 58px) 80px; min-width: 0; }

/* Hero (home) */
.hero {
    padding: 32px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: linear-gradient(135deg, color-mix(in srgb, var(--panel) 94%, transparent), var(--panel2));
    box-shadow: var(--shadow);
    margin-bottom: 26px;
}
.hero h1 {
    margin: .1em 0 .25em;
    font-size: clamp(34px, 5vw, 64px);
    line-height: 1; letter-spacing: -.02em;
}
.hero-lead { max-width: 78ch; color: var(--muted); font-size: 18px; }
.pill {
    display: inline-block;
    border: 1px solid var(--line);
    background: var(--panel2);
    color: var(--muted);
    border-radius: 999px;
    padding: 4px 10px;
    font-size: 12px;
}
.badges { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 20px; }
.badges span {
    border: 1px solid var(--line);
    background: var(--panel2);
    color: var(--muted);
    border-radius: 999px;
    padding: 5px 10px;
    font-size: 12px;
}

/* Home cards */
.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 14px;
    margin-top: 8px;
}
.card {
    display: flex; flex-direction: column; gap: 6px;
    padding: 16px 16px 18px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--panel2);
    color: var(--text);
    text-decoration: none;
    transition: transform .15s, border-color .15s, box-shadow .15s;
}
.card:hover {
    text-decoration: none;
    transform: translateY(-2px);
    border-color: var(--brand);
    box-shadow: 0 10px 30px rgba(124, 156, 255, .18);
}
.card-title { font-weight: 700; font-size: 16px; }
.card-desc { color: var(--muted); font-size: 14px; }

/* Sections */
section { scroll-margin-top: calc(var(--topbar-h) + 20px); }
.doc-section {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: color-mix(in srgb, var(--panel) 92%, transparent);
    padding: 24px 26px;
    margin: 18px 0;
    box-shadow: 0 10px 34px rgba(0, 0, 0, .12);
}
.doc-section h2 {
    margin: 0 0 6px;
    font-size: 28px;
    letter-spacing: -.01em;
    display: inline-flex; align-items: center; gap: 8px;
}
.doc-section h2 .anchor,
.doc-section h3 .anchor {
    opacity: 0;
    color: var(--muted);
    font-size: .8em;
    text-decoration: none;
    transition: opacity .15s;
}
.doc-section h2:hover .anchor,
.doc-section h3:hover .anchor { opacity: 1; }
.subtitle { margin: 0 0 18px; color: var(--muted); }
h3 { margin-top: 28px; display: inline-flex; align-items: center; gap: 6px; }

/* Tables */
.tablewrap {
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 14px;
    margin: 14px 0;
}
table { border-collapse: collapse; width: 100%; min-width: 680px; }
th, td { padding: 11px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th {
    color: var(--muted); font-size: 12px;
    text-transform: uppercase; letter-spacing: .08em;
    background: color-mix(in srgb, var(--panel2) 80%, transparent);
}
tr:last-child td { border-bottom: 0; }

/* Code blocks */
.codeblock {
    position: relative;
    margin: 16px 0;
    border: 1px solid var(--line);
    border-radius: 15px;
    background: var(--code);
    overflow: hidden;
}
.codeblock pre { margin: 0; padding: 18px; overflow: auto; }
.codeblock code { display: block; white-space: pre; color: var(--text); }
.codeblock .copy {
    position: absolute; top: 8px; right: 8px;
    display: inline-grid; place-items: center;
    width: 32px; height: 32px;
    border: 1px solid var(--line);
    background: var(--panel);
    color: var(--muted);
    border-radius: 8px;
    cursor: pointer;
    opacity: .7;
    transition: opacity .15s, border-color .15s, color .15s;
}
.codeblock:hover .copy { opacity: 1; }
.codeblock .copy:hover { border-color: var(--brand); color: var(--brand); }
.codeblock .copy.copied { border-color: var(--brand2); color: var(--brand2); }

/* Callouts */
.callout {
    border: 1px solid var(--line);
    border-left-width: 5px;
    border-radius: 14px;
    padding: 13px 15px;
    margin: 16px 0;
    background: var(--panel2);
}
.callout p { margin: 6px 0 0; }
.callout.warn { border-left-color: var(--warn); }
.callout.note { border-left-color: var(--brand); }
.callout.danger { border-left-color: var(--danger); }

/* Details */
details {
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--panel2);
    padding: 12px 14px;
    margin: 12px 0;
}
summary { cursor: pointer; font-weight: 700; }

/* Lists */
ul, ol { padding-left: 1.25rem; }
li { margin: .25rem 0; }

/* Footer */
.footer {
    color: var(--muted);
    text-align: center;
    padding: 28px;
    border-top: 1px solid var(--line);
    margin-top: 40px;
}

/* Mobile */
@media (max-width: 980px) {
    .topbar { grid-template-columns: auto 1fr auto; padding: 0 12px; }
    .menu-btn { display: inline-grid; }
    .search-wrap { min-width: 0; }
    .topbar-center { display: none; }
    .topbar-right .breadcrumb { display: none; }
    .layout { grid-template-columns: 1fr; }
    .sidebar {
        position: fixed; top: var(--topbar-h); left: 0;
        width: 280px; height: calc(100vh - var(--topbar-h));
        background: var(--bg);
        transform: translateX(-100%);
        transition: transform .2s ease;
        z-index: 30;
        border-right: 1px solid var(--line);
    }
    .sidebar.open { transform: translateX(0); }
    .content { padding: 22px 16px 60px; }
    .hero { padding: 22px; }
    .doc-section { padding: 18px; }
}

/* Print */
@media print {
    .topbar, .sidebar, .copy, .footer, .breadcrumb, .search-wrap, .menu-btn, .search-results { display: none !important; }
    .layout { display: block; }
    .content { padding: 0; }
    .doc-section, .hero { box-shadow: none; break-inside: avoid; }
}