/* timeline.css — shared by /dashboard (section) and /evolution (standalone page).
   Dark palette to match the dashboard design system. */

.tl-root {
  --tl-bg: #0b1220;
  --tl-card: #111a2c;
  --tl-line: rgba(255, 255, 255, 0.09);
  --tl-text: #e8eef8;
  --tl-dim: rgba(232, 238, 248, 0.56);
  background: var(--tl-card);
  border: 1px solid var(--tl-line);
  border-radius: 18px;
  padding: 22px 22px 16px;
  color: var(--tl-text);
  font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  max-width: 1100px;
  margin: 0 auto;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.35);
  position: relative;
}

/* --- candidate race panels ------------------------------------------------ */
.tl-panel {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--tl-line);
}
.tl-panel-head h3 {
  margin: 0 0 4px;
  font-size: 14.5px;
  font-weight: 800;
  letter-spacing: -0.1px;
}
.tl-panel-head p {
  margin: 0 0 10px;
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--tl-dim);
  max-width: 92ch;
}
.tl-panel canvas { display: block; width: 100%; border-radius: 10px; }

/* --- collapsible secondary panels (2 and 3) ------------------------------- */
.tl-fold { padding-bottom: 2px; }
.tl-fold-head {
  display: flex; align-items: center; gap: 9px; width: 100%;
  margin: 0; padding: 2px 0 4px; background: none; border: 0; cursor: pointer;
  color: inherit; font: inherit; text-align: left;
}
.tl-fold-head:focus-visible { outline: 2px solid #7cc4ff; outline-offset: 3px; border-radius: 6px; }
.tl-fold-caret { color: #7cc4ff; font-size: 11px; line-height: 1; transition: transform .18s ease; }
.tl-fold.is-open .tl-fold-caret { transform: rotate(90deg); }
.tl-fold-label { font-size: 14.5px; font-weight: 800; letter-spacing: -0.1px; transition: color .15s ease; }
.tl-fold-head:hover .tl-fold-label { color: #ffffff; }
.tl-fold-hint {
  margin-left: auto; flex: 0 0 auto; font-size: 10px; letter-spacing: .09em; text-transform: uppercase;
  color: var(--tl-dim); border: 1px solid var(--tl-line); border-radius: 999px; padding: 3px 9px;
  transition: color .15s ease, border-color .15s ease;
}
.tl-fold.is-open .tl-fold-hint { color: #9fd0ff; border-color: rgba(124, 196, 255, .45); }
.tl-fold-sub { margin: 0 0 10px; font-size: 11.5px; line-height: 1.45; color: var(--tl-dim); max-width: 92ch; }
.tl-fold-body[hidden] { display: none; }

.tl-kpi-lead .tl-kpi-v { color: #9fd0ff; font-size: 15px; }

.tl-chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.tl-chip {
  font-size: 11.5px;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--tl-line);
  color: rgba(232, 238, 248, 0.85);
}
.tl-chip strong { color: #fff; font-weight: 700; }
.tl-chip-gold {
  background: rgba(245, 166, 35, 0.12);
  border-color: rgba(245, 166, 35, 0.35);
}

/* hover tooltip shared by all three panels */
.tl-tip {
  position: absolute;
  z-index: 20;
  pointer-events: none;
  background: #0a1322;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 11.5px;
  line-height: 1.45;
  color: #e8eef8;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.5);
  max-width: 260px;
}
.tl-tip-dim { color: rgba(232, 238, 248, 0.55); }

/* --- header badges + admin-only refresh ----------------------------------- */
.tl-badges { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.tl-badge-muted {
  background: rgba(255, 255, 255, 0.03);
  color: rgba(232, 238, 248, 0.5);
  font-weight: 500;
  font-size: 10.5px;
}

.tl-admin {
  margin-top: 14px;
  padding: 12px 14px;
  border: 1px dashed rgba(124, 196, 255, 0.35);
  border-radius: 12px;
  background: rgba(124, 196, 255, 0.05);
}
.tl-admin-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.tl-admin-btn {
  appearance: none;
  border: 1px solid rgba(124, 196, 255, 0.55);
  background: rgba(124, 196, 255, 0.14);
  color: #cfe6ff;
  font: 600 12.5px Inter, system-ui, sans-serif;
  padding: 8px 14px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}
.tl-admin-btn:hover:not(:disabled) { background: rgba(124, 196, 255, 0.24); }
.tl-admin-btn:active:not(:disabled) { transform: translateY(1px); }
.tl-admin-btn:disabled { opacity: 0.6; cursor: progress; }
.tl-admin-status {
  font-size: 11.5px;
  color: rgba(232, 238, 248, 0.78);
  font-variant-numeric: tabular-nums;
}
.tl-admin-note {
  margin: 8px 0 0;
  font-size: 10.5px;
  line-height: 1.5;
  color: rgba(232, 238, 248, 0.45);
}
.tl-admin-note strong { color: rgba(232, 238, 248, 0.8); font-weight: 600; }


.tl-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.tl-title { font-size: 20px; font-weight: 800; margin: 0 0 4px; letter-spacing: -0.2px; }
.tl-sub { margin: 0; font-size: 13px; color: var(--tl-dim); }
.tl-badge {
  font-size: 12px; font-weight: 600; color: #9fd0ff;
  background: rgba(124, 196, 255, 0.1);
  border: 1px solid rgba(124, 196, 255, 0.25);
  padding: 6px 12px; border-radius: 999px; white-space: nowrap;
}

.tl-kpis {
  display: grid; gap: 10px; margin: 18px 0 6px;
  grid-template-columns: repeat(6, minmax(0, 1fr));
}
.tl-kpi {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--tl-line);
  border-radius: 12px; padding: 10px 12px;
}
.tl-kpi-v { display: block; font-size: 19px; font-weight: 800; font-variant-numeric: tabular-nums; }
.tl-kpi-l { display: block; font-size: 10.5px; color: var(--tl-dim); margin-top: 2px; line-height: 1.25; }

.tl-chart-wrap { margin-top: 16px; }
.tl-chart-title { font-size: 13px; font-weight: 700; margin-bottom: 6px; }
.tl-chart-note { font-weight: 400; color: var(--tl-dim); font-size: 11.5px; margin-left: 6px; }
.tl-root canvas { display: block; width: 100%; }

.tl-legend { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 8px; }
.tl-leg { font-size: 11.5px; color: var(--tl-dim); display: inline-flex; align-items: center; gap: 5px; }
.tl-leg i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

.tl-controls {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--tl-line);
}
.tl-play {
  display: inline-flex; align-items: center; gap: 8px;
  background: linear-gradient(135deg, #2d6cff, #1d4ed8);
  color: #fff; border: 0; border-radius: 999px;
  padding: 10px 20px; font-size: 14px; font-weight: 700;
  cursor: pointer; box-shadow: 0 8px 20px rgba(45, 108, 255, 0.35);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.tl-play:hover { transform: translateY(-1px); box-shadow: 0 12px 26px rgba(45, 108, 255, 0.45); }
.tl-play:focus-visible { outline: 2px solid #9fd0ff; outline-offset: 3px; }
.tl-ghost {
  background: rgba(255, 255, 255, 0.05); color: var(--tl-text);
  border: 1px solid var(--tl-line); border-radius: 10px;
  padding: 8px 12px; font-size: 13px; cursor: pointer;
}
.tl-ghost:hover { background: rgba(255, 255, 255, 0.1); }
/* Scrubber + timestamp ruler: the bubble over the thumb names the exact instant of the
   frame and stays visible whenever the run is stopped (see _updateScrubTip). */
.tl-scrub-wrap { position: relative; flex: 1 1 220px; min-width: 160px; display: flex; align-items: center; }
.tl-scrub { flex: 1 1 auto; width: 100%; min-width: 0; accent-color: #2d6cff; cursor: pointer; }
.tl-scrub-tip {
  position: absolute; bottom: calc(100% + 11px); left: 0; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 1px; white-space: nowrap;
  background: #0a1322; border: 1px solid rgba(255, 255, 255, 0.18); border-radius: 9px;
  padding: 6px 9px; font-size: 10.5px; line-height: 1.4; color: #e8eef8;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.55); pointer-events: none; z-index: 21;
  /* No opacity transition: the toggle must be synchronous — a stalled compositor
     (background tab, reduced motion) would otherwise leave a pinned ruler invisible. */
  opacity: 0; visibility: hidden;
}
.tl-scrub-tip.is-on { opacity: 1; visibility: visible; }
.tl-scrub-tip b { font-size: 12px; font-weight: 700; letter-spacing: -0.1px; }
.tl-scrub-tip span { color: rgba(232, 238, 248, 0.62); }
.tl-scrub-tip::after {
  content: ''; position: absolute; top: 100%; left: 50%; margin-left: -5px;
  border: 5px solid transparent; border-top-color: #0a1322;
}
.tl-speed {
  background: rgba(255, 255, 255, 0.05); color: var(--tl-text);
  border: 1px solid var(--tl-line); border-radius: 10px; padding: 8px 10px; font-size: 13px;
}
.tl-copied { font-size: 11.5px; color: #9fd0ff; word-break: break-all; }

.tl-note {
  margin: 12px 0 0; font-size: 11px; line-height: 1.5;
  color: rgba(232, 238, 248, 0.45);
}

.tl-nudge { display: none; }   /* phones/tablets reveal it in the media queries below */

/* Tablet and below: the controls need their own rows. Play+reset stay together, the scrubber
   takes a full row so a finger has the whole width, and the ruler label renders as a line of
   text above it (a 265 px bubble wider than the track cannot follow the thumb). */
@media (max-width: 900px) {
  .tl-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .tl-controls { gap: 8px; }
  .tl-play { order: 1; }
  .tl-ghost[data-tl="reset"] { order: 2; }
  .tl-scrub-wrap { order: 3; flex: 1 0 100%; flex-direction: column; align-items: stretch; gap: 6px; }
  .tl-speed { order: 4; }
  .tl-ghost[data-tl="share"] { order: 5; margin-left: auto; }
  .tl-copied { order: 6; flex: 1 0 100%; }
  .tl-scrub-tip {
    position: static; transform: none; order: -1; left: auto !important; bottom: auto;
    width: 100%; max-width: none; white-space: normal; text-align: left;
    padding: 6px 9px; line-height: 1.4;
  }
  .tl-scrub-tip::after { display: none; }
  .tl-nudge { display: flex; order: 7; flex: 1 0 100%; gap: 6px; }
  .tl-nudge button {
    flex: 1 1 0; padding: 9px 0; font: 600 12px Inter, system-ui, sans-serif;
    color: #cfe6ff; background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--tl-line); border-radius: 9px; cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }
  .tl-nudge button:active { background: rgba(124, 196, 255, 0.22); }
  .tl-nudge button[data-jump^="-"] { color: #9fb4cc; }
}

/* --- phone form factor -----------------------------------------------------
   The player is a 1100 px desktop composition: six KPI cells across, a 168 px label gutter
   inside a canvas, a slider next to five buttons. On a 390 px screen that leaves ~60 px of
   plot and a tooltip wider than the card, so everything below 640 px is re-laid out here and
   the canvas gutters/heights are reduced in JS (see _sizes / _drawViews). */
@media (max-width: 640px) {
  .tl-page { padding: 14px 10px 30px; }
  .tl-page-head h1 { font-size: 21px; line-height: 1.25; }
  .tl-page-head p { font-size: 12.5px; line-height: 1.5; }
  .tl-cta { gap: 8px; margin-top: 10px; }
  .tl-cta a { font-size: 12px; padding: 7px 12px; }
  .tl-page-foot { font-size: 11px; }

  .tl-root { padding: 14px 12px 10px; border-radius: 14px; }
  .tl-head { gap: 10px; }
  .tl-title { font-size: 17px; }
  .tl-sub { font-size: 11.5px; line-height: 1.45; }
  .tl-badges { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 6px; }
  .tl-badge { font-size: 10.5px; padding: 5px 10px; }

  .tl-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; margin: 12px 0 4px; }
  .tl-kpi { padding: 8px 10px; border-radius: 10px; }
  .tl-kpi-v { font-size: 15px; }
  .tl-kpi-l { font-size: 9.5px; }
  .tl-kpi-lead .tl-kpi-v { font-size: 13px; }

  .tl-panel { margin-top: 14px; padding-top: 12px; }
  .tl-panel-head h3, .tl-fold-label { font-size: 13px; }
  .tl-panel-head p, .tl-fold-sub { font-size: 10.5px; line-height: 1.45; }
  .tl-fold-hint { font-size: 9px; padding: 2px 7px; letter-spacing: 0.06em; }
  .tl-legend { gap: 8px; }
  .tl-leg { font-size: 10.5px; }

  .tl-controls { margin-top: 12px; padding-top: 12px; }
  .tl-play { flex: 1 1 auto; justify-content: center; padding: 9px 14px; font-size: 13px; }
  .tl-ghost[data-tl="reset"] { padding: 8px 11px; }
  .tl-speed, .tl-ghost[data-tl="share"] { flex: 1 1 auto; }
  .tl-ghost[data-tl="share"] { text-align: center; }
  .tl-copied { font-size: 10.5px; }
  .tl-scrub-tip b { font-size: 12.5px; }
  .tl-tip { max-width: calc(100vw - 44px); font-size: 11px; }

  .tl-note { font-size: 10px; line-height: 1.5; }
  .tl-admin { padding: 10px; }
  .tl-admin-btn { flex: 1 1 100%; }
}

/* Standalone /evolution page wrapper */
.tl-page {
  margin: 0; min-height: 100vh; background: #070d18; color: #e8eef8;
  font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  padding: 28px 18px 40px;
}
.tl-page-head { max-width: 1100px; margin: 0 auto 16px; }
.tl-page-head .brand { font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase; color: rgba(232, 238, 248, 0.5); }
.tl-page-head h1 { font-size: 26px; margin: 8px 0 6px; letter-spacing: -0.4px; }
.tl-page-head p { margin: 0; color: rgba(232, 238, 248, 0.6); font-size: 14px; max-width: 70ch; line-height: 1.55; }
.tl-page-foot { max-width: 1100px; margin: 18px auto 0; font-size: 12px; color: rgba(232, 238, 248, 0.4); }
.tl-page-foot a { color: #9fd0ff; text-decoration: none; }
.tl-cta { display: inline-flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.tl-cta a {
  font-size: 13px; text-decoration: none; color: #e8eef8;
  border: 1px solid rgba(255, 255, 255, 0.12); border-radius: 999px; padding: 8px 14px;
  background: rgba(255, 255, 255, 0.04);
}
.tl-cta a:hover { background: rgba(255, 255, 255, 0.1); }