/* Chrome (header, sidebar, highlighting) is JS-built; first paint waits
   for it so navigation never flashes the bare article. The inline head
   script adds .booting, site.js removes it, a 600ms timer is the failsafe. */
html.booting body { visibility: hidden; }

/* rasc.dev — design system
   Body: Inter (variable). Code: PragmataPro (variable, liga).
   Aesthetic: zed.dev structure (hairline grid, crosshair ticks, mono eyebrows,
   text-forward hero) with commitmono.com restraint. Light + dark. */

@font-face {
    font-family: 'InterVariable';
    src: url('../fonts/InterVariable.woff2') format('woff2');
    font-weight: 100 900;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'InterVariable';
    src: url('../fonts/InterVariable-Italic.woff2') format('woff2');
    font-weight: 100 900;
    font-style: italic;
    font-display: swap;
}
@font-face {
    font-family: 'PragmataPro';
    src: url('../fonts/PragmataProVF.woff2') format('woff2');
    font-weight: 300 700;
    font-style: normal;
    font-display: swap;
}

:root {
    --sans: 'InterVariable', ui-sans-serif, system-ui, sans-serif;
    --mono: 'PragmataPro', ui-monospace, 'SF Mono', monospace;

    --bg: #fcfcfa;
    --bg-raise: #f5f5f2;
    --bg-code: #f7f7f4;
    --bg-inline-code: #efefeb;
    --ink: #1a1a18;
    --ink-strong: #000;
    --muted: #66665f;
    --faint: #99998f;
    --hairline: rgba(20, 20, 10, 0.12);
    --hairline-soft: rgba(20, 20, 10, 0.06);
    --accent: #d6423c;
    --accent-ink: #b53431;
    --warn: #d29922;
    --tick: rgba(20, 20, 10, 0.35);
    --selection: rgba(214, 66, 60, 0.16);

    --syn-comment: #a3a39a;
    --syn-keyword: #a626a4;
    --syn-type: #c18401;
    --syn-string: #50a14f;
    --syn-number: #986801;
    --syn-fn: #4078f2;
    --syn-decorator: #d6423c;
    --syn-op: #526069;

    --header-h: 56px;
}

[data-theme='dark'] {
    --bg: #131312;
    --bg-raise: #1a1a19;
    --bg-code: #181817;
    --bg-inline-code: #242422;
    --ink: #e8e8e3;
    --ink-strong: #fff;
    --muted: #a0a096;
    --faint: #6d6d64;
    --hairline: rgba(235, 235, 215, 0.14);
    --hairline-soft: rgba(235, 235, 215, 0.07);
    --accent: #ff6b5e;
    --accent-ink: #ff8577;
    --warn: #e3c05a;
    --tick: rgba(235, 235, 215, 0.4);
    --selection: rgba(255, 107, 94, 0.22);

    --syn-comment: #5f6058;
    --syn-keyword: #c678dd;
    --syn-type: #e5c07b;
    --syn-string: #98c379;
    --syn-number: #d19a66;
    --syn-fn: #61afef;
    --syn-decorator: #ff6b5e;
    --syn-op: #8fa3ad;
}

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

::selection { background: var(--selection); }

html { scroll-padding-top: calc(var(--header-h) + 24px); }

body {
    font-family: var(--sans);
    font-size: 16px;
    line-height: 1.65;
    background: var(--bg);
    color: var(--ink);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

/* Ligatures stay off in inline code and shell blocks so CLI flags like --lib
   keep their two hyphens; highlighted rasc samples opt back in for arrows. */
code, pre, kbd, samp {
    font-family: var(--mono);
    font-feature-settings: 'liga' 0, 'calt' 0;
}
pre code:not(.nohighlight) {
    font-feature-settings: 'liga' 1, 'calt' 1;
}

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

/* ---- mono eyebrow labels ---- */
.eyebrow {
    font-family: var(--mono);
    font-size: 12px;
    font-weight: 400;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--accent);
    display: block;
    margin-bottom: 14px;
}

/* ---- header ---- */
.site-header {
    position: sticky;
    top: 0;
    z-index: 50;
    height: var(--header-h);
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--hairline);
    background: color-mix(in srgb, var(--bg) 82%, transparent);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}
.site-header .inner {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    align-items: center;
    gap: 28px;
}
.brand {
    font-family: var(--mono);
    font-size: 17px;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--ink-strong);
    display: flex;
    align-items: baseline;
    gap: 2px;
}
.brand .cursor {
    display: inline-block;
    width: 8px;
    height: 15px;
    background: var(--accent);
    transform: translateY(2px);
    animation: blink 1.2s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }
.site-nav {
    display: flex;
    gap: 22px;
    font-size: 13.5px;
    font-weight: 500;
    color: var(--muted);
    margin-left: 8px;
}
.site-nav a.active, .site-nav a:hover { color: var(--ink-strong); }
.header-spacer { flex: 1; }
.theme-toggle {
    appearance: none;
    border: 1px solid var(--hairline);
    background: transparent;
    color: var(--muted);
    font-family: var(--mono);
    font-size: 12px;
    padding: 5px 10px;
    border-radius: 6px;
    cursor: pointer;
}
.theme-toggle:hover { color: var(--ink-strong); border-color: var(--tick); }

/* ---- crosshair-cornered frames (zed motif) ---- */
.frame {
    position: relative;
    border: 1px solid var(--hairline);
}
.frame .tick {
    position: absolute;
    width: 13px;
    height: 13px;
    pointer-events: none;
    color: var(--tick);
}
.frame .tick::before, .frame .tick::after {
    content: '';
    position: absolute;
    background: currentColor;
}
.frame .tick::before { left: 6px; top: 0; width: 1px; height: 13px; }
.frame .tick::after { left: 0; top: 6px; width: 13px; height: 1px; }
.frame .tick.tl { top: -7px; left: -7px; }
.frame .tick.tr { top: -7px; right: -7px; }
.frame .tick.bl { bottom: -7px; left: -7px; }
.frame .tick.br { bottom: -7px; right: -7px; }

/* ---- landing ---- */
.hero {
    max-width: 1200px;
    margin: 0 auto;
    padding: 96px 24px 72px;
}
.hero h1 {
    font-size: clamp(40px, 6vw, 64px);
    font-weight: 640;
    font-variation-settings: 'opsz' 32;
    letter-spacing: -0.035em;
    line-height: 1.05;
    color: var(--ink-strong);
    max-width: 18ch;
}
.hero .lede {
    margin-top: 22px;
    font-size: 19px;
    line-height: 1.6;
    color: var(--muted);
    max-width: 58ch;
}
.hero .lede code {
    font-size: 0.92em;
    background: var(--bg-inline-code);
    padding: 1px 5px;
    border-radius: 4px;
}
.cta-row { display: flex; gap: 12px; margin-top: 34px; flex-wrap: wrap; }
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 560;
    padding: 10px 18px;
    border-radius: 8px;
    border: 1px solid var(--hairline);
    transition: transform 0.06s ease;
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--ink-strong); color: var(--bg); border-color: var(--ink-strong); }
.btn.primary:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.ghost:hover { border-color: var(--tick); color: var(--ink-strong); }
.btn kbd {
    font-size: 11px;
    border: 1px solid var(--hairline);
    border-radius: 4px;
    padding: 1px 5px;
    opacity: 0.7;
}

.section {
    max-width: 1200px;
    margin: 0 auto;
    padding: 72px 24px;
    border-top: 1px solid var(--hairline-soft);
}
.section h2 {
    font-size: 30px;
    font-weight: 620;
    letter-spacing: -0.025em;
    color: var(--ink-strong);
    margin-bottom: 12px;
}
.section > p { color: var(--muted); max-width: 62ch; }

.feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1px;
    background: var(--hairline-soft);
    border: 1px solid var(--hairline-soft);
    margin-top: 40px;
}
.feature {
    background: var(--bg);
    padding: 28px 26px;
}
.feature:hover { background: var(--bg-raise); }
.feature h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--ink-strong);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 9px;
}
.feature h3 .glyph {
    font-family: var(--mono);
    color: var(--accent);
    font-weight: 400;
}
.feature p { font-size: 14px; color: var(--muted); line-height: 1.6; }
.feature p code {
    font-size: 0.9em;
    background: var(--bg-inline-code);
    padding: 1px 4px;
    border-radius: 4px;
}
.feature .more {
    display: inline-block;
    margin-top: 12px;
    font-family: var(--mono);
    font-size: 12.5px;
    color: var(--accent);
}

/* stat band, commitmono-style bare numbers */
.stat-band {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1px;
    background: var(--hairline-soft);
    border: 1px solid var(--hairline-soft);
    margin-top: 40px;
}
.stat { background: var(--bg); padding: 26px; }
.stat .n {
    font-family: var(--mono);
    font-size: 34px;
    font-weight: 300;
    letter-spacing: -0.02em;
    color: var(--ink-strong);
}
.stat .n em { font-style: normal; color: var(--accent); }
.stat .d { font-size: 13px; color: var(--muted); margin-top: 6px; }

/* ---- docs layout ---- */
.docs-shell {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
    display: grid;
    grid-template-columns: 232px minmax(0, 1fr);
    gap: 56px;
}
.docs-sidebar {
    position: sticky;
    top: var(--header-h);
    align-self: start;
    height: calc(100vh - var(--header-h));
    overflow-y: auto;
    padding: 36px 0 48px;
    border-right: 1px solid var(--hairline-soft);
    font-size: 13.5px;
    scrollbar-width: thin;                          /* Firefox */
    scrollbar-color: var(--hairline) transparent;
}
/* Styling opts out of the native scrollbar, so trackpad overlay and
   always-on mouse modes render the same thin bar with no track. */
.docs-sidebar::-webkit-scrollbar { width: 8px; }
.docs-sidebar::-webkit-scrollbar-track { background: transparent; }
.docs-sidebar::-webkit-scrollbar-thumb {
    background: transparent;
    border-radius: 4px;
}
.docs-sidebar:hover::-webkit-scrollbar-thumb { background: var(--hairline); }
.docs-sidebar .group {
    font-family: var(--mono);
    font-size: 11px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--faint);
    margin: 26px 0 8px;
}
.docs-sidebar .group:first-child { margin-top: 0; }
.docs-sidebar a {
    display: block;
    padding: 5px 12px 5px 0;
    color: var(--muted);
    border-right: 2px solid transparent;
    margin-right: -1px;
}
.docs-sidebar a:hover { color: var(--ink-strong); }
.docs-sidebar a.sub {
    padding-left: 14px;
    font-size: 12.5px;
    border-left: 1px solid var(--hairline-soft);
}
.docs-sidebar a.active {
    color: var(--accent-ink);
    border-right-color: var(--accent);
    font-weight: 550;
}

.docs-main { padding: 44px 0 96px; min-width: 0; }
.docs-main [id] { scroll-margin-top: calc(var(--header-h) + 20px); }
.docs-main h1 {
    font-size: 36px;
    font-weight: 630;
    letter-spacing: -0.03em;
    line-height: 1.15;
    color: var(--ink-strong);
    margin-bottom: 14px;
}
.docs-main .subtitle {
    font-size: 17px;
    color: var(--muted);
    max-width: 62ch;
    margin-bottom: 8px;
}
.docs-main h2 {
    font-size: 23px;
    font-weight: 620;
    letter-spacing: -0.02em;
    color: var(--ink-strong);
    margin: 52px 0 12px;
    padding-top: 20px;
    border-top: 1px solid var(--hairline-soft);
}
.docs-main h3 {
    font-size: 17px;
    font-weight: 600;
    color: var(--ink-strong);
    margin: 34px 0 8px;
}
.docs-main p { margin: 12px 0; max-width: 72ch; }
.docs-main ul, .docs-main ol { margin: 12px 0 12px 22px; max-width: 70ch; }
.docs-main li { margin: 5px 0; }
.docs-main p code, .docs-main li code, .docs-main td code {
    font-size: 0.88em;
    background: var(--bg-inline-code);
    padding: 1.5px 5px;
    border-radius: 4px;
    white-space: nowrap;
}
.docs-main a:not(.btn) {
    color: var(--accent-ink);
    text-decoration: underline;
    text-decoration-color: color-mix(in srgb, var(--accent) 35%, transparent);
    text-underline-offset: 2.5px;
}
.docs-main a:not(.btn):hover { text-decoration-color: var(--accent); }
.docs-main table {
    border-collapse: collapse;
    font-size: 14px;
    margin: 18px 0;
    display: block;
    overflow-x: auto;
    max-width: 100%;
}
.docs-main th, .docs-main td {
    border: 1px solid var(--hairline-soft);
    padding: 8px 14px;
    text-align: left;
    vertical-align: top;
}
.docs-main th {
    font-family: var(--mono);
    font-size: 11.5px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    font-weight: 500;
    color: var(--muted);
    background: var(--bg-raise);
}

.callout {
    border: 1px solid var(--hairline);
    border-left: 3px solid var(--accent);
    background: var(--bg-raise);
    padding: 14px 18px;
    margin: 20px 0;
    font-size: 14.5px;
    max-width: 72ch;
}
.callout .label {
    font-family: var(--mono);
    font-size: 11px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--accent);
    display: block;
    margin-bottom: 5px;
}
.callout p { margin: 6px 0; }

/* prev/next pager */
.pager {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    margin-top: 72px;
    padding-top: 24px;
    border-top: 1px solid var(--hairline-soft);
    font-size: 14px;
}
.pager a {
    display: flex;
    flex-direction: column;
    gap: 3px;
    max-width: 46%;
}
.pager a .k {
    font-family: var(--mono);
    font-size: 11px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--faint);
}
.pager a .t { color: var(--ink-strong); font-weight: 550; }
.pager a:hover .t { color: var(--accent-ink); }
.pager a.next { margin-left: auto; text-align: right; }

/* ---- code examples ---- */
.example {
    margin: 22px 0;
    border: 1px solid var(--hairline);
    border-radius: 10px;
    overflow: hidden;
    background: var(--bg-code);
}
.example figcaption {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    border-bottom: 1px solid var(--hairline-soft);
    font-family: var(--mono);
    font-size: 12px;
    color: var(--muted);
    background: var(--bg-raise);
}
.example figcaption .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    opacity: 0.85;
}
.example figcaption .copy {
    margin-left: auto;
    appearance: none;
    border: none;
    background: none;
    font-family: var(--mono);
    font-size: 11.5px;
    color: var(--faint);
    cursor: pointer;
    padding: 2px 4px;
}
.example figcaption .copy:hover { color: var(--ink-strong); }
.example pre {
    padding: 16px 18px;
    overflow-x: auto;
    font-size: 13.5px;
    line-height: 1.62;
    font-weight: 380;
    tab-size: 4;
}
/* future in-page REPL mount; populated by repl.js once rasc.wasm ships */
.repl-mount { display: none; }
.example.repl-ready .repl-mount {
    display: block;
    border-top: 1px solid var(--hairline-soft);
    min-height: 120px;
}

.hero-example { max-width: 720px; margin-top: 52px; }

/* syntax token classes emitted by the highlighter */
.tok-c { color: var(--syn-comment); font-style: italic; }
.tok-k { color: var(--syn-keyword); }
.tok-t { color: var(--syn-type); }
.tok-s { color: var(--syn-string); }
.tok-n { color: var(--syn-number); }
.tok-f { color: var(--syn-fn); }
.tok-d { color: var(--syn-decorator); }
.tok-o { color: var(--syn-op); }

/* ---- footer ---- */
.site-footer {
    border-top: 1px solid var(--hairline);
    margin-top: 48px;
}
.site-footer .inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 30px 24px;
    display: flex;
    align-items: center;
    gap: 20px;
    font-size: 13px;
    color: var(--faint);
    flex-wrap: wrap;
}
.site-footer .keys { margin-left: auto; font-family: var(--mono); font-size: 12px; }
.site-footer kbd {
    border: 1px solid var(--hairline);
    border-radius: 4px;
    padding: 1px 6px;
    font-size: 11px;
}

@media (max-width: 900px) {
    .docs-shell { grid-template-columns: 1fr; gap: 0; }
    .docs-sidebar {
        position: static;
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--hairline-soft);
        padding: 20px 0;
    }
    .hero { padding-top: 56px; }
}

/* ---- live REPL ---- */
.repl-btn { margin-left: 0 !important; }
.repl-editor {
    position: relative;
}
.repl-editor pre {
    pointer-events: none;
    min-height: 100%;
}
/* Both layers must measure identically: no ligatures, no wrapping. The
   double class keeps this rule above `pre code:not(.nohighlight)`. */
.example .repl-editor pre code, .example .repl-editor textarea {
    font-feature-settings: 'liga' 0, 'calt' 0;
    letter-spacing: 0;
}
.repl-editor pre { overflow: hidden; }
.repl-editor textarea {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    padding: 16px 18px;
    border: none;
    outline: none;
    resize: none;
    background: transparent;
    color: transparent;
    caret-color: var(--ink-strong);
    font-family: var(--mono);
    font-size: 13.5px;
    line-height: 1.62;
    font-weight: 380;
    white-space: pre;
    overflow: auto;
    tab-size: 4;
}
.repl-editor textarea::selection { background: var(--selection); }
/* The textarea is the scroll surface but never shows its own bars. */
.repl-editor textarea { scrollbar-width: none; }
.repl-editor textarea::-webkit-scrollbar { display: none; }
.sq-error {
    text-decoration: underline wavy var(--accent) 1px;
    text-underline-offset: 3px;
}
.sq-warning {
    text-decoration: underline wavy var(--warn) 1px;
    text-underline-offset: 3px;
}
.repl-console {
    border-top: 1px solid var(--hairline-soft);
    background: var(--bg-raise);
    font-family: var(--mono);
    font-size: 12.5px;
    line-height: 1.7;
    padding: 8px 14px;
    max-height: 180px;
    overflow-y: auto;
}
.repl-console:empty { display: none; }
.repl-console .line.err { color: var(--accent-ink); }
.repl-console .line.meta { color: var(--faint); }
.repl-problems {
    border-top: 1px solid var(--hairline-soft);
    font-family: var(--mono);
    font-size: 12px;
    padding: 4px 14px 8px;
}
.repl-problems:empty { display: none; }
.repl-problems .problem { padding: 2px 0; color: var(--accent-ink); }
.repl-problems .problem.warning { color: var(--warn); }
.repl-exports {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    border-top: 1px solid var(--hairline-soft);
    padding: 8px 14px;
    font-family: var(--mono);
    font-size: 12px;
}
.repl-exports:empty { display: none; }
.repl-exports .label {
    color: var(--faint);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-size: 10.5px;
}
.repl-chip {
    appearance: none;
    border: 1px solid var(--hairline);
    background: var(--bg);
    color: var(--ink);
    font-family: var(--mono);
    font-size: 12px;
    padding: 3px 10px;
    border-radius: 999px;
    cursor: pointer;
}
.repl-chip:hover { border-color: var(--accent); color: var(--accent-ink); }
.repl-args {
    border: 1px solid var(--hairline);
    background: var(--bg);
    color: var(--ink);
    font-family: var(--mono);
    font-size: 12px;
    padding: 3px 8px;
    border-radius: 6px;
    min-width: 160px;
}
