/* =====================================================================
   Base: tokens for both themes, reset, type, buttons, nav, ruler,
   section heads, form fields, footer, and the inspector overlay.
   Two colours carry the whole identity:
     --accent  signal vermilion — the finished, human layer
     --blue    blueprint cyan   — the engineering underneath (x-ray, inspect)
   ===================================================================== */

:root {
  --bg: #0A0B0F;
  --bg-2: #101219;
  --panel: #14171F;
  --panel-2: #1B1F2A;
  --ink: #F3F0E8;
  --ink-2: #A9ACB8;
  --ink-3: #7D8292; /* 5.2:1 on --bg — the lowest that still passes AA */
  --line: rgba(243, 240, 232, .09);
  --line-2: rgba(243, 240, 232, .16);
  --accent: #FF5B2E;
  --accent-2: #FF8A5C;
  --on-accent: #120804;
  --blue: #5CC8FF;
  --blue-bg: #06121F;
  --blue-line: rgba(92, 200, 255, .16);
  --ok: #3DDC84;
  --warn: #FFB547;
  --bad: #FF5C6C;
  --shadow: 0 30px 80px -30px rgba(0, 0, 0, .7);

  --f-display: "Segoe UI Variable Display", "SF Pro Display", -apple-system, "Segoe UI", system-ui, "Helvetica Neue", Arial, sans-serif;
  --f-text: "Segoe UI Variable Text", "SF Pro Text", -apple-system, "Segoe UI", system-ui, "Helvetica Neue", Arial, sans-serif;
  --f-mono: ui-monospace, "Cascadia Code", "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --f-serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;

  --gutter: clamp(18px, 4.5vw, 64px);
  --maxw: 1240px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --ease-spring: cubic-bezier(.34, 1.56, .64, 1);
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #F3F0E8;
  --bg-2: #EAE6DC;
  --panel: #FFFFFF;
  --panel-2: #F7F5F0;
  --ink: #15161B;
  --ink-2: #4A4E5B;
  /* Checked against WCAG AA on --bg: #666A76 is 4.7:1; the accent is 4.8:1
     on the paper and 5.4:1 under white button text. Don't lighten them. */
  --ink-3: #666A76;
  --line: rgba(21, 22, 27, .10);
  --line-2: rgba(21, 22, 27, .18);
  --accent: #C23812;
  --accent-2: #A92E0E;
  --on-accent: #FFFFFF;
  --blue: #1A56F0;
  --blue-bg: #E6EEFF;
  --blue-line: rgba(26, 86, 240, .16);
  --ok: #148A4B;
  --warn: #A86400;
  --bad: #C8283A;
  --shadow: 0 30px 70px -34px rgba(40, 30, 10, .35);
  color-scheme: light;
}

/* ---------- reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
/* The UA's display:none loses to any author display rule; tabs rely on this. */
[hidden] { display: none !important; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; scroll-padding-top: 90px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.6 var(--f-text);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  transition: background-color .5s var(--ease), color .5s var(--ease);
}
/* Film grain over everything: keeps the flat dark from looking like a default. */
body::after {
  content: "";
  position: fixed; inset: 0;
  pointer-events: none; z-index: 90;
  opacity: .05;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}
:root[data-theme="light"] body::after { opacity: .07; mix-blend-mode: multiply; }

img, svg { max-width: 100%; display: block; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
::selection { background: var(--accent); color: var(--on-accent); }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 3px; border-radius: 6px; }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: fixed; left: 16px; top: -60px; z-index: 200; background: var(--accent); color: var(--on-accent); padding: 10px 16px; border-radius: 10px; font-weight: 700; text-decoration: none; }
.skip:focus { top: 16px; }

em { font-family: var(--f-serif); font-style: italic; font-weight: 400; letter-spacing: -.01em; }
h1, h2, h3 { font-family: var(--f-display); margin: 0; }

.kbd {
  display: inline-grid; place-items: center;
  min-width: 1.6em; height: 1.6em; padding: 0 .35em;
  border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 6px;
  font: 600 .78em/1 var(--f-mono); color: var(--ink);
  background: var(--panel);
}

/* ---------- buttons ---------- */
.btn {
  --b: var(--ink);
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: .5em;
  height: 52px; padding: 0 24px;
  border-radius: 999px; border: 1px solid transparent;
  font: 650 15px/1 var(--f-text); letter-spacing: -.005em;
  text-decoration: none; white-space: nowrap;
  transition: transform .35s var(--ease-spring), background-color .25s, color .25s, border-color .25s, box-shadow .35s var(--ease);
  will-change: transform;
}
.btn:active { transform: scale(.97); }
.btn-sm { height: 40px; padding: 0 16px; font-size: 14px; }
.btn-accent { background: var(--accent); color: var(--on-accent); box-shadow: 0 10px 30px -12px var(--accent); }
.btn-accent:hover { background: var(--accent-2); box-shadow: 0 16px 40px -12px var(--accent); }
.btn-ghost { border-color: var(--line-2); background: color-mix(in srgb, var(--panel) 40%, transparent); }
.btn-ghost:hover { border-color: var(--ink-2); background: var(--panel); }

.icon-btn {
  display: inline-flex; align-items: center; gap: 8px;
  height: 40px; min-width: 40px; padding: 0 11px;
  border-radius: 999px; border: 1px solid var(--line-2);
  background: transparent; color: var(--ink-2);
  font: 600 13px/1 var(--f-mono); letter-spacing: .02em;
  transition: color .2s, border-color .2s, background-color .2s;
}
.icon-btn:hover { color: var(--ink); border-color: var(--ink-3); }
.icon-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.inspect-btn[aria-pressed="true"] { color: var(--blue); border-color: var(--blue); background: var(--blue-bg); }
#themeToggle .i-moon { display: none; }
:root[data-theme="light"] #themeToggle .i-sun { display: none; }
:root[data-theme="light"] #themeToggle .i-moon { display: block; }

/* ---------- nav ---------- */
.nav {
  position: fixed; z-index: 80;
  top: 14px; left: 50%; transform: translateX(-50%);
  width: min(calc(100% - 28px), 1180px);
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 8px 8px 8px 16px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 70%, transparent);
  backdrop-filter: blur(18px) saturate(1.4);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
  transition: top .4s var(--ease), box-shadow .4s var(--ease), border-color .4s;
}
.nav.scrolled { box-shadow: 0 18px 50px -24px rgba(0, 0, 0, .55); border-color: var(--line-2); }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand-mark { width: 32px; height: 32px; }
.bm-bg { fill: var(--accent); }
.bm-s { fill: none; stroke: var(--on-accent); stroke-width: 3.2; stroke-linecap: round; stroke-linejoin: round; }
.bm-dot { fill: var(--blue); stroke: var(--bg); stroke-width: 1.6; }
.brand-word { font: 700 17px/1 var(--f-display); letter-spacing: -.02em; }
.brand-word b { font-weight: 400; color: var(--ink-2); margin-left: 3px; }
.nav-links { display: flex; gap: 2px; }
.nav-links a {
  position: relative;
  padding: 10px 14px; border-radius: 999px;
  font-size: 14px; font-weight: 550; color: var(--ink-2); text-decoration: none;
  transition: color .2s, background-color .2s;
}
.nav-links a:hover { color: var(--ink); background: var(--line); }
.nav-links a.active { color: var(--ink); }
.nav-links a.active::after { content: ""; position: absolute; left: 50%; bottom: 3px; width: 4px; height: 4px; margin-left: -2px; border-radius: 50%; background: var(--accent); }
.nav-tools { display: flex; align-items: center; gap: 8px; }

@media (max-width: 960px) {
  .nav-links { display: none; }
}
@media (max-width: 560px) {
  .nav { padding-left: 12px; gap: 8px; }
  .inspect-btn span, .brand-word b { display: none; }
  .nav-cta { padding: 0 14px; }
}
@media (max-width: 380px) {
  .inspect-btn { display: none; }
}

/* ---------- ruler ---------- */
.ruler {
  position: fixed; z-index: 70;
  right: 0; top: 0; bottom: 0; width: 26px;
  pointer-events: none;
  border-left: 1px solid var(--line);
}
.ruler-ticks {
  position: absolute; inset: 0;
  background:
    repeating-linear-gradient(to bottom, var(--line-2) 0 1px, transparent 1px 50px) right / 12px 100% no-repeat,
    repeating-linear-gradient(to bottom, var(--line) 0 1px, transparent 1px 10px) right / 6px 100% no-repeat;
}
.ruler-mark {
  position: absolute; right: 0; top: 0;
  width: 26px; height: 2px; background: var(--accent);
  transform: translateY(var(--ry, 0px));
}
.ruler-mark span {
  /* sits just below the mark so it isn't cut off at the top of the page */
  position: absolute; right: 32px; top: 6px;
  padding: 3px 7px; border-radius: 6px;
  font: 600 10px/1.2 var(--f-mono); color: var(--accent); white-space: nowrap;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
}
@media (max-width: 760px) { .ruler { display: none; } }

/* ---------- sections ---------- */
main { position: relative; }
.sec { position: relative; max-width: var(--maxw); margin: 0 auto; padding: clamp(90px, 13vw, 170px) var(--gutter) 0; }
.sec-head { max-width: 780px; margin-bottom: clamp(40px, 6vw, 72px); }
.sec-num {
  display: inline-flex; align-items: center; gap: 10px;
  font: 600 12px/1 var(--f-mono); letter-spacing: .14em; text-transform: uppercase; color: var(--accent);
}
.sec-num::before { content: ""; width: 28px; height: 1px; background: currentColor; }
.sec-head h2 {
  margin: 18px 0 18px;
  font-size: clamp(38px, 6.2vw, 80px); line-height: .98; font-weight: 750; letter-spacing: -.045em;
  text-wrap: balance;
}
.sec-head h2 em { color: var(--ink-2); }
.sec-head p { margin: 0; max-width: 620px; font-size: clamp(16px, 1.6vw, 19px); color: var(--ink-2); text-wrap: pretty; }

/* Scroll reveal: a gentle rise. JS adds .in; without JS nothing is hidden. */
.js .reveal { opacity: 0; transform: translateY(28px); transition: opacity .9s var(--ease), transform .9s var(--ease); }
.js .reveal.in { opacity: 1; transform: none; }

/* ---------- form fields ---------- */
.field { display: grid; gap: 8px; }
.field > span { font: 600 12px/1.3 var(--f-mono); letter-spacing: .04em; color: var(--ink-3); text-transform: uppercase; }
.field input:not([type="checkbox"]):not([type="range"]):not([type="color"]):not([type="file"]),
.field select, .field textarea {
  width: 100%;
  padding: 13px 15px;
  border-radius: 14px; border: 1px solid var(--line-2);
  background: var(--panel); color: var(--ink);
  font-size: 15px;
  transition: border-color .2s, box-shadow .2s;
}
.field textarea { resize: vertical; line-height: 1.55; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 4px var(--blue-line); }

/* ---------- toast ---------- */
.toast {
  position: fixed; z-index: 150; left: 50%; bottom: 24px;
  transform: translate(-50%, calc(100% + 40px));
  visibility: hidden;
  padding: 12px 18px; border-radius: 14px;
  background: var(--ink); color: var(--bg);
  font-weight: 600; font-size: 14px;
  box-shadow: var(--shadow);
  transition: transform .45s var(--ease-spring), visibility 0s .45s;
  max-width: calc(100% - 32px);
}
.toast.show { transform: translate(-50%, 0); visibility: visible; transition: transform .45s var(--ease-spring); }

/* ---------- footer ---------- */
.site-foot { max-width: var(--maxw); margin: 120px auto 0; padding: 28px var(--gutter) 30px; border-top: 1px solid var(--line); }
.foot-row { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; font-size: 14px; color: var(--ink-2); }
.foot-note { color: var(--ink-3); }
.vendor-footer { margin-top: 22px; text-align: center; font-size: 12px; line-height: 1.6; color: var(--ink-3); }
.vendor-footer b { color: var(--ink-2); font-weight: 700; letter-spacing: .01em; }
.vendor-footer .vf-dot { opacity: .5; margin: 0 6px; }

/* ---------- inspector (inspect.js) ---------- */
.insp-box, .insp-tip { position: fixed; z-index: 120; pointer-events: none; opacity: 0; transition: opacity .15s; }
.insp-box {
  left: 0; top: 0;
  border: 1px solid var(--blue);
  background: color-mix(in srgb, var(--blue) 10%, transparent);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--blue) 30%, transparent);
  transition: opacity .15s, transform .12s var(--ease), width .12s var(--ease), height .12s var(--ease);
}
.insp-box::before, .insp-box::after { /* dimension labels on the box edges */
  position: absolute; font: 600 10px/1 var(--f-mono); color: var(--blue); background: var(--blue-bg); padding: 2px 4px; border-radius: 3px;
}
.insp-box::before { content: attr(data-w); left: 50%; top: -18px; transform: translateX(-50%); }
.insp-box::after { content: attr(data-h); right: -6px; top: 50%; transform: translate(100%, -50%); }
.insp-tip {
  left: 0; top: 0; max-width: 300px;
  padding: 10px 12px; border-radius: 10px;
  background: var(--blue-bg); color: var(--ink);
  border: 1px solid var(--blue);
  font: 12px/1.55 var(--f-mono);
  box-shadow: var(--shadow);
}
.insp-tip b { color: var(--blue); font-weight: 700; }
.insp-tip .sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; vertical-align: -1px; margin-right: 5px; border: 1px solid var(--line-2); }
.insp-tip .dim { color: var(--ink-3); }
.inspecting .insp-box, .inspecting .insp-tip { opacity: 1; }
.inspecting, .inspecting * { cursor: crosshair !important; }
/* In inspect mode the whole page shows its skeleton. */
.inspecting main :is(section, header, div, ol, ul, li, form, label, p, h1, h2, h3, a, button) { outline: 1px dashed var(--blue-line); outline-offset: -1px; }
.inspecting body::before {
  content: ""; position: fixed; inset: 0; z-index: 60; pointer-events: none;
  background-image:
    linear-gradient(var(--blue-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--blue-line) 1px, transparent 1px);
  background-size: 8px 8px, 8px 8px;
  opacity: .35;
}
.insp-banner {
  position: fixed; z-index: 121; left: 50%; bottom: 20px; transform: translate(-50%, 160%);
  padding: 9px 14px; border-radius: 999px;
  background: var(--blue); color: var(--blue-bg);
  font: 700 12px/1 var(--f-mono); letter-spacing: .04em;
  transition: transform .4s var(--ease-spring);
}
.inspecting .insp-banner { transform: translate(-50%, 0); }

/* ---------- painted headings (effects.js) ---------- */
/* Drawn as outlines first, then painted left to right as they scroll in.
   effects.js adds .painted once the sweep is done so the heading is plain
   solid text again — Inspect mode must read a real colour, not transparent. */
.sec-head h2 { --paint: var(--ink); }
.sec-head h2 em { --paint: var(--ink-2); }
.js .sec-head h2:not(.painted), .js .sec-head h2:not(.painted) em {
  color: transparent;
  -webkit-text-stroke: 1px var(--line-2);
  background: linear-gradient(90deg, var(--paint) 0 50%, transparent 50%) 100% 0 / 200% 100% no-repeat;
  -webkit-background-clip: text; background-clip: text;
  transition: background-position 1.3s var(--ease) .2s;
}
.js .sec-head.in h2:not(.painted), .js .sec-head.in h2:not(.painted) em { background-position: 0 0; }

/* ---------- spotlight edges (effects.js) ---------- */
/* A 1px ring (masked to the border) lit where the cursor is. */
.spot { position: relative; }
.spot::after {
  content: ""; position: absolute; inset: 0; z-index: 1; pointer-events: none;
  border-radius: inherit; padding: 1px;
  background: radial-gradient(260px circle at var(--mx, 50%) var(--my, 50%), color-mix(in srgb, var(--accent) 85%, transparent), transparent 70%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  opacity: 0; transition: opacity .35s var(--ease);
}
.spot:hover::after { opacity: 1; }

/* ---------- page vitals (effects.js) ---------- */
.vitals { margin: 18px 0 0; text-align: center; font: 11.5px/1.6 var(--f-mono); color: var(--ink-3); }
.vitals:empty { display: none; }
.v-dot { display: inline-block; width: 7px; height: 7px; margin-right: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 8px var(--ok); vertical-align: 1px; animation: blink 1.6s steps(2) infinite; }

/* ---------- theme ripple (theme.js) ---------- */
::view-transition-old(root), ::view-transition-new(root) { animation: none; mix-blend-mode: normal; }
.vt-lock *, .vt-lock *::before, .vt-lock *::after { transition: none !important; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
  html { scroll-behavior: auto; }
  .js .reveal { opacity: 1; transform: none; }
}
