:root {
  --bg: #0f0f11;
  --bg-elev: #16161a;
  --bg-code: #17171b;
  --rule: #24242a;
  --text: #e8e6e3;
  --text-dim: #9a988f;
  --text-faint: #6a6860;
  --accent: #f5b041;
  --accent-dim: #8a6626;
  --add: #7ab87a;
  --rem: #c96a6a;
  --mono: "JetBrains Mono", "SF Mono", Menlo, Consolas, ui-monospace, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
  text-rendering: optimizeLegibility;
  /* Smooth-scroll the page for anchor jumps. The h2[id] scroll-margin-top
   * already keeps targets clear of the sticky header. */
  scroll-behavior: smooth;
}

/* Respect the system "reduce motion" preference — disable smooth-scroll
 * (and any future motion) for users who've opted out at the OS level. */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

body {
  margin: 0;
  padding: 0;
}

.page {
  max-width: 900px;
  margin: 0 auto;
  padding: 72px 32px 128px;
}

header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 56px;
  /* Sticky so the section nav stays reachable while scrolling. backdrop-blur
   * over a translucent --bg keeps content underneath legible. */
  position: sticky;
  top: 0;
  z-index: 10;
  padding: 14px 0;
  margin-top: -14px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(8px);
  -webkit-backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid transparent;
}

/* Once anchor-linked, the heading would otherwise scroll under the sticky
 * header — pad the scroll target so it lands below the bar. */
h2[id] {
  scroll-margin-top: 64px;
}

.brand {
  font-family: var(--mono);
  font-size: 22px;
  font-weight: 500;
  letter-spacing: -0.01em;
}

.brand .marker {
  color: var(--accent);
}

.nav {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text-dim);
  display: flex;
  gap: 20px;
}

.nav a {
  color: inherit;
}
.nav a:hover {
  color: var(--text);
}

/* External-link glyph — anything pointing off-site (http/https in the nav)
 * gets a trailing ↗ so users can tell it leaves the page before clicking. */
.nav a[href^="http"]::after {
  content: " ↗";
  font-size: 0.85em;
  color: var(--text-faint);
  margin-left: 1px;
}
.nav a[href^="http"]:hover::after {
  color: var(--text-dim);
}

/* Floating action button — pinned to the bottom-right of the viewport,
   flips contextual ligatures site-wide. Stays inside a safe-area inset
   on iOS so it doesn't collide with the home indicator. */
.fab {
  position: fixed;
  right: max(16px, env(safe-area-inset-right, 16px));
  bottom: max(16px, env(safe-area-inset-bottom, 16px));
  z-index: 10;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--text-dim);
  background: var(--bg-elev);
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  transition:
    color 80ms,
    border-color 80ms,
    background 80ms;
}
.fab:hover {
  color: var(--text);
  border-color: var(--text-dim);
  background: var(--bg-code);
}
.fab[aria-pressed="true"] {
  color: var(--accent);
  border-color: var(--accent-dim);
}

/* Ligature toggle: default off (no font-variant-ligatures hint), `on` when
   html.ligatures is present. JetBrains Mono (loaded as a webfont) ships
   with contextual ligatures for `=>`, `|>`, `!=`, `..=`, etc.; the toggle
   is a no-op if the user blocks the font. */
code,
pre,
.install,
.prompt,
.brand {
  font-variant-ligatures: none;
  font-feature-settings: "calt" 0;
}
html.ligatures code,
html.ligatures pre,
html.ligatures .install,
html.ligatures .prompt,
html.ligatures .brand {
  font-variant-ligatures: contextual;
  font-feature-settings: "calt" 1;
}

h1 {
  font-size: 40px;
  line-height: 1.15;
  letter-spacing: -0.02em;
  font-weight: 500;
  margin: 0 0 20px;
}

h1 em {
  font-style: normal;
  color: var(--accent);
}

.lede {
  font-size: 17px;
  color: var(--text-dim);
  margin: 0 0 28px;
}

h2 {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-faint);
  margin: 64px 0 20px;
  padding-top: 24px;
  border-top: 1px solid var(--rule);
}

h3 {
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 500;
  margin: 28px 0 10px;
}

h3 .import {
  color: var(--accent);
}

p {
  margin: 0 0 14px;
}

a {
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px solid var(--rule);
  transition: border-color 120ms ease;
}
a:hover {
  border-bottom-color: var(--accent);
}

code {
  font-family: var(--mono);
  font-size: 0.92em;
  background: var(--bg-elev);
  padding: 1px 6px;
  border-radius: 3px;
  color: var(--text);
}

pre {
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.55;
  background: var(--bg-code);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 16px 18px;
  margin: 12px 0 20px;
  overflow-x: auto;
  -webkit-text-size-adjust: 100%;
}

pre code {
  background: none;
  padding: 0;
  color: inherit;
  font-size: inherit;
}

.kw {
  color: #c678dd;
}
.str {
  color: #98c379;
}
.com {
  color: var(--text-faint);
  font-style: italic;
}
.num {
  color: #d19a66;
}
.fn {
  color: #61afef;
}
.type {
  color: #e5c07b;
}
.pure,
.pb-kw {
  color: var(--accent);
  font-weight: 500;
}
.op,
.pb-op {
  color: var(--accent);
}
/* Parabun keywords — memo / signal / effect / arena / defer / fun — share the
   pure accent since they're all purity/lifecycle modifiers; weight + italic
   distinguishes them from the surrounding TypeScript keyword color. */
.pb-kw {
  font-style: italic;
}
/* Parabun operators — ~>, |>, ..=, ..!, ..& — use a dimmer variant of the
   accent so they read as operators, not keywords. */
.pb-op {
  color: var(--accent-dim);
  font-weight: 600;
}
/* Highlight for a declared signal-bound identifier name. */
.pb-signal-ref {
  color: var(--accent);
}

.install {
  background: var(--bg-code);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 14px 18px;
  font-family: var(--mono);
  font-size: 14px;
  color: var(--text);
  margin-bottom: 14px;
  white-space: nowrap;
  overflow-x: auto;
}
.install .prompt {
  color: var(--text-faint);
  user-select: none;
  margin-right: 10px;
}

.caveat {
  font-size: 13px;
  color: var(--text-faint);
  font-family: var(--mono);
  margin-bottom: 28px;
}

.modules h3 {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-top: 36px;
}

.modules p {
  color: var(--text-dim);
}

.diff {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 16px 0 20px;
}

.diff figure.code {
  margin: 0;
}

/* Per-block code wrapper. <figure> groups the language label
   (in <figcaption>) with the <pre> body so the two stay visually
   adjacent with no gap between them. The page-wide ligature FAB
   handles toggling, so the header is label-only. */
figure.code {
  margin: 12px 0 20px;
}
.code-header {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-faint);
  background: var(--bg-code);
  border: 1px solid var(--rule);
  border-bottom: none;
  border-top-left-radius: 6px;
  border-top-right-radius: 6px;
  padding: 6px 12px;
}
figure.code > pre {
  margin: 0;
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}
.code-lang {
  letter-spacing: 0.02em;
}

@media (max-width: 640px) {
  .diff {
    grid-template-columns: 1fr;
  }
}

table.bench {
  width: 100%;
  border-collapse: collapse;
  margin: 14px 0 8px;
  font-family: var(--mono);
  font-size: 13px;
}

table.bench th,
table.bench td {
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid var(--rule);
}

table.bench th {
  color: var(--text-faint);
  font-weight: 400;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.08em;
}

table.bench td.num-cell {
  text-align: right;
  color: var(--text-dim);
}

table.bench tr.winner td {
  color: var(--text);
}
table.bench tr.winner td.num-cell {
  color: var(--accent);
}

.footnote {
  font-size: 14px;
  color: var(--text-dim);
}

.footnote code {
  background: var(--bg-code);
}

footer {
  margin-top: 96px;
  padding-top: 24px;
  border-top: 1px solid var(--rule);
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text-faint);
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  justify-content: space-between;
}

footer a {
  color: var(--text-dim);
}
footer a:hover {
  color: var(--text);
}

.disclaimer {
  margin-top: 32px;
  padding: 14px 16px;
  border-left: 2px solid var(--accent-dim);
  background: rgba(245, 176, 65, 0.04);
  font-size: 14px;
  color: var(--text-dim);
}

.disclaimer strong {
  color: var(--text);
  font-weight: 500;
}

/* One-shot accent pulse on bench .winner rows when the table scrolls
   into view, paired with the count-up in fx.js. */
table.bench tr.winner td {
  transition: background-color 240ms ease;
}
table.bench tr.winner.pulse td {
  background-color: rgba(245, 176, 65, 0.1);
}
