/* Duit website: foundation styles (fonts, tokens, reset, type, layout helpers, buttons, glyphs, header,
   footer, hero shell, motion guard). Loaded first; every other stylesheet builds on these tokens.

   GROUNDS  Tokens switch by data-ground="sky" | "cream" on any element; html/body default to cream. An
            element with data-ground also gets background var(--bg) and color var(--text) (zero specificity,
            so any class of yours overrides it). Style by token, never by an ancestor's ground: write
            color: var(--soft), not [data-ground="cream"] .x { ... }, because grounds nest (a sky window in
            a cream section). A .dw window (window.css) is sky unless it says data-ground="cream".
   TOKENS   --bg --surface --text --soft --dim --faint --accent --accent-fill --on-accent --ok --warn --bad,
            derived per ground: --line-strong --sel --accent-hover --mark.  Fixed: --mono --sans --ease
            --head-h (56px sticky header) --gutter (16-40px side gutter) --wrap (1200px) --sec-pad.
            --dim fails 4.5:1 contrast: decoration and disabled states only.
   LAYOUT   .wrap (centred, max 1200px content, gutters)  .sec (section vertical rhythm)  .sec-head (eyebrow +
            h2 + .lede block)  .eyebrow  .lede  .accent (one highlighted word; large text only on cream)
   BUTTONS  .btn-primary (accent fill, one per row)  .btn-ghost (outline)  .btn-sm (header size)
   GLYPHS   .g + .g-ok (*) .g-wait (~) .g-bad (!) .g-skip (.) -- colour always paired with the glyph
   A11Y     .sr (visually hidden)  .skip (skip link)  :focus-visible ring 2px accent
   HERO     .hero is a one-column grid: .hero-copy (row 1, held to the .wrap width by this file: do not set its
            width, margin-inline or padding-inline) then .hub (row 2, full hero width, edge to edge: the hub
            sets its own inner gutters and centres its window). Section ids land under the sticky header. */

/* ---------- Fonts (self-hosted, relative to this file) ---------- */
@font-face { font-family: "JetBrains Mono"; font-style: normal; font-weight: 400; font-display: swap; src: url("../fonts/jetbrains-mono-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "JetBrains Mono"; font-style: normal; font-weight: 700; font-display: swap; src: url("../fonts/jetbrains-mono-latin-700-normal.woff2") format("woff2"); }

/* ---------- Tokens ---------- */
:root {
  --mono: "JetBrains Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif;
  --ease: cubic-bezier(.16, 1, .3, 1);
  --head-h: 56px;
  --gutter: clamp(16px, 4vw, 40px);
  --wrap: 1200px;
  --sec-pad: clamp(64px, 8vw, 112px);
}
/* cream: the page default */
:root, [data-ground="cream"] {
  --bg: #f3ebdc; --surface: #ebe1cf; --text: #221e18; --soft: #675d4e; --dim: #a59882; --faint: #d8cdb8;
  --accent: #a5561b;
  --accent-fill: color-mix(in oklch, #a5561b 88%, #221e18); /* raw rust on cream is 4.49:1; nudged toward ink */
  --on-accent: #f3ebdc;
  /* ok and warn sit a shade under the spec's #4f7a3a / #a5561b: status glyphs are 13 px text and must hold
     4.5:1 on --surface as well as --bg (ok 5.02 / 4.59, warn 5.06 / 4.62) */
  --ok: #456e33; --warn: #9a4f17; --bad: #8f2f1a;
  --wait-weight: 700; /* in cream, warn and accent share a hue: the ~ glyph is set heavy to read as a mark */
  color-scheme: light;
}
/* sky: the hero, the header, the sky bands, and every .dw window that does not say cream */
[data-ground="sky"], .dw:not([data-ground]) {
  --bg: #07080d; --surface: #0f1119; --text: #fbf6ea; --soft: #c8bea9; --dim: #77746c; --faint: #34353f;
  --accent: #ffcf73; --accent-fill: #ffcf73; --on-accent: #07080d;
  --ok: #9ccf8a; --warn: #e08a4a; --bad: #ff8a6b;
  --wait-weight: 400;
  color-scheme: dark;
}
/* derived tokens: declared on every ground element so they resolve against that ground's values. Mixed in
   oklab, not oklch: the sky greys are near-achromatic, and an oklch mix of them resolves in Chrome to
   "oklch(L C none)", which paints with hue 0 (a pink cast on every hairline). oklab has no hue to lose. */
:root, [data-ground], .dw {
  --line-strong: color-mix(in oklab, var(--faint) 55%, var(--dim));
  --sel: color-mix(in oklab, var(--surface) 72%, var(--faint));
  --accent-hover: color-mix(in oklab, var(--accent-fill) 86%, var(--text));
  --mark: color-mix(in oklab, var(--accent) 24%, var(--surface));
}
:where([data-ground]) { background-color: var(--bg); color: var(--text); }

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; overflow-x: clip;
  background: var(--bg); color: var(--text);
  font-family: var(--sans); font-size: 16px; line-height: 1.6;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
}
@media (min-width: 900px) { body { font-size: 17px; } }
h1, h2, h3, h4, h5, h6, p, figure, blockquote, dl, dd, pre { margin: 0; }
:where(ul[class], ol[class], nav ul, nav ol) { list-style: none; margin: 0; padding: 0; }
img, video, canvas { display: block; max-width: 100%; height: auto; }
svg { flex-shrink: 0; }
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration-line: underline; text-decoration-thickness: 1px; text-underline-offset: .22em; text-decoration-color: var(--line-strong); }
a:hover { text-decoration-color: currentColor; }
[hidden] { display: none !important; }
::selection { background: var(--mark); color: var(--text); }
main:focus { outline: none; }

/* ---------- Type ---------- */
h1, h2, h3 { font-family: var(--mono); font-weight: 700; text-wrap: balance; }
h1 { font-size: clamp(30px, 4.6vw + 12px, 68px); line-height: 1.05; letter-spacing: -0.02em; }
h2 { font-size: clamp(26px, 2.6vw + 14px, 46px); line-height: 1.1; letter-spacing: -0.02em; }
h3 { font-size: clamp(17px, .4vw + 15px, 20px); line-height: 1.3; letter-spacing: -0.01em; }
p { text-wrap: pretty; }
.accent { color: var(--accent); }
code, kbd, samp { font-family: var(--mono); font-size: .92em; }

/* ---------- Layout helpers ---------- */
.wrap { width: 100%; max-width: calc(var(--wrap) + 2 * var(--gutter)); margin-inline: auto; padding-inline: var(--gutter); }
.sec { position: relative; padding-block: var(--sec-pad); }
.sec-head { max-width: 46rem; margin-bottom: clamp(32px, 4vw, 56px); }
.sec-head > h2 + * { margin-top: 18px; }
.sec-head.is-center { margin-inline: auto; text-align: center; }
.sec-head.is-center .lede { margin-inline: auto; }
.eyebrow {
  display: block; margin: 0 0 14px;
  font-family: var(--mono); font-size: 12px; font-weight: 400; line-height: 1.4;
  letter-spacing: .14em; text-transform: uppercase; color: var(--soft);
}
.lede { max-width: 62ch; font-size: clamp(17px, .25vw + 16px, 19px); line-height: 1.6; color: var(--soft); }

/* ---------- Buttons ---------- */
.btn-primary, .btn-ghost {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 20px; border: 1px solid transparent; border-radius: 6px;
  font-family: var(--mono); font-size: 14px; font-weight: 700; line-height: 1.2; letter-spacing: .02em;
  text-decoration: none; white-space: nowrap; cursor: pointer;
  transition: background-color .15s, border-color .15s, transform .1s;
}
.btn-primary { background: var(--accent-fill); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost { border-color: var(--line-strong); background: transparent; color: var(--text); }
.btn-ghost:hover { border-color: var(--soft); background: var(--surface); }
.btn-primary:active, .btn-ghost:active { transform: translateY(1px); }
.btn-sm { min-height: 38px; padding: 0 14px; font-size: 13px; }
.btn-sm::after { content: ""; position: absolute; inset: -3px 0; } /* keeps the tap target at 44px */

/* ---------- Status glyphs: colour always paired with a glyph ---------- */
.g { display: inline-block; flex: none; width: 1.1ch; font-family: var(--mono); font-style: normal; font-weight: 400; line-height: 1; text-align: center; }
.g-ok { color: var(--ok); }
.g-wait { color: var(--warn); font-weight: var(--wait-weight); }
.g-bad { color: var(--bad); }
.g-skip { color: var(--soft); }

/* ---------- Accessibility ---------- */
.sr { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0; }
.skip {
  position: absolute; top: 8px; left: 16px; z-index: 100; transform: translateY(-160%);
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 18px; border-radius: 6px;
  background: var(--accent-fill); color: var(--on-accent);
  font-family: var(--mono); font-size: 14px; font-weight: 700; text-decoration: none;
}
.skip:focus { transform: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn-primary:focus-visible, .skip:focus-visible { outline-offset: 3px; }

/* sections land below the sticky header */
[id] { scroll-margin-top: calc(var(--head-h) + 16px); }
section[id], main[id] { scroll-margin-top: var(--head-h); }

/* ---------- Header ---------- */
.site-head { position: sticky; top: 0; z-index: 50; border-bottom: 1px solid var(--faint); }
.head-row { display: flex; align-items: center; gap: 12px; height: calc(var(--head-h) - 1px); }
.brand {
  display: inline-flex; align-items: center; gap: 10px; min-height: 44px;
  color: var(--text); text-decoration: none;
  font-family: var(--mono); font-size: 14px; font-weight: 700; line-height: 1; letter-spacing: .32em; text-transform: uppercase;
}
.brand svg { width: 16px; height: 16px; }
.brand span { margin-right: -.32em; } /* the tracking after the last letter is not part of the word */
.head-row .brand { margin-right: auto; }
.nav ul { display: flex; align-items: center; gap: clamp(14px, 1.9vw, 30px); }
.nav a, .menu-panel a { text-decoration: none; font-family: var(--mono); }
.nav a { display: inline-flex; align-items: center; min-height: 44px; font-size: 13px; letter-spacing: .01em; color: var(--soft); transition: color .15s; }
.nav a:hover, .nav a[aria-current="page"] { color: var(--text); }
.head-cta { margin-left: clamp(4px, 1.4vw, 18px); }

/* the menu: a <details> that works without JS, shown under 900px */
.menu { display: none; }
.menu > summary {
  position: relative; display: inline-flex; align-items: center; gap: 8px; min-height: 38px; padding: 0 12px 0 11px;
  border: 1px solid var(--line-strong); border-radius: 6px; list-style: none; cursor: pointer; user-select: none;
  font-family: var(--mono); font-size: 13px; font-weight: 700; line-height: 1; letter-spacing: .02em;
  transition: background-color .15s, border-color .15s;
}
.menu > summary::-webkit-details-marker { display: none; }
.menu > summary::after { content: ""; position: absolute; inset: -3px 0; }
.menu > summary:hover, .menu[open] > summary { border-color: var(--soft); background: var(--surface); }
.menu > summary svg { width: 14px; height: 14px; }
.menu .mi-close, .menu[open] .mi-open { display: none; }
.menu[open] .mi-close { display: block; }
.menu-panel {
  position: absolute; top: 100%; left: 0; right: 0;
  max-height: calc(100svh - var(--head-h)); overflow-y: auto; overscroll-behavior: contain;
  padding: 4px var(--gutter) 8px; background: var(--bg); border-bottom: 1px solid var(--faint);
}
.menu-panel li:last-child a { border-bottom: 0; }
.menu-panel a {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 52px;
  border-bottom: 1px solid var(--faint); font-size: 15px; color: var(--text);
}
.menu-panel a::after { content: "\2193"; content: "\2193" / ""; color: var(--soft); font-size: 13px; }
.menu-panel a:not([href^="#"])::after { content: "\2192"; content: "\2192" / ""; } /* goes to another page */
.menu-panel a:hover::after { color: var(--text); }
@media (max-width: 899px) {
  .nav { display: none; }
  .menu { display: block; }
  .head-cta { margin-left: 0; }
}

/* ---------- Hero shell ---------- */
.hero {
  position: relative; isolation: isolate; overflow: clip;
  display: grid; grid-template-columns: minmax(0, 1fr); align-content: center; row-gap: clamp(32px, 4vw, 48px);
  min-height: min(calc(100svh - var(--head-h)), 920px);
  padding-block: clamp(40px, 4.5vw, 64px) clamp(48px, 6vw, 88px);
}
.hero > .hero-copy { width: 100%; max-width: calc(var(--wrap) + 2 * var(--gutter)); margin-inline: auto; padding-inline: var(--gutter); }
.hero > .hub { width: 100%; min-width: 0; }

/* ---------- Footer ----------
   One footer for every page, written by tools/pages.py (parts/footer.html on the home page): the brand, a
   one-line description, the founder line, an 11-link nav (8 home-page sections, then About, Terms, Privacy)
   and the legal lines, copyright first. */
.site-foot { padding-block: clamp(48px, 6vw, 80px) 28px; border-top: 1px solid var(--faint); }
.foot-top { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 32px clamp(32px, 6vw, 96px); align-items: start; }
.foot-brand p { max-width: 42ch; margin-top: 14px; font-size: 15px; line-height: 1.6; color: var(--soft); }
.foot-brand .foot-founder { margin-top: 10px; }
.foot-founder a { color: var(--text); }
/* filled column by column: the sections down the first two columns, About / Terms / Privacy in the third */
.foot-nav ul { display: grid; grid-auto-flow: column; grid-template-rows: repeat(4, auto); justify-content: start; column-gap: clamp(28px, 4vw, 56px); }
.foot-nav a { display: inline-flex; align-items: center; min-height: 44px; font-family: var(--mono); font-size: 13px; color: var(--soft); text-decoration: none; }
.foot-nav a:hover, .foot-nav a[aria-current="page"] { color: var(--text); text-decoration: underline; text-decoration-color: var(--line-strong); }
.foot-legal {
  display: grid; gap: 8px; margin-top: clamp(36px, 5vw, 56px); padding-top: 20px;
  border-top: 1px solid var(--faint); font-size: 13px; line-height: 1.6; color: var(--soft);
}
.foot-legal p { max-width: 96ch; }
.foot-legal p:first-child { color: var(--text); }
@media (max-width: 899px) {
  .foot-top { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 559px) {
  .foot-nav ul { grid-template-rows: repeat(6, auto); }
}

/* ---------- Motion ---------- */
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }
@media (prefers-reduced-motion: reduce) {
  /* the still is the finished state: write base styles as the end state and animate *from* the hidden one */
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
