/* ============================================================================
   EXKNOTS — docs site stylesheet
   Aesthetic: risograph mathematical field-zine. Warm newsprint paper, deep warm
   ink, two riso "spot" colors (federal blue + vermilion) echoing the two-color
   line diagrams. Signature detail: a hard offset "misregistration" shadow on
   cards. Dark mode flips to a cyanotype/blueprint ground.
   Fonts: Instrument Serif (display) · Newsreader (long-form) · JetBrains Mono.

   NOTE: the :root token block below is kept in sync with style.css (the
   explorer). If you change a token here, mirror it there.
   ========================================================================== */

/* ---- Design tokens ------------------------------------------------------- */
:root {
  /* paper / surfaces */
  --paper: #f4efe4;
  --paper-2: #ece2d0;
  --surface: #fcf8f0;
  --surface-2: #f6efe0;
  --figure-mat: #fbf7ee;
  /* ink */
  --ink: #1b1813;
  --ink-2: #5a5142;
  --ink-3: #8a7f6c;
  --rule: #ddd1ba;
  --rule-strong: #c7b99c;
  /* riso spot colors */
  --blue: #1f43c4;
  --blue-2: #16319a;
  --blue-soft: #dde2f5;
  --red: #d8402a;
  --red-2: #b22f1d;
  --red-soft: #f6dcd3;
  --ochre: #b2760f;
  --ochre-soft: #f0e3c4;
  /* difficulty tiers (fg / bg) */
  --d-beg-fg: #2c6a3a;  --d-beg-bg: #d9e9dc;
  --d-int-fg: #213f9c;  --d-int-bg: #dee3f5;
  --d-adv-fg: #855612;  --d-adv-bg: #f0e3c6;
  --d-exp-fg: #b02f1c;  --d-exp-bg: #f6ddd4;
  /* diagram palette (tokenized SVGs inherit these; gaps use the figure mat) */
  --dia-surface: var(--figure-mat);
  --dia-ink: #24211a;  --dia-inksoft: #6a6151;  --dia-rigid: #8a8275;  --dia-faint: #c9bda7;
  --dia-cord: #1f57c4; --dia-neg: #cf3a26; --dia-pos: #2f8f43; --dia-ring: #b97d12; --dia-gold: #c79a22; --dia-wood: #b07d52; --dia-wash: #ece3d0;
  /* misregistration shadow + arc accents */
  --pop: var(--blue);
  --arc1: #1f43c4;  --arc2: #0f8a86;  --arc3: #b2760f;  --arc4: #d8402a;

  --shadow-pop: 5px 5px 0 var(--blue-soft);
  --shadow-card: 0 1px 0 var(--rule), 0 14px 30px -22px rgba(27,24,19,.5);

  --maxw: 1180px;
  --measure: 68ch;
  --rad: 6px;
  --rad-lg: 12px;
  --nav-h: 62px;

  --serif: "Newsreader", Georgia, "Times New Roman", serif;
  --display: "Instrument Serif", "Newsreader", Georgia, serif;
  --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;

  --fs--1: .82rem;
  --fs-0: 1rem;
  --fs-1: 1.14rem;
  --fs-2: 1.42rem;
  --fs-3: 1.85rem;
  --fs-4: clamp(2rem, 4vw, 2.7rem);
  --fs-5: clamp(2.6rem, 6vw, 4.4rem);
  --fs-hero: clamp(3.4rem, 13vw, 9.5rem);
}

[data-theme="dark"] {
  --paper: #0f1320;
  --paper-2: #141a2b;
  --surface: #172033;
  --surface-2: #1d2740;
  --figure-mat: #1b2338;
  --ink: #ece5d6;
  --ink-2: #b4ac99;
  --ink-3: #808b9f;
  --rule: #2a3450;
  --rule-strong: #3b486a;
  --blue: #7aa2ff;
  --blue-2: #9bb8ff;
  --blue-soft: #18233f;
  --red: #ff7d5e;
  --red-2: #ff9a80;
  --red-soft: #2c1a14;
  --ochre: #e3b24c;
  --ochre-soft: #2a2414;
  --d-beg-fg: #84cf96;  --d-beg-bg: #15281b;
  --d-int-fg: #9bb6ff;  --d-int-bg: #16213f;
  --d-adv-fg: #e3b24c;  --d-adv-bg: #2a2414;
  --d-exp-fg: #ff8a6c;  --d-exp-bg: #2c1a14;
  --dia-ink: #e8e2d4; --dia-inksoft: #aab2c0; --dia-rigid: #8b94a6; --dia-faint: #3c4760;
  --dia-cord: #6f9cff; --dia-neg: #ff7d5e; --dia-pos: #5cc06f; --dia-ring: #e3b24c; --dia-gold: #e8c24e; --dia-wood: #c99a6e; --dia-wash: #222c44;
  --arc1: #7aa2ff;  --arc2: #4fd0c9;  --arc3: #e3b24c;  --arc4: #ff7d5e;
  --shadow-pop: 5px 5px 0 var(--blue-soft);
  --shadow-card: 0 1px 0 var(--rule), 0 18px 36px -24px rgba(0,0,0,.7);
}
/* OS dark by default, unless the visitor has forced light */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0f1320; --paper-2: #141a2b; --surface: #172033; --surface-2: #1d2740; --figure-mat: #1b2338;
    --ink: #ece5d6; --ink-2: #b4ac99; --ink-3: #808b9f; --rule: #2a3450; --rule-strong: #3b486a;
    --blue: #7aa2ff; --blue-2: #9bb8ff; --blue-soft: #18233f;
    --red: #ff7d5e; --red-2: #ff9a80; --red-soft: #2c1a14;
    --ochre: #e3b24c; --ochre-soft: #2a2414;
    --d-beg-fg: #84cf96; --d-beg-bg: #15281b; --d-int-fg: #9bb6ff; --d-int-bg: #16213f;
    --d-adv-fg: #e3b24c; --d-adv-bg: #2a2414; --d-exp-fg: #ff8a6c; --d-exp-bg: #2c1a14;
    --dia-ink: #e8e2d4; --dia-inksoft: #aab2c0; --dia-rigid: #8b94a6; --dia-faint: #3c4760;
    --dia-cord: #6f9cff; --dia-neg: #ff7d5e; --dia-pos: #5cc06f; --dia-ring: #e3b24c; --dia-gold: #e8c24e; --dia-wood: #c99a6e; --dia-wash: #222c44;
    --arc1: #7aa2ff; --arc2: #4fd0c9; --arc3: #e3b24c; --arc4: #ff7d5e;
    --shadow-card: 0 1px 0 var(--rule), 0 18px 36px -24px rgba(0,0,0,.7);
  }
}

/* ---- Reset & base -------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  margin: 0;
  font-family: var(--serif);
  font-size: var(--fs-1);
  line-height: 1.72;
  color: var(--ink);
  background-color: var(--paper);
  /* paper grain + faint blueprint hairlines */
  background-image:
    radial-gradient(var(--rule) .6px, transparent .6px),
    radial-gradient(var(--rule) .6px, var(--paper) .6px);
  background-size: 22px 22px, 22px 22px;
  background-position: 0 0, 11px 11px;
  background-attachment: fixed;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; height: auto; }
a { color: var(--blue); text-underline-offset: .18em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2.5px solid var(--blue); outline-offset: 3px; border-radius: 2px; }
::selection { background: var(--ochre-soft); color: var(--ink); }
.skip-link {
  position: absolute; left: -999px; top: 0; z-index: 100;
  background: var(--ink); color: var(--paper); padding: .6em 1em; border-radius: 0 0 var(--rad) 0;
}
.skip-link:focus { left: 0; }

/* ---- Type ---------------------------------------------------------------- */
h1, h2, h3, h4 { font-family: var(--serif); font-weight: 560; line-height: 1.12; color: var(--ink); letter-spacing: -.01em; }
h1 { font-size: var(--fs-5); }
h2 { font-size: var(--fs-3); margin: 2.4em 0 .6em; }
h3 { font-size: var(--fs-2); margin: 1.8em 0 .5em; }
h4 { font-size: var(--fs-1); margin: 1.4em 0 .4em; text-transform: uppercase; letter-spacing: .06em; font-family: var(--mono); font-weight: 600; font-size: .9rem; color: var(--ink-2); }
p { margin: 0 0 1.1em; }
strong { font-weight: 680; }
.eyebrow { font-family: var(--mono); font-size: var(--fs--1); text-transform: uppercase; letter-spacing: .22em; color: var(--ink-3); font-weight: 500; }
.notation, code { font-family: var(--mono); }
code {
  font-size: .88em; background: var(--surface-2); border: 1px solid var(--rule);
  padding: .08em .4em; border-radius: 4px; color: var(--blue-2);
}
.notation { color: var(--ink-2); }
pre {
  font-family: var(--mono); font-size: .85rem; line-height: 1.6; background: var(--surface-2);
  border: 1px solid var(--rule); border-left: 3px solid var(--blue); border-radius: var(--rad);
  padding: 1em 1.1em; overflow-x: auto; margin: 1.4em 0;
}
pre code { background: none; border: 0; padding: 0; color: var(--ink); font-size: 1em; }

/* ---- Layout helpers ------------------------------------------------------ */
.wrap { max-width: var(--maxw); margin-inline: auto; padding-inline: clamp(1rem, 4vw, 2.4rem); }
.prose { max-width: var(--measure); }
.prose > * + h2 { border-top: 1px solid var(--rule); padding-top: 1.6em; }
main { min-height: 60vh; }
.band { padding: clamp(3rem, 8vw, 6rem) 0; }
.band--alt { background: var(--paper-2); }

/* ---- Top nav ------------------------------------------------------------- */
.nav {
  position: sticky; top: 0; z-index: 50; height: var(--nav-h);
  display: flex; align-items: center; gap: 1.4rem;
  padding-inline: clamp(1rem, 4vw, 2.4rem);
  background: color-mix(in srgb, var(--paper) 86%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid transparent;
  transition: border-color .25s, box-shadow .25s;
}
.nav.is-scrolled { border-bottom-color: var(--rule); box-shadow: 0 6px 20px -18px rgba(27,24,19,.7); }
.brand { display: inline-flex; align-items: center; gap: .55rem; text-decoration: none; color: var(--ink); margin-right: auto; }
/* logomark base stroke (context overrides follow for hero/footer) */
.logomark { fill: none; }
.logomark .lm-strand { stroke: var(--blue); }
.logomark .lm-gap { stroke: var(--paper); }
.brand .logomark { width: 30px; height: 30px; flex: none; }
.brand .logomark .lm-gap { stroke: var(--paper); }
.brand-word { font-family: var(--display); font-size: 1.65rem; letter-spacing: .04em; line-height: 1; }
.brand-word .x { color: var(--red); font-style: italic; }
.nav-links { display: flex; align-items: center; gap: 1.15rem; list-style: none; margin: 0; padding: 0; }
.nav-links a {
  font-family: var(--mono); font-size: .8rem; text-transform: uppercase; letter-spacing: .12em;
  color: var(--ink-2); text-decoration: none; padding: .4em .1em; position: relative;
}
.nav-links a:hover, .nav-links a[aria-current="page"] { color: var(--ink); }
.nav-links a::after {
  content: ""; position: absolute; left: 0; right: 100%; bottom: .1em; height: 2px;
  background: var(--red); transition: right .22s ease;
}
.nav-links a:hover::after, .nav-links a[aria-current="page"]::after { right: 0; }
.nav-links a.cta { color: var(--paper); background: var(--blue); padding: .5em .9em; border-radius: var(--rad); }
.nav-links a.cta::after { display: none; }
.nav-links a.cta:hover { background: var(--blue-2); color: var(--paper); }

.theme-toggle, .nav-burger {
  appearance: none; background: var(--surface); border: 1px solid var(--rule-strong);
  color: var(--ink); width: 38px; height: 38px; border-radius: var(--rad); cursor: pointer;
  display: inline-grid; place-items: center; font-size: 1rem;
}
.theme-toggle:hover, .nav-burger:hover { border-color: var(--ink-2); }
.theme-toggle .moon { display: none; }
[data-theme="dark"] .theme-toggle .sun { display: none; }
[data-theme="dark"] .theme-toggle .moon { display: inline; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .sun { display: none; }
  :root:not([data-theme="light"]) .theme-toggle .moon { display: inline; }
}
.nav-burger { display: none; }

/* mobile nav */
@media (max-width: 820px) {
  .nav-links {
    position: fixed; inset: var(--nav-h) 0 auto 0; flex-direction: column; align-items: flex-start;
    gap: .2rem; background: var(--paper); border-bottom: 1px solid var(--rule);
    padding: 1rem clamp(1rem, 4vw, 2.4rem) 1.4rem; transform: translateY(-12px); opacity: 0;
    pointer-events: none; transition: opacity .2s, transform .2s;
    box-shadow: 0 20px 40px -28px rgba(0,0,0,.6);
  }
  .nav-links.open { transform: none; opacity: 1; pointer-events: auto; }
  .nav-links a { font-size: .95rem; padding: .55em 0; width: 100%; }
  .nav-links a.cta { width: 100%; text-align: center; }
  .nav-burger { display: inline-grid; }
}

/* ---- Hero (landing) ------------------------------------------------------ */
.hero {
  position: relative; overflow: hidden; color: #ece5d6;
  background: #0e1320;
  padding: clamp(4rem, 10vw, 7.5rem) 0 clamp(3.5rem, 8vw, 6rem);
}
.hero::before { /* mesh wash */
  content: ""; position: absolute; inset: -20%;
  background:
    radial-gradient(40% 50% at 22% 30%, rgba(31,67,196,.55), transparent 70%),
    radial-gradient(36% 46% at 80% 24%, rgba(216,64,42,.4), transparent 72%),
    radial-gradient(50% 60% at 60% 90%, rgba(178,118,15,.3), transparent 70%);
  filter: blur(8px); animation: drift 26s ease-in-out infinite alternate;
}
.hero::after { /* hairline grid texture */
  content: ""; position: absolute; inset: 0; opacity: .14; pointer-events: none;
  background-image: linear-gradient(rgba(255,255,255,.5) 1px, transparent 1px),
                    linear-gradient(90deg, rgba(255,255,255,.5) 1px, transparent 1px);
  background-size: 44px 44px;
  -webkit-mask-image: radial-gradient(70% 70% at 50% 40%, #000, transparent 80%);
          mask-image: radial-gradient(70% 70% at 50% 40%, #000, transparent 80%);
}
@keyframes drift { from { transform: translate3d(-2%, -1%, 0) scale(1.02); } to { transform: translate3d(2%, 2%, 0) scale(1.06); } }
.hero .wrap { position: relative; z-index: 1; text-align: center; }
.hero .logomark { width: clamp(72px, 12vw, 120px); height: auto; margin: 0 auto .6rem; display: block; }
.hero .logomark .lm-strand { stroke: #ff7d5e; }
.hero .logomark .lm-gap { stroke: #0e1320; }
.hero-word {
  font-family: var(--display); font-weight: 400; font-size: var(--fs-hero); line-height: .9;
  letter-spacing: .02em; margin: 0;
  background: linear-gradient(100deg, #8fb0ff 0%, #ffd089 50%, #ff7d5e 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero-word .x { font-style: italic; }
.hero-tag { font-size: clamp(1.1rem, 2.4vw, 1.5rem); color: #c8c2b4; max-width: 30ch; margin: 1rem auto 2rem; }
.hero-cta { display: flex; gap: .9rem; justify-content: center; flex-wrap: wrap; }
.btn {
  font-family: var(--mono); font-size: .82rem; text-transform: uppercase; letter-spacing: .1em;
  padding: .85em 1.4em; border-radius: var(--rad); text-decoration: none; border: 1.5px solid transparent;
  display: inline-flex; align-items: center; gap: .5em; transition: transform .15s, box-shadow .15s, background .2s;
}
.btn--primary { background: var(--red); color: #fff; box-shadow: 4px 4px 0 rgba(0,0,0,.35); }
.btn--primary:hover { transform: translate(-2px,-2px); box-shadow: 6px 6px 0 rgba(0,0,0,.35); color: #fff; }
.btn--ghost { border-color: #6f7a96; color: #ece5d6; }
.btn--ghost:hover { border-color: #ece5d6; color: #ece5d6; }

/* section heading kicker used across landing */
.section-head { display: flex; align-items: baseline; gap: 1rem; margin-bottom: 1.8rem; }
.section-head h2 { margin: 0; }
.section-head .count { font-family: var(--mono); color: var(--ink-3); font-size: .85rem; }

/* ---- Arc cards ----------------------------------------------------------- */
.arc-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1.1rem; }
.arc-card {
  position: relative; padding: 1.4rem 1.3rem 1.5rem; border-radius: var(--rad-lg);
  background: var(--surface); border: 1px solid var(--rule); overflow: hidden;
}
.arc-card::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 5px; background: var(--ac, var(--blue)); }
.arc-card .arc-n { font-family: var(--mono); font-size: .78rem; letter-spacing: .14em; color: var(--ac, var(--blue)); text-transform: uppercase; }
.arc-card h3 { font-size: 1.3rem; margin: .35rem 0 .5rem; }
.arc-card .arc-range { font-family: var(--mono); font-size: .76rem; color: var(--ink-3); }
.arc-card p { font-size: .95rem; color: var(--ink-2); margin: .5rem 0 0; }

/* ---- Puzzle catalog ------------------------------------------------------ */
.cat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.3rem; }
.arc-group + .arc-group { margin-top: 2.6rem; }
.arc-group > .eyebrow { display: block; margin-bottom: 1rem; color: var(--ac, var(--ink-3)); }
.pcard {
  position: relative; display: flex; flex-direction: column; gap: .55rem;
  padding: 1.3rem 1.3rem 1.4rem; background: var(--surface); color: var(--ink);
  border: 1.5px solid var(--ink); border-radius: var(--rad);
  box-shadow: 5px 5px 0 var(--ac, var(--blue));
  text-decoration: none; transition: transform .16s ease, box-shadow .16s ease;
}
.pcard:hover { transform: translate(-3px,-3px); box-shadow: 8px 8px 0 var(--ac, var(--blue)); }
.pcard .pc-top { display: flex; align-items: flex-start; justify-content: space-between; gap: .5rem; }
.pcard .pc-num { font-family: var(--display); font-size: 2.4rem; line-height: .8; color: var(--ink-3); }
.pcard:hover .pc-num { color: var(--ac, var(--blue)); }
.pcard .pc-glyph { width: 38px; height: 38px; flex: none; opacity: .9; }
.pcard .pc-glyph .lm-strand { stroke: var(--ac, var(--blue)); }
.pcard .pc-glyph .lm-gap { stroke: var(--surface); }
.pcard h3 { font-size: 1.32rem; margin: .1rem 0 0; }
.pcard .pc-principle { font-style: italic; color: var(--ink-2); font-size: .95rem; }
.pcard .pc-meta { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin-top: auto; padding-top: .5rem; }
.pc-type { font-family: var(--mono); font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); }
.pcard .pc-explore {
  font-family: var(--mono); font-size: .72rem; text-transform: uppercase; letter-spacing: .08em;
  color: var(--red); margin-top: .2rem;
}

/* ---- Difficulty pills ---------------------------------------------------- */
.pill {
  display: inline-flex; align-items: center; gap: .4em; font-family: var(--mono);
  font-size: .68rem; text-transform: uppercase; letter-spacing: .07em; font-weight: 500;
  padding: .3em .65em; border-radius: 999px;
}
.pill::before { content: ""; width: .5em; height: .5em; border-radius: 50%; background: currentColor; }
.pill.beginner     { color: var(--d-beg-fg); background: var(--d-beg-bg); }
.pill.intermediate { color: var(--d-int-fg); background: var(--d-int-bg); }
.pill.advanced     { color: var(--d-adv-fg); background: var(--d-adv-bg); }
.pill.expert       { color: var(--d-exp-fg); background: var(--d-exp-bg); }

/* ---- Split entry band ---------------------------------------------------- */
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 1.3rem; }
.split a {
  display: block; padding: 2rem; border-radius: var(--rad-lg); text-decoration: none;
  border: 1px solid var(--rule); background: var(--surface); color: var(--ink);
  transition: transform .16s, box-shadow .16s;
}
.split a:hover { transform: translateY(-3px); box-shadow: var(--shadow-card); }
.split h3 { margin-top: 0; }
.split p { color: var(--ink-2); margin-bottom: 0; }

/* ---- Generic content tables --------------------------------------------- */
.prose table, .table-wrap table { border-collapse: collapse; width: 100%; margin: 1.4em 0; font-size: .95rem; }
.table-wrap { overflow-x: auto; }
.prose th, .prose td, .table-wrap th, .table-wrap td { text-align: left; padding: .55em .8em; border-bottom: 1px solid var(--rule); }
.prose thead th, .table-wrap thead th { font-family: var(--mono); font-size: .76rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-2); border-bottom: 1.5px solid var(--rule-strong); }
.prose tbody tr:nth-child(even), .table-wrap tbody tr:nth-child(even) { background: var(--surface-2); }
.prose td:not(:first-child), .table-wrap td:not(:first-child) { font-variant-numeric: tabular-nums; }

/* ---- Figures / diagrams -------------------------------------------------- */
.dia-figure { margin: 1.9rem auto; max-width: 520px; text-align: center; }
.dia-figure.dia-narrow { max-width: 360px; }
.dia-figure.dia-wide { max-width: 720px; }
.dia-figure img.dia, .dia-figure svg.dia {
  width: 100%; height: auto; background: var(--figure-mat, #fbf7ef);
  border: 1px solid var(--rule); border-radius: var(--rad-lg); padding: 1rem;
}
.dia-figure figcaption { font-size: .82rem; color: var(--ink-3); margin-top: .55rem; line-height: 1.45; font-style: italic; }

/* ---- Callouts ------------------------------------------------------------ */
.callout { border-radius: var(--rad); padding: 1em 1.15em; margin: 1.4em 0; border: 1px solid var(--rule); background: var(--surface-2); }
.callout--lesson { border-left: 4px solid var(--blue); }
.callout--intuition { border-left: 4px solid var(--ochre); background: var(--ochre-soft); }
.callout .callout-label { font-family: var(--mono); font-size: .72rem; text-transform: uppercase; letter-spacing: .1em; color: var(--ink-2); display: block; margin-bottom: .25em; }
blockquote { margin: 1.4em 0; padding: .4em 0 .4em 1.2em; border-left: 3px solid var(--rule-strong); color: var(--ink-2); font-style: italic; }

/* ---- Article header (puzzle / theory) ----------------------------------- */
.doc-header { position: relative; padding: clamp(2rem, 5vw, 3.4rem) 0 1.6rem; border-bottom: 1px solid var(--rule); margin-bottom: 1.6rem; overflow: hidden; }
.doc-header::before { content: ""; position: absolute; inset: 0; background: linear-gradient(120deg, color-mix(in srgb, var(--ac, var(--blue)) 14%, transparent), transparent 60%); pointer-events: none; }
.doc-header .wrap { position: relative; }
.doc-num { font-family: var(--display); font-size: clamp(3rem, 9vw, 5.5rem); line-height: .85; color: var(--ac, var(--blue)); }
.doc-title { font-size: var(--fs-4); margin: .1em 0 .4em; }
.doc-meta { display: flex; align-items: center; gap: .7rem; flex-wrap: wrap; margin-bottom: 1rem; }
.doc-meta .pc-type, .doc-meta .pc-principle { font-size: .85rem; }
.doc-meta .pc-principle { font-style: italic; color: var(--ink-2); }
.doc-lead { font-size: 1.2rem; color: var(--ink-2); max-width: var(--measure); }
.doc-actions { margin-top: 1.2rem; }

/* ---- Doc layout with TOC rail ------------------------------------------- */
.doc-layout { display: grid; grid-template-columns: minmax(0, 1fr) 220px; gap: 2.6rem; align-items: start; }
.toc { position: sticky; top: calc(var(--nav-h) + 1.4rem); font-size: .85rem; }
.toc .eyebrow { display: block; margin-bottom: .7rem; }
.toc ol { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--rule); }
.toc li { margin: 0; }
.toc a { display: block; padding: .28em 0 .28em .9em; margin-left: -1px; color: var(--ink-3); text-decoration: none; border-left: 2px solid transparent; line-height: 1.3; }
.toc a:hover { color: var(--ink); }
.toc a.active { color: var(--ink); border-left-color: var(--red); }
.toc a.lvl-3 { padding-left: 1.7em; font-size: .95em; }

/* reading-progress bar */
.progress { position: fixed; top: var(--nav-h); left: 0; height: 3px; width: 0; background: var(--red); z-index: 49; transition: width .1s linear; }

/* anchor link affordance */
.anchor-link { opacity: 0; margin-left: .35em; color: var(--ink-3); text-decoration: none; font-weight: 400; }
h2:hover .anchor-link, h3:hover .anchor-link { opacity: 1; }

/* prev / next */
.prevnext { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin: 3rem 0 1rem; }
.prevnext a { border: 1px solid var(--rule); border-radius: var(--rad); padding: 1rem 1.2rem; text-decoration: none; color: var(--ink); background: var(--surface); transition: border-color .15s, transform .15s; }
.prevnext a:hover { border-color: var(--ink-2); transform: translateY(-2px); }
.prevnext .pn-k { font-family: var(--mono); font-size: .72rem; text-transform: uppercase; letter-spacing: .1em; color: var(--ink-3); display: block; }
.prevnext .pn-next { text-align: right; }
.prevnext .pn-name { font-size: 1.05rem; }

/* ---- Footer -------------------------------------------------------------- */
.foot { background: #0e1320; color: #c8c2b4; margin-top: 4rem; padding: 3rem 0 2.4rem; }
.foot a { color: #c8c2b4; text-decoration: none; }
.foot a:hover { color: #fff; }
.foot .logomark { width: 34px; height: 34px; }
.foot .logomark .lm-strand { stroke: #ff7d5e; }
.foot .logomark .lm-gap { stroke: #0e1320; }
.foot-grid { display: grid; grid-template-columns: 1.4fr repeat(3, 1fr); gap: 1.6rem; }
.foot h4 { color: #ece5d6; margin: 0 0 .7rem; }
.foot ul { list-style: none; margin: 0; padding: 0; }
.foot li { margin: .3em 0; font-size: .92rem; }
.foot-fine { margin-top: 2.4rem; padding-top: 1.4rem; border-top: 1px solid rgba(255,255,255,.12); font-family: var(--mono); font-size: .76rem; color: #8a8475; display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }

/* ---- Scroll reveal ------------------------------------------------------- */
.reveal { opacity: 0; transform: translateY(14px); transition: opacity .5s ease, transform .5s ease; }
.reveal.in { opacity: 1; transform: none; }

/* ---- Responsive ---------------------------------------------------------- */
@media (max-width: 1000px) {
  .doc-layout { grid-template-columns: 1fr; }
  .toc { display: none; }
  .arc-grid { grid-template-columns: repeat(2, 1fr); }
  .cat-grid { grid-template-columns: repeat(2, 1fr); }
  .foot-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
  .arc-grid, .cat-grid, .split, .prevnext { grid-template-columns: 1fr; }
  .foot-grid { grid-template-columns: 1fr; }
  .prevnext .pn-next { text-align: left; }
}

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