/*
 * Shared styles for the static pages: privacy.html, 404.html and the
 * generated skills/ pages (scripts/skill_pages.py). They are plain HTML served
 * outside the Vite bundle, so they cannot import the app's CSS; this file
 * gives them the same faces, colours and chrome.
 *
 * The tokens below MIRROR web/src/tokens.css (the subset these pages use).
 * Change a value there, change it here.
 *
 * Fonts: scripts/copy_fonts.mjs copies them into public/fonts/ before every
 * dev and build run. Self-hosted, never a font CDN (see privacy.html).
 */
@font-face {
  font-family: 'Bricolage Grotesque Variable';
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src: url('fonts/bricolage-grotesque-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Noto Sans';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('fonts/noto-sans-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-024F, U+1E00-1E9F, U+1EF2-1EFF, U+2113;
}
@font-face {
  font-family: 'Noto Sans';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('fonts/noto-sans-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ============================================================ tokens */
:root {
  color-scheme: light;

  --brand-50: #eef7fe; --brand-100: #d9edfc; --brand-200: #b9dcf6; --brand-300: #8ec8f0;
  --brand-500: #3aa3ec; --brand-600: #1d8ad8; --brand-700: #1479c2; --brand-800: #0f67a8; --brand-900: #0c5a93;
  --rw-50: #fdf2f7; --rw-100: #fbe4ef; --rw-200: #f6c4da; --rw-500: #e0528d; --rw-600: #c4316d; --rw-700: #a3245a;
  --math-50: #eff8ff; --math-100: #dcefff; --math-200: #b5ddfb; --math-500: #2b9be6; --math-600: #0b78bf; --math-700: #075f99;
  --ok-500: #22a35a; --warn-500: #eab308; --bad-500: #e5384f;
  --streak-500: #f2771a;

  --surface: #ffffff;
  --surface-subtle: #f6f8fa;
  --surface-sunken: #eef1f4;
  --fg-1: #11151a;
  --fg-2: #3d444d;
  --fg-3: #5b636e;
  --fg-4: #8b939e;
  --fg-inv-1: #ffffff;
  --fg-link: var(--brand-700);
  --fg-link-hover: var(--brand-800);
  --hair-1: #e4e8ed;
  --hair-2: #cdd3db;
  --hair-ctl: #8a94a3;
  --focus: var(--brand-700);
  --n-900: #11151a;
  /* Fills under white text, the same in both themes (tokens.css). */
  --fill-brand: #1479c2; --fill-brand-hover: #0f67a8; --fill-brand-press: #0c5a93;
  --fill-brand-edge: #0a4a7a; --hair-edge: #c3cad3;

  /* No system-ui anywhere: the pages must render in the brand faces. */
  --display: 'Bricolage Grotesque Variable', 'Noto Sans', sans-serif;
  --sans: 'Noto Sans', sans-serif;
  --type-title:   800 48px/50px var(--display);
  --type-h1:      800 34px/38px var(--display);
  --type-h2:      800 22px/28px var(--display);
  --type-h3:      750 17px/22px var(--display);
  --type-lead:    400 17px/26px var(--sans);
  --type-body:    400 15px/24px var(--sans);
  --type-ui:      500 14px/20px var(--sans);
  --type-small:   400 13px/18px var(--sans);
  --type-label:   650 12px/16px var(--sans);
  --tr-title: -.035em; --tr-h1: -.03em; --tr-h2: -.015em; --tr-h3: -.01em; --tr-ui: -.005em; --tr-label: .06em;
  --num-xl: 72px; --tr-num-xl: -.045em;

  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 20px; --sp-6: 24px;
  --sp-8: 32px; --sp-10: 40px; --sp-12: 48px; --sp-16: 64px;
  --container: 1160px;
  --gutter: 32px;
  --measure: 720px;
  --rad-xs: 6px; --rad-sm: 8px; --rad-md: 12px; --rad-pill: 999px;
  --ease-std: cubic-bezier(.2, 0, 0, 1);
  --dur-instant: 80ms;
  --dur-fast: 120ms;
}

/* Dark theme: the app's dark values (tokens.css), the subset used here. */
:root[data-theme=dark] {
  color-scheme: dark;
  --brand-50: #0f2133; --brand-100: #10283d; --brand-700: #5cb0ec; --brand-800: #9fd0f4;
  --rw-50: #2a121e; --rw-100: #3a1426; --rw-700: #f08cb6;
  --math-50: #0d2235; --math-100: #0f2a42; --math-700: #6cbcf2;
  --surface: #12171d;
  --surface-subtle: #171d24;
  --surface-sunken: #222a33;
  --fg-1: #e8ecf1;
  --fg-2: #c3cad3;
  --fg-3: #9da6b1;
  --fg-4: #6f7883;
  --hair-1: #262e37;
  --hair-2: #36404b;
  --hair-ctl: #76808d;
  --hair-edge: #36404b;
}
@media (max-width: 819px) {
  :root {
    --type-title: 800 34px/36px var(--display);
    --type-h1:    800 26px/30px var(--display);
    --type-h2:    800 20px/26px var(--display);
    --type-lead:  400 16px/24px var(--sans);
    --num-xl: 56px;
    --gutter: 16px;
  }
}
/* Section scope, as in tokens.css: put .sec-RW or .sec-MATH on a container. */
.sec-RW { --sec-50: var(--rw-50); --sec-100: var(--rw-100); --sec-500: var(--rw-500); --sec-600: var(--rw-600); --sec-700: var(--rw-700); }
.sec-MATH { --sec-50: var(--math-50); --sec-100: var(--math-100); --sec-500: var(--math-500); --sec-600: var(--math-600); --sec-700: var(--math-700); }

/* ============================================================ base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; background: var(--surface); color: var(--fg-1);
  font: var(--type-body);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, ul, ol { margin: 0; }
:is(h1, h2) { text-wrap: balance; }
p { margin: 0; text-wrap: pretty; }
strong { font-weight: 650; }
a { color: var(--fg-link); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--fg-link-hover); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
svg { display: block; flex: none; }

/* ============================================================ header
   The app's 64px top bar, reduced to the brand and one way into practice. */
.sh { background: var(--surface); border-bottom: 1px solid var(--hair-1); }
.sh-in {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4);
  max-width: var(--container); height: 63px; margin: 0 auto; padding: 0 var(--gutter);
}
.sh-brand {
  display: inline-flex; align-items: center; gap: 10px; min-width: 0;
  border-radius: var(--rad-sm); color: var(--fg-1); text-decoration: none;
}
.sh-brand:hover { color: var(--fg-1); }
.wordmark { font: 800 19px/24px var(--display); letter-spacing: -.03em; white-space: nowrap; }
.wordmark b { font-weight: inherit; color: var(--brand-700); }
@media (max-width: 819px) {
  .sh-in { height: 51px; }
  .sh-brand { gap: 8px; }
  .sh-brand svg { width: 24px; height: 24px; }
  .wordmark { font-size: 18px; }
}

/* ============================================================ buttons
   Press-down, as in the app: a solid lip the button drops onto. */
.btn {
  --edge: var(--hair-edge); --lip: 3px;
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  min-height: 40px; padding: 0 16px; border: 2px solid var(--hair-2); border-radius: var(--rad-md);
  background: var(--surface); color: var(--fg-1); text-align: center; text-decoration: none; cursor: pointer;
  font: 600 14px/20px var(--sans); letter-spacing: var(--tr-ui); white-space: nowrap;
  box-shadow: 0 var(--lip) 0 var(--edge);
  transition: background-color var(--dur-fast) var(--ease-std), border-color var(--dur-fast) var(--ease-std),
    color var(--dur-fast) var(--ease-std), transform var(--dur-instant) linear, box-shadow var(--dur-instant) linear;
}
.btn svg { width: 16px; height: 16px; }
.btn.sm { --lip: 2px; min-height: 32px; padding: 0 12px; border-radius: 10px; font-size: 13px; line-height: 18px; }
.btn.lg { --lip: 4px; min-height: 48px; padding: 0 20px; font-size: 15px; line-height: 22px; }
.btn:hover { background: var(--surface-subtle); border-color: var(--hair-ctl); color: var(--fg-1); }
.btn:active { background: var(--surface-sunken); transform: translateY(var(--lip)); box-shadow: 0 0 0 var(--edge); }
.btn.primary { --edge: var(--fill-brand-edge); background: var(--fill-brand); border-color: var(--fill-brand); color: var(--fg-inv-1); }
.btn.primary:hover { background: var(--fill-brand-hover); border-color: var(--fill-brand-hover); color: var(--fg-inv-1); }
.btn.primary:active { background: var(--fill-brand-press); border-color: var(--fill-brand-press); }
.btn.quiet { --lip: 0px; background: none; border-color: transparent; color: var(--fg-2); }
.btn.quiet:hover { background: var(--surface-subtle); border-color: transparent; color: var(--fg-1); }
.btn.quiet:active { background: var(--surface-sunken); }

/* ============================================================ breadcrumb */
.crumbs { display: flex; flex-wrap: wrap; gap: var(--sp-1) var(--sp-2); padding: 0; list-style: none; font: var(--type-small); color: var(--fg-3); }
.crumbs li + li::before { content: '/'; margin-right: var(--sp-2); color: var(--fg-4); }
.crumbs a { color: var(--fg-3); }
.crumbs a:hover { color: var(--fg-link-hover); }
.crumbs [aria-current] { color: var(--fg-2); }

/* ============================================================ rows (spec 7.11) */
.rows { padding: 0; list-style: none; border-top: 1px solid var(--hair-1); }
.row {
  display: flex; align-items: center; gap: var(--sp-3); min-height: 56px; padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--hair-1); color: var(--fg-1); text-decoration: none;
  transition: background-color var(--dur-fast) var(--ease-std);
}
a.row:hover { background: var(--surface-subtle); color: var(--fg-1); }
.row-main { flex: 1; min-width: 0; }
.row-t { display: block; font: var(--type-h3); letter-spacing: var(--tr-h3); }
.row-m { display: block; margin-top: 2px; font: var(--type-small); color: var(--fg-3); }
.row-n { flex: none; font: var(--type-ui); color: var(--fg-2); text-align: right; font-variant-numeric: tabular-nums lining-nums; }
.row-chev { color: var(--fg-3); }

/* ============================================================ footer
   One footer on every static page (SP-12), in step with components/Footer.tsx. */
.sf { border-top: 1px solid var(--hair-1); background: var(--surface); }
.sf-in {
  display: flex; flex-direction: column; gap: var(--sp-3);
  max-width: var(--container); margin: 0 auto; padding: var(--sp-6) var(--gutter) var(--sp-8);
  font: 400 13px/20px var(--sans); color: var(--fg-3);
}
.sf-links { display: flex; flex-wrap: wrap; gap: var(--sp-1) var(--sp-5); padding: 0; list-style: none; }
.sf-links a { color: var(--fg-2); font-weight: 500; text-decoration-color: var(--hair-2); }
.sf-links a:hover { color: var(--fg-link-hover); text-decoration-color: currentColor; }

/* ============================================================ prose (privacy)
   One 720px column; at 1100px and wider a sticky 200px contents list sits
   to its left. */
.doc {
  max-width: var(--container); margin: 0 auto;
  padding: var(--sp-12) var(--gutter) var(--sp-16);
}
.toc { display: none; }
@media (min-width: 1100px) {
  .doc {
    display: grid; grid-template-columns: 200px minmax(0, var(--measure));
    justify-content: center; align-items: start; gap: var(--sp-16);
  }
  .toc { display: block; position: sticky; top: var(--sp-8); padding-top: 6px; }
}
.toc-h { font: var(--type-label); letter-spacing: var(--tr-label); text-transform: uppercase; color: var(--fg-3); }
.toc ol { margin-top: var(--sp-3); padding: 0; list-style: none; border-left: 1px solid var(--hair-1); }
.toc a {
  display: block; margin-left: -1px; padding: 6px 0 6px 14px; border-left: 2px solid transparent;
  font: var(--type-ui); color: var(--fg-2); text-decoration: none;
}
.toc a:hover { border-left-color: var(--hair-ctl); color: var(--fg-1); }

.prose { max-width: var(--measure); font: 400 16px/1.7 var(--sans); color: var(--fg-2); }
.prose h1 { font: var(--type-title); letter-spacing: var(--tr-title); color: var(--fg-1); }
.prose .updated { margin-top: var(--sp-3); font: var(--type-small); color: var(--fg-3); }
.prose h2 {
  margin-top: var(--sp-10); scroll-margin-top: var(--sp-6);
  font: var(--type-h2); letter-spacing: var(--tr-h2); color: var(--fg-1);
}
.prose h1 + .updated + p { margin-top: var(--sp-6); font: var(--type-lead); color: var(--fg-2); }
.prose h2 + * { margin-top: var(--sp-3); }
.prose p + :is(p, ul) { margin-top: var(--sp-4); }
.prose ul + p { margin-top: var(--sp-4); }
.prose ul { padding-left: 22px; }
.prose li + li { margin-top: var(--sp-2); }
.prose li::marker { color: var(--fg-4); }
.prose strong { color: var(--fg-1); }
@media (max-width: 819px) {
  .doc { padding-top: var(--sp-8); padding-bottom: var(--sp-12); }
  .prose h2 { margin-top: var(--sp-8); }
}

/* ============================================================ skill pages
   The skills index and the 29 skill pages written by scripts/skill_pages.py
   (spec 8.8). One 720px column, like privacy. */
.sk {
  max-width: calc(var(--measure) + 2 * var(--gutter)); margin: 0 auto;
  padding: var(--sp-10) var(--gutter) var(--sp-16);
}
.sk .crumbs { margin-bottom: var(--sp-6); }
.eyebrow {
  font: var(--type-label); letter-spacing: var(--tr-label); text-transform: uppercase;
  color: var(--sec-700, var(--brand-700));
}
.eyebrow.brand { color: var(--brand-700); }
.sk h1 { margin-top: var(--sp-2); font: var(--type-title); letter-spacing: var(--tr-title); }
.sk .lede { max-width: 60ch; margin-top: var(--sp-3); font: var(--type-lead); color: var(--fg-2); }
.sk .cta { margin-top: var(--sp-6); }
.sk section { margin-top: var(--sp-10); }
.sk h2 { font: var(--type-h2); letter-spacing: var(--tr-h2); }
.sk h2 + p { margin-top: var(--sp-2); font: 400 16px/26px var(--sans); color: var(--fg-2); }
.sk :is(h2, p) + :is(.rows, .sibs) { margin-top: var(--sp-4); }
.back-all { margin-top: var(--sp-10); }

/* Difficulty colours: the dot on a tag and a segment of the mix bar. */
.d-E { --dot: var(--ok-500); }
.d-M { --dot: var(--warn-500); }
.d-H { --dot: var(--bad-500); }

/* Static tags (spec 7.5): the skill's Easy, Medium and Hard counts. */
.tags { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-top: var(--sp-4); padding: 0; list-style: none; }
.tag {
  display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px;
  border-radius: var(--rad-pill); background: var(--surface-subtle); color: var(--fg-2);
  font: 600 12px/16px var(--sans); font-variant-numeric: tabular-nums lining-nums;
}
.tag::before { content: ''; width: 8px; height: 8px; border-radius: var(--rad-pill); background: var(--dot); }

/* Index: section headers carry the section colour, domains are quiet labels. */
.sk-group { margin-top: var(--sp-12); }
.sk-h { display: flex; flex-wrap: wrap; align-items: center; gap: 0 var(--sp-2); color: var(--sec-700); }
.sk-h::before { content: ''; width: 8px; height: 8px; border-radius: var(--rad-pill); background: var(--sec-500); }
.sk-hn { font-weight: 600; color: var(--fg-3); }
.sk-domain {
  margin: var(--sp-8) 0 var(--sp-2); font: var(--type-label); letter-spacing: var(--tr-label);
  text-transform: uppercase; color: var(--fg-3);
}
.sk-h + .sk-domain { margin-top: var(--sp-4); }
.sk-group .row-n { min-width: 104px; color: var(--fg-3); }
.mix { clip-path: inset(0 round 3px); }
.mix rect { fill: var(--dot); }

/* The count under the name, only where the name needs the row's width. */
.row-c { display: none; }
@media (max-width: 479px) {
  .row-c { display: block; }
  .row .row-n { display: none; }
}

/* Sibling skills: chips on desktop, full-width 48px rows on phone, where
   chips wrapped into two-line blobs. */
.sibs { display: flex; flex-wrap: wrap; gap: var(--sp-2); padding: 0; list-style: none; }
.sibs a {
  display: inline-flex; align-items: center; min-height: 32px; padding: 0 12px;
  border: 1px solid var(--hair-2); border-radius: var(--rad-md); background: var(--surface);
  color: var(--fg-2); font: var(--type-ui); letter-spacing: var(--tr-ui); text-decoration: none;
  transition: border-color var(--dur-fast) var(--ease-std), background-color var(--dur-fast) var(--ease-std);
}
.sibs a:hover { border-color: var(--hair-ctl); color: var(--fg-1); }
.sibs .row-chev { display: none; }
@media (max-width: 819px) {
  .sk { padding-top: var(--sp-6); padding-bottom: var(--sp-12); }
  .sk section { margin-top: var(--sp-8); }
  .sk-group { margin-top: var(--sp-10); }
  .sibs { display: block; border-top: 1px solid var(--hair-1); }
  .sibs a {
    display: flex; justify-content: space-between; gap: var(--sp-3); min-height: 48px; padding: var(--sp-2) var(--sp-4);
    border: 0; border-bottom: 1px solid var(--hair-1); border-radius: 0; color: var(--fg-1);
  }
  .sibs a:hover { background: var(--surface-subtle); }
  .sibs .row-chev { display: block; }
}

/* ============================================================ 404 */
.nf-page { height: 100%; overflow-x: hidden; }
.nf-page body { display: flex; flex-direction: column; min-height: 100%; }
.nf {
  flex: 1 0 auto; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: var(--sp-12) var(--gutter); text-align: center;
}
.nf-code {
  margin-top: var(--sp-4); font: 800 var(--num-xl)/1 var(--display); letter-spacing: var(--tr-num-xl);
  color: var(--brand-700); font-variant-numeric: tabular-nums lining-nums;
}
.nf h1 { margin-top: var(--sp-4); font: var(--type-h1); letter-spacing: var(--tr-h1); }
.nf-lead { max-width: 44ch; margin-top: var(--sp-3); font: var(--type-lead); color: var(--fg-3); text-wrap: balance; }
.nf .btn.lg { margin-top: var(--sp-8); }
.nf-more { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: var(--sp-1); margin-top: var(--sp-4); padding: 0; list-style: none; }
.nf-more li + li::before { content: '\00b7'; margin-right: var(--sp-1); color: var(--fg-4); }
.nf-more a { display: inline-block; padding: 6px 8px; font: var(--type-ui); color: var(--fg-2); text-decoration-color: var(--hair-2); }
.nf-more a:hover { color: var(--fg-link-hover); text-decoration-color: currentColor; }

/* Bulb (components/Mascot.tsx), the same fills as the app. */
.bulb-glass, .bulb-limb-fill { fill: var(--brand-500); }
.bulb-base { fill: var(--fill-brand); }
.bulb-limb { fill: none; stroke: var(--brand-500); stroke-width: 9; stroke-linecap: round; }
.bulb-check { fill: none; stroke: var(--fg-inv-1); stroke-width: 9; stroke-linecap: round; stroke-linejoin: round; }
.bulb-ink { fill: var(--n-900); }
.bulb-line { fill: none; stroke: var(--n-900); stroke-width: 3.4; stroke-linecap: round; stroke-linejoin: round; }
.bulb-shine { fill: var(--fg-inv-1); }
.bulb-cheek { fill: var(--rw-200); }
.bulb-sweat { fill: var(--brand-200); }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
