/* spindle — static site. Hand-written; no frameworks, no external requests. */

/* ---------- design tokens ---------------------------------------------- */
:root {
  /* dark: phosphor on carbon — the site default */
  --bg: #070b09;
  --bg-dot: #1a2a1e;
  --panel: #0c120e;
  --panel2: #0f1711;
  --ink: #cfe3d3;
  --muted: #86a08a;
  --faint: #56695b;
  --line: #1c2a20;
  --line2: #29392e;
  --acc: #45e07f;
  --acc2: #e8b339;
  --s-green: #22a55b;  /* chart series — validated for dark surface */
  --s-amber: #b3831c;
  --s-blue: #3d82d1;
  --s-red: #d84a3e;
  --code-bg: #0a120d;
  --term-bg: #0a100b;  /* terminals stay phosphor in both themes */
  --term-ink: #b9d6ba;
  --term-acc: #52d97b;
  --glow: 0 0 14px rgba(69, 224, 127, .35);
  --figcard: #f3f1ea;
  --sel: rgba(69, 224, 127, .25);
}
:root[data-theme="light"] {
  /* light: ink on paper — via the toggle */
  --bg: #f6f4ee;
  --bg-dot: #d9d4c4;
  --panel: #fdfcf8;
  --panel2: #f0ede3;
  --ink: #1c241e;
  --muted: #58655a;
  --faint: #8b948b;
  --line: #d9d5c8;
  --line2: #c8c3b2;
  --acc: #0e6330;      /* ui accent (validated series green, light) */
  --acc2: #8a5f04;     /* ui amber */
  --s-green: #0e6330;  /* chart series — validated for light surface */
  --s-amber: #a86e06;
  --s-blue: #0b62c4;
  --s-red: #bb3227;
  --code-bg: #eeebe0;
  --term-bg: #10160f;
  --term-ink: #b9d6ba;
  --term-acc: #52d97b;
  --glow: none;
  --figcard: #ffffff;
  --sel: rgba(14, 99, 48, .18);
}

/* ---------- base -------------------------------------------------------- */
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
:root { --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, "Liberation Mono", monospace;
        --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; }
body {
  margin: 0;
  background: var(--bg);
  background-image: radial-gradient(var(--bg-dot) 1px, transparent 1.4px);
  background-size: 26px 26px;
  color: var(--ink);
  font: 16px/1.6 var(--sans);
  -webkit-text-size-adjust: 100%;
}
::selection { background: var(--sel); }
a { color: var(--acc); text-decoration-color: color-mix(in srgb, var(--acc) 45%, transparent); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
code, kbd, pre, .mono { font-family: var(--mono); }
code { background: var(--code-bg); border: 1px solid var(--line); border-radius: 4px; padding: .08em .35em; font-size: .86em; }
pre code { background: none; border: 0; padding: 0; font-size: inherit; }
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 20px; }
.small { font-size: .84rem; color: var(--muted); }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
svg { max-width: 100%; height: auto; display: block; }
svg text { font-family: var(--mono); }

/* ---------- header ------------------------------------------------------ */
header.top {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
}
header.top .wrap { display: flex; align-items: center; gap: 18px; height: 52px; }
.brand { font-family: var(--mono); font-weight: 700; letter-spacing: .04em; color: var(--ink); text-decoration: none; }
.brand b { color: var(--acc); text-shadow: var(--glow); font-weight: 700; }
nav.sections { display: flex; gap: 14px; overflow-x: auto; scrollbar-width: none; flex: 1; }
nav.sections::-webkit-scrollbar { display: none; }
nav.sections a { font-family: var(--mono); font-size: .78rem; letter-spacing: .05em; text-transform: uppercase;
  color: var(--muted); text-decoration: none; white-space: nowrap; padding: 4px 2px; }
nav.sections a:hover { color: var(--acc); }
#themeBtn {
  font-family: var(--mono); font-size: .75rem; letter-spacing: .05em; cursor: pointer;
  color: var(--ink); background: var(--panel); border: 1px solid var(--line2); border-radius: 6px; padding: 5px 10px;
}
#themeBtn:hover { border-color: var(--acc); color: var(--acc); }

/* ---------- hero -------------------------------------------------------- */
.hero { position: relative; overflow: hidden; border-bottom: 1px solid var(--line);
  background-image: radial-gradient(color-mix(in srgb, var(--bg-dot) 130%, var(--acc) 6%) 1px, transparent 1.4px);
  background-size: 22px 22px; }
.hero .wrap { display: grid; grid-template-columns: minmax(300px, 5fr) 6fr; gap: 28px; align-items: center; padding: 56px 20px 48px; }
.hero h1 { font-family: var(--mono); font-size: clamp(2.4rem, 6vw, 3.6rem); margin: 0 0 10px; letter-spacing: .01em; }
.hero h1 .cursor { color: var(--acc); text-shadow: var(--glow); }
.motion-ok .hero h1 .cursor { animation: blink 1.2s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.hero p.pitch { font-size: 1.06rem; color: var(--muted); max-width: 46ch; margin: 0 0 22px; }
.chips { display: flex; flex-wrap: wrap; gap: 10px; margin: 0 0 24px; padding: 0; list-style: none; }
.chips li { border: 1px solid var(--line2); background: var(--panel); border-radius: 8px; padding: 10px 14px; min-width: 118px; }
.chips .v { display: block; font-family: var(--mono); font-size: 1.3rem; font-weight: 700; color: var(--acc); text-shadow: var(--glow); }
.chips .k { display: block; font-family: var(--mono); font-size: .68rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-top: 2px; }
.ctas { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.btn { font-family: var(--mono); font-size: .82rem; letter-spacing: .05em; text-transform: uppercase; text-decoration: none;
  padding: 10px 16px; border-radius: 6px; border: 1px solid var(--acc); }
.btn.primary { background: var(--acc); color: var(--bg); font-weight: 700; }
.btn.primary:hover { box-shadow: var(--glow); }
.btn.ghost { color: var(--acc); background: transparent; }
.btn.ghost:hover { background: color-mix(in srgb, var(--acc) 10%, transparent); }
.ctas .note { flex-basis: 100%; }

/* hero ring svg */
.ringbox { min-width: 0; }
#ringsvg .slot { fill: var(--faint); opacity: .38; }
#ringsvg .slot.f { fill: var(--acc); opacity: .8; }
#ringsvg .reticle { fill: none; stroke: var(--faint); opacity: .5; }
#ringsvg .lane { stroke: var(--line2); stroke-width: 1.2; fill: none; }
#ringsvg .node { fill: var(--panel); stroke: var(--line2); rx: 6; }
#ringsvg text { fill: var(--muted); font-size: 11px; letter-spacing: .06em; }
#ringsvg text.big { fill: var(--ink); font-size: 12px; font-weight: 700; }
#ringsvg text.seq { fill: var(--acc); }
#ringsvg .p .halo { fill: var(--acc); opacity: .18; }
#ringsvg .p .core { fill: var(--acc); }
#ringsvg .dust { fill: var(--acc2); }
#ringsvg .mark { stroke: var(--acc2); stroke-width: 1.2; fill: none; }
#ringsvg text.mk { fill: var(--acc2); }

/* ---------- sections ---------------------------------------------------- */
section { padding: 60px 0 20px; }
section > .wrap > h2 { font-family: var(--mono); font-size: 1.35rem; letter-spacing: .04em; margin: 0 0 6px; }
h2 .idx { color: var(--acc); text-shadow: var(--glow); margin-right: 10px; }
.sub { color: var(--muted); max-width: 72ch; margin: 0 0 26px; }
.rule { border: 0; border-top: 1px dashed var(--line2); margin: 40px 0 0; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; align-items: start; }
.grid2 > *, .cards3 > .card { min-width: 0; } /* let pre/table scroll inside, never widen the page */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 20px 22px; }
.card h3 { font-family: var(--mono); font-size: 1rem; margin: 0 0 8px; letter-spacing: .03em; }
.card h3 .tag { font-size: .66rem; letter-spacing: .1em; text-transform: uppercase; color: var(--bg);
  background: var(--acc2); border-radius: 4px; padding: 2px 7px; margin-left: 8px; vertical-align: 2px; }
.card p { font-size: .92rem; color: var(--muted); }
.card p b, .card li b { color: var(--ink); }
.cards3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }

/* verdict lines */
.verdict { font-family: var(--mono); font-size: .8rem; border-left: 3px solid var(--acc2); padding: 6px 10px;
  background: color-mix(in srgb, var(--acc2) 8%, transparent); color: var(--ink); }

/* ---------- charts ------------------------------------------------------ */
.chart { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px 14px 8px; }
.chart .grid line { stroke: var(--line); }
.chart .axis line, .chart .axis path { stroke: var(--line2); }
.chart text { fill: var(--muted); font-size: 11px; }
.chart text.lab { font-size: 12px; }
.chart .s-paced { stroke: var(--s-green); stroke-width: 2.2; fill: none; }
.chart .s-naive { stroke: var(--s-amber); stroke-width: 2; stroke-dasharray: 5 4; fill: none; }
.chart .pt-paced { fill: var(--s-green); }
.chart .pt-naive { fill: var(--panel); stroke: var(--s-amber); stroke-width: 1.6; }
.chart text.l-paced { fill: var(--s-green); font-weight: 700; }
.chart text.l-naive { fill: var(--s-amber); font-weight: 700; }
.chart .anno { stroke: var(--s-red); stroke-width: 1.4; }
.chart text.anno { fill: var(--s-red); font-weight: 700; font-size: 12px; }
.chart .dashed { stroke-dasharray: 4 4; }
/* draw-on-scroll: only when JS present; reduced-motion collapses the transitions.
   The solid line draws via dashoffset; the naive line FADES instead, so its dash
   pattern (the colorblind-safe secondary encoding) is never repurposed. */
.js .draw .drawline { stroke-dasharray: 1; stroke-dashoffset: 1; }
.js .draw.on .drawline { stroke-dashoffset: 0; transition: stroke-dashoffset 1.7s ease .15s; }
.js .draw .s-naive, .js .draw .pts, .js .draw .anno, .js .draw .l-naive, .js .draw .l-paced { opacity: 0; }
.js .draw.on .s-naive { opacity: 1; transition: opacity 1s ease .7s; }
.js .draw.on .pts, .js .draw.on .anno, .js .draw.on .l-naive, .js .draw.on .l-paced
  { opacity: 1; transition: opacity .8s ease 1.4s; }

.mini .s-a { stroke: var(--s-green); stroke-width: 1.8; fill: none; }
.mini .s-b { stroke: var(--s-amber); stroke-width: 1.8; fill: none; }
.mini .s-m { stroke: var(--faint); stroke-width: 1.6; fill: none; }
.mini text { fill: var(--muted); font-size: 9.5px; }
.mini text.wm { fill: var(--faint); opacity: .5; font-size: 15px; letter-spacing: .3em; font-weight: 700; }
.mini .pt-g { fill: var(--s-green); } .mini .pt-a { fill: var(--s-amber); } .mini .pt-m { fill: var(--faint); }
.mini .ax { stroke: var(--line2); }

/* ---------- architecture diagram --------------------------------------- */
.arch { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.arch .box { fill: var(--panel2); stroke: var(--line2); rx: 6; }
.arch .seg { fill: color-mix(in srgb, var(--acc) 4%, var(--panel2)); stroke: var(--acc); stroke-dasharray: 6 4; rx: 8; opacity: .96; }
.arch .row { fill: var(--panel); stroke: var(--line2); rx: 3; }
.arch .cell { fill: none; stroke: var(--faint); stroke-dasharray: 2 3; }
.arch .cell.solid { fill: color-mix(in srgb, var(--acc) 14%, var(--panel)); stroke: var(--acc); stroke-dasharray: none; }
.arch .cell.msg { fill: color-mix(in srgb, var(--acc2) 30%, var(--panel)); stroke: var(--acc2); stroke-dasharray: none; }
.arch text { fill: var(--muted); font-size: 10.5px; }
.arch text.t { fill: var(--ink); font-size: 12px; font-weight: 700; letter-spacing: .04em; }
.arch text.f { font-size: 10px; }
.arch .flow { stroke: var(--acc); stroke-width: 1.6; fill: none; }
.arch .arrhead { fill: var(--acc); stroke: none; }
.arch .tok { fill: var(--acc2); }
.arch g.hl { cursor: help; }
.arch g.hl:hover .row, .arch g.hl:hover .box, .arch g.hl:hover .cell { stroke: var(--acc); stroke-width: 1.6; }
.arch g.hl:hover text { fill: var(--ink); }
@supports (offset-path: path("M0 0 L4 4")) {
  .motion-ok .arch .tok { x: -4px; y: -4px; offset-path: path("M150 250 L300 250 L300 330 L580 330 L580 250 L730 250"); offset-rotate: 0deg; animation: tokmove 7s linear infinite; }
  .motion-ok .arch .tok.t2 { animation-delay: 2.33s; }
  .motion-ok .arch .tok.t3 { animation-delay: 4.66s; }
}
@keyframes tokmove {
  0% { offset-distance: 0%; opacity: 0; }
  6% { opacity: 1; }
  94% { opacity: 1; }
  100% { offset-distance: 100%; opacity: 0; }
}

/* ---------- asm tabs (radio-based, no JS needed) ------------------------ */
.asmtabs input[type="radio"] { position: absolute; opacity: 0; pointer-events: none; }
.asmtabs .tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.asmtabs label { font-family: var(--mono); font-size: .74rem; letter-spacing: .04em; cursor: pointer;
  border: 1px solid var(--line2); border-radius: 6px; padding: 6px 10px; color: var(--muted); background: var(--panel2); }
.asmtabs input:focus-visible ~ .tabs { outline: 2px solid var(--acc); outline-offset: 3px; border-radius: 6px; }
.asmtabs .pane { display: none; }
#asm-a:checked ~ .panes .pane-a, #asm-b:checked ~ .panes .pane-b, #asm-c:checked ~ .panes .pane-c { display: block; }
#asm-a:checked ~ .tabs label[for="asm-a"], #asm-b:checked ~ .tabs label[for="asm-b"], #asm-c:checked ~ .tabs label[for="asm-c"]
  { color: var(--acc); border-color: var(--acc); background: color-mix(in srgb, var(--acc) 8%, var(--panel)); }
pre.asm { background: var(--term-bg); color: var(--term-ink); border: 1px solid var(--line); border-radius: 8px;
  padding: 12px 14px; font-size: .74rem; line-height: 1.5; overflow-x: auto; margin: 0 0 10px; }
pre.asm .k { color: var(--term-acc); font-weight: 700; }   /* ordering instructions */
pre.asm .w { color: #e8b339; font-weight: 700; }           /* fences */
pre.asm .c { color: #7d9a80; }                              /* comments */
.tally { font-family: var(--mono); font-size: .8rem; border: 1px dashed var(--line2); border-radius: 6px;
  padding: 8px 12px; display: flex; gap: 18px; flex-wrap: wrap; }
.tally .bad { color: var(--s-red); font-weight: 700; }
.tally .good { color: var(--s-green); font-weight: 700; }

/* ---------- textbook ---------------------------------------------------- */
ol.toc { list-style: none; margin: 0; padding: 0; columns: 2; column-gap: 28px; }
ol.toc li { font-family: var(--mono); font-size: .84rem; padding: 6px 0; border-bottom: 1px dashed var(--line);
  break-inside: avoid; }
ol.toc .n { color: var(--acc); margin-right: 10px; }
ol.toc a { color: var(--ink); text-decoration: none; }
ol.toc a:hover { color: var(--acc); }
pre.note { background: var(--code-bg); border: 1px solid var(--line); border-left: 3px solid var(--acc);
  border-radius: 6px; padding: 14px 16px; font-size: .76rem; line-height: 1.55; overflow-x: auto; color: var(--ink); }
pre.note .cm { color: var(--muted); }
pre.note .hl { color: var(--acc); font-weight: 700; }

/* ---------- terminal blocks --------------------------------------------- */
.term { background: var(--term-bg); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; position: relative; }
.term .bar { display: flex; align-items: center; justify-content: space-between; padding: 7px 12px;
  border-bottom: 1px solid color-mix(in srgb, var(--term-ink) 14%, transparent);
  font-family: var(--mono); font-size: .7rem; letter-spacing: .08em; text-transform: uppercase; color: #7d9a80; }
.term pre { margin: 0; padding: 14px 16px; color: var(--term-ink); font-size: .8rem; line-height: 1.65; overflow-x: auto; }
.term .ps { color: var(--term-acc); user-select: none; }
.term .out { color: #7d9a80; }
.term .copy { font-family: var(--mono); font-size: .68rem; letter-spacing: .06em; text-transform: uppercase; cursor: pointer;
  color: #7d9a80; background: transparent; border: 1px solid #2a3a2c; border-radius: 5px; padding: 3px 9px; }
.term .copy:hover { color: var(--term-acc); border-color: var(--term-acc); }

/* figure cards (paper figures keep their white ground, honestly framed) */
figure.figcard { margin: 24px 0 0; background: var(--figcard); border: 1px solid var(--line2); border-radius: 10px; padding: 14px; }
figure.figcard img { width: 100%; height: auto; display: block; }
figure.figcard figcaption { font-size: .8rem; color: #4c554d; padding: 10px 4px 0; }
details.data { margin-top: 12px; overflow-x: auto; }
details.data summary { font-family: var(--mono); font-size: .78rem; color: var(--muted); cursor: pointer; }
details.data table { border-collapse: collapse; margin-top: 10px; font-family: var(--mono); font-size: .78rem; }
details.data th, details.data td { border: 1px solid var(--line); padding: 5px 10px; text-align: right; }
details.data th { color: var(--muted); font-weight: 400; }
details.data td:first-child, details.data th:first-child { text-align: left; }

/* ---------- footer ------------------------------------------------------ */
footer { border-top: 1px solid var(--line); margin-top: 60px; padding: 40px 0 60px; }
footer blockquote { margin: 0 0 20px; border-left: 3px solid var(--acc2); padding: 10px 16px;
  background: color-mix(in srgb, var(--acc2) 6%, transparent); color: var(--muted); font-size: .88rem; }
footer .cols { display: flex; flex-wrap: wrap; gap: 24px; justify-content: space-between; align-items: baseline; }
footer .mono { font-size: .78rem; color: var(--faint); }

/* ---------- responsive -------------------------------------------------- */
@media (max-width: 880px) {
  .hero .wrap { grid-template-columns: 1fr; padding-top: 36px; }
  .grid2, .cards3 { grid-template-columns: 1fr; }
  ol.toc { columns: 1; }
}
@media (max-width: 640px) {
  /* the hero ring renders at ~0.44 scale on phones — keep its type readable */
  #ringsvg text { font-size: 12.5px; }
  #ringsvg text.big { font-size: 17px; }
  #ringsvg text.seq, #ringsvg text.mk { font-size: 14px; }
}

/* ---------- motion gating ----------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .arch .tok { offset-path: none !important; animation: none !important; }
}
