/* BreakoutBot track record — design tokens + component system.
 *
 * Everything visual comes from the tokens below. The previous stylesheet grew 13
 * ad-hoc font sizes (0.7 → 1.5rem) and 14 ad-hoc spacing values (4 → 64px), which is
 * why panels that were individually fine did not look like one system. Six type
 * steps, one 4px spacing scale, three radii, and a single .panel skeleton that every
 * section reuses. Add a token before adding a magic number.
 *
 * No external assets: the CSP is default-src 'self', so system font stacks only.
 */

:root {
  /* ── surfaces: 0 is the page, each step sits above the previous ── */
  --s0: #0a0d13;
  --s1: #111621;
  --s2: #171d2b;
  --s3: #1e2637;

  --line: #212a3a;
  --line-strong: #2c374b;

  /* ── text: 1 primary, 2 secondary, 3 labels ── */
  --t1: #e8eef6;
  --t2: #9aa8bd;
  --t3: #6c7a90;

  /* ── state: each colour pairs with a low-alpha wash for chips/rows ── */
  --pos: #3fb950;
  --pos-dim: rgba(63, 185, 80, 0.12);
  --neg: #f85149;
  --neg-dim: rgba(248, 81, 73, 0.12);
  --warn: #d29922;
  --warn-dim: rgba(210, 153, 34, 0.12);
  --info: #58a6ff;
  --info-dim: rgba(88, 166, 255, 0.12);

  /* ── type: six steps, nothing between ── */
  --fs-xs: 0.6875rem;   /* labels, table headers */
  --fs-sm: 0.8125rem;   /* table cells, notes */
  --fs-md: 0.9375rem;   /* body */
  --fs-lg: 1.125rem;    /* section titles */
  --fs-xl: 1.5rem;      /* stat values */
  --fs-2xl: 2.25rem;    /* hero values */

  /* ── space: 4px base, eight steps ── */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 24px;
  --sp-6: 32px;
  --sp-7: 48px;
  --sp-8: 64px;

  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;

  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  --wrap: 1120px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--s0);
  color: var(--t1);
  font-family: var(--sans);
  font-size: var(--fs-md);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

main { max-width: var(--wrap); margin: 0 auto; padding: var(--sp-5) var(--sp-4) var(--sp-8); }

a { color: var(--info); }

/* Every figure on the page is monospaced and column-aligned — the single biggest
   reason a dense table reads as calm rather than noisy. */
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--t2); }
.dim { color: var(--t3); }
.small { font-size: var(--fs-sm); }
.pos { color: var(--pos); }
.neg { color: var(--neg); }

/* ── loading / error ───────────────────────────────────────────────────────── */
.state {
  max-width: var(--wrap);
  margin: 18vh auto;
  text-align: center;
  color: var(--t2);
  font-family: var(--mono);
  font-size: var(--fs-sm);
}
.state.error { color: var(--neg); }

/* ── header ────────────────────────────────────────────────────────────────── */
.hdr {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--sp-4);
  padding-bottom: var(--sp-4);
  border-bottom: 1px solid var(--line);
}
.hdr h1 {
  margin: 0;
  font-size: var(--fs-lg);
  font-weight: 650;
  letter-spacing: -0.01em;
}
.hdr-sub { margin: var(--sp-1) 0 0; font-size: var(--fs-sm); color: var(--t2); }
.hdr-right { display: flex; flex-direction: column; align-items: flex-end; gap: var(--sp-2); }

.badge {
  font-family: var(--mono);
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.07em;
  padding: 3px var(--sp-2);
  border-radius: var(--r-sm);
  border: 1px solid;
}
.badge-paper   { color: var(--info); border-color: var(--info); background: var(--info-dim); }
.badge-testnet { color: var(--warn); border-color: var(--warn); background: var(--warn-dim); }
.badge-live    { color: var(--pos); border-color: var(--pos); background: var(--pos-dim); }

/* ── panel: the one card skeleton every section reuses ─────────────────────── */
.panel {
  margin: var(--sp-4) 0;
  padding: var(--sp-5);
  background: var(--s1);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
}
.panel-hd {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-3);
  margin-bottom: var(--sp-4);
}
.panel-title {
  margin: 0;
  font-size: var(--fs-md);
  font-weight: 650;
  letter-spacing: -0.005em;
}
.panel-note { font-size: var(--fs-sm); color: var(--t2); text-align: right; }

/* ── status strip ──────────────────────────────────────────────────────────── */
.strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-2) var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  background: var(--s1);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  margin: var(--sp-4) 0;
}
.strip.is-stale { border-color: var(--warn); background: linear-gradient(0deg, var(--warn-dim), var(--warn-dim)), var(--s1); }

.chip {
  display: inline-flex;
  align-items: baseline;
  gap: var(--sp-2);
  font-size: var(--fs-sm);
  padding: var(--sp-1) var(--sp-2);
  border-radius: var(--r-sm);
  background: var(--s2);
  border: 1px solid var(--line);
}
.chip b { font-family: var(--mono); font-variant-numeric: tabular-nums; font-weight: 600; }
.chip-lbl { color: var(--t3); font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.06em; }
.chip-pos  { border-color: rgba(63,185,80,0.35);  background: var(--pos-dim); }
.chip-warn { border-color: rgba(210,153,34,0.35); background: var(--warn-dim); }
.chip-neg  { border-color: rgba(248,81,73,0.35);  background: var(--neg-dim); }

.pulse {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--pos);
  box-shadow: 0 0 0 3px var(--pos-dim);
  flex: none;
}
.pulse.is-stale { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-dim); }

/* ── stats: one component, three sizes ─────────────────────────────────────── */
.stats {
  display: grid;
  gap: var(--sp-3);
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}
.stats-hero { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.stats-tight { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }

.stat {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  padding: var(--sp-4);
  background: var(--s2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
}
.stat-val {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: var(--fs-xl);
  font-weight: 600;
  letter-spacing: -0.02em;
}
.stat-lbl { font-size: var(--fs-xs); color: var(--t3); text-transform: uppercase; letter-spacing: 0.06em; }
.stat-sub { font-size: var(--fs-sm); color: var(--t2); }

.stat-hero { padding: var(--sp-5); background: var(--s2); }
.stat-hero .stat-val { font-size: var(--fs-2xl); }
.stat-hero.accent-pos  { border-color: rgba(63,185,80,0.4); }
.stat-hero.accent-neg  { border-color: rgba(248,81,73,0.4); }
.stat-hero.accent-warn { border-color: rgba(210,153,34,0.4); }

/* ── charts ────────────────────────────────────────────────────────────────── */
.chart { width: 100%; display: block; overflow: visible; }
.chart-axis { fill: var(--t3); font-family: var(--mono); font-size: 10px; }
.chart-grid { stroke: var(--line); stroke-width: 1; }
.chart-ref  { stroke: var(--t3); stroke-width: 1; stroke-dasharray: 3 4; opacity: 0.7; }
.chart-line { fill: none; stroke: var(--pos); stroke-width: 1.75; stroke-linejoin: round; }
.chart-area { fill: var(--pos); opacity: 0.10; }
.chart-dd   { fill: var(--neg); opacity: 0.16; }
.chart-dd-line { fill: none; stroke: var(--neg); stroke-width: 1.25; }

/* ── tables ────────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
th, td {
  padding: var(--sp-2) var(--sp-3);
  text-align: left;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
thead th {
  color: var(--t3);
  font-weight: 600;
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom-color: var(--line-strong);
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--s2); }
td.num, th.num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }
td.why { white-space: normal; color: var(--t2); font-size: var(--fs-sm); max-width: 340px; }

/* The trades table is the only one with a wrapping cell, so it is the only one that
   collapses badly. At width:100% in a narrow viewport the audit note is squeezed into
   a sliver and wraps to ~20 lines, which sets a ~600px row height and leaves the other
   cells floating in the middle of it. Give this table its natural width and let
   .table-wrap scroll instead. Scoped to #trades — the breakdown tables have no
   wrapping cell and still fit a phone. */
#trades { min-width: 900px; }

/* Belt and braces: clamp the note itself so one verbose entry cannot drive the row
   height on any screen. The clamp lives on a span because changing `display` on a
   <td> would break table layout. Full text stays in the title attribute. */
.why-txt {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ── tags ──────────────────────────────────────────────────────────────────── */
.tag {
  display: inline-block;
  font-family: var(--mono);
  font-size: var(--fs-xs);
  font-weight: 600;
  padding: 1px var(--sp-2);
  border-radius: var(--r-sm);
  background: var(--s3);
  color: var(--t2);
  white-space: nowrap;
}
.tag-BULL { color: var(--pos); background: var(--pos-dim); }
.tag-BEAR { color: var(--neg); background: var(--neg-dim); }
.tag-NEUTRAL { color: var(--t2); background: var(--s3); }
.tag-MOMENTUM { color: var(--info); background: var(--info-dim); }
.tag-MR { color: var(--warn); background: var(--warn-dim); }
.tag-HARD_STOP { color: var(--neg); background: var(--neg-dim); }
.tag-THROTTLE_ON { color: var(--warn); background: var(--warn-dim); }
.tag-THROTTLE_OFF { color: var(--pos); background: var(--pos-dim); }
.tag-DAILY_FREEZE { color: var(--info); background: var(--info-dim); }

/* ── timeline ──────────────────────────────────────────────────────────────── */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li {
  display: flex;
  gap: var(--sp-3);
  align-items: baseline;
  padding: var(--sp-2) 0;
  border-bottom: 1px solid var(--line);
  font-size: var(--fs-sm);
}
.timeline li:last-child { border-bottom: none; }
.ev-ts { color: var(--t3); white-space: nowrap; font-family: var(--mono); font-size: var(--fs-xs); }
.ev-detail { color: var(--t1); }
.empty { color: var(--t3); font-style: italic; }

/* ── funnel ────────────────────────────────────────────────────────────────── */
.funnel { display: grid; gap: var(--sp-2); }
.funnel-row { display: grid; grid-template-columns: 128px 1fr 88px; gap: var(--sp-3); align-items: center; }
.funnel-lbl { font-size: var(--fs-xs); color: var(--t3); text-transform: uppercase; letter-spacing: 0.06em; }
.funnel-bar { height: 8px; border-radius: 999px; background: var(--s3); overflow: hidden; }
.funnel-fill { height: 100%; background: var(--info); opacity: 0.75; border-radius: 999px; }
.funnel-val { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: var(--fs-sm); text-align: right; }

/* ── monthly grid ──────────────────────────────────────────────────────────── */
.months { display: grid; gap: var(--sp-2); grid-template-columns: repeat(auto-fit, minmax(112px, 1fr)); }
.month {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  padding: var(--sp-3);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--s2);
}
.month-lbl { font-size: var(--fs-xs); color: var(--t3); text-transform: uppercase; letter-spacing: 0.06em; }
.month-val { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: var(--fs-md); font-weight: 600; }

/* ── disclosure ────────────────────────────────────────────────────────────── */
details.panel > summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-3);
  font-size: var(--fs-md);
  font-weight: 650;
}
details.panel > summary::-webkit-details-marker { display: none; }
details.panel > summary::after {
  content: "＋";
  color: var(--t3);
  font-family: var(--mono);
  font-weight: 400;
}
details.panel[open] > summary::after { content: "－"; }
details.panel[open] > summary { margin-bottom: var(--sp-4); }

/* ── backtest cards ────────────────────────────────────────────────────────── */
.cards-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: var(--sp-3); }
.bt-card { background: var(--s2); border: 1px solid var(--line); border-radius: var(--r-sm); padding: var(--sp-4); }
.bt-period { font-weight: 650; margin-bottom: var(--sp-3); font-size: var(--fs-sm); }
.bt-metrics { display: flex; gap: var(--sp-5); }
.bt-metrics div span { display: block; }
.bt-metrics .m-val { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: var(--fs-md); font-weight: 600; }
.bt-metrics .m-lbl { font-size: var(--fs-xs); color: var(--t3); text-transform: uppercase; letter-spacing: 0.06em; }
.bt-note { margin-top: var(--sp-3); font-size: var(--fs-sm); color: var(--t2); }

/* ── footer ────────────────────────────────────────────────────────────────── */
.footer { margin-top: var(--sp-6); }
.footer ul { margin: 0; padding-left: var(--sp-4); }
.footer li { margin-bottom: var(--sp-2); font-size: var(--fs-sm); color: var(--t2); }
.footer li strong { color: var(--t1); }

/* ── responsive ────────────────────────────────────────────────────────────── */
@media (max-width: 720px) {
  main { padding: var(--sp-4) var(--sp-3) var(--sp-7); }
  .hdr { flex-direction: column; }
  .hdr-right { align-items: flex-start; }
  .panel { padding: var(--sp-4); }
  .panel-hd { flex-direction: column; gap: var(--sp-1); }
  .panel-note { text-align: left; }
  .stat-hero .stat-val { font-size: var(--fs-xl); }
  .funnel-row { grid-template-columns: 96px 1fr 68px; }

  /* Drop the audit note on phones. It is the only wrapping cell, so once it is gone
     the min-width crutch is unnecessary too: every remaining cell is nowrap, the
     table simply overflows and .table-wrap scrolls, and rows stay one line tall.
     No data is lost — the note is still in each row's title attribute, and the full
     table is there on a wider screen. */
  #trades { min-width: 0; }
  #trades .why { display: none; }
}

@media (prefers-reduced-motion: no-preference) {
  .pulse { animation: breathe 2.4s ease-in-out infinite; }
  @keyframes breathe { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }
}

/* Chain-link segments under the benchmark methodology note. */
.bench-seg {
  display: inline-block;
  margin-top: .25rem;
  padding-left: 1rem;
  font-variant-numeric: tabular-nums;
  opacity: .85;
}

/* ── site nav: home · without AI · with AI ─────────────────────────────────── */
.topnav {
  max-width: var(--wrap);
  margin: 0 auto;
  padding: var(--sp-4) var(--sp-4) 0;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
}
.topnav a {
  color: var(--t2);
  text-decoration: none;
  font-size: var(--fs-sm);
  padding: var(--sp-1) var(--sp-3);
  border: 1px solid transparent;
  border-radius: 999px;
}
.topnav a:hover { color: var(--t1); border-color: var(--line-strong); }
.topnav a[aria-current="page"] { color: var(--t1); border-color: var(--line-strong); background: var(--s2); }
.topnav .topnav-brand { color: var(--t1); font-weight: 650; margin-right: auto; padding-left: 0; }
.topnav .topnav-brand[aria-current="page"] { background: none; border-color: transparent; }

/* ── landing ───────────────────────────────────────────────────────────────── */
.intro { padding: var(--sp-6) 0 var(--sp-5); max-width: 760px; }
.intro h1 { font-size: var(--fs-2xl); line-height: 1.15; margin: var(--sp-2) 0 var(--sp-4); letter-spacing: -0.01em; }
.intro-kicker { margin: 0; font-size: var(--fs-xs); color: var(--t3); text-transform: uppercase; letter-spacing: 0.08em; }
.intro-lead { margin: 0; color: var(--t2); font-size: var(--fs-md); }

.choose { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: var(--sp-4); margin-bottom: var(--sp-5); }
.choice {
  display: flex; flex-direction: column; gap: var(--sp-3);
  padding: var(--sp-5);
  background: var(--s1);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  color: var(--t1);
  text-decoration: none;
}
.choice:hover { border-color: var(--line-strong); background: var(--s2); }
.choice-ai { border-color: rgba(88, 166, 255, 0.35); }
.choice-ai:hover { border-color: var(--info); }
.choice-kicker { font-size: var(--fs-xs); color: var(--t3); text-transform: uppercase; letter-spacing: 0.08em; }
.choice-title { font-size: var(--fs-xl); font-weight: 650; }
.choice-desc { color: var(--t2); font-size: var(--fs-sm); }
.choice-stats { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-2) var(--sp-4); padding: var(--sp-3) 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.choice-go { color: var(--info); font-size: var(--fs-sm); margin-top: auto; }
.cs { display: flex; flex-direction: column; }
.cs-lbl { font-size: var(--fs-xs); color: var(--t3); text-transform: uppercase; letter-spacing: 0.06em; }
.cs-val { font-size: var(--fs-md); font-weight: 600; }

.since-base { fill: none; stroke: var(--t2); stroke-width: 1.75; stroke-linejoin: round; }
.since-ai   { fill: none; stroke: var(--info); stroke-width: 1.75; stroke-linejoin: round; }
.key { display: inline-block; width: 14px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: var(--sp-1); }
.key-base { background: var(--t2); }
.key-ai   { background: var(--info); }

/* ── with-ai: banner + review table ────────────────────────────────────────── */
.ai-banner {
  display: flex; gap: var(--sp-3); align-items: flex-start;
  padding: var(--sp-4);
  margin-bottom: var(--sp-4);
  background: var(--info-dim);
  border: 1px solid rgba(88, 166, 255, 0.35);
  border-radius: var(--r-md);
}
.ai-dot { width: 10px; height: 10px; margin-top: 6px; border-radius: 50%; background: var(--info); flex: none; }
.paused {
  padding: var(--sp-4);
  margin-bottom: var(--sp-4);
  background: var(--warn-dim);
  border: 1px solid rgba(210, 153, 34, 0.4);
  border-radius: var(--r-md);
}
.paused h2 { margin: 0 0 var(--sp-2); font-size: var(--fs-md, 1rem); color: var(--warn); }
.paused p, .paused li { font-size: var(--fs-sm); color: var(--t2); }
.paused p { margin: var(--sp-2) 0; }
.paused ul { margin: var(--sp-2) 0; padding-left: 1.2em; }
.paused strong { color: inherit; }
.choice-paused { color: var(--warn); font-size: var(--fs-sm); }
.tag-veto   { color: var(--neg); background: var(--neg-dim); }
.tag-allow  { color: var(--pos); background: var(--pos-dim); }
.tag-nodata { color: var(--warn); background: var(--warn-dim); }
.ai-why { min-width: 280px; max-width: 520px; white-space: normal; font-size: var(--fs-sm); color: var(--t2); }
.ai-why summary { cursor: pointer; color: var(--t1); }
.ai-why p, .ai-why ul { margin: var(--sp-2) 0 0; }

@media (max-width: 720px) {
  .intro { padding-top: var(--sp-5); }
  .intro h1 { font-size: var(--fs-xl); }
  .topnav { padding: var(--sp-3) var(--sp-3) 0; }
  .ai-why { min-width: 220px; }
}
