/* Interactive sections and charts. Page-wide tokens live in template.html. */
:root {
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-muted: #898781;
  --grid: #e9ecef;
  --axis: #c3cad0;
  --ref: #8f99a3;
  --band: rgba(29, 35, 42, 0.07);
  --status-warning: #fab219;
  --status-serious: #ec835a;
  --status-critical: #d03b3b;
  --raised: #ffffff;
}
@media (prefers-color-scheme: dark) {
  :root {
    --series-1: #3987e5;
    --series-2: #d95926;
    --grid: #232a32;
    --axis: #38414b;
    --ref: #7c8894;
    --band: rgba(228, 233, 238, 0.08);
    --raised: #1a2027;
  }
}
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

h2[id] { scroll-margin-top: 64px; }
h3 { font-size: 1.05rem; margin: 0 0 4px; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}

/* Section navigation */
.section-nav {
  position: sticky; top: 0; z-index: 5;
  display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none;
  margin: 28px -16px 0; padding: 8px 16px;
  background: var(--bg); border-bottom: 1px solid var(--line);
  font-size: 0.9rem;
}
.section-nav::-webkit-scrollbar { display: none; }
.section-nav a {
  flex: none; padding: 4px 10px; border-radius: 6px;
  color: var(--muted); text-decoration: none;
}
.section-nav a:hover { background: var(--code-bg); color: var(--fg); }
.section-nav a[aria-current] { background: var(--code-bg); color: var(--fg); font-weight: 600; }

/* Demo frame */
.demo {
  margin: 24px 0 32px; padding: 20px;
  border: 1px solid var(--line); border-radius: 8px;
}
.demo > .demo-intro { margin: 0 0 16px; color: var(--muted); font-size: 0.95rem; }
.demo .note { margin: 2px 0 0; }
:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }

/* Controls */
.controls { display: flex; flex-wrap: wrap; gap: 14px 24px; align-items: flex-end; margin-bottom: 20px; }
.controls-inline { margin-bottom: 12px; }
fieldset.segmented { border: 0; margin: 0; padding: 0; min-width: 0; }
fieldset.segmented legend, .slider-label {
  display: block; padding: 0; margin-bottom: 4px;
  color: var(--muted); font-size: 0.85rem;
}
.segmented-row { display: flex; flex-wrap: wrap; gap: 4px; }
.segmented-row label { position: relative; cursor: pointer; }
.segmented-row input { position: absolute; inset: 0; margin: 0; opacity: 0; cursor: pointer; }
.segmented-row span {
  display: block; padding: 5px 11px; border: 1px solid var(--line); border-radius: 6px;
  font-size: 0.9rem; white-space: nowrap;
}
.segmented-row label:hover span { background: var(--code-bg); }
.segmented-row input:checked + span { background: var(--fg); border-color: var(--fg); color: var(--bg); }
.segmented-row input:focus-visible + span { outline: 2px solid var(--link); outline-offset: 2px; }
.slider { display: block; flex: 1 1 220px; }
.slider input { display: block; width: 100%; margin: 6px 0 0; accent-color: var(--series-1); }
.check { display: flex; align-items: center; gap: 8px; padding-bottom: 5px; font-size: 0.9rem; cursor: pointer; }
.check input { margin: 0; width: 16px; height: 16px; accent-color: var(--series-1); }

.button, .chip {
  font: inherit; color: var(--fg); background: transparent; cursor: pointer;
  border: 1px solid var(--line); border-radius: 6px;
}
.button { min-width: 72px; padding: 5px 12px; font-size: 0.9rem; }
.button:hover, .chip:hover { background: var(--code-bg); }
.chip { padding: 3px 9px; font-size: 0.85rem; }
.chip[aria-pressed="true"] { background: var(--fg); border-color: var(--fg); color: var(--bg); }

/* Stat tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 16px; margin-bottom: 20px; }
.tile-label { color: var(--muted); font-size: 0.85rem; }
.tile-value { font-size: 1.5rem; font-weight: 600; line-height: 1.3; }
.tile-note { color: var(--muted); font-size: 0.85rem; }

/* Charts */
.chart { position: relative; width: 100%; touch-action: pan-y; border-radius: 4px; }
.chart svg { display: block; width: 100%; }
.chart-title { margin: 18px 0 2px; font-size: 0.9rem; font-weight: 600; }
.c-grid { stroke: var(--grid); stroke-width: 1; }
.c-axis { stroke: var(--axis); stroke-width: 1; }
.c-ref { stroke: var(--ref); stroke-width: 1; }
.c-marker { stroke: var(--ref); stroke-width: 1; }
.c-cursor { stroke: var(--fg); stroke-width: 1; pointer-events: none; }
.c-band { fill: var(--band); }
.c-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.c-dot { stroke: var(--bg); stroke-width: 2; }
.c-tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.c-note { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.c-label { fill: var(--fg); font-size: 12px; }

.legend { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 4px 0; color: var(--muted); font-size: 0.85rem; }
.legend > span { display: inline-flex; align-items: center; gap: 6px; }
.legend-key { display: inline-block; width: 14px; height: 2px; border-radius: 1px; }
.legend-swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; }

.tip {
  position: absolute; z-index: 3; pointer-events: none;
  min-width: 140px; max-width: 240px; padding: 8px 10px;
  background: var(--raised); border: 1px solid var(--line); border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.14);
  font-size: 0.82rem; line-height: 1.4;
}
.tip[hidden] { display: none; }
.tip-title { color: var(--muted); margin-bottom: 2px; white-space: nowrap; }
.tip-value { font-size: 1rem; font-weight: 600; }
.tip-row { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.tip-row span:last-child { color: var(--muted); }
.tip-key { flex: none; width: 10px; height: 2px; border-radius: 1px; }

/* Alert strip: lines up with the plot area of the charts above and below it. */
.tier-strip { display: flex; gap: 2px; height: 8px; margin: 6px 76px 6px 44px; }
.tier-strip span { display: block; flex-basis: 0; min-width: 2px; border-radius: 2px; }

.reasons-title { margin: 18px 0 4px; font-weight: 600; font-size: 0.95rem; }
.reasons { margin: 0 0 12px; padding-left: 20px; font-size: 0.95rem; }
details { margin-top: 12px; font-size: 0.95rem; }
summary { cursor: pointer; color: var(--link); }
details .table-wrap { margin-top: 8px; max-height: 320px; overflow: auto; }

/* Forecast explorer */
.transport { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-bottom: 16px; }
.transport input { flex: 1 1 200px; min-width: 0; margin: 0; accent-color: var(--series-1); }
.transport-time { flex: 0 0 auto; font-size: 0.9rem; font-variant-numeric: tabular-nums; }
.map-layout { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.map { position: relative; width: 100%; }
.map-canvas {
  display: block; width: 100%; height: 100%; border-radius: 4px;
  image-rendering: pixelated; cursor: crosshair; touch-action: pan-y;
}
.map-ring {
  position: absolute; width: 14px; height: 14px; transform: translate(-50%, -50%);
  border: 2px solid #ffffff; border-radius: 50%; box-shadow: 0 0 0 2px #0b0b0b; pointer-events: none;
}
.map-ring-hover { display: none; width: 10px; height: 10px; box-shadow: 0 0 0 1px #0b0b0b; }
.map-place {
  position: absolute; width: 6px; height: 6px; transform: translate(-50%, -50%);
  background: #ffffff; border-radius: 50%; box-shadow: 0 0 0 1px #0b0b0b; pointer-events: none;
}
.map-place-label {
  position: absolute; left: 9px; top: -7px; white-space: nowrap;
  padding: 0 3px; border-radius: 3px; background: rgba(255, 255, 255, 0.82);
  color: #0b0b0b; font-size: 11px; line-height: 16px;
}
.map-side { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.readout-name { font-weight: 600; }
.readout-value { margin-top: 8px; font-size: 1.5rem; font-weight: 600; line-height: 1.2; }
.readout-band { font-size: 0.95rem; }
.place-row { display: flex; flex-wrap: wrap; gap: 4px; }
.map-scale .chart-title { margin-top: 0; }
.map-scale-bar { height: 10px; border-radius: 2px; margin-top: 4px; }
.map-scale-ticks { position: relative; height: 18px; margin: 2px 10px 4px 2px; color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.map-scale-ticks span { position: absolute; top: 0; transform: translateX(-50%); }

@media (max-width: 640px) {
  .demo { padding: 16px 12px; margin-inline: -4px; }
  .map-layout { grid-template-columns: 1fr; }
  .tile-value { font-size: 1.3rem; }
}
@media print {
  .section-nav, .controls, .transport { display: none; }
}
