/* ChessReasoner-120M — analytical dark.
   Engineering blueprint meets chess notation: hairline rules, marginal section
   numbers, an 8x8 grid substrate, one amber signal accent for the inference
   path and a cold cyan for everything discarded before inference. */

@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,300;9..144,400;9..144,600;9..144,900&family=IBM+Plex+Mono:wght@300;400;500;600&family=Newsreader:opsz,wght@6..72,300;6..72,400;6..72,500&display=swap');

:root {
  --ink:        #07090c;
  --ink-2:      #0c1015;
  --ink-3:      #12181f;
  --rule:       #1e2831;
  --rule-soft:  #161e26;
  --bone:       #e8e3d8;
  --bone-dim:   #a7a397;
  --bone-faint: #6b6a63;
  --amber:      #e0a03c;
  --amber-soft: #7a5820;
  --cyan:       #52b5c4;
  --cyan-soft:  #2a5f68;
  --red:        #d1614a;
  --green:      #7fa661;

  --measure: 68ch;
  --gutter: clamp(1.25rem, 4vw, 5rem);

  --f-display: 'Fraunces', 'Iowan Old Style', Georgia, serif;
  --f-body: 'Newsreader', Georgia, serif;
  --f-mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', monospace;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--ink);
  color: var(--bone);
  font-family: var(--f-body);
  font-size: 17px;
  line-height: 1.68;
  font-weight: 300;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* --- the board substrate: an 8x8 grid, barely there ---------------------- */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image:
    linear-gradient(var(--rule-soft) 1px, transparent 1px),
    linear-gradient(90deg, var(--rule-soft) 1px, transparent 1px);
  background-size: 96px 96px;
  mask-image: radial-gradient(ellipse 120% 90% at 50% 0%, #000 0%, transparent 78%);
  opacity: .5;
}
/* film grain */
body::after {
  content: '';
  position: fixed;
  inset: -50%;
  pointer-events: none;
  z-index: 1;
  opacity: .022;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain 6s steps(4) infinite;
}
@keyframes grain {
  0%,100% { transform: translate(0,0) }
  25% { transform: translate(-2%,1%) }
  50% { transform: translate(1%,-2%) }
  75% { transform: translate(-1%,-1%) }
}

main, header, footer { position: relative; z-index: 2; }

/* --- typography ---------------------------------------------------------- */
h1, h2, h3, h4 {
  font-family: var(--f-display);
  font-weight: 400;
  font-variation-settings: 'SOFT' 20, 'WONK' 1;
  letter-spacing: -.015em;
  line-height: 1.08;
  margin: 0;
}
p { margin: 0 0 1.15em; max-width: var(--measure); }
a { color: var(--amber); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--bone); }
strong { font-weight: 500; color: #fff; }
em { font-style: italic; color: var(--bone); }

code, .mono { font-family: var(--f-mono); font-size: .84em; letter-spacing: -.01em; }
code {
  background: var(--ink-3);
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: .08em .34em;
  color: var(--amber);
}

.lede {
  font-size: clamp(1.12rem, 1.7vw, 1.4rem);
  line-height: 1.55;
  color: var(--bone-dim);
  font-weight: 300;
}

/* --- shell --------------------------------------------------------------- */
.wrap { max-width: 1320px; margin: 0 auto; padding: 0 var(--gutter); }

section { padding: clamp(4.5rem, 9vw, 9rem) 0; border-top: 1px solid var(--rule-soft); }
section:first-of-type { border-top: 0; }

.sec-head {
  display: grid;
  grid-template-columns: 5.5rem 1fr;
  gap: 0 clamp(1rem, 3vw, 2.5rem);
  margin-bottom: clamp(2rem, 4vw, 3.5rem);
  align-items: start;
}
.sec-num {
  font-family: var(--f-mono);
  font-size: .7rem;
  letter-spacing: .22em;
  color: var(--amber-soft);
  padding-top: .85rem;
  border-top: 1px solid var(--amber-soft);
}
.sec-head h2 { font-size: clamp(1.9rem, 4.4vw, 3.4rem); }
.sec-head .kicker {
  font-family: var(--f-mono);
  font-size: .68rem;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--bone-faint);
  margin-bottom: .9rem;
  display: block;
}
.sec-body { grid-column: 2; max-width: var(--measure); }
@media (max-width: 720px) {
  .sec-head { grid-template-columns: 1fr; }
  .sec-body { grid-column: 1; }
  .sec-num { border-top: 0; padding-top: 0; }
}

/* --- hero ---------------------------------------------------------------- */
.hero {
  min-height: 100svh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: 2rem 0 0;
  border-top: 0;
}
.hero-top {
  display: flex; justify-content: space-between; align-items: baseline;
  font-family: var(--f-mono); font-size: .68rem;
  letter-spacing: .2em; text-transform: uppercase; color: var(--bone-faint);
  padding-bottom: 1.4rem; border-bottom: 1px solid var(--rule-soft);
}
.hero-mid { display: grid; grid-template-columns: 1.05fr .95fr; gap: clamp(1.5rem,4vw,4rem); align-items: center; padding: clamp(2rem,5vw,4rem) 0; }
@media (max-width: 900px) { .hero-mid { grid-template-columns: 1fr; } }

.hero h1 {
  font-size: clamp(3rem, 9.5vw, 7.5rem);
  font-weight: 300;
  font-variation-settings: 'SOFT' 40, 'WONK' 1, 'opsz' 144;
  line-height: .92;
  margin-bottom: 1.5rem;
}
.hero h1 .lo { display: block; font-style: italic; color: var(--amber); font-weight: 300; }
.hero h1 .n { font-family: var(--f-mono); font-size: .3em; font-weight: 300; letter-spacing: .04em; color: var(--bone-faint); vertical-align: super; }

#hero-canvas { width: 100%; aspect-ratio: 4/3; max-height: 60vh; cursor: grab; }
#hero-canvas:active { cursor: grabbing; }
.canvas-hint {
  font-family: var(--f-mono); font-size: .64rem; letter-spacing: .16em;
  text-transform: uppercase; color: var(--bone-faint); text-align: center; margin-top: .4rem;
}

.stats { display: grid; grid-template-columns: repeat(4, 1fr); border-top: 1px solid var(--rule); }
@media (max-width: 720px) { .stats { grid-template-columns: repeat(2,1fr); } }
.stat { padding: 1.4rem 1.2rem 2.2rem; border-right: 1px solid var(--rule-soft); }
.stat:last-child { border-right: 0; }
.stat .v { font-family: var(--f-mono); font-size: clamp(1.3rem,2.6vw,2rem); font-weight: 300; color: var(--bone); display: block; letter-spacing: -.03em; }
.stat .v em { font-style: normal; color: var(--amber); }
.stat .k { font-family: var(--f-mono); font-size: .64rem; letter-spacing: .16em; text-transform: uppercase; color: var(--bone-faint); margin-top: .45rem; display: block; }

/* --- reveal -------------------------------------------------------------- */
.rv { opacity: 0; transform: translateY(18px); transition: opacity .8s cubic-bezier(.2,.7,.3,1), transform .8s cubic-bezier(.2,.7,.3,1); }
.rv.in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  .rv { opacity: 1; transform: none; transition: none; }
  body::after { animation: none; }
  html { scroll-behavior: auto; }
}

/* --- figures / panels ---------------------------------------------------- */
.fig {
  margin: 2.5rem 0;
  border: 1px solid var(--rule);
  background: linear-gradient(180deg, var(--ink-2), var(--ink));
  border-radius: 2px;
}
.fig-head {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  padding: .8rem 1.1rem; border-bottom: 1px solid var(--rule);
  font-family: var(--f-mono); font-size: .66rem; letter-spacing: .17em;
  text-transform: uppercase; color: var(--bone-faint);
}
.fig-body { padding: clamp(1rem, 2.4vw, 2rem); }
.fig-cap {
  padding: .8rem 1.1rem; border-top: 1px solid var(--rule-soft);
  font-size: .84rem; color: var(--bone-faint); line-height: 1.55; max-width: none;
  margin: 0;
}
.full { max-width: none; }

/* --- bar chart ----------------------------------------------------------- */
.bars { display: grid; gap: .55rem; }
.bar-row { display: grid; grid-template-columns: minmax(9rem, 15rem) 1fr 4.2rem; gap: .9rem; align-items: center; font-size: .88rem; }
.bar-row .lbl { color: var(--bone-dim); text-align: right; line-height: 1.3; }
.bar-track { height: 22px; background: var(--ink-3); border: 1px solid var(--rule-soft); position: relative; overflow: hidden; }
.bar-fill { height: 100%; width: 0; transition: width 1.1s cubic-bezier(.2,.8,.3,1); background: var(--cyan-soft); }
.bar-row.hi .bar-fill { background: linear-gradient(90deg, var(--amber-soft), var(--amber)); }
.bar-row.us .bar-fill { background: repeating-linear-gradient(45deg, var(--rule) 0 6px, var(--ink-3) 6px 12px); }
.bar-row .num { font-family: var(--f-mono); font-size: .8rem; color: var(--bone); }
.bar-track::after {
  content:''; position:absolute; left:50%; top:0; bottom:0; width:1px;
  background: var(--rule); }

/* --- 2D architecture diagram --------------------------------------------- */
.arch { display: grid; grid-template-columns: 1fr 320px; gap: 0; }
@media (max-width: 980px) { .arch { grid-template-columns: 1fr; } }
.arch-svg { width: 100%; height: auto; display: block; }
.arch-rail {
  border-left: 1px solid var(--rule);
  padding: 1.4rem 1.3rem;
  min-height: 320px;
}
@media (max-width: 980px) { .arch-rail { border-left: 0; border-top: 1px solid var(--rule); } }
.arch-rail h4 { font-size: 1.15rem; margin-bottom: .2rem; }
.arch-rail .tag {
  display: inline-block; font-family: var(--f-mono); font-size: .6rem;
  letter-spacing: .16em; text-transform: uppercase; padding: .18rem .5rem;
  border: 1px solid var(--rule); color: var(--bone-faint); margin-bottom: .9rem;
}
.arch-rail .tag.keep { color: var(--amber); border-color: var(--amber-soft); }
.arch-rail .tag.drop { color: var(--cyan); border-color: var(--cyan-soft); }
.arch-rail p { font-size: .89rem; line-height: 1.6; color: var(--bone-dim); }
.arch-rail dl { margin: 1rem 0 0; font-family: var(--f-mono); font-size: .74rem; }
.arch-rail dt { color: var(--bone-faint); letter-spacing: .1em; text-transform: uppercase; font-size: .62rem; margin-top: .7rem; }
.arch-rail dd { margin: .15rem 0 0; color: var(--bone); }

.node { cursor: pointer; }
.node .box { transition: fill .25s, stroke .25s; }
.node:hover .box, .node.sel .box { fill: #1b232c; stroke: var(--amber); }
.node.aux:hover .box, .node.aux.sel .box { stroke: var(--cyan); }
.svg-lbl { font-family: var(--f-mono); font-size: 10px; fill: var(--bone); letter-spacing: .04em; }
.svg-sub { font-family: var(--f-mono); font-size: 8px; fill: var(--bone-faint); }
.svg-note { font-family: var(--f-mono); font-size: 8px; fill: var(--bone-faint); letter-spacing: .1em; text-transform: uppercase; }

/* --- tokenizer explainer ------------------------------------------------- */
.tok-grid { display: grid; grid-template-columns: minmax(240px, 340px) 1fr; gap: clamp(1.2rem, 3vw, 2.5rem); align-items: start; }
@media (max-width: 860px) {
  /* stacked: cap the board so it does not balloon to the figure width */
  .tok-grid { grid-template-columns: 1fr; justify-items: center; }
  .tok-grid > div:first-child { width: min(100%, 360px); }
  .tok-grid > div:last-child { width: 100%; }
}

.board {
  display: grid; grid-template-columns: repeat(8, 1fr);
  border: 1px solid var(--rule); aspect-ratio: 1;
  max-width: 400px; margin-inline: auto;
}
.sq {
  display: grid; place-items: center; position: relative; cursor: pointer;
  font-size: clamp(15px, 2.4vw, 26px); line-height: 1;
  text-shadow: 0 1px 2px #0009;
  transition: background .18s, box-shadow .18s;
}
.sq.lt { background: #20293233; }
.sq.dk { background: #0d1319; }
.sq.lt { background: #1c252e; }
.sq.on { background: var(--amber) !important; color: var(--ink); box-shadow: inset 0 0 0 1px #fff3; }
.sq .co {
  position: absolute; bottom: 1px; right: 2px; font-family: var(--f-mono);
  font-size: 7px; color: var(--bone-faint); opacity: .55; pointer-events: none;
}
.sq.on .co { color: var(--ink); opacity: .8; }

.tok-stream { display: flex; flex-wrap: wrap; gap: 3px; align-content: flex-start; }
.tk {
  font-family: var(--f-mono); font-size: 10px; padding: 3px 5px;
  border: 1px solid var(--rule); background: var(--ink-3); color: var(--bone-dim);
  cursor: pointer; transition: all .18s; border-radius: 2px; white-space: nowrap;
}
.tk:hover { border-color: var(--bone-faint); }
.tk.on { background: var(--amber); color: var(--ink); border-color: var(--amber); }
.tk.mark { color: var(--cyan); border-color: var(--cyan-soft); }
.tk.flag { color: var(--bone-faint); }
.tok-legend { font-family: var(--f-mono); font-size: .68rem; color: var(--bone-faint); margin-top: 1rem; letter-spacing: .06em; }
.tok-readout {
  font-family: var(--f-mono); font-size: .78rem; color: var(--amber);
  border-top: 1px solid var(--rule); margin-top: 1rem; padding-top: .8rem; min-height: 3.2em;
}

/* --- tables -------------------------------------------------------------- */
.tbl { width: 100%; border-collapse: collapse; font-size: .86rem; }
.tbl th {
  text-align: left; font-family: var(--f-mono); font-weight: 400; font-size: .64rem;
  letter-spacing: .16em; text-transform: uppercase; color: var(--bone-faint);
  padding: .5rem .7rem; border-bottom: 1px solid var(--rule);
}
.tbl td { padding: .55rem .7rem; border-bottom: 1px solid var(--rule-soft); color: var(--bone-dim); vertical-align: top; }
.tbl td.n, .tbl th.n { text-align: right; font-family: var(--f-mono); font-size: .82rem; color: var(--bone); }
.tbl tr.hi td { color: var(--bone); background: #ffffff05; }
.tbl tr.hi td.n { color: var(--amber); }

/* --- cards --------------------------------------------------------------- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px,1fr)); gap: 1px; background: var(--rule-soft); border: 1px solid var(--rule-soft); }
.card { background: var(--ink); padding: 1.5rem 1.3rem; }
.card h4 { font-size: 1.1rem; margin-bottom: .5rem; }
.card p { font-size: .87rem; color: var(--bone-dim); margin: 0; max-width: none; }
.card .ix { font-family: var(--f-mono); font-size: .62rem; letter-spacing: .18em; color: var(--amber-soft); display: block; margin-bottom: .7rem; }

/* --- bug list ------------------------------------------------------------ */
.bug { border-left: 2px solid var(--red); padding: .1rem 0 .1rem 1.2rem; margin: 0 0 2rem; }
.bug.fixed { border-left-color: var(--green); }
.bug .id { font-family: var(--f-mono); font-size: .64rem; letter-spacing: .18em; text-transform: uppercase; color: var(--bone-faint); }
.bug h4 { font-size: 1.12rem; margin: .3rem 0 .5rem; }
.bug p { font-size: .89rem; color: var(--bone-dim); }
.bug .metric { font-family: var(--f-mono); font-size: .78rem; color: var(--bone); background: var(--ink-3); border: 1px solid var(--rule); padding: .5rem .8rem; display: inline-block; margin-top: .3rem; }
.bug .metric .was { color: var(--red); }
.bug .metric .now { color: var(--green); }

/* --- 3D scene section ---------------------------------------------------- */
#scene-canvas { width: 100%; aspect-ratio: 16/10; min-height: 380px; display: block; cursor: grab; }
#scene-canvas:active { cursor: grabbing; }
.scene-ui { display: flex; flex-wrap: wrap; gap: .4rem; padding: .9rem 1.1rem; border-top: 1px solid var(--rule); }
.chip {
  font-family: var(--f-mono); font-size: .66rem; letter-spacing: .1em; text-transform: uppercase;
  padding: .35rem .7rem; border: 1px solid var(--rule); background: transparent;
  color: var(--bone-faint); cursor: pointer; transition: all .2s; border-radius: 2px;
}
.chip:hover { color: var(--bone); border-color: var(--bone-faint); }
.chip.on { color: var(--ink); background: var(--amber); border-color: var(--amber); }
.scene-readout {
  padding: .9rem 1.1rem; border-top: 1px solid var(--rule-soft);
  font-family: var(--f-mono); font-size: .76rem; color: var(--bone-dim); min-height: 3.4em; line-height: 1.55;
}
.scene-readout b { color: var(--amber); font-weight: 500; }

/* --- misc ---------------------------------------------------------------- */
.rule { height: 1px; background: var(--rule-soft); margin: 2.5rem 0; }
.pull {
  font-family: var(--f-display); font-size: clamp(1.3rem, 3vw, 2rem);
  line-height: 1.25; color: var(--bone); font-style: italic;
  border-left: 2px solid var(--amber); padding-left: 1.5rem; margin: 2.5rem 0;
  max-width: 44ch; font-variation-settings: 'SOFT' 30, 'WONK' 1;
}
.eq {
  font-family: var(--f-mono); font-size: .92rem; color: var(--bone);
  background: var(--ink-2); border: 1px solid var(--rule); border-left: 2px solid var(--amber-soft);
  padding: 1rem 1.2rem; margin: 1.6rem 0; overflow-x: auto;
}
.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px,1fr)); gap: 1px; background: var(--rule-soft); border: 1px solid var(--rule-soft); margin: 1.8rem 0; }
.kv > div { background: var(--ink); padding: .9rem 1rem; }
.kv dt { font-family: var(--f-mono); font-size: .6rem; letter-spacing: .16em; text-transform: uppercase; color: var(--bone-faint); }
.kv dd { margin: .3rem 0 0; font-family: var(--f-mono); font-size: .95rem; color: var(--bone); }

footer { border-top: 1px solid var(--rule); padding: 3rem 0 4rem; }
footer .wrap { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 1rem;
  font-family: var(--f-mono); font-size: .68rem; letter-spacing: .12em;
  text-transform: uppercase; color: var(--bone-faint); }

.nav { position: fixed; right: var(--gutter); top: 50%; transform: translateY(-50%); z-index: 40; display: grid; gap: .5rem; }
@media (max-width: 1150px) { .nav { display: none; } }
.nav a { width: 22px; height: 1px; background: var(--rule); display: block; transition: all .3s; position: relative; }
.nav a::after {
  content: attr(data-t); position: absolute; right: 30px; top: -.65em;
  font-family: var(--f-mono); font-size: .6rem; letter-spacing: .14em; text-transform: uppercase;
  color: var(--bone-faint); white-space: nowrap; opacity: 0; transition: opacity .25s; }
.nav a:hover { background: var(--amber); width: 34px; }
.nav a:hover::after { opacity: 1; }
.nav a.on { background: var(--amber); width: 34px; }
