/* neuronet-arena demo. Tokens follow brettadams0.github.io's palette:
   near-black ground, amber accent, teal secondary, IBM Plex. Dark only — the
   arena is a lit scene on a dark field, and the page is built around it. */

/* ---- tokens (§7.1). Demo pages carry a copy of this block (§7.11). ---- */
/* Tokens for brettadams0.github.io. Dark only. Demo pages copy this :root block (spec 7.11). */
:root {
  color-scheme: dark;

  /* Colour: existing values, unchanged */
  --bg: #0b0f14;
  --bg-2: #0e141b;
  --surface: #131a22;
  --surface-2: #18212b;
  --border: #222c38;
  --border-strong: #2f3b4a;
  --text: #e7ecf2;
  --soft: #c4ccd6;
  --muted: #8695a7;
  --faint: #5a6878;        /* list markers and control edges only; never words (3.37:1 on --bg) */
  --amber: #ffb454;
  --amber-hi: #ffc97f;
  --teal: #4fd6c4;
  --red: #ef6a5f;
  --good: #3ccf6e;

  /* Colour: new */
  --dim: #7b8a9c;          /* words that used --faint; >= 4.61:1 on every background */
  --good-text: #9fe3b7;    /* text on green washes: status line, Live demo badge */
  --on-amber: #1a1206;     /* text on --amber / --amber-hi fills */
  --term: var(--bg-2);     /* terminal and code panels */
  --focus: var(--amber);
  --amber-line: rgba(255, 180, 84, 0.5);
  --amber-wash: rgba(255, 180, 84, 0.1);
  --good-line: rgba(60, 207, 110, 0.3);
  --good-wash: rgba(60, 207, 110, 0.07);

  /* Type */
  --sans: "IBM Plex Sans", "IBM Plex Sans Fallback", -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
  --mono: "IBM Plex Mono", "IBM Plex Mono Fallback", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --fs-xs: 0.75rem;                            /* 12px */
  --fs-sm: 0.875rem;                           /* 14px */
  --fs-base: 1rem;                             /* 16px */
  --fs-md: 1.0625rem;                          /* 17px */
  --fs-lg: 1.1875rem;                          /* 19px */
  --fs-xl: 1.375rem;                           /* 22px */
  --fs-2xl: clamp(2rem, 5vw, 2.75rem);         /* 32–44px */
  --fs-3xl: clamp(1.625rem, 4.5vw, 3rem);      /* 26–48px */
  --fs-display: clamp(2.75rem, 6vw, 4.5rem);   /* 44–72px */
  --lh-tight: 1.1;
  --lh-snug: 1.3;
  --lh-base: 1.6;
  --lh-loose: 1.75;
  --tracking-tight: -0.03em;
  --tracking-caps: 0.08em;

  /* Space (4 px base) */
  --space-1: 0.25rem;   /* 4 */
  --space-2: 0.5rem;    /* 8 */
  --space-3: 0.75rem;   /* 12 */
  --space-4: 1rem;      /* 16 */
  --space-5: 1.25rem;   /* 20 */
  --space-6: 1.5rem;    /* 24 */
  --space-7: 2rem;      /* 32 */
  --space-8: 3rem;      /* 48 */
  --space-9: 4rem;      /* 64 */
  --space-10: 5.5rem;   /* 88 */

  /* Layout */
  --container: 1200px;
  --container-demo: 1320px;
  --container-post: 760px;
  --gutter: 24px;
  --header-h: 56px;

  /* Shape and layers */
  --radius-sm: 6px;
  --radius: 10px;
  --radius-pill: 999px;
  --shadow-focus: 0 0 0 3px var(--bg), 0 0 0 5px var(--focus);
  --z-header: 10;
  --z-skip: 20;

  /* Motion (section 9) */
  --dur-fast: 120ms;
  --dur: 180ms;
  --dur-slow: 240ms;
  --ease-out: cubic-bezier(0.2, 0, 0, 1);
  --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
}

@media (max-width: 640px) {
  :root { --gutter: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  :root { --dur-fast: 0ms; --dur: 0ms; --dur-slow: 0ms; }
}

/* IBM Plex, self-hosted (7.5). Files are Google Fonts' latin subsets, byte for byte. Licence: ../fonts/OFL.txt */
@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("/assets/fonts/ibm-plex-sans-latin-var.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: "IBM Plex Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/assets/fonts/ibm-plex-mono-latin-400.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: "IBM Plex Mono";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/assets/fonts/ibm-plex-mono-latin-500.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: "IBM Plex Mono";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/assets/fonts/ibm-plex-mono-latin-600.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;
}

/* Metric-matched fallbacks: shown until Plex arrives, sized so no line re-wraps on swap (7.5). */
@font-face {
  font-family: "IBM Plex Sans Fallback";
  src: local("Arial"), local("ArialMT"), local("Liberation Sans"), local("Helvetica");
  size-adjust: 100.3%;
  ascent-override: 102.2%;
  descent-override: 27.4%;
  line-gap-override: 0%;
}
@font-face {
  font-family: "IBM Plex Sans Fallback";
  font-weight: 600 700;
  src: local("Arial Bold"), local("Arial-BoldMT"), local("Liberation Sans Bold"), local("Helvetica Bold");
  size-adjust: 98%;
  ascent-override: 104.6%;
  descent-override: 28.1%;
  line-gap-override: 0%;
}
@font-face {
  font-family: "IBM Plex Mono Fallback";
  src: local("Courier New"), local("CourierNewPSMT"), local("Liberation Mono");
  size-adjust: 100%;
  ascent-override: 102.5%;
  descent-override: 27.5%;
  line-gap-override: 0%;
}
/* ---- end tokens ---- */

/* Demo-only tokens (not in the site's block): the chart series and two accents. */
:root {
  --blue: #63a9f0;
  /* Chart series: the accents stepped down to a validated line band. */
  --series-1: #c98500;
  --series-2: #22a392;
  --bad: #ef6a5f;
}

/* ---- shell: a copy of brettadams0.github.io's assets/css/demo-shell.css (site spec 8.20).
   A copy, not a link, so web/ still works when this repo runs on its own. ---- */

/* Utilities the shell and the page share */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
           overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.prefix { color: var(--amber); white-space: pre; }   /* section 7.10 */
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; border-radius: 4px; }
.demo-links a:focus-visible, .demo-source a:focus-visible, .footer-links a:focus-visible { outline-offset: 2px; }
main:focus { outline: none; }

/* Skip link (as site.css, with tokens) */
.skip-link {
  position: absolute; left: var(--space-4); top: -48px; z-index: var(--z-skip);
  padding: var(--space-2) var(--space-3); border-radius: var(--radius-sm);
  background: var(--amber); color: var(--bg); text-decoration: none;
}
.skip-link:focus { top: var(--space-3); }

/* Header row: crumb left, links right. Not sticky. */
.demo-shell { border-bottom: 1px solid var(--border); }
.demo-shell-inner, .demo-foot-inner {
  max-width: var(--container-demo); margin: 0 auto; padding-left: var(--gutter); padding-right: var(--gutter);
}
.demo-shell-inner {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: var(--space-2) var(--space-4); min-height: 52px;
}
.demo-crumb { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); margin: 0; font: 500 var(--fs-sm) var(--mono); }
.demo-sep { color: var(--dim); }
.demo-name { color: var(--text); }
.demo-links { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1) var(--space-5); font-size: var(--fs-sm); }
.demo-back, .demo-links a, .demo-source a, .footer-links a {
  display: inline-flex; align-items: center; min-height: 24px;
  color: var(--muted); text-decoration: none;
  transition: color var(--dur-fast) var(--ease-out);
}
.demo-back:hover, .demo-links a:hover, .demo-source a:hover, .footer-links a:hover { color: var(--text); }
.demo-back:active, .demo-links a:active, .demo-source a:active { color: var(--amber); }
.demo-links .demo-resume {   /* as .nav-resume, section 8.1 */
  min-height: 36px; padding: 0 14px; border: 1px solid var(--amber-line); border-radius: var(--radius);
  color: var(--amber); font-weight: 500;
  transition: background-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}
.demo-links .demo-resume:hover { background: var(--amber-wash); color: var(--amber-hi); }
.demo-links .demo-resume:active { background: rgba(255, 180, 84, 0.16); }

/* How it works */
.demo-how { max-width: var(--container-post); margin: var(--space-8) 0 0; padding-top: var(--space-6); border-top: 1px solid var(--border); }
.demo-how h2 { margin: 0 0 var(--space-3); font-size: var(--fs-sm); font-weight: 600; }
.demo-how ul:not(.chips) { margin: 0 0 var(--space-4); padding-left: 1.1em; color: var(--soft); }
.demo-how ul:not(.chips) li { margin: 5px 0; }
.demo-how ul:not(.chips) li::marker { color: var(--faint); }
.demo-how p a, .demo-how li a { color: var(--muted); }
.demo-source { display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-5); margin: var(--space-4) 0 0; font-weight: 500; }

/* Chips (as section 8.10): the version chip */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; }
.chips li {
  padding: 3px 9px; border: 1px solid var(--border); border-radius: var(--radius-pill);
  background: var(--bg-2); color: var(--soft); font: var(--fs-xs) / 1.5 var(--mono);
  white-space: normal; overflow-wrap: anywhere;
}

/* Footer */
.demo-foot { margin-top: var(--space-8); border-top: 1px solid var(--border); color: var(--muted); font-size: var(--fs-sm); }
.demo-foot-inner {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: var(--space-3) var(--space-6); padding-top: var(--space-6); padding-bottom: var(--space-7);
}
.demo-foot p { margin: 0; }
.demo-foot p > a { color: var(--muted); }   /* running text: keeps its underline */
.demo-foot p > a:hover { color: var(--text); }
.footer-links { display: flex; flex-wrap: wrap; gap: 0 var(--space-6); }

@media (max-width: 640px) {
  .demo-shell-inner { flex-direction: column; align-items: flex-start; gap: 0; padding-top: var(--space-1); padding-bottom: var(--space-1); }
  .demo-back, .demo-links a, .demo-source a, .footer-links a, .demo-links .demo-resume { min-height: 44px; }
  .demo-foot-inner { flex-direction: column; align-items: flex-start; }
}
/* ---- end shell ---- */

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 var(--sans);
}

a { color: var(--amber); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--amber-hi); }
code, kbd { font-family: var(--mono); font-size: 0.88em; }
kbd {
  padding: 1px 5px;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 4px;
  color: var(--text);
}

.wrap { max-width: var(--container-demo); margin: 0 auto; padding: 0 var(--gutter); }

/* Intro */

.intro { padding: 28px 0 20px; max-width: 860px; }
h1 { margin: 0 0 8px; font: 600 30px/1.2 var(--mono); letter-spacing: -0.01em; }
.lede { margin: 0; color: var(--soft); font-size: 16px; }
.lede em { color: var(--text); font-style: normal; font-weight: 600; }

/* Layout */

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  grid-template-areas: "stage side" "explain side";
  gap: 20px;
  align-items: start;
}
.stage { grid-area: stage; }
.side { grid-area: side; }
.explain { grid-area: explain; }

/* Arena */

.arena-frame {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg);
}
#arena { display: block; width: 100%; height: auto; aspect-ratio: 960 / 600; cursor: crosshair; }

.hud {
  position: absolute;
  top: 10px;
  left: 12px;
  display: flex;
  gap: 14px;
  padding: 5px 10px;
  border-radius: 6px;
  background: rgba(11, 15, 20, 0.78);
  font: 12.5px var(--mono);
  color: var(--muted);
  pointer-events: none;
  font-variant-numeric: tabular-nums;
}
.hud b { color: var(--text); font-weight: 500; }

.key {
  position: absolute;
  top: 10px;
  right: 12px;
  display: flex;
  gap: 12px;
  margin: 0;
  padding: 5px 10px;
  list-style: none;
  border-radius: 6px;
  background: rgba(11, 15, 20, 0.78);
  font: 12px var(--mono);
  color: var(--muted);
  pointer-events: none;
}
.key li { display: flex; align-items: center; gap: 6px; }
.key i { display: inline-block; width: 9px; height: 9px; border-radius: 50%; }
.key .k-food { background: var(--teal); }
.key .k-hazard { background: var(--red); }
.key .k-agent, .key .k-leader {
  width: 0; height: 0; border-radius: 0;
  border-left: 10px solid #c3ccd8;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
}
.key .k-leader { border-left-color: var(--amber); }

/* Controls */

.controls { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; margin-top: 12px; }
.controls .group { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

.btn, .seg button {
  appearance: none;
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: 500 13.5px var(--sans);
  cursor: pointer;
}
.btn:hover, .seg button:hover { background: var(--surface-2); }
.btn-primary { min-width: 84px; background: var(--amber); border-color: var(--amber); color: var(--bg); font-weight: 600; }
.btn-primary:hover { background: var(--amber-hi); }

.seg { display: inline-flex; }
.seg button { border-radius: 0; margin-left: -1px; }
.seg button:first-child { border-radius: 8px 0 0 8px; margin-left: 0; }
.seg button:last-child { border-radius: 0 8px 8px 0; }
.seg button[aria-checked="true"] { background: var(--surface-2); border-color: var(--amber); color: var(--amber); position: relative; z-index: 1; }

.seed { display: inline-flex; align-items: center; gap: 6px; font: 13px var(--mono); color: var(--muted); }
.seed input {
  width: 96px;
  min-height: 36px;
  padding: 0 8px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: 13px var(--mono);
}
.hint { margin: 10px 0 0; color: var(--muted); font-size: 13px; }

/* Side cards */

.side { display: flex; flex-direction: column; gap: 16px; }
.card { padding: 14px 16px 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.card h2 { margin: 0; font-size: 14px; font-weight: 600; }
.meta { color: var(--muted); font: 12px var(--mono); }

.legend { display: flex; gap: 12px; margin: 0; padding: 0; list-style: none; font-size: 12px; color: var(--muted); }
.legend li { display: flex; align-items: center; gap: 6px; }
.legend .line { display: inline-block; width: 14px; height: 2px; border-radius: 1px; }
.legend .s1 { background: var(--series-1); }
.legend .s2 { background: var(--series-2); }

.chart { position: relative; height: 170px; }
.chart svg { display: block; width: 100%; height: 100%; overflow: visible; }
.chart .grid { stroke: var(--border); stroke-width: 1; }
.chart .axis-label { fill: var(--muted); font: 10.5px var(--mono); font-variant-numeric: tabular-nums; }
.chart .handoff { stroke: var(--border-strong); stroke-width: 1; }
.chart .handoff-label { fill: var(--muted); font: 10px var(--mono); }
.chart .s1 { stroke: var(--series-1); }
.chart .s2 { stroke: var(--series-2); }
.chart polyline { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .crosshair { stroke: var(--muted); stroke-width: 1; }
.chart .dot { stroke: var(--surface); stroke-width: 2; }
.chart .empty { fill: var(--muted); font: 12px var(--sans); }
.tooltip {
  position: absolute;
  pointer-events: none;
  padding: 6px 9px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--bg);
  font: 12px var(--sans);
  white-space: nowrap;
  transform: translate(-50%, -100%);
}
.tooltip .t-gen { color: var(--muted); font: 11px var(--mono); }
.tooltip .t-row { display: flex; align-items: center; gap: 6px; }
.tooltip .t-row i { width: 10px; height: 2px; }
.tooltip b { font-weight: 600; font-variant-numeric: tabular-nums; }

.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0 0; }
.tiles div { padding: 8px 10px; border-radius: 8px; background: var(--surface-2); }
.tiles dt { color: var(--muted); font-size: 11.5px; }
.tiles dd { margin: 2px 0 0; font-size: 20px; font-weight: 600; }

.table-view { margin-top: 10px; font-size: 12.5px; color: var(--muted); }
.table-view summary { display: list-item; min-height: 24px; line-height: 24px; cursor: pointer; }
.table-scroll { max-height: 180px; overflow: auto; margin-top: 6px; }
.table-view table { width: 100%; border-collapse: collapse; font: 12px var(--mono); font-variant-numeric: tabular-nums; }
.table-view th, .table-view td { padding: 3px 6px; text-align: right; border-bottom: 1px solid var(--border); }
.table-view th { color: var(--muted); font-weight: 500; position: sticky; top: 0; background: var(--surface); }
.table-view td { color: var(--text); }

#brain { display: block; width: 100%; height: auto; aspect-ratio: 360 / 260; }
.vitals { margin-top: 8px; }
.energy { display: flex; align-items: center; gap: 8px; font: 12px var(--mono); color: var(--muted); }
.energy .bar { flex: 1; height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.energy .bar i { display: block; height: 100%; width: 60%; border-radius: 3px; background: var(--amber); }
.energy b { min-width: 28px; text-align: right; color: var(--text); font-weight: 500; font-variant-numeric: tabular-nums; }
.readout { margin: 8px 0 0; color: var(--muted); font: 12px/1.5 var(--mono); min-height: 3em; }
.readout b { color: var(--text); font-weight: 500; }

.parity p { margin: 0 0 10px; color: var(--soft); font-size: 13.5px; }
.badge {
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  color: var(--muted);
  font: 500 11.5px var(--mono);
}
.badge.ok { color: var(--good); border-color: rgba(60, 207, 110, 0.5); }
.badge.bad { color: var(--bad); border-color: rgba(239, 106, 95, 0.5); }
.badge.ok::before { content: "✓ "; }
.badge.bad::before { content: "✕ "; }
.parity-table { width: 100%; border-collapse: collapse; font: 12.5px var(--mono); font-variant-numeric: tabular-nums; }
.parity-table th { color: var(--muted); font-weight: 500; text-align: right; padding: 4px 6px; border-bottom: 1px solid var(--border); }
.parity-table th:first-child, .parity-table td:first-child { text-align: left; color: var(--muted); }
.parity-table td { text-align: right; padding: 5px 6px; border-bottom: 1px solid var(--border); }
.parity-table td.match { color: var(--good); }
.parity-table td.miss { color: var(--bad); }
.parity-table td.pending { color: var(--dim); }

/* Explanation */

.explain {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 18px 28px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}
.explain h2 { margin: 0 0 6px; font: 600 14px var(--mono); color: var(--amber); }
.explain p { margin: 0; color: var(--soft); font-size: 14px; }

@media (max-width: 1080px) {
  .layout { grid-template-columns: 1fr; grid-template-areas: "stage" "side" "explain"; }
  .side { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
}

@media (max-width: 640px) {
  h1 { font-size: 24px; }
  .lede { font-size: 15px; }
  .key { display: none; }
  .hud { gap: 10px; font-size: 11.5px; }
  .explain { grid-template-columns: 1fr; }
}

/* Selection on vs off, side by side */
.compare { margin: 18px 0 0; }
.compare-lede { margin: 0 0 12px; color: var(--soft); font-size: 14px; max-width: 72ch; }
.compare-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr)); gap: 12px; }
.compare-grid figure { margin: 0; }
.compare-grid canvas { display: block; width: 100%; height: auto; aspect-ratio: 8 / 5; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); }
.compare-grid figcaption { margin-top: 4px; color: var(--muted); font: 12px/1.5 var(--mono); }
.cmp-chart { display: block; width: 100%; max-height: 140px; margin-top: 12px; background: var(--bg); border: 1px solid var(--border); border-radius: 6px; }
.cmp-chart polyline { fill: none; stroke-width: 1.6; }
.cmp-chart .on { stroke: var(--amber); }
.cmp-chart .off { stroke: var(--muted); }
.cmp-chart text { fill: var(--muted); font: 9px var(--mono); }
.compare-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 12px; }
.cmp-status { margin: 0; color: var(--soft); font: 13px/1.5 var(--mono); }
