/* Hourly charts (charts.js): sticky readout, small-multiple SVG charts, table twins. Light/dark tokens. */

/* Tokens. Series slots and status steps come from the dataviz reference palette, validated against the app
   surfaces (light #ffffff, dark #0f1a24). Chart text uses ink tokens only, never a series colour. */
.hc {
  color-scheme: light;
  --hc-surface: #ffffff;
  --hc-ink: #0e1a24;
  --hc-ink-2: #445566;
  --hc-muted: #5f6f7e;            /* 5.2:1 on the surface; the app's #6b7c8c (4.3:1) is too light for 11px text */
  --hc-grid: #e8eef3;             /* hairline, one step off the surface */
  --hc-axis: #c9d4dd;             /* zero baseline */
  --hc-night: #f0f4f7;
  --hc-sel: rgba(14, 26, 36, 0.06);
  --hc-cross: #6b7c8c;
  --hc-focus: #0b5e8e;
  --hc-s1: #2a78d6;               /* slot 1 blue: wind, waves, water, pressure, rain */
  --hc-s2: #eb6834;               /* slot 2 orange: gusts, air temperature */
  --hc-area-opacity: 0.1;
  --hc-past-opacity: 0.38;
  --hc-good: #0ca30c;             /* status: great & good */
  --hc-fair: #fab219;
  --hc-poor: #ec835a;
  --hc-bad: #d03b3b;
  /* --hc-sticky-top (not declared here): the host may set it on any ancestor when a sticky header sits above. */

  position: relative;
  background: var(--hc-surface);
  color: var(--hc-ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) .hc {
    color-scheme: dark;
    --hc-surface: #0f1a24;
    --hc-ink: #e8f0f6;
    --hc-ink-2: #a9b9c7;
    --hc-muted: #8a9cad;
    --hc-grid: #1d2b37;
    --hc-axis: #2e3f4d;
    --hc-night: #0a131b;
    --hc-sel: rgba(232, 240, 246, 0.07);
    --hc-cross: #8a9cad;
    --hc-focus: #3aa0d8;
    --hc-s1: #3987e5;
    --hc-s2: #d95926;
    --hc-area-opacity: 0.16;
    --hc-past-opacity: 0.4;
  }
}

:root[data-theme="dark"] .hc {
  color-scheme: dark;
  --hc-surface: #0f1a24;
  --hc-ink: #e8f0f6;
  --hc-ink-2: #a9b9c7;
  --hc-muted: #8a9cad;
  --hc-grid: #1d2b37;
  --hc-axis: #2e3f4d;
  --hc-night: #0a131b;
  --hc-sel: rgba(232, 240, 246, 0.07);
  --hc-cross: #8a9cad;
  --hc-focus: #3aa0d8;
  --hc-s1: #3987e5;
  --hc-s2: #d95926;
  --hc-area-opacity: 0.16;
  --hc-past-opacity: 0.4;
}

/* --- Sticky readout (also the keyboard slider) ----------------------------------- */

.hc-readout {
  position: sticky;
  top: var(--hc-sticky-top, 0px);
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 6px 14px;
  padding: 8px 4px 9px;
  background: var(--hc-surface);
  border-bottom: 1px solid var(--hc-grid);
  outline: none;
  cursor: default;
}

.hc-readout:focus-visible {
  border-radius: 10px;
  box-shadow: inset 0 0 0 2px var(--hc-focus);
}

.hc-ro-cell {
  display: flex;
  flex-direction: column;
  gap: 1px;
  flex: 0 0 auto;
}

.hc-ro-v {
  display: flex;
  align-items: baseline;
  gap: 3px;
  font-size: 15px;
  font-weight: 650;
  line-height: 20px;
  color: var(--hc-ink);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.hc-ro-time .hc-ro-v {
  font-size: 17px;
  font-weight: 700;
}

.hc-ro-u {
  font-size: 11px;
  font-weight: 500;
  color: var(--hc-muted);
}

.hc-ro-l {
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  line-height: 14px;
  color: var(--hc-muted);
  white-space: nowrap;
}

.hc-ro-arrow {
  flex: 0 0 auto;
  fill: var(--hc-ink-2);
}

.hc-sw {
  flex: 0 0 auto;
  align-self: center;
  width: 9px;
  height: 9px;
  border-radius: 2px;
  background: var(--hc-grid);
}

.hc-sw.is-great,
.hc-sw.is-good { background: var(--hc-good); }
.hc-sw.is-fair { background: var(--hc-fair); }
.hc-sw.is-poor { background: var(--hc-poor); }
.hc-sw.is-bad { background: var(--hc-bad); }

/* --- Captions -------------------------------------------------------------------- */

.hc-hint,
.hc-foot,
.hc-note {
  margin: 0;
  padding: 0 2px;
  font-size: 12px;
  line-height: 1.4;
  color: var(--hc-muted);
}

.hc-hint { padding-top: 8px; }
.hc-hint-mouse { display: none; }

@media (hover: hover) and (pointer: fine) {
  .hc-hint-touch { display: none; }
  .hc-hint-mouse { display: inline; }
}
.hc-foot { padding-top: 4px; padding-bottom: 4px; }

.hc-note {
  padding-top: 2px;
  padding-bottom: 6px;
  font-size: 13px;
  color: var(--hc-ink-2);
}

/* --- One small multiple ---------------------------------------------------------- */

.hc-chart {
  padding-top: 10px;
}

.hc-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 2px 12px;
  padding: 0 2px 2px;
}

.hc-title {
  margin: 0;
  font-size: 14px;
  font-weight: 650;
  line-height: 20px;
  color: var(--hc-ink);
}

.hc-unit {
  margin-left: 2px;
  font-size: 12px;
  font-weight: 400;
  color: var(--hc-muted);
}

.hc-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 10px;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 12px;
  line-height: 18px;
  color: var(--hc-ink-2);
}

.hc-legend li {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.hc-key { flex: 0 0 auto; display: inline-block; }
.hc-key-line { width: 14px; height: 2px; border-radius: 1px; }
.hc-key-rect { width: 9px; height: 9px; border-radius: 2px; }
.hc-key.hc-s1 { background: var(--hc-s1); }
.hc-key.hc-s2 { background: var(--hc-s2); }
.hc-key.is-good { background: var(--hc-good); }
.hc-key.is-fair { background: var(--hc-fair); }
.hc-key.is-poor { background: var(--hc-poor); }
.hc-key.is-bad { background: var(--hc-bad); }

/* --- SVG ------------------------------------------------------------------------- */

.hc-svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
  touch-action: pan-y pinch-zoom;    /* horizontal drags scrub; vertical drags scroll; pinch still zooms */
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

.hc-svg text {
  font-family: inherit;
  font-size: 11px;
  fill: var(--hc-muted);
  font-variant-numeric: tabular-nums;
}

.hc-svg .hc-ty { text-anchor: end; }
.hc-svg .hc-tx { text-anchor: middle; }

.hc-svg .hc-peak {
  font-weight: 650;
  fill: var(--hc-ink-2);
  text-anchor: middle;
  paint-order: stroke;
  stroke: var(--hc-surface);
  stroke-width: 3px;
  stroke-linejoin: round;
}

.hc-svg .hc-peak.is-night { stroke: var(--hc-night); }  /* halo matches the band it sits on */

.hc-nightband { fill: var(--hc-night); }

.hc-gl {
  stroke: var(--hc-grid);
  stroke-width: 1;
  shape-rendering: crispEdges;
}

.hc-gl.hc-base { stroke: var(--hc-axis); }

.hc-selband { fill: var(--hc-sel); }

.hc-cross {
  stroke: var(--hc-cross);
  stroke-width: 1;
  shape-rendering: crispEdges;
}

.hc-line {
  fill: none;
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.hc-line.hc-s1 { stroke: var(--hc-s1); }
.hc-line.hc-s2 { stroke: var(--hc-s2); }

.hc-area { stroke: none; fill-opacity: var(--hc-area-opacity); }
.hc-area.hc-s1 { fill: var(--hc-s1); }
.hc-area.hc-s2 { fill: var(--hc-s2); }

.hc-pt.hc-s1,
.hc-col.hc-s1 { fill: var(--hc-s1); }
.hc-pt.hc-s2,
.hc-col.hc-s2 { fill: var(--hc-s2); }

.hc-col.is-great,
.hc-col.is-good { fill: var(--hc-good); }
.hc-col.is-fair { fill: var(--hc-fair); }
.hc-col.is-poor { fill: var(--hc-poor); }
.hc-col.is-bad { fill: var(--hc-bad); }
.hc-col.is-none { fill: var(--hc-axis); }

.hc-arrow { fill: var(--hc-ink-2); }

.hc-svg .is-past { opacity: var(--hc-past-opacity); }

.hc-dot {
  stroke: var(--hc-surface);
  stroke-width: 2;
}

.hc-dot.hc-s1 { fill: var(--hc-s1); }
.hc-dot.hc-s2 { fill: var(--hc-s2); }

/* --- Table twin ------------------------------------------------------------------ */

.hc-tbl > summary {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;                  /* touch target */
  padding: 0 2px;
  font-size: 12px;
  color: var(--hc-muted);
  cursor: pointer;
  list-style: none;
  -webkit-tap-highlight-color: transparent;
}

.hc-tbl > summary::-webkit-details-marker { display: none; }

.hc-tbl > summary::before {
  content: "";
  width: 6px;
  height: 6px;
  margin: 0 3px 0 2px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(-45deg);
}

.hc-tbl[open] > summary::before { transform: rotate(45deg); }

.hc-tbl > summary:focus-visible {
  outline: 2px solid var(--hc-focus);
  outline-offset: -2px;
  border-radius: 8px;
}

.hc-tbl-wrap {
  max-width: 100%;
  overflow-x: auto;
  padding-bottom: 8px;
}

.hc-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  line-height: 1.3;
  color: var(--hc-ink);
  font-variant-numeric: tabular-nums;
}

.hc-table th,
.hc-table td {
  padding: 5px 6px;
  border-bottom: 1px solid var(--hc-grid);
  text-align: right;
  white-space: nowrap;
}

.hc-table th:first-child,
.hc-table .is-text { text-align: left; }
.hc-table th:first-child { padding-left: 2px; }

.hc-table thead th {
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.25;
  vertical-align: bottom;
  color: var(--hc-muted);
}

.hc-th-u {
  display: block;
  font-weight: 400;
}

.hc-table tbody th { font-weight: 600; }
.hc-table tr.is-past { color: var(--hc-muted); }
.hc-table tr.is-sel { background: var(--hc-sel); }

.hc-vh {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

/* --- Forced colours / print ------------------------------------------------------ */

@media (forced-colors: active) {
  /* System colours for chrome and lines; gusts get a dash as their second channel. Status columns keep their
     colours (forced-color-adjust: none on the legend/readout swatches) and always come with numbers and labels. */
  .hc-readout:focus-visible { outline: 2px solid Highlight; outline-offset: -2px; }
  .hc-svg text { fill: CanvasText; }
  .hc-svg .hc-line { stroke: CanvasText; }
  .hc-svg .hc-line.hc-s2 { stroke-dasharray: 4 3; }
  .hc-svg .hc-area { fill: none; }
  .hc-svg .hc-dot, .hc-svg .hc-pt { fill: CanvasText; stroke: Canvas; }
  .hc-svg .hc-col.hc-s1 { fill: CanvasText; }
  .hc-svg .hc-arrow, .hc-ro-arrow { fill: CanvasText; }
  .hc-svg .hc-gl { stroke: GrayText; }
  .hc-svg .hc-cross { stroke: Highlight; }
  .hc-svg .hc-nightband, .hc-svg .hc-selband { fill: none; }
  .hc-key-rect, .hc-sw { forced-color-adjust: none; }
  .hc-key-line { height: 0; border-top: 2px solid CanvasText; } /* backgrounds are forced to Canvas; borders are not */
  .hc-key-line.hc-s2 { border-top-style: dashed; }
}

@media print {
  .hc-readout { position: static; }
  .hc-hint { display: none; }
}
