/* Dyshell base: tokens, fonts, reset, type, layout and the shared components (docs-plan-overhaul-dec1.md 2.1 to 2.4).
   Every other stylesheet uses these tokens. Themed tokens are set twice for light: under the media query (unless the page
   forces dark) and under [data-theme="light"]. */

/* Mona Sans (variable 200 to 900) for display and text, Red Hat Mono (variable 300 to 700) for small labels. SIL OFL 1.1,
   Latin subsets from fontsource: docs/credits/fonts.md */
@font-face { font-family: "Mona Sans"; src: url("../fonts/mona-sans.woff2") format("woff2"); font-weight: 200 900; font-style: normal; font-display: swap; }
@font-face { font-family: "Red Hat Mono"; src: url("../fonts/red-hat-mono.woff2") format("woff2"); font-weight: 300 700; font-style: normal; font-display: swap; }
/* Arial scaled to Mona Sans's width and line metrics (measured in Chromium at weight 400), so the swap barely shifts the layout */
@font-face { font-family: "Mona Sans Fallback"; src: local("Arial"), local("ArialMT"), local("Liberation Sans"), local("Arimo"); size-adjust: 102.69%; ascent-override: 106.15%; descent-override: 31.16%; line-gap-override: 0%; }

:root {
  /* Colour: cream and sepia on a warm near-black; burnt orange only for the hero's last word, focus, selection and label ticks */
  --ink: #121110;        /* page ground */
  --ink-0: #0d0c0b;      /* footer sky, deepest ground */
  --ink-2: #1a1816;      /* panels, form card, solid nav */
  --ink-3: #24211e;      /* raised, hover fill */
  --line: #35302a;       /* hairlines */
  --line-soft: #221f1c;  /* section rules */
  --control: #7d7467;    /* input and cell borders, 3:1 or better */
  --paper: #f1eadf;      /* primary text, primary button fill */
  --mist: #b0a698;       /* secondary text */
  --dim: #958c7e;        /* mono labels, captions, placeholders */
  --accent: #a9542a;     /* fills: label tick, selection */
  --accent-text: #d98e62;/* the one orange word, focus ring */
  --on-accent: #ffffff;
  --err: #f0907a;
  /* Art tones, dim to bright */
  --tone-1: #3a332b; --tone-1b: #5a4e40; --tone-2: #8b7964; --tone-2b: #b9a68b; --tone-3: #efe3cc;
  --star-0: #fff8ea; --star-1: #d8b27c; --glow: #e8cfa6;
  --focus: var(--accent-text);
  --mute: 55%;
  --w-display: 380;
  --grain-opacity: .16;
  color-scheme: dark;

  /* Type */
  --f-sans: "Mona Sans", "Mona Sans Fallback", system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-display: var(--f-sans);
  --f-mono: "Red Hat Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --t-label: .75rem;
  --t-sm: .875rem;
  --t-base: 1rem;
  --t-lg: 1.25rem;
  --t-xl: clamp(1.25rem, 1.1rem + .5vw, 1.5rem);
  --t-2xl: clamp(2rem, 1.25rem + 2.4vw, 3.25rem);
  --t-3xl: clamp(2.75rem, 1.3rem + 4vw, 4.75rem);

  /* Space (4 px base), layout */
  --s-1: .25rem; --s-2: .5rem; --s-3: .75rem; --s-4: 1rem; --s-5: 1.5rem; --s-6: 2rem;
  --s-7: 3rem; --s-8: 4rem;
  --section-y: clamp(4.5rem, 9vw, 9rem);
  --max: 75rem;
  --gutter: clamp(1rem, 4.8vw, 2.5rem);
  --gutter-l: max(var(--gutter), env(safe-area-inset-left, 0px));
  --gutter-r: max(var(--gutter), env(safe-area-inset-right, 0px));
  --header-h: 64px;

  /* Radii: one soft family. Every radius in every file comes from these four (the lab's boxed variant swaps them) */
  --r-pill: 999px; --r-sm: 8px; --r-md: 14px; --r-lg: 22px;

  /* Motion */
  --t-press: 120ms; --t-fast: 200ms; --t-move: 320ms; --t-slow: 900ms;
  --ease: cubic-bezier(.2, .7, .1, 1);   /* enter */
  --ease-io: cubic-bezier(.45, 0, .2, 1); /* move */

  /* Grain: static SVG noise, tinted by the layer's opacity */
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .5 0 0 0 0 .5 0 0 0 0 .5 0 0 0 .6 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
@media (min-width: 50rem) { :root { --header-h: 76px; } }
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --ink: #f4eee4; --ink-0: #e9e0d1; --ink-2: #ece4d7; --ink-3: #e3d9c9; --line: #d6cab8; --line-soft: #e6dccd; --control: #857a6b;
    --paper: #1b1714; --mist: #5e554a; --dim: #6a6053; --accent: #9e4a22; --accent-text: #8a401d; --on-accent: #ffffff;
    --err: #a3321c;
    --tone-1: #ddd2c1; --tone-1b: #c7b8a2; --tone-2: #9c8a72; --tone-2b: #7a6a55; --tone-3: #3a3129;
    --star-0: #eddbb9; --star-1: #6f5236; --glow: #b08c60;
    --mute: 62%; --w-display: 420; --grain-opacity: .1; color-scheme: light;
  }
}
:root[data-theme="light"] {
  --ink: #f4eee4; --ink-0: #e9e0d1; --ink-2: #ece4d7; --ink-3: #e3d9c9; --line: #d6cab8; --line-soft: #e6dccd; --control: #857a6b;
  --paper: #1b1714; --mist: #5e554a; --dim: #6a6053; --accent: #9e4a22; --accent-text: #8a401d; --on-accent: #ffffff;
  --err: #a3321c;
  --tone-1: #ddd2c1; --tone-1b: #c7b8a2; --tone-2: #9c8a72; --tone-2b: #7a6a55; --tone-3: #3a3129;
  --star-0: #eddbb9; --star-1: #6f5236; --glow: #b08c60;
  --mute: 62%; --w-display: 420; --grain-opacity: .1; color-scheme: light;
}
@media (prefers-contrast: more) {
  :root, :root:not([data-theme="dark"]), :root[data-theme] { --mist: var(--paper); --dim: var(--paper); --mute: 100%; --line: var(--control); --line-soft: var(--control); }
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: calc(var(--header-h) + 1rem); }
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }
body {
  margin: 0; background: var(--ink); color: var(--paper);
  font: 400 var(--t-base)/1.55 var(--f-sans);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  overflow-x: clip;
}
img, svg, video { display: block; max-width: 100%; height: auto; }
a { color: inherit; }
h1, h2, h3, p, ul, ol, dl, dd, figure { margin: 0; }
ul[role="list"], ol[role="list"] { list-style: none; padding: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
::selection { background: var(--accent); color: var(--on-accent); }

/* Type */
h1, h2 { font-family: var(--f-display); font-weight: var(--w-display); text-wrap: balance; }
h1 { font-size: var(--t-3xl); line-height: 1; letter-spacing: -.04em; max-width: 14ch; }
h2 { font-size: var(--t-2xl); line-height: 1.04; letter-spacing: -.035em; max-width: 22ch; }
h3 { font-size: var(--t-xl); font-weight: 500; line-height: 1.25; letter-spacing: -.02em; text-wrap: balance; }
p { max-width: 34rem; text-wrap: pretty; }
/* Emphasis: the muted second half. Orange only for the homepage hero's last word */
.mute, :is(h1, h2, h3, .statement) em { font-style: normal; color: color-mix(in srgb, currentColor var(--mute), transparent); }
.hero h1 em { color: var(--accent-text); }
.statement { font: var(--w-display) clamp(1.75rem, 1rem + 2.5vw, 3rem)/1.1 var(--f-display); letter-spacing: -.035em; max-width: 26ch; text-wrap: pretty; }
.lede { font-size: clamp(1.0625rem, 1rem + .3vw, 1.25rem); line-height: 1.5; letter-spacing: -.01em; color: var(--mist); max-width: 34rem; }
.small { font-size: var(--t-sm); line-height: 1.5; }
/* Mono caps label with a 6 px orange tick: every section label and page eyebrow */
.label { display: flex; align-items: center; gap: .625rem; max-width: none; margin: 0;
  font: 500 var(--t-label)/1.2 var(--f-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--dim); white-space: nowrap; }
.label::before { content: ""; flex: none; width: 6px; height: 6px; background: var(--accent); }
/* Mono data lines: mixed case, no tracking */
.mono { font-family: var(--f-mono); letter-spacing: 0; }
.muted { color: var(--mist); }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }

/* Layout */
.wrap { max-width: var(--max); margin-inline: auto; padding-left: var(--gutter-l); padding-right: var(--gutter-r); }
.section { border-top: 1px solid var(--line-soft); padding-block: var(--section-y); }
.section-grid { display: grid; gap: var(--s-5) var(--s-7); grid-template-columns: minmax(0, 1fr); }
.section-grid > * { min-width: 0; }
@media (min-width: 60rem) {
  .section-grid { grid-template-columns: 12rem minmax(0, 1fr); }
  .section-grid > .label { margin-top: .75rem; align-self: start; }
  /* Registration marks: a faint 7 px plus where the section's top rule meets the container edges */
  .section > .wrap { position: relative; }
  .section > .wrap::before, .section > .wrap::after { content: ""; position: absolute; top: calc(-1 * var(--section-y) - 4px); width: 7px; height: 7px; pointer-events: none;
    background: linear-gradient(var(--line) 0 0) center / 7px 1px no-repeat, linear-gradient(var(--line) 0 0) center / 1px 7px no-repeat; }
  .section > .wrap::before { left: calc(var(--gutter-l) - 4px); }
  .section > .wrap::after { right: calc(var(--gutter-r) - 4px); }
}

/* Skip link */
.skip { position: absolute; left: var(--gutter-l); top: -4rem; z-index: 100; display: inline-flex; align-items: center; min-height: 44px; padding: 0 var(--s-4);
  background: var(--paper); color: var(--ink); border-radius: var(--r-pill); text-decoration: none; font-weight: 500; }
.skip:focus { top: calc(env(safe-area-inset-top, 0px) + var(--s-2)); }

/* Wordmark: one inline SVG (built by tools/build.py), sized by its height */
.wordmark { display: inline-flex; align-items: center; min-height: 44px; color: var(--paper); text-decoration: none; }
.wm { display: block; height: 22px; width: auto; max-width: none; flex: none; }

/* Buttons. Primary: cream pill; with .btn-ico it ends in a round chip whose arrow slides out right as the next slides in.
   No lift, no shadow, no glow. */
.btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 14px; min-height: 44px;
  padding: 0 22px; border-radius: var(--r-pill); border: 1px solid transparent;
  font: 500 .9375rem/1 var(--f-sans); letter-spacing: -.005em; text-decoration: none; white-space: nowrap; cursor: pointer;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation; --ico: 30px;
  transition: background-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
.btn:active { transition-duration: var(--t-press); }
.btn:has(.btn-ico) { padding: 0 7px 0 22px; }
.btn-lg { min-height: 52px; padding: 0 26px; font-size: 1rem; --ico: 38px; }
.btn-lg:has(.btn-ico) { padding: 0 7px 0 26px; }
.btn-sm { min-height: 36px; padding: 0 16px; font-size: .875rem; }
.btn-sm::before { content: ""; position: absolute; inset: -5px 0; }   /* 44 px touch target */
.btn-primary { background: var(--paper); color: var(--ink); }
.btn-primary:hover { background: color-mix(in srgb, var(--paper) 90%, var(--ink)); }
.btn-primary:active { background: color-mix(in srgb, var(--paper) 82%, var(--ink)); }
.btn-line { background: transparent; color: var(--paper); border-color: color-mix(in srgb, var(--paper) 45%, transparent); }
.btn-line:hover { background: var(--paper); color: var(--ink); border-color: var(--paper); }
.btn-line:active { background: color-mix(in srgb, var(--paper) 82%, var(--ink)); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .4; pointer-events: none; }
.btn-ico { position: relative; flex: none; width: var(--ico); height: var(--ico); border-radius: var(--r-pill); background: var(--ink); color: var(--paper); overflow: hidden; }
.btn-ico .arrow { position: absolute; inset: 0; margin: auto; width: 16px; height: 16px; transition: transform var(--t-move) cubic-bezier(.2, 0, 0, 1); }
.btn-ico .arrow:first-child { transform: translateX(calc(-1 * var(--ico))); }
.btn:hover .btn-ico .arrow:first-child, .btn:focus-visible .btn-ico .arrow:first-child { transform: none; }
.btn:hover .btn-ico .arrow:last-child, .btn:focus-visible .btn-ico .arrow:last-child { transform: translateX(var(--ico)); }
/* an arrow set straight in the button (older markup) */
.btn > .arrow { flex: none; width: 1em; height: 1em; transition: transform var(--t-move) var(--ease); }
.btn:hover > .arrow { transform: translateX(3px); }

/* Links */
.link { color: var(--paper); text-decoration: underline 1px var(--control); text-underline-offset: .22em; transition: text-decoration-color var(--t-fast) var(--ease); }
.link:hover { text-decoration-color: var(--paper); }
.more { display: inline-flex; align-items: center; gap: .5em; min-height: 44px; color: var(--paper); font-weight: 500; text-decoration: none; }
.more .arrow { flex: none; width: 1em; height: 1em; transition: transform var(--t-move) var(--ease); }
.more:hover .arrow { transform: translateX(3px); }

/* Corner brackets: four L corners lock on around a card on hover and keyboard focus. The card needs its own ::after free */
.brackets { position: relative; }
.brackets::after { content: ""; position: absolute; inset: -6px; pointer-events: none; opacity: 0; transform: scale(1.06);
  transition: opacity var(--t-move) var(--ease), transform var(--t-move) var(--ease);
  background:
    linear-gradient(var(--paper) 0 0) left top / 10px 1px no-repeat, linear-gradient(var(--paper) 0 0) left top / 1px 10px no-repeat,
    linear-gradient(var(--paper) 0 0) right top / 10px 1px no-repeat, linear-gradient(var(--paper) 0 0) right top / 1px 10px no-repeat,
    linear-gradient(var(--paper) 0 0) left bottom / 10px 1px no-repeat, linear-gradient(var(--paper) 0 0) left bottom / 1px 10px no-repeat,
    linear-gradient(var(--paper) 0 0) right bottom / 10px 1px no-repeat, linear-gradient(var(--paper) 0 0) right bottom / 1px 10px no-repeat; }
.brackets:hover::after, .brackets:focus-visible::after { opacity: 1; transform: none; }

/* Hairline grid: cells share single hairlines. Set --hgrid-bg to the section ground when it is not --ink */
.hgrid { display: grid; gap: 1px; background: var(--line); border: 1px solid var(--line); }
.hgrid > * { background: var(--hgrid-bg, var(--ink)); min-width: 0; }

/* Text swap (site.js window.dySwap): the old label rises out as the new one rises in */
.dy-swap { position: relative; display: inline-block; white-space: nowrap; vertical-align: top; transition: width var(--t-fast) var(--ease-io); }
.dy-swap > .dy-in { display: inline-block; animation: dy-in var(--t-fast) var(--ease) both; }
.dy-swap > .dy-out { position: absolute; left: 0; top: 0; animation: dy-out var(--t-fast) var(--ease-io) forwards; }
@keyframes dy-in { from { opacity: 0; transform: translateY(6px); } }
@keyframes dy-out { to { opacity: 0; transform: translateY(-6px); } }

/* Grain overlay: add .grain to any positioned block; .grain-live (hero only) steps the noise */
.grain { position: relative; isolation: isolate; }
.grain::after { content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none; background-image: var(--grain); opacity: var(--grain-opacity); mix-blend-mode: overlay; }
@media (prefers-reduced-motion: no-preference) { .grain-live::after { animation: dy-grain .9s steps(1) infinite; } }
@keyframes dy-grain {
  0% { background-position: 0 0; } 16.7% { background-position: -37px 21px; } 33.3% { background-position: 53px -64px; }
  50% { background-position: -81px -12px; } 66.7% { background-position: 18px 77px; } 83.3% { background-position: 69px 40px; }
}

/* Scroll reveal: [data-reveal] fades up once (site.js sets data-in). Hidden only when scripting is on; until site.js has run
   (it sets data-reveal-on on <html>) a 3 s animation shows the element anyway, so a script that never runs hides nothing */
@media (scripting: enabled) and (prefers-reduced-motion: no-preference) {
  [data-reveal] { opacity: 0; transform: translateY(12px); transition: opacity var(--t-slow) var(--ease), transform var(--t-slow) var(--ease); }
  :root:not([data-reveal-on]) [data-reveal] { animation: dy-show 1ms 3s forwards; }
  [data-reveal][data-in] { opacity: 1; transform: none; }
}
@keyframes dy-show { to { opacity: 1; transform: none; } }

@media (forced-colors: active) {
  .label::before { background: CanvasText; }
  .btn { border-color: ButtonText; }
  .brackets::after { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0s !important; animation-duration: 0s !important; animation-delay: 0s !important; animation-iteration-count: 1 !important; }
}
