/* Post-specific styles on top of theme.css. Charts and the demo use a validated categorical
   palette with light and dark steps; colour follows the predictor, never its rank. */
:root,
[data-theme="dark"] {
  --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500;
  --series-5: #d55181; --series-6: #008300; --series-7: #9085e9;
  --truth: #f5f5f5;
  --grid: #2a2a2a;
  --scrim: rgba(0, 0, 0, 0.45);
}
[data-theme="light"] {
  --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a; --series-4: #eda100;
  --series-5: #e87ba4; --series-6: #008300; --series-7: #6250d6;
  --truth: #111111;
  --grid: #ececec;
  --scrim: rgba(0, 0, 0, 0.35);
}



.numbers { font-variant-numeric: tabular-nums; }

figure { margin: 24px 0; }
figure > figcaption, .demo figcaption {
  font-size: var(--text-small); line-height: 1.55; color: var(--muted-foreground); margin-top: 10px; max-width: 75ch;
}
figcaption.figure-title {
  font-size: var(--text-section);
  line-height: var(--text-section--line-height);
  font-weight: var(--font-weight-semibold);
  color: var(--foreground);
  margin-bottom: 4px;
}
.figure-note {
  font-size: var(--text-body);
  line-height: var(--text-body--line-height);
  color: var(--secondary-foreground);
  margin: 0 0 12px;
  max-width: 70ch;
}

/* --- playable demo --- */
.demo { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.stage { position: relative; aspect-ratio: 16 / 9; background: #000; border-radius: var(--radius); overflow: hidden; }
.stage video, .stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.stage video { object-fit: contain; }
.stage .stamp {
  position: absolute; left: 10px; bottom: 8px; padding: 2px 8px; border-radius: 4px;
  background: rgba(0, 0, 0, 0.6); color: #f5f5f5; font-size: var(--text-mini); line-height: var(--text-mini--line-height);
  font-variant-numeric: tabular-nums;
}
.stage .stamp:empty { display: none; }
.controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-top: 12px; }
.controls input[type="range"] { flex: 1; min-width: 160px; accent-color: var(--primary); }
.time { color: var(--muted-foreground); font-size: var(--text-small); font-variant-numeric: tabular-nums; min-width: 9ch; }
button.control, .chip, .segmented button {
  font: inherit;
  font-size: var(--text-small);
  line-height: var(--text-small--line-height);
  font-weight: var(--font-weight-medium);
  color: var(--secondary-foreground);
  background: var(--background);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 10px;
  min-height: 34px;
  cursor: pointer;
  transition: transform 150ms cubic-bezier(0.2, 0, 0, 1), border-color 150ms cubic-bezier(0.2, 0, 0, 1);
}
button.control:active, .chip:active, .segmented button:active { transform: scale(0.96); }
@media (hover: hover) and (pointer: fine) {
  button.control:hover, .chip:hover, .segmented button:hover { border-color: var(--muted-foreground); }
}
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.chip { display: inline-flex; align-items: center; gap: 8px; }
.chip[aria-pressed="true"] { color: var(--foreground); border-color: var(--secondary-foreground); background: var(--secondary); }
.chip[aria-pressed="false"] .swatch { opacity: 0.35; }
.swatch { display: inline-block; width: 16px; height: 4px; border-radius: 2px; flex: none; }
.swatch.truth { background: var(--truth); }
.toggles { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 10px; color: var(--secondary-foreground); font-size: var(--text-small); }
.toggles label { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
table.readout, table.results { border-collapse: collapse; width: 100%; margin-top: 12px; font-size: var(--text-small); font-variant-numeric: tabular-nums; }
table.readout th, table.results th { text-align: right; font-weight: var(--font-weight-medium); color: var(--muted-foreground); padding: 4px 8px; border-bottom: 1px solid var(--border); }
table.readout td, table.results td { text-align: right; padding: 5px 8px; color: var(--foreground); }
table.readout th:first-child, table.readout td:first-child, table.results th:first-child, table.results td:first-child { text-align: left; }
table.results tr.best td { font-weight: var(--font-weight-semibold); }
.table-wrap { overflow-x: auto; }

/* --- charts --- */
.segmented { display: inline-flex; gap: 4px; margin-bottom: 8px; }
.segmented button[aria-pressed="true"] { color: var(--foreground); border-color: var(--secondary-foreground); background: var(--secondary); }
svg.chart { width: 100%; height: auto; display: block; overflow: visible; }
/* The time chart keeps a readable minimum width and scrolls sideways on phones. */
.scroll-x { overflow-x: auto; }
.scroll-x svg.chart { min-width: 600px; }
svg.chart text { font-family: var(--font-sans); fill: var(--secondary-foreground); font-size: 12px; }
svg.chart .label { fill: var(--foreground); font-size: 13px; }
svg.chart .value { fill: var(--foreground); font-weight: 600; font-size: 13px; }
svg.chart .grid { stroke: var(--grid); stroke-width: 1; }
svg.chart .reference { stroke: var(--muted-foreground); stroke-dasharray: 4 4; stroke-width: 1; }
.line-chart { position: relative; }
.tooltip {
  position: absolute; pointer-events: none; z-index: 2; background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-medium); padding: 8px 10px; font-size: var(--text-small);
  line-height: 1.6; color: var(--foreground); white-space: nowrap; font-variant-numeric: tabular-nums;
}
.legend { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }

/* --- predictor list and NCA diagram --- */
ul.predictors { list-style: none; padding: 0; margin: 16px 0; display: grid; gap: 14px; }
ul.predictors li { display: grid; grid-template-columns: 22px 1fr; gap: 0 10px; }
ul.predictors .swatch { margin-top: 11px; }
ul.predictors b { color: var(--foreground); font-weight: var(--font-weight-semibold); }
ul.predictors span.text { color: var(--secondary-foreground); }
.diagram-wrap { overflow-x: auto; }
.diagram-wrap svg { min-width: 640px; }
svg.diagram text { font-family: var(--font-sans); font-size: 13px; fill: var(--foreground); }
svg.diagram .sub { fill: var(--muted-foreground); font-size: 12px; }
svg.diagram rect { fill: var(--background); stroke: var(--border); }
svg.diagram rect.rule { fill: var(--secondary); stroke: var(--secondary-foreground); }
svg.diagram path { stroke: var(--muted-foreground); fill: none; }

@media (prefers-reduced-motion: reduce) {
  button.control, .chip, .segmented button { transition: none; }
}

/* Site link back to athonmillane.com, in the top bar and footer. */
.topbar a.home { color: var(--secondary-foreground); text-decoration: none; font-weight: var(--font-weight-medium); }
.topbar a.home:hover { color: var(--foreground); text-decoration: underline; }
footer.bottom a { color: inherit; }
