/* Palette: slots 1-5 are the identity addendum's validated five-hue line
   palette (blue, orange, green, purple, pink in spectrum order). Orange sits
   marginally under 3:1 on white, so every chart ships direct labels and a
   table view as the required relief. --accent/--accent-tint rotate through
   the styling spectrum per panel, set from app.js.

   The page is light only -- `color-scheme: light` below pins it, so a viewer
   whose OS is set to dark still gets these surfaces rather than a UA-inverted
   approximation of them. */
:root {
  color-scheme: light;
  --plane:          #f9f9f7;
  --surface:        #fcfcfb;
  --ink:            #0b0b0b;
  --ink-2:          #52514e;
  --ink-muted:      #898781;
  --grid:           #e1e0d9;
  --axis:           #c3c2b7;
  --border:         rgba(11, 11, 11, 0.10);
  --good:           #357f44;
  --critical:       #c1373c;
  --warning:        #fab219;
  --band:           #0090ff;

  --accent:         #0090ff;
  --accent-tint:    #e0f1ff;
  --accent-ink:     #fff;

  --series-1: #0090ff;
  --series-2: #f76b15;
  --series-3: #46a758;
  --series-4: #6e56cf;
  --series-5: #d6409f;
  --series-6: #008300;
  --series-7: #4a3aa7;
  --series-8: #e34948;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--plane);
  color: var(--ink);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

.wrap { max-width: 1440px; margin: 0 auto; padding: 0 20px 64px; }

/* ---------- masthead ---------- */

header.masthead {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 20;
}
/* Full-bleed colour band per the identity: flat colour, square edges. */
.masthead .band { background: var(--band); }
.masthead .band .wrap { padding-top: 12px; padding-bottom: 12px; }
.masthead .wrap { padding-bottom: 0; }
.masthead-top { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.masthead h1 { font-size: 16px; margin: 0; letter-spacing: -0.01em; color: #fff; }
.masthead .tagline { color: rgba(255, 255, 255, 0.85); font-size: 13px; margin: 0; }
.masthead .spacer { flex: 1 1 auto; }
.stamp { color: rgba(255, 255, 255, 0.7); font-size: 12px; font-variant-numeric: tabular-nums; }

nav.panels { display: flex; gap: 2px; flex-wrap: wrap; margin-top: 8px; }
nav.panels button {
  appearance: none; border: 0; background: transparent; cursor: pointer;
  color: var(--ink-2); font: inherit; font-size: 13px;
  padding: 7px 10px; border-bottom: 2px solid transparent; border-radius: 4px 4px 0 0;
}
nav.panels button:hover { background: var(--plane); color: var(--ink); }
nav.panels button[aria-current="true"] { color: var(--ink); border-bottom-color: var(--series-1); }

/* ---------- panel intro: a section label on a solid spectrum block ---------- */

.panel-intro { margin: 18px 0 4px; max-width: 68ch; }
.panel-intro h2 {
  display: inline-block;
  background: var(--accent); color: var(--accent-ink);
  font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
  padding: 5px 12px; border-radius: 5px; margin: 0 0 8px;
}
.panel-intro p { margin: 0; color: var(--ink-2); font-size: 13.5px; }

/* ---------- chart grid ---------- */

.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); margin-top: 16px; }
.grid.wide { grid-template-columns: repeat(auto-fill, minmax(560px, 1fr)); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px 10px;
  display: flex; flex-direction: column;
}
.card h3 { margin: 0; font-size: 14px; font-weight: 600; letter-spacing: -0.005em; }
.card .sub { margin: 2px 0 0; color: var(--ink-2); font-size: 12.5px; }
.card .unit { color: var(--ink-muted); font-size: 11.5px; margin: 6px 0 2px; }
.plot { position: relative; margin: 0 -4px; }

/* Fixed-horizon pairs: two windows of the same measure, side by side. */
.plot-row { display: flex; gap: 14px; }
.plot-row .plot-col { flex: 1 1 0; min-width: 0; }
.horizon-label {
  color: var(--ink-muted); font-size: 10.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.05em; margin: 2px 0 1px;
  display: flex; align-items: center; gap: 5px;
}
.horizon-swatch {
  width: 9px; height: 9px; border-radius: 2px; flex: none;
  background: var(--accent-tint);
}
.chart-highlight { fill: var(--accent-tint); opacity: 0.6; }
@media (max-width: 720px) {
  .plot-row { flex-direction: column; gap: 4px; }
}
.chart-svg { display: block; width: 100%; outline: none; }
.chart-svg:focus-visible { outline: 2px solid var(--series-1); outline-offset: 2px; border-radius: 4px; }

.legend { display: flex; flex-wrap: wrap; gap: 4px 12px; margin: 8px 0 10px; }
.legend button {
  appearance: none; border: 0; background: none; cursor: pointer; font: inherit;
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--ink-2); font-size: 12px; padding: 2px 0;
}
.legend button:hover { color: var(--ink); }
.legend button[aria-pressed="false"] { opacity: 0.42; text-decoration: line-through; }
.legend .key { width: 14px; height: 2px; border-radius: 1px; flex: none; }

/* ---------- annotation notes: the numbered list under a chart ---------- */

.chart-notes { display: grid; gap: 4px; margin: 8px 0 10px; }
.chart-notes .note { display: flex; gap: 7px; align-items: baseline; font-size: 12px; color: var(--ink-2); }
.note-badge {
  flex: none; width: 15px; height: 15px; border-radius: 50%;
  background: var(--accent-tint); color: var(--ink);
  font-size: 9.5px; font-weight: 700; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
  align-self: flex-start; margin-top: 2px;
}

.card footer {
  display: flex; align-items: center; gap: 10px;
  margin-top: auto; padding-top: 7px; border-top: 1px solid var(--border);
  color: var(--ink-muted); font-size: 11.5px;
}
.card footer .spacer { flex: 1 1 auto; }
.card footer button {
  appearance: none; border: 1px solid var(--border); background: transparent;
  color: var(--ink-muted); font: inherit; font-size: 11.5px;
  padding: 2px 7px; border-radius: 4px; cursor: pointer;
}
.card footer button:hover { color: var(--ink); }

/* ---------- svg chrome ---------- */

.chart-grid line { stroke: var(--grid); stroke-width: 1; shape-rendering: crispEdges; }
.chart-zero { stroke: var(--axis); stroke-width: 1; }
.chart-tick { fill: var(--ink-muted); font-size: 10px; font-variant-numeric: tabular-nums; }
.chart-empty-text { fill: var(--ink-muted); font-size: 12px; }
.chart-line { stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart-direct-label { font-size: 10.5px; font-weight: 600; }
.chart-end-value { font-weight: 700; font-variant-numeric: tabular-nums; }
.chart-hover line { stroke: var(--ink-muted); stroke-width: 1; }
.chart-dot { stroke: var(--surface); stroke-width: 1.5; }
.chart-note-dot { fill: var(--surface); stroke-width: 2; }
.chart-note-num {
  font-size: 9.5px; font-weight: 700; fill: var(--ink);
  paint-order: stroke; stroke: var(--surface); stroke-width: 3px;
}

.series-1 { stroke: var(--series-1); } .series-fill-1 { fill: var(--series-1); } .series-text-1 { fill: var(--series-1); }
.series-2 { stroke: var(--series-2); } .series-fill-2 { fill: var(--series-2); } .series-text-2 { fill: var(--series-2); }
.series-3 { stroke: var(--series-3); } .series-fill-3 { fill: var(--series-3); } .series-text-3 { fill: var(--series-3); }
.series-4 { stroke: var(--series-4); } .series-fill-4 { fill: var(--series-4); } .series-text-4 { fill: var(--series-4); }
.series-5 { stroke: var(--series-5); } .series-fill-5 { fill: var(--series-5); } .series-text-5 { fill: var(--series-5); }
.series-6 { stroke: var(--series-6); } .series-fill-6 { fill: var(--series-6); } .series-text-6 { fill: var(--series-6); }
.series-7 { stroke: var(--series-7); } .series-fill-7 { fill: var(--series-7); } .series-text-7 { fill: var(--series-7); }
.series-8 { stroke: var(--series-8); } .series-fill-8 { fill: var(--series-8); } .series-text-8 { fill: var(--series-8); }

/* ---------- tooltip: value leads, label follows ---------- */

.chart-tooltip {
  position: absolute; pointer-events: none; z-index: 5;
  background: var(--surface); border: 1px solid var(--border); border-radius: 6px;
  padding: 6px 8px; min-width: 140px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
  font-size: 12px;
}
.tip-period { color: var(--ink-muted); font-size: 11px; margin-bottom: 3px; font-variant-numeric: tabular-nums; }
.tip-row { display: flex; align-items: baseline; gap: 6px; white-space: nowrap; }
.tip-key { width: 10px; height: 2px; border-radius: 1px; flex: none; align-self: center; }
.tip-value { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.tip-label { color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; }

.series-stroke-1 { background: var(--series-1); } .series-stroke-2 { background: var(--series-2); }
.series-stroke-3 { background: var(--series-3); } .series-stroke-4 { background: var(--series-4); }
.series-stroke-5 { background: var(--series-5); } .series-stroke-6 { background: var(--series-6); }
.series-stroke-7 { background: var(--series-7); } .series-stroke-8 { background: var(--series-8); }

/* ---------- table view (the relief for sub-3:1 light slots) ---------- */

.table-view { margin-top: 8px; max-height: 260px; overflow: auto; border: 1px solid var(--border); border-radius: 6px; }
.table-view table { border-collapse: collapse; width: 100%; font-size: 11.5px; font-variant-numeric: tabular-nums; }
.table-view th, .table-view td { padding: 3px 8px; text-align: right; white-space: nowrap; }
.table-view th:first-child, .table-view td:first-child { text-align: left; }
.table-view thead th { position: sticky; top: 0; background: var(--surface); color: var(--ink-2); font-weight: 600; border-bottom: 1px solid var(--border); }
.table-view tbody tr:nth-child(even) { background: color-mix(in srgb, var(--plane) 60%, transparent); }

/* ---------- health + method pages ---------- */

.page { max-width: 100ch; }
.page h2 { font-size: 20px; margin: 20px 0 6px; letter-spacing: -0.015em; }
.page h3 { font-size: 15px; margin: 22px 0 6px; }
.page p, .page li { color: var(--ink-2); font-size: 13.5px; max-width: 78ch; }
.page code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 4px; padding: 1px 4px; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 14px 0 4px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; }
.tile .value { font-size: 21px; font-weight: 650; letter-spacing: -0.02em; white-space: nowrap; }
.tile .name { color: var(--ink-muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.05em; margin-top: 2px; }
.tile .value.bad { color: var(--critical); }
.tile .value.ok { color: var(--good); }

table.health { border-collapse: collapse; width: 100%; font-size: 12.5px; margin-top: 10px; }
table.health th, table.health td { padding: 5px 8px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
table.health th { color: var(--ink-2); font-weight: 600; position: sticky; top: 96px; background: var(--plane); }
table.health td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.health tr.missing td { color: var(--ink-muted); }
.pill { display: inline-block; font-size: 11px; padding: 1px 6px; border-radius: 999px; border: 1px solid var(--border); }
.pill.ok { color: var(--good); border-color: color-mix(in srgb, var(--good) 40%, transparent); }
.pill.bad { color: var(--critical); border-color: color-mix(in srgb, var(--critical) 40%, transparent); }
.pill.warn { color: var(--ink-2); }

.banner {
  border: 1px solid color-mix(in srgb, var(--warning) 45%, var(--border));
  background: color-mix(in srgb, var(--warning) 8%, var(--surface));
  border-radius: 8px; padding: 10px 12px; margin: 16px 0; font-size: 13px; color: var(--ink-2);
}
.banner b { color: var(--ink); }

@media (max-width: 620px) {
  .grid, .grid.wide { grid-template-columns: 1fr; }
  .wrap { padding: 0 12px 48px; }
}
