/* Ballast dashboard. Visual language: a nautical chart. Pale "water" paper, navy ink,
   and chart magenta (the colour nautical charts use for hazards) reserved for risk:
   the VaR line and the days losses broke through it. Series colours are the validated
   dataviz palette (slots 1-2), checked against these surfaces in both modes. */

@font-face { font-family: "Barlow"; font-weight: 400; font-display: swap; src: url("fonts/barlow-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow"; font-weight: 500; font-display: swap; src: url("fonts/barlow-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow"; font-weight: 600; font-display: swap; src: url("fonts/barlow-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow Semi Condensed"; font-weight: 400; font-display: swap; src: url("fonts/barlow-semi-condensed-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow Semi Condensed"; font-weight: 500; font-display: swap; src: url("fonts/barlow-semi-condensed-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow Semi Condensed"; font-weight: 600; font-display: swap; src: url("fonts/barlow-semi-condensed-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Spectral"; font-weight: 500; font-display: swap; src: url("fonts/spectral-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Spectral"; font-weight: 400; font-style: italic; font-display: swap; src: url("fonts/spectral-latin-400-italic.woff2") format("woff2"); }

:root {
  color-scheme: light;
  --paper: #f5f8f9;
  --water: #e3eef2;
  --ink: #0e2433;
  --ink-2: #44596a;
  --muted: #56697a;
  --rule: #d6e0e6;
  --axis: #b4c3cd;
  --hazard: #b02c78;
  --s1: #2a78d6;
  --s2: #eb6834;
  --neutral-mark: #a3b3be;
  --div-pos: #2a78d6;
  --div-neg: #e34948;
  --status-good: #0ca30c;
  --status-warning: #fab219;
  --status-critical: #d03b3b;
  --seq-1: #e1edfb; --seq-2: #b7d3f6; --seq-3: #86b6ef; --seq-4: #5598e7; --seq-5: #256abf; --seq-6: #184f95;
  --on-seq-light: #0e2433; --on-seq-dark: #ffffff;   /* text on shades 1-4 and 5-6: each at least 4.5:1 */
  --focus: #2a78d6;

  --font-text: "Barlow", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-data: "Barlow Semi Condensed", "Barlow", system-ui, sans-serif;
  --font-display: "Spectral", Georgia, "Times New Roman", serif;

  --step--1: 0.8rem;
  --step-0: 1rem;
  --step-1: 1.25rem;
  --step-2: 1.5625rem;
  --step-3: 1.953rem;
  --step-4: 2.441rem;
  --gutter: clamp(16px, 4vw, 40px);
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --paper: #0d1b24; --water: #142a37; --ink: #e5edf1; --ink-2: #a8b9c4; --muted: #8a9dab;
    --rule: #1f3340; --axis: #34495a; --hazard: #d6509c; --s1: #3987e5; --s2: #d95926;
    --neutral-mark: #4f6676; --div-pos: #3987e5; --div-neg: #e66767;
    --seq-1: #16314a; --seq-2: #184f95; --seq-3: #1c5cab; --seq-4: #256abf; --seq-5: #3987e5; --seq-6: #6da7ec;
    --on-seq-light: #e5edf1; --on-seq-dark: #0d1b24;
    --focus: #6da7ec;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #0d1b24; --water: #142a37; --ink: #e5edf1; --ink-2: #a8b9c4; --muted: #8a9dab;
  --rule: #1f3340; --axis: #34495a; --hazard: #d6509c; --s1: #3987e5; --s2: #d95926;
  --neutral-mark: #4f6676; --div-pos: #3987e5; --div-neg: #e66767;
  --seq-1: #16314a; --seq-2: #184f95; --seq-3: #1c5cab; --seq-4: #256abf; --seq-5: #3987e5; --seq-6: #6da7ec;
  --on-seq-light: #e5edf1; --on-seq-dark: #0d1b24;
  --focus: #6da7ec;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 var(--step-0)/1.55 var(--font-text);
  font-feature-settings: "kern", "liga";
}
a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--hazard); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 2px; }
code { font-family: var(--font-data); background: var(--water); padding: 0.05em 0.35em; border-radius: 3px; }
h2, h3 { font-family: var(--font-display); font-weight: 500; line-height: 1.2; margin: 0; }
h2 { font-size: var(--step-3); margin-bottom: 0.4rem; }
h3 { font-size: var(--step-1); margin: 2.2rem 0 0.7rem; }
p { margin: 0; }

.wrap { max-width: 1240px; margin: 0 auto; padding: 0 var(--gutter); }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 1rem; top: 1rem; background: var(--paper); padding: 0.5rem 1rem; z-index: 10; }

/* ---------- masthead ---------- */
.masthead { border-bottom: 1px solid var(--rule); }
.masthead-row { display: flex; align-items: center; gap: 1.5rem; min-height: 64px; flex-wrap: wrap; padding-top: 0.6rem; padding-bottom: 0.6rem; }
.wordmark { display: inline-flex; align-items: center; gap: 0.55rem; text-decoration: none; font: 500 var(--step-2)/1 var(--font-display); }
.wordmark-mark { width: 28px; height: 28px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.masthead-note { color: var(--ink-2); font-size: var(--step--1); flex: 1 1 14rem; }
.masthead-links { display: flex; gap: 1.25rem; align-items: center; font-size: var(--step--1); flex-wrap: wrap; }
.theme-toggle, .views button, .table-toggle {
  font: 500 var(--step--1)/1 var(--font-text); color: var(--ink); background: transparent;
  border: 1px solid var(--rule); border-radius: 4px; padding: 0.45rem 0.7rem; cursor: pointer;
}
.theme-toggle:hover, .views button:hover, .table-toggle:hover { background: var(--water); }

/* ---------- hero ---------- */
.hero { padding: clamp(2rem, 5vw, 3.5rem) 0 1.5rem; }
.hero-text {
  font: 500 clamp(1.35rem, 1.05rem + 1vw, 2.05rem)/1.3 var(--font-display);
  max-width: 46ch; letter-spacing: -0.005em; text-wrap: pretty;
}
.waterline { margin: 1.75rem 0 0.4rem; min-height: 150px; }
.hero-caption { color: var(--ink-2); font-size: var(--step--1); max-width: 75ch; }

/* ---------- tabs ---------- */
.tabs { position: sticky; top: 0; z-index: 5; background: var(--paper); border-bottom: 1px solid var(--rule); }
.tabs-row { display: flex; gap: 0.25rem; overflow-x: auto; scrollbar-width: none; }
.tabs-row::-webkit-scrollbar { display: none; }
.tabs a {
  flex: none; padding: 0.85rem 0.8rem 0.75rem; text-decoration: none; color: var(--ink-2);
  font-weight: 500; border-bottom: 2px solid transparent; white-space: nowrap;
}
.tabs a:hover { color: var(--ink); }
.tabs a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--hazard); }

/* ---------- panels ---------- */
.panels { padding-top: 2.25rem; padding-bottom: 4rem; }
.panel { scroll-margin-top: 60px; }
.lede { color: var(--ink-2); max-width: 72ch; margin-bottom: 1.75rem; }
.note { color: var(--ink-2); font-size: var(--step--1); max-width: 80ch; margin-top: 0.6rem; }
.grid-2, .grid-2-1 { display: grid; gap: 2rem 3rem; align-items: start; margin-top: 1rem; }
@media (min-width: 900px) {
  .grid-2 { grid-template-columns: 1fr 1fr; }
  .grid-2-1 { grid-template-columns: 2fr 1fr; }
}

/* ---------- charts ---------- */
.chart { margin: 0; min-width: 0; }
.chart-wide { margin-top: 2rem; }
.chart-title { font: 500 var(--step-0)/1.3 var(--font-text); margin: 0 0 0.15rem; }
.chart-sub { color: var(--ink-2); font-size: var(--step--1); margin: 0 0 0.6rem; }
.chart-body { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart svg:focus-visible { outline-offset: 4px; }
.legend { display: flex; flex-wrap: wrap; gap: 0.35rem 1.1rem; font-size: var(--step--1); color: var(--ink-2); margin: 0 0 0.5rem; padding: 0; list-style: none; }
.legend li { display: inline-flex; align-items: center; gap: 0.4rem; }
.key { display: inline-block; width: 16px; height: 0; border-top: 2px solid; }
.key.rect { width: 10px; height: 10px; border: 0; border-radius: 2px; }
.key.dot { width: 8px; height: 8px; border: 0; border-radius: 50%; }
.table-toggle { margin-top: 0.6rem; }
.chart-table { margin-top: 0.6rem; max-height: 22rem; overflow: auto; }

.grid { stroke: var(--rule); stroke-width: 1; shape-rendering: crispEdges; }
.baseline { stroke: var(--axis); stroke-width: 1; shape-rendering: crispEdges; }
.tick { fill: var(--muted); font: 400 12px/1 var(--font-data); font-variant-numeric: tabular-nums; }
.data-label { fill: var(--ink-2); font: 500 12px/1 var(--font-data); font-variant-numeric: tabular-nums; }
.data-label.strong { fill: var(--ink); font-weight: 600; }
.line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.area { stroke: none; opacity: 0.1; }
.c-s1 { stroke: var(--s1); fill: var(--s1); }
.c-s2 { stroke: var(--s2); fill: var(--s2); }
.c-hazard { stroke: var(--hazard); fill: var(--hazard); }
.c-neutral { stroke: var(--neutral-mark); fill: var(--neutral-mark); }
.c-pos { fill: var(--div-pos); stroke: var(--div-pos); }
.c-neg { fill: var(--div-neg); stroke: var(--div-neg); }
.line.c-s1, .line.c-s2, .line.c-hazard, .line.c-neutral { fill: none; }
.dot { stroke: var(--paper); stroke-width: 2; }
.bar:hover, .bar.active { opacity: 0.75; }
.crosshair { stroke: var(--ink-2); stroke-width: 1; shape-rendering: crispEdges; }
.hit { fill: transparent; }

.tooltip {
  position: fixed; z-index: 20; pointer-events: none; min-width: 9rem; max-width: 18rem;
  background: var(--paper); color: var(--ink); border: 1px solid var(--rule); border-radius: 6px;
  padding: 0.55rem 0.7rem; font: 400 var(--step--1)/1.35 var(--font-data);
  box-shadow: 0 6px 24px rgba(14, 36, 51, 0.14);
}
.tooltip-head { color: var(--ink-2); margin-bottom: 0.3rem; }
.tooltip-row { display: grid; grid-template-columns: 14px auto 1fr; gap: 0.45rem; align-items: center; }
.tooltip-row strong { font-weight: 600; font-variant-numeric: tabular-nums; }
.tooltip-row span:last-child { color: var(--ink-2); }

/* ---------- tables ---------- */
.table-scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font: 400 0.95rem/1.35 var(--font-data); }
caption { text-align: left; color: var(--ink-2); font-size: var(--step--1); padding-bottom: 0.4rem; }
th, td { padding: 0.5rem 0.75rem; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--rule); }
th { font-weight: 500; color: var(--ink-2); vertical-align: bottom; }
th:first-child, td:first-child { text-align: left; padding-left: 0; }
td { font-variant-numeric: tabular-nums; }
td.text, th.text { text-align: left; white-space: normal; }
tr.total td { font-weight: 600; border-bottom: 0; border-top: 1px solid var(--axis); }
tbody tr:hover td { background: var(--water); }
.sub { display: block; color: var(--muted); font-size: 0.85em; }
.inline-bar { display: inline-block; vertical-align: middle; height: 8px; border-radius: 0 2px 2px 0; margin-left: 0.5rem; background: var(--s1); }
.inline-bar.neg { background: var(--div-neg); border-radius: 2px 0 0 2px; }
.heat { color: var(--on-seq-light); }
.heat.l1 { background: var(--seq-1); } .heat.l2 { background: var(--seq-2); } .heat.l3 { background: var(--seq-3); }
.heat.l4 { background: var(--seq-4); }
.heat.l5 { background: var(--seq-5); color: var(--on-seq-dark); } .heat.l6 { background: var(--seq-6); color: var(--on-seq-dark); }
.status { display: inline-flex; align-items: center; gap: 0.35rem; }
.status::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: currentColor; }
.status.green::before { background: var(--status-good); }
.status.yellow::before { background: var(--status-warning); }
.status.red::before { background: var(--status-critical); }

/* ---------- views form ---------- */
.views { margin: 0; }
.views h3 { margin-top: 0; }
.view-row { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; margin-top: 0.75rem; font-size: 0.95rem; }
.view-row select, .view-row input {
  font: 400 0.95rem/1.2 var(--font-data); color: var(--ink); background: var(--paper);
  border: 1px solid var(--axis); border-radius: 4px; padding: 0.4rem 0.45rem;
}
.view-row input { width: 5.5rem; text-align: right; font-variant-numeric: tabular-nums; }
.view-row .remove { border: 0; padding: 0.4rem; color: var(--ink-2); }
.views-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 1rem; }
.form-error { color: var(--div-neg); font-size: var(--step--1); min-height: 1.2em; margin-top: 0.5rem; }

/* ---------- checks ---------- */
.checks { list-style: none; padding: 0; margin: 0; display: grid; gap: 0; max-width: 62rem; }
.checks li { display: grid; grid-template-columns: minmax(10rem, 16rem) 1fr; gap: 0.4rem 2rem; padding: 1.1rem 0; border-bottom: 1px solid var(--rule); }
.checks h3 { margin: 0; font-size: var(--step-0); font-family: var(--font-text); font-weight: 600; }
.checks .result { font: 500 var(--step-1)/1.25 var(--font-data); }
.checks .how { color: var(--ink-2); font-size: var(--step--1); margin-top: 0.25rem; }
@media (max-width: 640px) { .checks li { grid-template-columns: 1fr; } }

/* ---------- API reference ---------- */
.endpoint { border-bottom: 1px solid var(--rule); padding: 1rem 0; }
.endpoint summary { cursor: pointer; display: flex; flex-wrap: wrap; gap: 0.25rem 0.9rem; align-items: baseline; list-style: none; }
.endpoint summary::-webkit-details-marker { display: none; }
.endpoint .method { font: 600 var(--step--1)/1 var(--font-data); color: var(--paper); background: var(--ink-2); padding: 0.25rem 0.4rem; border-radius: 3px; }
.endpoint .path { font: 500 1rem/1.3 var(--font-data); }
.endpoint .what { color: var(--ink-2); font-size: var(--step--1); }
.endpoint table { margin-top: 0.75rem; }
.api-group { font-family: var(--font-display); }

.footer { border-top: 1px solid var(--rule); padding: 2rem 0 3rem; color: var(--ink-2); font-size: var(--step--1); }
.footer p { max-width: 80ch; }
.footer p + p { margin-top: 0.5rem; }
.empty { color: var(--ink-2); padding: 1rem 0; }

@media (prefers-reduced-motion: no-preference) {
  .waterline .bars-in { animation: rise 700ms ease-out both; transform-origin: 0 50%; }
  @keyframes rise { from { opacity: 0; } to { opacity: 1; } }
}
@media print {
  .tabs, .theme-toggle, .views, .table-toggle { display: none; }
  .panel[hidden] { display: block; }
}
