/* Weather station page. Colours are tokens, with a dark set for dark mode. */

:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --hover: rgba(11, 11, 11, 0.05);
  --focus: #2a78d6;
  --shadow: 0 4px 16px rgba(11, 11, 11, 0.08);

  --series-temperature: #eb6834;
  --series-dew_point: #2a78d6;
  --series-humidity: #1baf7a;
  --series-qnh: #6250d6;

  --status-warning: #fab219;
  --status-critical: #d03b3b;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --ink: #f0efec;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --hover: rgba(255, 255, 255, 0.06);
    --focus: #3987e5;
    --shadow: 0 4px 16px rgba(0, 0, 0, 0.5);

    --series-temperature: #d95926;
    --series-dew_point: #3987e5;
    --series-humidity: #199e70;
    --series-qnh: #9085e9;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --ink: #f0efec;
  --ink-2: #c3c2b7;
  --muted: #898781;
  --grid: #2c2c2a;
  --axis: #383835;
  --border: rgba(255, 255, 255, 0.10);
  --hover: rgba(255, 255, 255, 0.06);
  --focus: #3987e5;
  --shadow: 0 4px 16px rgba(0, 0, 0, 0.5);

  --series-temperature: #d95926;
  --series-dew_point: #3987e5;
  --series-humidity: #199e70;
  --series-qnh: #9085e9;
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

.page {
  max-width: 960px;
  margin: 0 auto;
  padding: 24px 16px 40px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* Header and status */

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 16px;
  margin-bottom: 16px;
}

h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  color: var(--ink-2);
  font-size: 14px;
}

.status svg { flex: none; }
.status-icon-warning { fill: var(--status-warning); }
.status-icon-critical { fill: var(--status-critical); }
.status-icon-mark { fill: #0b0b0b; }
.status-icon-critical .status-icon-mark { fill: #ffffff; }

/* Cards and current values */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
}

.now {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}

.hero,
.tile-pressure { grid-column: 1 / -1; }

@media (min-width: 720px) {
  .now { grid-template-columns: 1.5fr 1fr 1fr 1fr; }
  .hero,
  .tile-pressure { grid-column: auto; }
}

.label {
  color: var(--ink-2);
  font-size: 13px;
}

.hero-value {
  font-size: 52px;
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.01em;
}

.value {
  font-size: 28px;
  font-weight: 600;
  line-height: 1.25;
}

.unit {
  color: var(--ink-2);
  font-size: 0.55em;
  font-weight: 500;
  letter-spacing: 0;
}

.sub {
  margin-top: 4px;
  color: var(--ink-2);
  font-size: 13px;
}

/* Range selector */

.range {
  display: inline-flex;
  gap: 2px;
  margin: 0 0 12px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
}

.range label { position: relative; }

.range input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.range span {
  display: block;
  padding: 6px 14px;
  border-radius: 999px;
  color: var(--ink-2);
  font-size: 14px;
}

.range label:hover input:not(:checked) + span { background: var(--hover); }
.range input:checked + span { background: var(--ink); color: var(--surface); font-weight: 600; }
.range input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 1px; }

/* Charts */

.charts {
  display: grid;
  gap: 12px;
}

.chart { margin: 0; }

.chart figcaption {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
}

.chart h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}

.unit-note {
  color: var(--muted);
  font-size: 13px;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  margin: 6px 0 0;
  padding: 0;
  list-style: none;
  color: var(--ink-2);
  font-size: 13px;
}

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

.key {
  display: inline-block;
  width: 14px;
  height: 2px;
  border-radius: 1px;
}

.key.s-temperature { background: var(--series-temperature); }
.key.s-dew_point { background: var(--series-dew_point); }
.key.s-humidity { background: var(--series-humidity); }
.key.s-qnh { background: var(--series-qnh); }

.plot {
  position: relative;
  margin-top: 8px;
  transition: opacity 0.15s;
}

.is-loading .plot { opacity: 0.5; }

.chart-svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
  touch-action: pan-y;
}

.chart-svg:focus { outline: none; }
.chart-svg:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }

.grid { stroke: var(--grid); stroke-width: 1; }
.axis { stroke: var(--axis); stroke-width: 1; }
.crosshair { stroke: var(--muted); stroke-width: 1; }

.tick {
  fill: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.tick-y { text-anchor: end; }
.tick-x { text-anchor: middle; }

.end-label {
  fill: var(--ink-2);
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

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

.line.s-temperature { stroke: var(--series-temperature); }
.line.s-dew_point { stroke: var(--series-dew_point); }
.line.s-humidity { stroke: var(--series-humidity); }
.line.s-qnh { stroke: var(--series-qnh); }

.dot { stroke: var(--surface); stroke-width: 2; }
.dot.s-temperature { fill: var(--series-temperature); }
.dot.s-dew_point { fill: var(--series-dew_point); }
.dot.s-humidity { fill: var(--series-humidity); }
.dot.s-qnh { fill: var(--series-qnh); }

.overlay {
  fill: transparent;
  pointer-events: all;
  cursor: crosshair;
}

.tooltip {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 1;
  min-width: 150px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  font-size: 13px;
  white-space: nowrap;
  pointer-events: none;
}

.tooltip[hidden] { display: none; }

.tooltip-time {
  margin-bottom: 4px;
  color: var(--ink-2);
}

.tooltip-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tooltip-row strong {
  color: var(--ink);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.tooltip-row .name { color: var(--ink-2); }

.empty {
  margin: 0;
  padding: 72px 0;
  color: var(--ink-2);
  text-align: center;
}

/* Table view */

.table-view summary {
  margin-top: 8px;
  color: var(--ink-2);
  font-size: 13px;
  cursor: pointer;
}

.table-wrap {
  max-height: 320px;
  margin-top: 8px;
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

th, td {
  padding: 4px 8px;
  border-bottom: 1px solid var(--grid);
  text-align: right;
}

th:first-child, td:first-child { text-align: left; }

thead th {
  position: sticky;
  top: 0;
  background: var(--surface);
  color: var(--ink-2);
  font-weight: 600;
}

/* Footer */

.page-foot {
  margin-top: 24px;
  color: var(--ink-2);
  font-size: 13px;
}

.page-foot p { margin: 0; }
