/* style.css — Coastal Traffic Authority observatory.
 * Neutral ink palette, one teal accent, tabular numerals, deliberate
 * hierarchy, no card borders on every panel. Tuned for 1280 / 1024 / 768 px
 * and an operator watching it for eight hours.
 */

:root {
  /* Neutral ground + ink. One accent only (teal, from config). */
  --bg: #0f1518;
  --panel: #161d21;
  --panel-2: #1d262b;
  --ink: #e7edef;
  --ink-soft: #9fb0b6;
  --ink-faint: #64767c;
  --grid: #263136;
  --rule: #222c30;
  --accent: #2fb89e; /* matches config.ACCENT hsl(173,62%,40%) */
  --accent-soft: rgba(47, 184, 158, 0.16);
  --focus: #ffd166; /* contrast ring, not the browser default */
  --danger: #e3665b;
  --radius: 6px;

  --fs-h1: 22px;
  --fs-h2: 13px;
  --fs-body: 14px;
  --fs-mono: 12px;

  --gap: 16px;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4f6f7;
    --panel: #ffffff;
    --panel-2: #eef2f3;
    --ink: #172024;
    --ink-soft: #4a595e;
    --ink-faint: #7c8a8f;
    --grid: #e2e8e9;
    --rule: #dbe1e2;
    --accent: #13997f;
    --accent-soft: rgba(19, 153, 127, 0.14);
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: var(--fs-body);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

/* Tabular numerals everywhere so figures line up across an eight-hour shift. */
.tabular,
.tabular-num,
td,
th,
.num,
.digits,
h1 .unit,
.axis text,
mark {
  font-variant-numeric: tabular-nums;
  -webkit-font-numeric: tabular-nums;
}

h1,
h2,
h3 {
  font-weight: 600;
  letter-spacing: 0.01em;
  margin: 0;
}

/* Accessible fallback: visually hidden but read by screen readers. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---- Focus ring: bespoke, high-contrast, never the browser default -------- */
:focus-visible,
:focus.highlight {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: 3px;
}
:focus:not(:focus-visible) {
  outline: none;
}

.app {
  max-width: 1360px;
  margin: 0 auto;
  padding: 18px var(--gap) 40px;
}

/* ---- Header --------------------------------------------------------------- */
header.top {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 24px;
  align-items: baseline;
  justify-content: space-between;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--rule);
  margin-bottom: var(--gap);
}
header.top .eyebrow {
  color: var(--accent);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  margin-bottom: 3px;
}
header.top h1 {
  font-size: var(--fs-h1);
}
header.top h1 .unit {
  color: var(--ink-faint);
  font-weight: 400;
  font-size: 14px;
  margin-left: 6px;
}
header.top .sub {
  color: var(--ink-soft);
  font-size: 12.5px;
  max-width: 60ch;
}
.live-count {
  text-align: right;
  flex-shrink: 0;
}
.live-count .n {
  font-size: 22px;
  font-weight: 600;
  color: var(--ink);
}
.live-count .n .total {
  color: var(--ink-faint);
  font-weight: 400;
  margin-left: 4px;
}
.live-count .lbl {
  font-size: 11px;
  color: var(--ink-faint);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

/* ---- Panel grid ----------------------------------------------------------- */
.grid {
  display: grid;
  gap: var(--gap);
  grid-template-columns: 1fr;
}
.grid.two {
  grid-template-columns: 1fr;
}
@media (min-width: 1040px) {
  .grid.two {
    grid-template-columns: 1fr 1fr;
  }
}
.panel.full {
  grid-column: 1 / -1;
}
@media (min-width: 1040px) {
  .grid.cols-2 {
    grid-template-columns: 1.35fr 1fr;
  }
  .grid.cols-3 {
    grid-template-columns: 1fr 1fr;
  }
}

.panel {
  background: var(--panel);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 14px 16px 12px;
  min-width: 0;
}
/* Deliberately not every panel gets the same border weight: the two wide
 * panels read on a thin rule, the accent sits in the label only. */
.panel.wide {
  border-color: transparent;
  background: transparent;
  padding: 6px 4px;
}
/* The scatter/frame overlay canvas is `position:absolute`; .chart-wrap is the
   positioned containing block so the canvas sits exactly over the SVG plot
   instead of escaping to a full-width ancestor. */
.chart-wrap {
  position: relative;
}
.panel h2 {
  font-size: var(--fs-h2);
  color: var(--ink);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 4px;
}
.panel .caption {
  color: var(--ink-faint);
  font-size: 11.5px;
  margin-bottom: 8px;
}
.panel .caption code {
  color: var(--ink-soft);
  font-family: ui-monospace, "SB Mono", Menlo, Consolas, monospace;
}

/* ---- Filters -------------------------------------------------------------- */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 22px;
  align-items: flex-start;
  background: var(--panel);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: var(--gap);
}
.filter-group {
  min-width: 150px;
}
.filter-group > .fg-title {
  font-size: 10.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 6px;
}
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.chip {
  font: inherit;
  font-size: 12px;
  color: var(--ink-soft);
  background: var(--panel-2);
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 3px 11px;
  cursor: pointer;
  user-select: none;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.chip:hover {
  color: var(--ink);
}
.chip[aria-pressed="true"] {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--ink);
}
.chip[data-classidx="0"] {
  color: var(--c0);
}
.chip[data-classidx="1"] {
  color: var(--c1);
}
.chip[data-classidx="2"] {
  color: var(--c2);
}
.chip[data-classidx="3"] {
  color: var(--c3);
}
.chip[data-classidx="4"] {
  color: var(--c4);
}
input[type="range"] {
  width: 190px;
  accent-color: var(--accent);
}
.month-range .mr-values {
  font-size: 12px;
  color: var(--ink-soft);
  margin-top: 4px;
}
select.control {
  font: inherit;
  font-size: 12.5px;
  color: var(--ink);
  background: var(--panel-2);
  border: 1px solid var(--rule);
  border-radius: 5px;
  padding: 5px 8px;
}
.filter-actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
  align-items: center;
  align-self: center;
}
button.action {
  font: inherit;
  font-size: 12.5px;
  color: var(--ink);
  background: var(--panel-2);
  border: 1px solid var(--rule);
  border-radius: 5px;
  padding: 6px 12px;
  cursor: pointer;
}
button.action:hover {
  border-color: var(--accent);
  color: var(--ink);
}
button.action.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #041612;
  font-weight: 600;
}

.applied-tag {
  display: inline-block;
  font-size: 10.5px;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 3px;
  padding: 1px 6px;
  margin-left: 6px;
}

/* ---- Charts --------------------------------------------------------------- */
svg.chart {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}
.chart-axis text {
  fill: var(--ink-faint);
  font-size: 10px;
  font-family: inherit;
}
.chart-axis .tick-line {
  stroke: var(--grid);
}
.chart-axis .axis-line {
  stroke: var(--rule);
}
.chart-title-label {
  fill: var(--ink-soft);
  font-size: 10px;
}
.axis-label {
  fill: var(--ink-faint);
  font-size: 10px;
}
.bar-label {
  fill: var(--ink-faint);
  font-size: 10px;
}
[data-role="mark"] {
  cursor: pointer;
}
[data-role="mark"].focus rect,
[data-role="mark"].focus circle {
  stroke: var(--focus) !important;
  stroke-width: 2.5px;
}
.brush-rect {
  fill: var(--accent-soft);
  stroke: var(--accent);
  stroke-width: 1.5;
  cursor: move;
}
.tooltip-el {
  position: absolute;
  pointer-events: none;
  background: #0b1113;
  border: 1px solid var(--accent);
  border-radius: 4px;
  padding: 6px 8px;
  font-size: 11.5px;
  color: var(--ink);
  white-space: nowrap;
  transform: translate(-50%, -110%);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
  z-index: 20;
  opacity: 0;
  transition: opacity 0.08s linear;
}
.tooltip-el.show {
  opacity: 1;
}
.tooltip-el .tt-title {
  color: var(--ink-faint);
  font-size: 10px;
  margin-bottom: 2px;
}
.tooltip-el .tt-val {
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.spark-cell {
  cursor: pointer;
}

/* ---- Frame graph ---------------------------------------------------------- */
#frameGraphWrap {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
#frameGraph canvas {
  background: var(--panel-2);
  border: 1px solid var(--rule);
  border-radius: 4px;
}
.fps-stat {
  font-size: 12px;
  color: var(--ink-soft);
}
.fps-stat strong {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

/* ---- Self-test overlay ---------------------------------------------------- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(6, 10, 12, 0.72);
  backdrop-filter: blur(3px);
  z-index: 50;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  overflow: auto;
}
.overlay.hidden {
  display: none;
}
.overlay-card {
  background: var(--panel);
  border: 1px solid var(--rule);
  border-radius: 8px;
  width: min(880px, 100%);
  padding: 20px 22px;
}
.overlay-card h2 {
  font-size: 16px;
  margin-bottom: 2px;
}
.overlay-card .sub {
  color: var(--ink-faint);
  font-size: 12px;
  margin-bottom: 14px;
}
.test-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px 20px;
}
@media (min-width: 640px) {
  .test-grid {
    grid-template-columns: 1fr 1fr;
  }
}
.test-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  padding: 4px 0;
  border-bottom: 1px dashed var(--rule);
}
.test-row .tl {
  color: var(--ink-soft);
  flex: 1;
}
.test-row .tv {
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 2px 8px;
  border-radius: 3px;
}
.badge.pass {
  color: #081713;
  background: var(--accent);
}
.badge.fail {
  color: #1a0908;
  background: var(--danger);
}
.badge.note {
  color: var(--ink-faint);
  background: var(--panel-2);
}
.overlay-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
  align-items: center;
}
.banner {
  font-size: 12.5px;
  padding: 8px 12px;
  border-radius: 5px;
  margin-bottom: 14px;
}
.banner.pass {
  background: var(--accent-soft);
  color: var(--ink);
  border: 1px solid var(--accent);
}
.banner.fail {
  background: rgba(227, 102, 91, 0.16);
  color: var(--ink);
  border: 1px solid var(--danger);
}

/* ---- Method / requirements ------------------------------------------------ */
details.method {
  margin-top: 26px;
  background: var(--panel);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 4px 16px;
}
details.method > summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  padding: 12px 0;
  letter-spacing: 0.04em;
}
details.method .sec {
  padding: 10px 0;
  border-top: 1px solid var(--rule);
}
details.method .sec h3 {
  font-size: 12.5px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 4px;
}
details.method p,
details.method li {
  color: var(--ink-soft);
  font-size: 12.5px;
}
details.method code {
  color: var(--ink);
  background: var(--panel-2);
  padding: 0 5px;
  border-radius: 3px;
  font-size: 11.5px;
}
.req-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  margin-top: 6px;
}
.req-table th,
.req-table td {
  border: 1px solid var(--rule);
  padding: 5px 8px;
  text-align: left;
  vertical-align: top;
  color: var(--ink-soft);
}
.req-table th {
  color: var(--ink);
  background: var(--panel-2);
}
.req-table .ver {
  white-space: nowrap;
  font-weight: 700;
}
.ver.done {
  color: var(--accent);
}
.ver.nodone {
  color: var(--danger);
}

table.access {
  width: 100%;
  border-collapse: collapse;
  font-size: 11.5px;
  margin-top: 8px;
}
table.access th,
table.access td {
  border: 1px solid var(--rule);
  padding: 3px 6px;
  text-align: right;
}
table.access th:first-child,
table.access td:first-child {
  text-align: left;
  color: var(--ink-soft);
}
table.access thead th {
  color: var(--ink);
  background: var(--panel-2);
}

kbd {
  font: inherit;
  font-size: 10.5px;
  background: var(--panel-2);
  border: 1px solid var(--rule);
  border-bottom-width: 2px;
  border-radius: 3px;
  padding: 1px 5px;
  color: var(--ink-soft);
}

.muted {
  color: var(--ink-faint);
}
.row-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.small {
  font-size: 11.5px;
}

/* Honour users who ask the OS to minimise motion. The only movement in the
   observatory is the short colour/opacity transitions above, so silence them
   entirely under a reduce-request. No keyframe animations are used anywhere. */
@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}
