/**
 * SUEWS Benchmark page styles
 *
 * Extends the subpage system (tokens.css + base.css + subpage.css) with the
 * components specific to a regression-benchmark results page: the verdict
 * band, the energy-balance metric table, the release-regression chart, and
 * the provenance grid. No new palette, no new type families — consistency
 * with the established suews.io system is the whole point.
 *
 * Requires tokens.css, base.css and subpage.css to be loaded first.
 */

/* ========== Per-flux palette mapping (the palette is the model) ========== */
:root {
  --flux-kup: var(--sun-gold);       /* reflected shortwave  */
  --flux-lup: var(--sun-gold-dark);  /* outgoing longwave    */
  --flux-qn:  var(--sky-blue);       /* net all-wave         */
  --flux-qh:  var(--energy-orange);  /* sensible heat        */
  --flux-qe:  var(--water-blue);     /* latent heat (water)  */
  --good: var(--veg-green);
  --bad:  var(--energy-orange);
}
[data-theme="light"] { --flux-qn: var(--wave-blue); }

/* ========== Release rail (the version dimension) ========== */
.bm-releases {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  position: relative;
  z-index: 10;
  margin-top: 24px;
}
.bm-releases-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--text-muted);
  margin-right: 6px;
}
.bm-release {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  padding: 5px 11px;
  border: 1px solid var(--border-light);
  border-radius: 3px;
  color: var(--text-muted);
  text-decoration: none;
  background: none;
  cursor: pointer;
  transition: border-color var(--transition-standard), color var(--transition-standard);
}
.bm-release:hover,
.bm-release:focus-visible {
  border-color: var(--border-medium);
  color: var(--text-secondary);
  text-decoration: none;
}
.bm-release[aria-current="true"] {
  border-color: var(--accent-highlight);
  color: var(--text-primary);
}
.bm-release[disabled] {
  opacity: 0.4;
  cursor: not-allowed;
}
.bm-release[disabled]:hover { border-color: var(--border-light); color: var(--text-muted); }
.bm-release[aria-current="true"]::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent-highlight);
}
.bm-release .latest {
  font-size: 0.6rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent-label);
}
.bm-releases-note {
  width: 100%;
  margin: 6px 0 0;
  font-size: 0.8rem;
  font-style: italic;
  color: var(--text-muted);
}

/* ========== Verdict band ========== */
.bm-verdict {
  position: relative;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 20px 32px;
  padding: 24px 28px;
  margin-top: 8px;
  border: 1px solid var(--border-medium);
  border-radius: 4px;
  background: var(--bg-card);
}

.bm-status {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.95rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-primary);
}

/* status disc: redundant with the word + glyph, never colour alone */
.bm-status .disc {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}
.bm-status .glyph { font-size: 1.05rem; line-height: 1; }
.bm-verdict[data-state="pass"] .disc { background: var(--good); }
.bm-verdict[data-state="pass"] .glyph { color: var(--good); }
.bm-verdict[data-state="fail"] .disc { background: var(--bad); }
.bm-verdict[data-state="fail"] .glyph { color: var(--bad); }
/* neutral/informational state: a baseline run, nothing to compare against yet */
.bm-verdict[data-state="baseline"] .disc { background: var(--accent-highlight); }

.bm-verdict-summary {
  font-family: 'Crimson Pro', Georgia, serif;
  font-size: 1.15rem;
  font-style: italic;
  color: var(--text-secondary);
  line-height: 1.5;
  flex: 1 1 280px;
}

.bm-chips { display: flex; flex-wrap: wrap; gap: 10px; }
.bm-chip {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 5px 10px;
  border: 1px solid var(--border-light);
  border-radius: 3px;
  white-space: nowrap;
}
.bm-chip b { color: var(--text-secondary); font-weight: 500; }

/* ========== Metric table ========== */
.bm-table-wrap { overflow-x: auto; }
.bm-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
  min-width: 560px;
}
.bm-table thead th {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.68rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--text-muted);
  text-align: right;
  padding: 0 0 12px;
  border-bottom: 1px solid var(--border-medium);
}
.bm-table thead th.group { color: var(--accent-label); text-align: center; padding-bottom: 4px; }
.bm-table thead th.var-col { text-align: left; }
.bm-table tbody td {
  padding: 13px 0;
  border-bottom: 1px solid var(--border-light);
  font-family: 'JetBrains Mono', monospace;
  font-variant-numeric: tabular-nums;
  text-align: right;
  color: var(--text-primary);
}
.bm-table tbody tr:last-child td { border-bottom: none; }
.bm-table td.var-col {
  text-align: left;
  font-family: 'Crimson Pro', Georgia, serif;
  font-size: 1.1rem;
  color: var(--text-primary);
}
.bm-table td.var-col .unit {
  font-family: 'Instrument Sans', system-ui, sans-serif;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-left: 8px;
}
.bm-table td.ref { color: var(--text-muted); }     /* reference column is quieter */
.bm-table td .n { color: var(--text-muted); }

/* small swatch keyed to the flux; the name beside it carries the meaning */
.bm-swatch {
  display: inline-block;
  width: 9px; height: 9px;
  border-radius: 2px;
  margin-right: 10px;
  vertical-align: baseline;
}

/* delta vs reference: sign + arrow + colour (triple-encoded), not colour-only */
.bm-delta { font-size: 0.82rem; white-space: nowrap; }
.bm-delta .arrow { margin-right: 3px; }
.bm-delta.better { color: var(--good); }
.bm-delta.worse  { color: var(--bad); }
.bm-table-note {
  margin-top: 14px;
  font-size: 0.82rem;
  color: var(--text-muted);
  font-style: italic;
}

/* ========== Headline summary: better / same / worse vs previous ========== */
.bm-summary-lead {
  font-family: 'Crimson Pro', Georgia, serif;
  font-size: 1.25rem;
  line-height: 1.5;
  color: var(--text-secondary);
  max-width: 640px;
  margin-bottom: 28px;
}
.bm-summary-lead b { color: var(--text-primary); font-weight: 500; font-style: normal; }

.bm-proportion-wrap { max-width: 560px; margin-bottom: 40px; }
.bm-proportion {
  display: flex;
  height: 18px;
  border-radius: 3px;
  overflow: hidden;
  border: 1px solid var(--border-light);
}
.bm-proportion .seg { height: 100%; }
.bm-proportion .seg.better { background: var(--good); }
.bm-proportion .seg.same   { background: var(--text-muted); }
.bm-proportion .seg.worse  { background: var(--bad); }
.bm-proportion-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
  margin-top: 14px;
}
.bm-proportion-legend span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.76rem;
  color: var(--text-secondary);
}
.bm-proportion-legend i { width: 11px; height: 11px; border-radius: 2px; flex-shrink: 0; }
.bm-proportion-legend b { color: var(--text-primary); font-weight: 500; }

/* flux x time-interval matrix */
.bm-matrix {
  display: grid;
  grid-template-columns: minmax(96px, auto) repeat(4, minmax(54px, 1fr));
  gap: 8px;
  align-items: center;
  max-width: 560px;
}
.bm-matrix .col-h {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.64rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  text-align: center;
  padding-bottom: 4px;
}
.bm-matrix .corner { content: ''; }
.bm-matrix .row-h {
  font-family: 'Crimson Pro', Georgia, serif;
  font-size: 1.05rem;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 9px;
}
.bm-cell {
  height: 38px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.9rem;
  border: 1px solid var(--border-light);
  color: var(--text-muted);
}
.bm-cell[data-state="better"] {
  background: color-mix(in srgb, var(--good) 15%, transparent);
  border-color: color-mix(in srgb, var(--good) 38%, transparent);
  color: var(--good);
}
.bm-cell[data-state="worse"] {
  background: color-mix(in srgb, var(--bad) 15%, transparent);
  border-color: color-mix(in srgb, var(--bad) 38%, transparent);
  color: var(--bad);
}
/* numeric cell: a real value (e.g. seasonal MAE), not a better/worse verdict */
.bm-cell.num {
  color: var(--text-primary);
  background: var(--bg-card);
  font-variant-numeric: tabular-nums;
}
.bm-matrix-note {
  margin-top: 16px;
  font-size: 0.82rem;
  font-style: italic;
  color: var(--text-muted);
}

/* ========== Release-regression chart ========== */
.bm-figure { position: relative; z-index: 10; }
.bm-chart {
  width: 100%;
  height: auto;
  border: 1px solid var(--border-light);
  border-radius: 4px;
  background: var(--bg-card);
  padding: 8px;
}
.bm-chart .axis { stroke: var(--border-medium); stroke-width: 1; }
.bm-chart .grid { stroke: var(--grid-line); stroke-width: 1; }
.bm-chart .tick {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  fill: var(--text-muted);
}
.bm-chart .series { fill: none; stroke-width: 2; }
.bm-chart .dot { stroke: var(--bg-primary); stroke-width: 1.5; }
.bm-chart .series-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 500;
}
.bm-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  margin-top: 18px;
}
.bm-legend span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  color: var(--text-secondary);
}
.bm-legend span i { width: 16px; height: 2px; border-radius: 1px; display: inline-block; }

.bm-figcaption {
  margin-top: 16px;
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.6;
  max-width: 640px;
}

/* ========== Provenance grid ========== */
.bm-prov {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 28px 40px;
}
.bm-prov dt {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.bm-prov dd {
  margin: 0;
  font-size: 0.98rem;
  color: var(--text-primary);
  line-height: 1.5;
}
.bm-prov dd .mono {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  color: var(--text-secondary);
}
.bm-prov dd a { color: var(--accent-highlight); border-bottom: 1px solid transparent; transition: border-color var(--transition-standard); }
.bm-prov dd a:hover, .bm-prov dd a:focus-visible { border-bottom-color: currentColor; text-decoration: none; }

/* ========== Suite scoreboard (overview of all sites) ========== */
.bm-suite { display: flex; flex-direction: column; position: relative; z-index: 10; }

.bm-suite-row {
  display: grid;
  grid-template-columns: 16px minmax(170px, 1.3fr) minmax(168px, 1fr) auto 20px;
  align-items: center;
  gap: 24px;
  padding: 20px 8px 20px 4px;
  border-bottom: 1px solid var(--border-light);
  text-decoration: none;
  color: inherit;
  border-radius: 4px;
  transition: background var(--transition-standard);
}
.bm-suite-row:hover,
.bm-suite-row:focus-visible {
  background: var(--bg-card-hover);
  text-decoration: none;
}
.bm-suite-row .disc { width: 11px; height: 11px; border-radius: 50%; }
.bm-suite-row[data-state="pass"] .disc { background: var(--good); }
.bm-suite-row[data-state="fail"] .disc { background: var(--bad); }
.bm-suite-row[data-state="baseline"] .disc { background: var(--accent-highlight); }
.bm-suite-row[data-state="planned"] .disc { background: none; border: 1px solid var(--border-medium); }
.bm-site-status-line {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  color: var(--text-secondary);
}
.bm-suite-row[data-state="planned"] .bm-site-name { color: var(--text-secondary); }
.bm-planned {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.74rem;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.bm-site-name {
  display: block;
  font-family: 'Crimson Pro', Georgia, serif;
  font-size: 1.4rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--text-primary);
  line-height: 1.15;
}
.bm-site-meta {
  display: block;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-top: 6px;
}
.bm-site-status {
  font-family: 'Instrument Sans', system-ui, sans-serif;
  font-size: 0.9rem;
  color: var(--text-secondary);
}
.bm-suite-row[data-state="fail"] .bm-site-status { color: var(--bad); }

/* per-site improvement/degradation indicator (suite overview) */
.bm-site-change { display: flex; flex-direction: column; gap: 7px; }
.bm-minibar {
  display: flex;
  height: 6px;
  width: 100%;
  max-width: 150px;
  border-radius: 2px;
  overflow: hidden;
  background: var(--border-light);
}
.bm-minibar .seg { height: 100%; }
.bm-minibar .seg.better { background: var(--good); }
.bm-minibar .seg.same   { background: var(--text-muted); }
.bm-minibar .seg.worse  { background: var(--bad); }
.bm-change-counts {
  display: flex;
  gap: 14px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  color: var(--text-muted);
}
.bm-change-counts .up   { color: var(--good); }
.bm-change-counts .down { color: var(--bad); }
.bm-site-release {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  color: var(--text-muted);
  text-align: right;
}
.bm-suite-row .go {
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-muted);
  text-align: right;
  transition: transform var(--transition-standard), color var(--transition-standard);
}
.bm-suite-row:hover .go,
.bm-suite-row:focus-visible .go { transform: translateX(3px); color: var(--accent-highlight); }

.bm-suite-note {
  margin-top: 18px;
  font-size: 0.82rem;
  font-style: italic;
  color: var(--text-muted);
}

/* breadcrumb on the detail page */
.bm-crumb { display: inline-flex; gap: 8px; align-items: center; }
.bm-crumb .sep { color: var(--text-muted); }

@media (max-width: 640px) {
  .bm-suite-row { grid-template-columns: 12px 1fr auto; gap: 16px; }
  .bm-suite-row .bm-site-release,
  .bm-suite-row .go { display: none; }
}
@media (max-width: 600px) {
  .bm-verdict { padding: 20px; gap: 16px; }
  .bm-verdict-summary { font-size: 1.05rem; }
}
