/* site/model/stats.html -- KPI-tile row + breakdown table, doesn't fit
   model.css's prose-article layout (that file is for docs.html's long-form
   text) or matches.css's sticker-card rules -- same "new CSS file per page
   family" precedent as matches.css/model.css themselves. */

.stats-lede {
  max-width: 960px;
  margin: 0 auto 1.5rem;
  font-size: 1.05rem;
  color: var(--text-primary);
  line-height: 1.6;
}

.stats-updated {
  max-width: 960px;
  margin: -0.75rem auto 1.75rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.stats-updated:empty {
  display: none;
}

.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  max-width: 960px;
  margin: 0 auto 2rem;
}

.kpi-tile {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-1);
  padding: 1.1rem 1rem;
  text-align: center;
}

.kpi-value {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-primary);
}

.kpi-label {
  margin-top: 0.35rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.breakdown-section[hidden] {
  display: none;
}

.breakdown-section {
  max-width: 960px;
  margin: 0 auto 2.5rem;
}

.breakdown-section h2 {
  font-size: 1.2rem;
  margin: 0 0 0.75rem;
  color: var(--text-primary);
}

/* Text and chart side by side, together spanning the same width every
   other section on this page uses (960px) -- a lone 560px-wide chart
   stacked under a paragraph left the whole section looking half-width next
   to the KPI tiles/baselines panel/table above and below it. Wraps to a
   single column below ~640px (mobile), same breakpoint spirit as the rest
   of the site's responsive layout. */
.calibration-layout {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2rem;
}

.section-intro {
  flex: 1 1 280px;
  max-width: 320px;
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.55;
}

/* The chart is a viewBox SVG at width:100%; height:auto -- its height comes
   from the 480x420 ratio, no fixed pixel height needed here. */
.calibration-chart {
  flex: 2 1 400px;
  max-width: 560px;
  align-self: center;
}

.baselines-panel {
  max-width: 960px;
  margin: 0 auto 2.5rem;
  padding: 1rem 1.25rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-1);
}

.baseline-row {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.baseline-row + .baseline-row {
  margin-top: 0.3rem;
}

.baseline-label {
  display: inline-block;
  min-width: 6.5rem;
  font-weight: 600;
  color: var(--text-primary);
}

.breakdown-table {
  overflow-x: auto;
}

.breakdown-table table {
  min-width: 0;
}

.breakdown-table td {
  padding: 0.5rem;
  text-align: center;
  border-bottom: 1px solid var(--gridline);
}

/* Period line stacked right above the freshness line: tighten the gap. */
.stats-updated:not(:empty) + .stats-updated {
  margin-top: -1.5rem;
}

/* Calibration chart cursor + tooltip (see model_stats.js attachCalibrationCursor). */
.calibration-chart {
  position: relative;
}

.calibration-chart svg:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.cal-tooltip {
  position: absolute;
  display: grid;
  gap: 0.1rem;
  padding: 0.4rem 0.6rem;
  font-size: 0.8rem;
  color: var(--text-primary);
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  pointer-events: none;
  white-space: nowrap;
}

.cal-tooltip[hidden] {
  display: none;
}
