/* ============================================================================
   M* site — base.css
   Shared layout + components. All color/typography come from CSS variables that
   the theme files (theme-minimal.css / theme-bold.css) define. Switching themes
   = flipping the data-theme attribute on <html> (see theme.js). No build step,
   no external dependencies.
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 18px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background-color .25s ease, color .25s ease;
}

/* ---- layout ------------------------------------------------------------- */
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 24px; }
.narrow { max-width: 760px; margin-left: auto; margin-right: auto; }
section { padding: 14px 0; }
.section-pad { padding: 40px 0; }
.divider { height: 1px; background: var(--border); border: 0; margin: 8px auto; max-width: var(--maxw); }

/* ---- typography --------------------------------------------------------- */
h1, h2, h3, h4 { font-family: var(--font-head); color: var(--heading); line-height: 1.2; font-weight: 700; }
h1 { font-size: clamp(2rem, 4.4vw, 3.1rem); letter-spacing: -.02em; margin: 0 0 .3em; }
h2 { font-size: clamp(1.5rem, 2.8vw, 2rem); letter-spacing: -.01em; margin: 1.8em 0 .5em; }
h3 { font-size: 1.2rem; margin: 1.6em 0 .4em; }
p { margin: 0 0 1.1em; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
strong { color: var(--heading); font-weight: 700; }
.eyebrow { font-family: var(--font-head); text-transform: uppercase; letter-spacing: .14em; font-size: .78rem; font-weight: 700; color: var(--accent); margin: 0 0 .6em; }
.lead { font-size: 1.22rem; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: .9rem; }

/* ---- top bar ------------------------------------------------------------ */
.topbar { position: sticky; top: 0; z-index: 50; backdrop-filter: blur(10px);
  background: var(--bar-bg); border-bottom: 1px solid var(--border); }
.topbar .wrap { display: flex; align-items: center; justify-content: space-between; height: 60px; }
.brand { font-family: var(--font-head); font-weight: 800; font-size: 1.15rem; color: var(--heading); letter-spacing: -.01em; }
.brand .star { color: var(--accent); }
.topnav { display: flex; gap: 18px; align-items: center; }
.topnav a { color: var(--muted); font-size: .95rem; font-weight: 600; }
.topnav a:hover { color: var(--heading); text-decoration: none; }
@media (max-width: 720px){ .topnav .nav-hide { display:none; } }

/* ---- theme switcher ----------------------------------------------------- */
.theme-toggle { display: inline-flex; border: 1px solid var(--border); border-radius: 999px; overflow: hidden; background: var(--surface); }
.theme-toggle button { appearance: none; border: 0; background: transparent; color: var(--muted);
  font: 600 .82rem/1 var(--font-head); padding: 8px 13px; cursor: pointer; transition: all .15s ease; }
.theme-toggle button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }

/* ---- hero --------------------------------------------------------------- */
.hero { background: var(--hero-bg); color: var(--hero-text); border-bottom: 1px solid var(--border); overflow: hidden; position: relative; }
.hero .wrap { padding-top: 54px; padding-bottom: 46px; }
.hero h1 { color: var(--hero-heading); }
.hero .lead { color: var(--hero-muted); max-width: 40ch; }
.hero-grid { display: grid; grid-template-columns: 1.05fr 1fr; gap: 40px; align-items: center; }
@media (max-width: 880px){ .hero-grid { grid-template-columns: 1fr; gap: 26px; } }
.byline { font-size: .95rem; color: var(--hero-muted); margin: 0 0 18px; }
.byline b { color: var(--hero-heading); }

/* ---- buttons / resource strip ------------------------------------------ */
.btnrow { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 22px; }
.btn { display: inline-flex; align-items: center; gap: 8px; font: 700 .95rem var(--font-head);
  padding: 11px 18px; border-radius: var(--radius); border: 1px solid transparent; cursor: pointer; transition: transform .12s ease, box-shadow .12s ease; }
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn-primary { background: var(--accent); color: var(--on-accent); box-shadow: var(--shadow); }
.btn-ghost { background: transparent; color: var(--hero-heading); border-color: var(--hero-border); }
.btn .tag { font-size: .68rem; opacity: .8; font-weight: 600; }

/* ---- generic cards / callouts ------------------------------------------ */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px 24px; box-shadow: var(--shadow); }
.callout { border-left: 4px solid var(--accent); background: var(--accent-soft); border-radius: 0 var(--radius) var(--radius) 0;
  padding: 16px 20px; margin: 22px 0; }
.callout .eyebrow { margin-bottom: .25em; }
.pull { font-family: var(--font-head); font-size: 1.35rem; line-height: 1.35; color: var(--heading); border-top: 2px solid var(--accent); border-bottom: 2px solid var(--accent); padding: 18px 0; margin: 26px 0; }

/* feature list (what the walk graph unlocks) */
.features { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; margin: 18px 0; padding: 0; list-style: none; }
@media (max-width: 720px){ .features { grid-template-columns: 1fr; } }
.features li { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; }
.features h4 { margin: 0 0 .35em; font-size: 1.02rem; color: var(--heading); }
.features p { margin: 0; font-size: .96rem; color: var(--muted); }
.features .k { color: var(--accent); }

/* family chips */
.chips { display: flex; flex-wrap: wrap; gap: 10px; margin: 14px 0 4px; padding: 0; list-style: none; }
.chip { font: 600 .85rem var(--font-head); background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 6px 13px; color: var(--muted); }
.chip b { color: var(--heading); }

/* ---- figures ------------------------------------------------------------ */
figure { margin: 26px 0; }
figure img { width: 100%; height: auto; display: block; border-radius: var(--radius); border: 1px solid var(--border); background: #fff; }
figcaption { font-size: .88rem; color: var(--muted); margin-top: 10px; text-align: center; }
.prelim { display: inline-block; font: 700 .68rem var(--font-head); letter-spacing: .08em; text-transform: uppercase;
  color: var(--on-accent); background: var(--warn); border-radius: 6px; padding: 3px 8px; margin-right: 8px; vertical-align: middle; }
.gallery { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 640px){ .gallery { grid-template-columns: 1fr; } }
.figgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
@media (max-width: 760px){ .figgrid { grid-template-columns: 1fr; } }

/* ---- tables ------------------------------------------------------------- */
.tablewrap { overflow-x: auto; margin: 22px 0; }
table { border-collapse: collapse; width: 100%; font-size: .94rem; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
thead th { font-family: var(--font-head); color: var(--heading); border-bottom: 2px solid var(--border); }
tbody tr:hover { background: var(--accent-soft); }
.t-win { color: var(--accent); font-weight: 700; }
table .ours { color: var(--accent); font-weight: 700; }

/* ---- code --------------------------------------------------------------- */
pre { background: var(--code-bg); color: var(--code-text); border: 1px solid var(--code-border); border-radius: var(--radius);
  padding: 16px 18px; overflow-x: auto; font: 14px/1.6 var(--font-mono); margin: 18px 0; position: relative; }
code { font-family: var(--font-mono); font-size: .92em; }
:not(pre) > code { background: var(--accent-soft); color: var(--heading); padding: .12em .4em; border-radius: 5px; }
pre .cmt { color: var(--code-cmt); }
pre .kw  { color: var(--code-kw); font-weight: 600; }
pre .str { color: var(--code-str); }
pre .fn  { color: var(--code-fn); }
.codecap { font-size: .85rem; color: var(--muted); margin: -8px 0 18px; }

/* ---- diagrams (SVG) ----------------------------------------------------- */
.diagram { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin: 22px 0; }
.diagram svg { width: 100%; height: auto; display: block; }
.node rect, .node circle { transition: fill .35s ease, stroke .35s ease, filter .35s ease; }
.node text { font: 600 13px var(--font-head); fill: var(--heading); }
.node .sub { font: 500 10px var(--font-body); fill: var(--muted); }
.edge { stroke: var(--edge); stroke-width: 2; fill: none; transition: stroke .3s ease, stroke-width .3s ease, opacity .3s ease; }
.edge.active { stroke: var(--accent); stroke-width: 3.5; }
.n-enc rect { fill: var(--node-encoder); stroke: var(--node-encoder-bd); }
.n-bb  rect { fill: var(--node-backbone); stroke: var(--node-backbone-bd); }
.n-dec rect { fill: var(--node-decoder); stroke: var(--node-decoder-bd); }
.n-cdc rect { fill: var(--node-codec); stroke: var(--node-codec-bd); }
.node.firing rect, .node.firing circle { filter: drop-shadow(0 0 10px var(--accent)); stroke: var(--accent); stroke-width: 3; }
.tok { fill: var(--accent); }
.legend { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 12px; font-size: .82rem; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.legend i { width: 14px; height: 14px; border-radius: 4px; display: inline-block; border: 1px solid rgba(0,0,0,.15); }
.controls { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 14px; }
.controls button { appearance: none; cursor: pointer; font: 600 .85rem var(--font-head); padding: 8px 14px;
  border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--muted); transition: all .15s ease; }
.controls button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.diagram-cap { font-size: .9rem; color: var(--muted); margin-top: 10px; min-height: 1.5em; }
.gpu-badge { font: 700 10px var(--font-mono); }

/* ---- coming soon -------------------------------------------------------- */
.roadmap { list-style: none; padding: 0; margin: 14px 0; display: grid; gap: 10px; }
.roadmap li { display: flex; gap: 12px; align-items: flex-start; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 13px 16px; }
.roadmap .ic { color: var(--accent); font-weight: 800; flex: none; }
.roadmap b { color: var(--heading); }

/* ---- footer ------------------------------------------------------------- */
.foot { border-top: 1px solid var(--border); margin-top: 30px; background: var(--surface); }
.foot .wrap { padding: 30px 24px; display: flex; flex-wrap: wrap; gap: 20px; justify-content: space-between; }
.foot .small { color: var(--muted); max-width: 52ch; }

/* reveal-on-scroll (progressive enhancement; visible by default if JS off) */
.reveal { opacity: 1; transform: none; }
.js .reveal { opacity: 0; transform: translateY(14px); transition: opacity .6s ease, transform .6s ease; }
.js .reveal.in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce){
  .js .reveal { opacity: 1; transform: none; transition: none; }
  html { scroll-behavior: auto; }
}
.todo { outline: 2px dashed var(--warn); outline-offset: 2px; }
