/* Coastal Traffic Authority - movement observatory
 * dashboard.css - a dark graphite console for eight-hour watching:
 * one neutral ramp for the five classes, one perceptual ramp for density,
 * one amber accent reserved for interaction and for the total line.
 * No card outlines on every panel; hierarchy comes from rules, space and
 * type size. The colour literals here match js/palette.js, which is where
 * the canvases and SVG get their paints.
 */

:root {
  --bg: #0e1113;
  --panel: #14181b;
  --raised: #191e21;
  --rule: #272e32;
  --grid: #1e2427;
  --ink: #e8ebed;
  --ink2: #aab3b9;
  --ink3: #8b959c;
  --accent: #e2a63c;
  --accent-ink: #ffd9a0;
  --dim: #434c52;
  --mark: #6f7b82;
  --sans: ui-sans-serif, system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Consolas, "DejaVu Sans Mono", monospace;
  --gut: clamp(14px, 1.6vw, 22px);
  --row: 6px;
}

* { box-sizing: border-box; }

html { background: var(--bg); }

body {
  margin: 0;
  padding: 0 var(--gut) 4rem;
  font: 400 14px/1.5 var(--sans);
  color: var(--ink);
  background:
    radial-gradient(120% 90% at 12% -10%, #171c20 0%, rgba(23, 28, 32, 0) 60%),
    var(--bg);
  -webkit-text-size-adjust: 100%;
  text-rendering: optimizeLegibility;
}

.num, table, .tick, .rowvalue, .rowshare, .metrics dd, .count, .sheet__table td, .sheet__table th {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

h1, h2, h3, p, ul, ol, dl, dd { margin: 0; }

/* ---------------------------------------------------------------- masthead */
.masthead {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--gut);
  align-items: end;
  padding: 26px 0 14px;
  border-bottom: 1px solid var(--rule);
}
.org {
  font-size: 11px;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--ink3);
  margin-bottom: 4px;
}
h1 {
  font-size: clamp(22px, 2.5vw, 31px);
  font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 1.1;
}
.dek { max-width: 54ch; color: var(--ink2); font-size: 13px; margin-top: 7px; }
.readout { text-align: right; }
.count { font-family: var(--mono); font-size: 13px; color: var(--ink2); display: flex; flex-wrap: wrap; gap: 4px 10px; justify-content: flex-end; align-items: baseline; }
.count .big { font-size: 34px; line-height: 1; color: var(--ink); letter-spacing: -0.02em; }
.count .unit { color: var(--ink2); font-family: var(--sans); font-size: 12px; }
.count .of { color: var(--ink3); font-family: var(--sans); font-size: 12px; white-space: nowrap; }
.sharebar {
  height: 3px; margin: 7px 0 6px; background: var(--rule);
  position: relative; overflow: hidden;
}
.sharebar::after {
  content: ""; position: absolute; inset: 0 auto 0 0; width: var(--share, 100%);
  background: var(--accent);
}
.filtersline { font-size: 12px; color: var(--ink3); min-height: 18px; }
.actions { margin-top: 8px; display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }

/* ---------------------------------------------------------------- buttons */
.btn {
  font: 500 12px/1 var(--sans);
  color: var(--ink);
  background: var(--raised);
  border: 1px solid var(--rule);
  border-radius: 2px;
  padding: 7px 10px;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 7px;
}
.btn:hover { border-color: var(--mark); }
.btn--tiny { padding: 4px 7px; font-size: 11px; color: var(--ink2); }
.btn--switch[aria-pressed="true"] { background: var(--accent); color: #10130f; border-color: var(--accent); }
.kbd {
  font: 400 10px/1 var(--mono); color: var(--ink3);
  border: 1px solid var(--rule); border-radius: 2px; padding: 2px 3px;
}
.btn--switch[aria-pressed="true"] .kbd { color: #4c432a; border-color: rgba(0, 0, 0, .3); }

/* ---------------------------------------------------------------- controls */
.controls {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--gut);
  padding: 14px 0 13px; border-bottom: 1px solid var(--rule);
}
.fset { min-width: 0; }
.fset__label {
  font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--ink3); margin-bottom: 6px;
}
.fset__label a { color: var(--ink3); text-decoration: none; border-bottom: 1px dotted var(--mark); }
.fset__label a:hover { color: var(--accent-ink); }
.fset--inline .fset__label { display: inline; margin: 0 8px 0 0; }
.fset--inline { display: flex; align-items: center; gap: 8px; }
.fset--end { margin-left: auto; }
.chips { display: flex; gap: 5px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  font: 500 12px/1 var(--sans); color: var(--ink);
  background: transparent; border: 1px solid var(--rule);
  padding: 6px 9px; border-radius: 2px; cursor: pointer;
}
.chip--tight { padding: 6px 8px; font-size: 11px; color: var(--ink2); }
.chip .swatch { width: 9px; height: 9px; flex: none; }
.chip:hover { border-color: var(--mark); }
.chip--off { color: var(--ink3); border-style: dashed; background: transparent; }
.chip--off .swatch rect { fill: var(--dim) !important; }
.chip__n { color: var(--ink3); font-size: 11px; }
.chip--off .chip__n { opacity: 0.4; }
.sel {
  font: 500 12px/1 var(--sans); color: var(--ink);
  background: var(--raised); border: 1px solid var(--rule); border-radius: 2px;
  padding: 6px 6px;
}
.sel--tiny { font-size: 11px; padding: 4px 5px; }
.selects { font-size: 11px; color: var(--ink3); }
.inlinelabel { font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink3); display: inline-flex; gap: 6px; align-items: center; }

.status {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}
.skiplink {
  position: absolute; left: -9999px; top: 0; z-index: 20;
  background: var(--accent); color: #10130f; padding: 8px 12px; font-weight: 600;
}
.skiplink:focus { left: var(--gut); }

/* ---------------------------------------------------------------- dashboard */
.dash { display: grid; gap: clamp(16px, 2vw, 26px) clamp(18px, 2.4vw, 34px); padding-top: 22px; }

.panel { min-width: 0; display: block; }
.panel__head {
  display: flex; align-items: baseline; gap: 10px 14px; flex-wrap: wrap;
  padding-bottom: 5px; border-bottom: 1px solid var(--grid);
}
.panel__head h2 { font-size: 14px; font-weight: 600; letter-spacing: -0.005em; }
.panel__note { font-size: 11px; color: var(--ink3); flex: 1 1 auto; min-width: 0; }
.panel__tools { margin-left: auto; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.panel__sub { font-size: 11px; color: var(--ink3); margin: 6px 0 0; max-width: 96ch; }
.panel--series .panel__note { order: 3; flex-basis: 100%; margin-left: 0; }
.legend { display: flex; gap: 5px; flex-wrap: wrap; order: 4; flex-basis: 100%; margin-top: 7px; }
.legend .chip { padding: 4px 8px; }

.chart { position: relative; min-height: 40px; margin-top: 10px; outline: none; }
.chart > svg { display: block; position: relative; }
.chart > svg.overlay { position: absolute; left: 0; top: 0; z-index: 2; }
.chart canvas { display: block; }
.chart[tabindex] { cursor: crosshair; touch-action: none; }
.chart[tabindex]:hover { background: rgba(255, 255, 255, 0.012); }
.panel--perf .chart { cursor: default; margin-top: 6px; }

/* custom focus, never the browser ring */
.chart:focus { outline: none; }
.chart:focus-visible { box-shadow: 0 0 0 2px var(--bg), 0 0 0 3.5px var(--accent); }
.chart:focus:not(:focus-visible) { box-shadow: none; }
.sheet__body:focus-visible, .btn:focus-visible, .chip:focus-visible, .sel:focus-visible, a:focus-visible {
  outline: none; box-shadow: 0 0 0 2px var(--bg), 0 0 0 3.5px var(--accent);
}

/* svg furniture */
.gridline { stroke: var(--grid); stroke-width: 1; }
.yearline { stroke: var(--rule); stroke-width: 1; }
.axisline { stroke: var(--rule); stroke-width: 1; }
.tick { fill: var(--ink3); font: 400 10.5px/1 var(--mono); }
.tick--x { text-anchor: middle; }
.yearlabel { fill: var(--ink2); font: 600 10px/1 var(--sans); letter-spacing: 0.08em; }
.axislabel { fill: var(--ink3); font: 400 10.5px/1 var(--sans); }
.rowlabel { fill: var(--ink); font: 400 11.5px/1 var(--sans); }
.rowvalue { fill: var(--ink); font: 400 11.5px/1 var(--mono); }
.rowshare { fill: var(--ink3); font: 400 10.5px/1 var(--mono); }
.boxlabel { fill: var(--ink2); font: 400 10.5px/1 var(--mono); }
.band { shape-rendering: crispEdges; }
.totalline { stroke-linejoin: round; }
.totalline-halo { stroke-linejoin: round; }
.ghostarea { mix-blend-mode: normal; }
.barctx { fill: var(--dim); }
.bar { fill: var(--mark); }
.bar--on { fill: var(--accent); }
.box { fill: none; stroke: var(--ink2); stroke-width: 1; }
.whisker { stroke: var(--mark); stroke-width: 1; }
.median { stroke: var(--accent); stroke-width: 2; }
.mask { fill: var(--bg); fill-opacity: 0.66; }
.brush { fill: rgba(226, 166, 60, 0.10); stroke: var(--accent); stroke-width: 1; }
.brushhandle { fill: var(--accent); }
.brushline { stroke: var(--accent); stroke-width: 1; }
.cursor { stroke: var(--ink2); stroke-width: 1; stroke-dasharray: 2 3; }
.focusring { fill: none; stroke: var(--accent); stroke-width: 2; }
.selected { fill: none; stroke: var(--ink); stroke-width: 1.5; }
.cellframe { fill: none; stroke: var(--grid); stroke-width: 1; }
.markfocus { fill: none; stroke: var(--accent); stroke-width: 1.5; }

.summary { font-size: 12px; color: var(--ink2); margin-top: 9px; max-width: 104ch; }
.alt { margin-top: 10px; overflow: auto; max-height: 340px; border-top: 1px solid var(--grid); }
table { border-collapse: collapse; font-size: 11.5px; width: 100%; }
caption { text-align: left; color: var(--ink3); font-size: 11px; padding: 8px 0; }
th, td { text-align: left; padding: 3px 10px 3px 0; border-bottom: 1px solid var(--grid); white-space: nowrap; }
thead th { color: var(--ink3); font-weight: 500; font-size: 10px; letter-spacing: 0.07em; text-transform: uppercase; }
tbody th { font-weight: 500; color: var(--ink); }
td.num, tbody td { font-family: var(--mono); }
tfoot th, tfoot td { border-top: 1px solid var(--rule); border-bottom: 0; color: var(--ink2); }

.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 2px 18px; margin-top: 10px; }
.metrics > div { display: flex; justify-content: space-between; gap: 10px; border-bottom: 1px solid var(--grid); padding: 4px 0; }
.metrics dt { font-size: 11px; color: var(--ink3); }
.metrics dd { font-family: var(--mono); font-size: 12px; text-align: right; }

/* ---------------------------------------------------------------- tooltip */
.tt {
  position: fixed; left: 0; top: 0; z-index: 40; pointer-events: none;
  background: var(--raised); border: 1px solid var(--rule);
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.45);
  padding: 7px 9px; max-width: 320px;
}
.tt__title { font-size: 11.5px; font-weight: 600; color: var(--ink); margin-bottom: 4px; letter-spacing: 0.01em; }
.tt table { font-size: 11px; }
.tt th, .tt td { border: 0; padding: 1px 8px 1px 0; }
.tt th { color: var(--ink3); font-weight: 400; }
.tt__c { width: 8px; padding: 0 6px 0 0; }
.tt__c::before { content: ""; display: block; width: 7px; height: 7px; background: inherit; }
.tt__share { color: var(--ink3); }
.tt__foot { font-size: 10.5px; color: var(--ink3); margin-top: 4px; }

/* ---------------------------------------------------------------- sheet */
.sheet {
  position: fixed; z-index: 30; right: 10px; top: 10px;
  width: min(470px, calc(100vw - 20px));
  max-height: calc(100vh - 20px); overflow: auto;
  background: var(--panel); border: 1px solid var(--rule);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.5);
}
.sheet[hidden] { display: none; }
.sheet__bar {
  position: sticky; top: 0; background: var(--panel);
  padding: 11px 13px 9px; border-bottom: 1px solid var(--rule); z-index: 1;
}
.sheet__bar h2 { font-size: 13px; letter-spacing: 0.09em; text-transform: uppercase; color: var(--ink2); }
.sheet__lead { font-size: 11.5px; color: var(--ink3); margin-top: 6px; }
.sheet__bar .btn { position: absolute; right: 11px; top: 11px; }
.sheet__body { padding: 4px 13px 16px; outline: none; }
.sheet__h { font-size: 11px; letter-spacing: 0.09em; text-transform: uppercase; color: var(--ink2); margin: 14px 0 4px; }
.sheet__table { table-layout: fixed; width: 100%; }
.sheet__table th[scope="col"] { font-size: 10px; }
.sheet__table col.c-name { width: 44%; }
.sheet__table col.c-num { width: 12%; }
.sheet__table col.c-ok { width: 8%; }
.sheet__table th[scope="row"] { font-weight: 500; text-align: left; color: var(--ink);
  font-size: 12px; line-height: 1.25; white-space: normal; }
.sheet__table tr { border-top: 1px solid var(--grid); }
.sheet__table th, .sheet__table td { vertical-align: top; padding: 5px 5px 6px 0; overflow-wrap: anywhere; }
.sheet__table .subline { font-size: 10px; color: var(--ink3); max-width: none; }
.sheet__table tr.fail { background: rgba(226, 166, 60, 0.12); }
.sheet__table tr.fail td:last-child { color: var(--accent-ink); font-weight: 600; }
.sheet__table tr.pass td:last-child { color: var(--ink3); }
.badge { font: 500 11px/1 var(--mono); color: var(--ink2); }
.badge--ok { color: var(--ink2); }
.badge--bad { color: var(--accent-ink); }
.js .sheet__bar::after { content: ""; }

/* ---------------------------------------------------------------- prose */
.prose {
  margin: clamp(40px, 6vw, 80px) auto 0; max-width: 78ch; padding-top: 10px;
  border-top: 1px solid var(--rule);
}
.prose h2 { font-size: 17px; font-weight: 600; margin: 30px 0 10px; }
.prose h2:first-child { margin-top: 0; }
.prose h3 { font-size: 12px; letter-spacing: 0.09em; text-transform: uppercase; color: var(--ink2); margin: 26px 0 8px; }
.prose p { color: var(--ink2); margin: 0 0 11px; max-width: 84ch; }
.prose ul, .prose ol { color: var(--ink2); padding-left: 20px; margin: 0 0 12px; }
.prose li { margin-bottom: 5px; }
.prose a { color: var(--accent-ink); text-decoration: none; border-bottom: 1px solid rgba(226, 166, 60, 0.4); }
.prose table { margin: 0 0 14px; }
.prose td { white-space: normal; }
.dict th[scope="row"] { font-family: var(--mono); font-size: 11px; color: var(--ink); white-space: nowrap; }
.aggregates li { font-size: 13px; }
kbd {
  font: 400 11px/1 var(--mono); border: 1px solid var(--rule); border-radius: 2px;
  padding: 2px 4px; color: var(--ink);
}
noscript .prose { border-top: 1px solid var(--rule); }

@media (max-width: 900px) {
  .masthead { grid-template-columns: 1fr; align-items: start; }
  .readout { text-align: left; }
  .actions { justify-content: flex-start; }
}

/* The self-test sheet is an overlay. Where there is room it takes a column and
   the dashboard is narrowed so nothing is ever hidden behind it; below 900 px it
   becomes a bottom drawer. */
@media (min-width: 900px) {
  body.sheet-open { padding-right: 500px; }
  .sheet { top: 10px; bottom: auto; }
}
@media (min-width: 900px) and (max-width: 1199px) {
  body.sheet-open .dash { grid-template-columns: minmax(0, 1fr); }
}
@media (min-width: 1180px) {
  .dash { grid-template-columns: repeat(12, minmax(0, 1fr)); }
  .panel--series { grid-column: span 12; }
  .panel--scatter { grid-column: span 7; }
  .panel--calendar { grid-column: span 5; }
  .panel--dest { grid-column: span 5; }
  .panel--dist { grid-column: span 7; }
  .panel--perf { grid-column: span 12; }
}
@media (min-width: 900px) and (max-width: 1179px) {
  .dash { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .panel--series, .panel--perf { grid-column: 1 / -1; }
}
@media (max-width: 899px) {
  .dash { grid-template-columns: minmax(0, 1fr); }
  .sheet { inset: auto 8px 8px 8px; width: auto; max-height: 46vh; }
  .controls { gap: 12px; }
}

@media (prefers-reduced-motion: no-preference) {
  .btn, .chip, .sel { transition: border-color 120ms linear, background-color 120ms linear, color 120ms linear; }
  .sharebar::after { transition: width 160ms ease-out; }
  .bar, .barctx { transition: width 90ms linear; }
}

/* the keyboard cursor when a panel is not focused: a hint, not a ring */
.cursorhint { fill: none; stroke: var(--ink3); stroke-width: 1; stroke-dasharray: 2 2; opacity: 0.55; }
