/* RingScript site — one calm palette, light & dark, no dependencies. */

/* One light theme on purpose: a white page, code always on dark panels.
   (The Playground keeps its own editor styling.) */
:root {
    color-scheme: light;
    --bg: #ffffff;
    --panel: #ffffff;
    --ink: #1c2126;
    --ink-soft: #4a5560;
    --muted: #6a737d;
    --accent: #1a7f5a;
    --accent-2: #0b6bcb;
    --accent-soft: #eef6f2;
    --accent-ink: #ffffff;
    --error: #b42318;
    --border: #e2e8ee;
    /* Code sits on a soft light panel, not a black box — easier on the eye
       against a white page, and the syntax colours stay legible. */
    --code-bg: #f7f9fc;
    --code-ink: #24313f;
    --code-border: #dbe3ec;
    --k: #8b3fc9;   /* keywords   */
    --s: #0a7d4b;   /* strings    */
    --n: #b35c00;   /* numbers    */
    --c: #71808f;   /* comments   */
    --a: #0b6bcb;   /* :atoms     */
    --t: #1f6feb;   /* html tags  */
    --f: #7a4f01;   /* functions  */
    --mono: "Cascadia Code", Consolas, "SF Mono", monospace;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font: 18.5px/1.75 system-ui, "Segoe UI", -apple-system, sans-serif;
    -webkit-font-smoothing: antialiased;
}
/* Horizontal only: the shorthand would win on specificity over the vertical
   padding of `section`, and every section is also a .wrap. */
.wrap { max-width: 64rem; margin: 0 auto; padding-left: 1.25rem; padding-right: 1.25rem; }
.narrow { max-width: 46rem; }

/* ---------------------------------------------------------------- nav */
nav {
    position: sticky; top: 0; z-index: 20;
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border);
}
nav .wrap { display: flex; align-items: center; gap: 1.4rem; padding-top: .7rem; padding-bottom: .7rem; }
nav a { color: var(--ink-soft); text-decoration: none; font-size: 1rem; }
nav a:hover { color: var(--ink); }
nav a.active { color: var(--accent); font-weight: 600; }
/* The RS mark sits with the wordmark, not above it: inline-flex so the two
   share a baseline-ish centre and the rounded square never stretches. */
nav .brand {
    margin-right: auto; font-weight: 700; color: var(--ink); font-size: 1.15rem;
    display: inline-flex; align-items: center;
}
/* Spacing goes on the mark, not as a flex `gap`: "Ring" and the "Script"
   span are two flex items, so a gap would prise the wordmark apart too. */
nav .brand img { width: 26px; height: 26px; display: block; flex: 0 0 auto; margin-right: .5rem; }
nav .brand span { color: var(--accent); }
nav a.repo { display: inline-flex; align-items: center; gap: .4rem; }
nav a.repo svg { width: 1.05em; height: 1.05em; fill: currentColor; }
nav .cta {
    background: var(--accent); color: var(--accent-ink);
    padding: .35rem 1rem; border-radius: 7px; font-weight: 600;
}
nav .cta:hover { color: var(--accent-ink); opacity: .9; }

/* --------------------------------------------------------------- hero */
/* Vertical only — the header is also a .wrap, and the shorthand would tie
   on specificity and win by order, wiping out its horizontal padding.
   (Same trap as `section`; there it is the element selector that loses.) */
.hero { text-align: center; padding-top: 4rem; padding-bottom: 2.5rem; }
.hero img.logo { width: 200px; height: auto; margin-bottom: .6rem; }
.hero h1 { font-size: clamp(2rem, 5vw, 2.9rem); line-height: 1.15; margin: .3rem 0 .8rem; letter-spacing: -.02em; }
.hero h1 em { font-style: normal; color: var(--accent); }
.hero p.sub { font-size: 1.2rem; color: var(--ink-soft); max-width: 40rem; margin: 0 auto 1.4rem; }
.badges { display: flex; gap: .5rem; justify-content: center; flex-wrap: wrap; margin-bottom: 1.6rem; }
.badge {
    font-size: .95rem; color: var(--ink-soft);
    border: 1px solid var(--border); border-radius: 100px;
    padding: .25rem .9rem; background: var(--panel);
}
.actions { display: flex; gap: .7rem; justify-content: center; flex-wrap: wrap; }
.btn {
    display: inline-block; padding: .6rem 1.5rem; border-radius: 8px;
    text-decoration: none; font-weight: 600; font-size: 1rem;
    border: 1px solid var(--accent);
}
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.ghost { color: var(--accent); background: transparent; }
.btn:hover { opacity: .9; }

/* Marks a link that opens in a new tab. Kept at .9em (never small in
   absolute terms) and slightly lifted, so it reads as a sign, not a glyph. */
.newtab {
    font-size: 1em;          /* never smaller than the label it marks */
    display: inline-block;
    transform: translateY(-.06em);
    opacity: .8;
}
a:hover .newtab { opacity: 1; }

/* Under 768px the six nav items no longer fit on one line: they used to
   overflow and drag the whole document sideways, and just above that they
   squeezed until their own labels wrapped. Let them wrap properly, and stop
   pinning the bar — stacked rows would eat a sixth of a phone screen for
   the whole scroll. */
@media (max-width: 767px) {
    nav { position: static; }
    nav .wrap { flex-wrap: wrap; gap: .15rem 1rem; }
    nav .brand { width: 100%; margin-right: 0; }
    /* A 27px line of text is a poor thumb target. Padding takes each link
       to ~40px tall; the row gap shrinks to match, so the bar keeps its
       height. The CTA has its own padding and is already big enough. */
    nav a { font-size: .98rem; padding-top: .4rem; padding-bottom: .4rem; }
}

/* -------------------------------------------------------------- cards */
/* Sections breathe: a clear gap from whatever sits above them. */
section { padding: 4.5rem 0 1rem; }
section + section { padding-top: 4.5rem; }
/* Headings set their own leading. Body text wants 1.75; a heading at that
   spacing falls apart the moment it wraps, which on a phone is most of
   them — the two halves of a title drift apart and stop reading as one. */
h1, h2, h3 { line-height: 1.25; }
h1 { font-size: clamp(1.9rem, 6vw, 2.3rem); letter-spacing: -.02em; }
h2 { font-size: 1.6rem; letter-spacing: -.01em; margin: 0 0 .6rem; }
h3 { font-size: 1.1rem; margin: 0 0 .35rem; }
.lead { color: var(--ink-soft); font-size: 1.05rem; max-width: 44rem; margin: 0 0 2rem; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); gap: 1rem; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 1.3rem 1.4rem; }
.card p { margin: 0; color: var(--ink-soft); font-size: 1.02rem; }
/* Neutral geometric glyphs, deliberately not emoji: they inherit a calm
   grey and never fight the text for attention. */
.card .icon {
    font-size: 2rem; line-height: 1;
    display: block; margin-bottom: .7rem;
    color: var(--muted); opacity: .55;
}

/* --------------------------------------------------------------- code */
pre, code { font-family: var(--mono); }
pre.code {
    background: var(--code-bg); color: var(--code-ink);
    border: 1px solid var(--code-border); border-radius: 10px;
    padding: 1.1rem 1.2rem; overflow-x: auto; margin: 0;
    font-size: 15px; line-height: 1.7;
}
pre.code .k { color: var(--k); font-weight: 600; }
pre.code .s { color: var(--s); }
pre.code .n { color: var(--n); }
pre.code .c { color: var(--c); font-style: italic; }
pre.code .a { color: var(--a); }
pre.code .t { color: var(--t); }
pre.code .f { color: var(--f); }
/* Marks something announced but not yet released. */
.soon {
    display: inline-block; vertical-align: middle;
    margin-left: .5rem; padding: .1em .7em;
    border: 1px solid var(--border); border-radius: 100px;
    background: var(--bg);
    font-size: .95rem; font-weight: 600; color: var(--muted);
    white-space: nowrap;
}

/* Links inside prose and cards: the site's green, underlined on hover —
   never the browser default blue. Buttons keep their own styling. */
article a:not(.btn), .card a, .pair a, .limit a, .layer a {
    color: var(--accent); text-decoration: none; font-weight: 600;
}
article a:not(.btn):hover, .card a:hover, .pair a:hover { text-decoration: underline; }
.book a:hover { text-decoration: none; }

p code, li code, td code {
    background: var(--accent-soft); color: var(--ink);
    padding: .08em .35em; border-radius: 4px; font-size: .95em;
}

/* ------------------------------------------------------------ compare */
/* Stacked, never side by side: the two versions are line-for-line
   equivalents, and reading them one under the other is what makes the
   difference visible. */
.compare { display: grid; grid-template-columns: 1fr; gap: 2rem; align-items: start; max-width: 52rem; }
/* A grid item is min-width:auto by default, so a long code line would push
   the column — and the page — wider than the phone. Pinned to 0, the block
   scrolls inside itself instead, which is what `pre.code` already asks for. */
.compare > div, .grid > *, .limits > *, .pair > * { min-width: 0; }
.compare .label {
    font-size: 1.05rem; color: var(--ink-soft);
    margin-bottom: .6rem; display: block;
}
.compare .label b { color: var(--ink); font-size: 1.12rem; }
.compare .label .tag {
    display: inline-block; margin-left: .5rem; padding: .05em .7em;
    border-radius: 100px; font-size: 1rem; font-weight: 600;
    background: var(--accent-soft); color: var(--accent);
}
.preamble { max-width: 52rem; margin: 0 0 2rem; }
.preamble p { color: var(--ink-soft); margin: 0 0 .6rem; }

/* ---------------------------------------------------------- try panel */
.try { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; max-width: 42rem; margin: 0 auto; }
.try-head { display: flex; justify-content: space-between; padding: .5rem .9rem; font-size: .8rem; color: var(--muted); border-bottom: 1px solid var(--border); }
.try textarea {
    display: block; width: 100%; border: 0; outline: none; resize: vertical;
    background: var(--code-bg); color: var(--code-ink); caret-color: #fff;
    font: 15px/1.6 var(--mono); padding: .8rem 1rem; min-height: 6rem;
}
.try-bar { display: flex; gap: .8rem; align-items: flex-start; padding: .6rem .9rem; background: #0a101a; border-top: 1px solid var(--code-border); }
.try-bar button {
    border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink);
    border-radius: 7px; padding: .35rem 1.2rem; font: 600 .95rem system-ui; cursor: pointer; flex: 0 0 auto;
}
.try-bar button:disabled { opacity: .5; cursor: default; }
.try-bar pre { margin: 0; flex: 1; font: 14px/1.5 var(--mono); color: #7d8b9d; white-space: pre-wrap; word-break: break-word; max-height: 8rem; overflow: auto; }
.try-bar pre.has { color: var(--s); }
.try-bar pre .err { color: var(--error); }

/* -------------------------------------------------------------- misc */
.steps { counter-reset: s; list-style: none; padding: 0; max-width: 46rem; }
.steps li { counter-increment: s; position: relative; padding-left: 2.4rem; margin-bottom: 1rem; color: var(--ink-soft); }
.steps li::before {
    content: counter(s); position: absolute; left: 0; top: .05rem;
    width: 1.7rem; height: 1.7rem; border-radius: 50%;
    background: var(--accent-soft); color: var(--accent);
    font-weight: 700; font-size: .9rem; display: grid; place-items: center;
}
.steps li b { color: var(--ink); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); gap: 1rem; background: var(--accent-soft); border: 1px solid var(--border); border-radius: 12px; padding: 1.4rem; text-align: center; }
.stats .num { font-size: 1.9rem; font-weight: 700; color: var(--accent); }
.stats .what { font-size: 1rem; color: var(--ink-soft); }
figure { margin: 0; }
figure img { width: 100%; border: 1px solid var(--border); border-radius: 12px; display: block; }
figcaption { font-size: 1.02rem; color: var(--ink-soft); text-align: center; margin-top: .9rem; line-height: 1.6; }

footer { border-top: 1px solid var(--border); margin-top: 2rem; padding: 2rem 0 3rem; color: var(--ink-soft); font-size: 1rem; }
footer a { color: var(--accent); text-decoration: none; }
footer .wrap { display: flex; gap: 1.2rem; flex-wrap: wrap; align-items: center; }
footer .sp { margin-left: auto; }
