/* FairLine — design system
   A quant-terminal surface: calm, dense, precise. Dark theme built around
   a blue-black (not black) base, one warm accent, and a home/draw/away
   series triad (cool blue -> amber -> warm magenta) that deliberately
   mirrors the scoreboard's left-center-right arrangement. */

:root {
  color-scheme: dark;

  /* --- surfaces --- */
  --bg: #0a0e15;
  --surface: #121722;
  --surface-2: #1a212e;
  --surface-hover: #212a3a;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);

  /* --- ink --- */
  --ink: #edf0f6;
  --ink-2: #9aa5ba;
  --muted: #626c81;

  /* --- chart structure --- */
  --grid: rgba(255, 255, 255, 0.055);
  --baseline: rgba(255, 255, 255, 0.24);
  --phase-band: rgba(255, 255, 255, 0.03);

  /* --- one accent (brand / interactive) --- */
  --accent: #e0a63f;
  --accent-dim: rgba(224, 166, 63, 0.14);

  /* --- home/draw/away series triad: cool -> neutral -> warm,
     matching the scoreboard's left/center/right reading order --- */
  --home: #5b9bd9;
  --draw: #e0a63f; /* = accent, deliberately: draw sits between the two */
  --away: #c77dc9;

  /* --- semantic edge colors (model vs. market) --- */
  --pos: #45b981;
  --neg: #e2606f;
  --warn: #e0a63f;

  /* --- radii --- */
  --radius-sm: 6px;
  --radius-lg: 12px;
  --radius-pill: 999px;

  /* --- spacing grid: 4px base --- */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-6: 24px;
  --sp-8: 32px;

  /* --- type --- */
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-serif: ui-serif, Georgia, "Times New Roman", serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Code", "Consolas", monospace;

  --text-2xl: 34px;   /* scoreboard score */
  --text-xl: 19px;    /* brand wordmark */
  --text-md: 14px;    /* body */
  --text-sm: 12.5px;  /* secondary body / table */
  --text-xs: 11px;    /* labels, meta, chips */

  font-family: var(--font-sans);
}

* { box-sizing: border-box; }
::selection { background: var(--accent-dim); color: var(--ink); }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-size: var(--text-md);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); }
a:hover { color: var(--ink); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ================================================================ header */
.top {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-6) var(--sp-4);
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, var(--surface) 0%, var(--bg) 130%);
}
.top-row {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  flex-wrap: wrap;
}
.brand { display: flex; align-items: baseline; gap: var(--sp-2); }
.mark { font-size: 20px; color: var(--accent); }
.name { font-family: var(--font-serif); font-weight: 600; font-size: var(--text-xl); letter-spacing: 0.1px; }
.tag { color: var(--muted); font-size: var(--text-xs); letter-spacing: 0.2px; }

.modes {
  display: flex;
  gap: 2px;
  margin-left: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px;
}
.modes button {
  background: none;
  border: 0;
  color: var(--ink-2);
  padding: 6px 14px;
  border-radius: 4px;
  cursor: pointer;
  font: inherit;
  font-size: var(--text-sm);
  font-weight: 500;
  transition: background-color 120ms ease, color 120ms ease;
}
.modes button:hover { color: var(--ink); }
.modes button.active { background: var(--surface-hover); color: var(--ink); font-weight: 650; }

/* status rail: the mode badge stays its own visually distinct element —
   larger, left-accented — never demoted to footnote size. */
.status-rail {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  flex-wrap: wrap;
}
.mode-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.6px;
  padding: 6px 12px 6px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  border-left: 3px solid currentColor;
  background: var(--surface);
  white-space: nowrap;
}
.mode-badge.synthetic { color: var(--warn); }
.mode-badge.live-real { color: var(--pos); }

.status-chips { display: flex; gap: var(--sp-2); align-items: center; flex-wrap: wrap; }
.chip {
  font-size: var(--text-xs);
  padding: 5px 10px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  color: var(--ink-2);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.chip.ok { color: var(--pos); border-color: color-mix(in oklab, var(--pos) 40%, transparent); }
.chip.bad { color: var(--neg); border-color: color-mix(in oklab, var(--neg) 40%, transparent); }
.chip.muted { color: var(--muted); }

.chip.ok::before, .chip.bad::before {
  content: "";
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  margin-right: 6px;
  vertical-align: 1px;
}
@media (prefers-reduced-motion: no-preference) {
  .chip.ok::before { animation: pulse 2.2s ease-in-out infinite; }
}
@keyframes pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 color-mix(in oklab, var(--pos) 55%, transparent); }
  50% { opacity: 0.7; box-shadow: 0 0 0 3px color-mix(in oklab, var(--pos) 0%, transparent); }
}

/* ================================================================ scoreboard */
.scoreboard {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-8);
  padding: var(--sp-6) var(--sp-6) var(--sp-4);
}
.team { display: flex; align-items: center; gap: var(--sp-3); min-width: 200px; }
.team.home { justify-content: flex-end; }
.team-name { font-size: 21px; font-weight: 650; letter-spacing: 0.1px; }
.team.home .team-name { color: var(--home); }
.team.away .team-name { color: var(--away); }
.cards { font-size: var(--text-sm); letter-spacing: 1px; }
.mid { text-align: center; min-width: 140px; }
.score {
  font-family: var(--font-mono);
  font-size: var(--text-2xl);
  font-weight: 600;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.clock {
  color: var(--ink-2);
  font-size: var(--text-sm);
  margin-top: var(--sp-2);
  display: flex;
  gap: var(--sp-3);
  justify-content: center;
  align-items: center;
  font-variant-numeric: tabular-nums;
  font-family: var(--font-mono);
}
.phase {
  color: var(--muted);
  text-transform: uppercase;
  font-size: var(--text-xs);
  letter-spacing: 1px;
  font-family: var(--font-sans);
}

/* ================================================================ layout */
main {
  max-width: 1220px;
  margin: 0 auto;
  padding: var(--sp-2) var(--sp-6) var(--sp-6);
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  min-width: 0;
}
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-4);
  min-width: 0;
}
.panel-head {
  display: flex;
  align-items: baseline;
  gap: var(--sp-4);
  margin-bottom: var(--sp-3);
  flex-wrap: wrap;
}
.panel h2 {
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--ink-2);
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.7px;
}
.row { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: var(--sp-4); align-items: stretch; }
.row .panel { display: flex; flex-direction: column; min-width: 0; }

@media (max-width: 900px) {
  .row { grid-template-columns: minmax(0, 1fr); }
  .team { min-width: 0; }
  .scoreboard { gap: var(--sp-4); }
}

/* ================================================================ charts */
.chart-wrap { position: relative; }
.chart-wrap svg { width: 100%; height: 230px; display: block; }
.legend { display: flex; gap: var(--sp-4); font-size: var(--text-xs); color: var(--ink-2); margin-left: auto; }
.legend .key { display: inline-flex; align-items: center; gap: 5px; }
.legend .dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.swatch-line { display: inline-block; width: 20px; height: 0; border-top: 2px solid var(--ink-2); vertical-align: middle; margin: 0 3px; }
.swatch-line.dashed { border-top-style: dashed; }

.tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: var(--sp-2) var(--sp-3);
  font-size: var(--text-sm);
  color: var(--ink-2);
  display: none;
  min-width: 165px;
  z-index: 5;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}
.tooltip .t-head {
  color: var(--ink);
  font-weight: 600;
  margin-bottom: var(--sp-1);
  font-variant-numeric: tabular-nums;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
}
.tooltip table { border-collapse: collapse; width: 100%; }
.tooltip td { padding: 1px 4px 1px 0; font-variant-numeric: tabular-nums; font-family: var(--font-mono); font-size: var(--text-xs); }

/* svg pieces used from JS */
.gridline { stroke: var(--grid); stroke-width: 1; }
.axis-label { fill: var(--muted); font-size: 10px; font-family: var(--font-mono); }
.zero-line { stroke: var(--baseline); stroke-width: 1.25; }
.phase-band { fill: var(--phase-band); }
.event-line { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 2 3; opacity: 0.6; }
.event-icon { font-size: 11px; }
.series { fill: none; stroke-width: 2; }
.series.dashed { stroke-dasharray: 5 4; opacity: 0.85; }
.series-label { font-size: 10px; font-family: var(--font-mono); font-variant-numeric: tabular-nums; dominant-baseline: middle; }
.crosshair { stroke: var(--ink-2); stroke-width: 1; stroke-dasharray: 3 3; opacity: 0.5; }

/* ================================================================ price board */
.board { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-family: var(--font-mono); font-size: var(--text-sm); }
.board th {
  text-align: right;
  color: var(--muted);
  font-size: var(--text-xs);
  font-family: var(--font-sans);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
  padding: var(--sp-1) var(--sp-2) var(--sp-2);
  border-bottom: 1px solid var(--border-strong);
}
.board th:first-child { text-align: left; }
.board td { padding: var(--sp-2); text-align: right; border-bottom: 1px solid var(--border); color: var(--ink-2); }
.board td:first-child { text-align: left; color: var(--ink); font-family: var(--font-sans); font-size: var(--text-md); }
.board tr:last-child td { border-bottom: 0; }
.board tr:hover td { background: var(--surface-hover); }
.board .pos { color: var(--pos); font-weight: 600; }
.board .neg { color: var(--neg); font-weight: 600; }
.board .mkdot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: var(--sp-2); vertical-align: 1px; }
.board-note { color: var(--muted); font-size: var(--text-xs); }
.board-scroll { overflow-x: auto; min-width: 0; }
.board th, .board td { white-space: nowrap; }

@media (max-width: 640px) {
  .board { min-width: 560px; }
}

/* ================================================================ feed panel */
.feed-panel { display: flex; flex-direction: column; }
.feed-desc { color: var(--ink-2); font-size: var(--text-sm); margin: var(--sp-2) 0; }
.code {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--sp-2) var(--sp-3);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--ink-2);
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
}
.feed-links { display: flex; flex-wrap: wrap; gap: var(--sp-4); margin-top: var(--sp-3); }
.feed-links a { color: var(--accent); text-decoration: none; font-size: var(--text-sm); }
.feed-links a:hover { text-decoration: underline; color: var(--ink); }

/* ================================================================ footer / honesty banner */
footer { max-width: 1220px; margin: 0 auto; padding: 0 var(--sp-6) var(--sp-8); }
.honesty-panel {
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-lg);
  background: var(--surface);
  padding: var(--sp-3) var(--sp-4);
  color: var(--muted);
  font-size: var(--text-sm);
}
.honesty-panel strong { color: var(--ink-2); }
.honesty-panel em { color: var(--ink-2); font-style: italic; }

/* ================================================================ docs page */
.docs-main { max-width: 800px; display: flex; flex-direction: column; gap: var(--sp-4); }
.docs-main .panel h2 { text-transform: none; font-size: 16px; letter-spacing: 0; color: var(--ink); font-family: var(--font-serif); font-weight: 600; margin: 0 0 var(--sp-2); }
.back-link { color: var(--ink-2); text-decoration: none; padding: 6px 14px; font-size: var(--text-sm); }
.back-link:hover { color: var(--ink); }
.docs-main code { font-family: var(--font-mono); background: var(--surface-2); padding: 1px 5px; border-radius: 4px; font-size: 0.92em; }
.docs-main .feedback-list { margin: var(--sp-2) 0; padding-left: 1.3em; }
.docs-main .feedback-list li { color: var(--ink-2); font-size: var(--text-sm); margin-bottom: var(--sp-3); }
.docs-main .feedback-list li:last-child { margin-bottom: 0; }

/* ================================================================ small screens */
@media (max-width: 480px) {
  .top { padding: var(--sp-3) var(--sp-4); }
  main { padding: var(--sp-1) var(--sp-4) var(--sp-4); }
  .scoreboard { padding: var(--sp-4) var(--sp-3) var(--sp-2); gap: var(--sp-3); }
  .team { min-width: 0; gap: var(--sp-2); }
  .team-name { font-size: 15px; }
  .score { font-size: 26px; }
  :root { --text-2xl: 26px; }
  .chart-wrap svg { height: 190px; }
  .board { font-size: 11.5px; }
  .board td, .board th { padding: 6px; }
}
