/* ===== Stats Page ===== */

.stats-page {
  padding-block: var(--space-xl) var(--space-section);
}

.stats-header {
  margin-bottom: var(--space-2xl);
  padding-bottom: var(--space-xl);
  border-bottom: var(--border-hair);
}

.stats-header__title {
  font-family: var(--font-serif);
  font-size: var(--text-hero);
  font-weight: 600;
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
  margin-bottom: var(--space-sm);
}

.stats-header__title em {
  font-style: italic;
  color: var(--accent-signal);
}

.stats-header__sub {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: var(--text-subhead);
  color: var(--text-secondary);
  max-width: 60ch;
}

/* Hero metrics row */
.stats-hero {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-lg);
  margin-bottom: var(--space-2xl);
}

@media (max-width: 768px) {
  .stats-hero { grid-template-columns: 1fr; }
}

.stat-tile {
  padding: var(--space-lg) var(--space-xl);
  background: var(--bg-surface);
  border: var(--border-hair);
  border-radius: var(--radius-lg);
  position: relative;
  overflow: hidden;
}

.stat-tile::before {
  content: '';
  position: absolute;
  top: 0; left: 0; bottom: 0;
  width: 3px;
  background: var(--accent-signal);
}

.stat-tile--home::before { background: var(--home-win); }
.stat-tile--draw::before { background: var(--draw); }
.stat-tile--away::before { background: var(--away-win); }

.stat-tile__label {
  font-family: var(--font-mono);
  font-size: var(--text-micro);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  color: var(--text-muted);
  margin-bottom: var(--space-sm);
}

.stat-tile__value {
  font-family: var(--font-mono);
  font-size: clamp(2.5rem, 5vw, 3.5rem);
  font-weight: 700;
  line-height: 1;
  letter-spacing: var(--tracking-tight);
  color: var(--text-primary);
}

.stat-tile__value .percent {
  font-size: 0.5em;
  color: var(--text-muted);
  margin-left: 0.1em;
}

.stat-tile__ci {
  font-family: var(--font-mono);
  font-size: var(--text-small);
  color: var(--text-secondary);
  margin-top: var(--space-sm);
}

.stat-tile__ci .muted { color: var(--text-muted); }

.stat-tile__hits {
  font-family: var(--font-mono);
  font-size: var(--text-micro);
  color: var(--text-muted);
  margin-top: 0.25rem;
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
}

/* Chart section */
.stats-section {
  margin-bottom: var(--space-2xl);
}

.stats-section__head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: var(--space-lg);
  padding-bottom: var(--space-sm);
  border-bottom: var(--border-hair);
}

.stats-section__title {
  font-family: var(--font-serif);
  font-size: var(--text-title);
  font-weight: 600;
}

.stats-section__title em {
  font-style: italic;
  color: var(--accent-signal);
}

.stats-section__note {
  font-family: var(--font-mono);
  font-size: var(--text-small);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
}

.sparkline-wrap {
  padding: var(--space-lg);
  background: var(--bg-surface);
  border: var(--border-hair);
  border-radius: var(--radius-lg);
}

.sparkline-wrap svg {
  width: 100%;
  height: auto;
}

/* Single-month fallback (when trend has only one data point) */
.spark-single {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  padding: var(--space-sm) 0;
}

.spark-single-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-family: var(--font-mono);
  font-size: var(--text-small);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
}

.spark-single-row .spark-month {
  color: var(--text-primary);
  font-size: var(--text-subhead);
  font-weight: 600;
  letter-spacing: var(--tracking-tight);
  text-transform: none;
  font-family: var(--font-mono);
}

.spark-single-rows {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.spark-bar-row {
  display: grid;
  grid-template-columns: 56px 1fr 72px;
  align-items: center;
  gap: var(--space-md);
}

.spark-bar-label {
  font-family: var(--font-mono);
  font-size: var(--text-micro);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
}

.spark-bar {
  height: 10px;
  background: var(--bg-elevated);
  border-radius: 999px;
  overflow: hidden;
  position: relative;
}

.spark-bar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 400ms cubic-bezier(0.16, 1, 0.3, 1);
}

.spark-bar-ml { background: var(--accent-signal); }
.spark-bar-dir { background: var(--home-win); }

.spark-bar-val {
  font-family: var(--font-mono);
  font-size: var(--text-small);
  color: var(--text-primary);
  text-align: right;
  font-weight: 700;
}

/* Stage breakdown table */
.stage-table {
  width: 100%;
  font-family: var(--font-mono);
  border-collapse: collapse;
}

.stage-table th {
  text-align: left;
  padding: var(--space-sm);
  background: var(--bg-elevated);
  font-family: var(--font-mono);
  font-size: var(--text-micro);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  color: var(--text-muted);
  font-weight: 600;
  border-bottom: var(--border-strong);
}

.stage-table td {
  padding: var(--space-sm);
  border-bottom: var(--border-hair);
  color: var(--text-secondary);
}

.stage-table td.stage { color: var(--text-primary); font-weight: 600; }
.stage-table td.rate { color: var(--accent-signal); font-weight: 700; }

.stage-table tr:hover td { background: var(--bg-elevated); }

/* Calibration block */
.calibration {
  padding: var(--space-lg) var(--space-xl);
  background: var(--bg-surface);
  border: var(--border-hair);
  border-left: 3px solid var(--accent-signal);
  border-radius: var(--radius-md);
  font-family: var(--font-serif);
  font-style: italic;
  color: var(--text-secondary);
  font-size: var(--text-subhead);
  line-height: var(--leading-snug);
}

.calibration strong { color: var(--accent-signal); font-style: normal; }
