/* Weatherspan — chrome and chart tokens.
   Palette values come from the validated reference palette (slots 1 & 2 only):
   light #2a78d6 / #eb6834, dark #3987e5 / #d95926 — both modes pass the
   lightness-band, chroma, CVD, normal-vision and contrast checks. */

:root {
  color-scheme: light;
  --surface-1: #fcfcfb;
  --plane: #f9f9f7;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --series-1: #2a78d6;   /* subject: observed / projected */
  --series-2: #eb6834;   /* reference: climate baseline */
  --good: #0ca30c;
  --warning: #fab219;
  --critical: #d03b3b;
  --wash-1: rgba(42, 120, 214, 0.10);
  --wash-2: rgba(235, 104, 52, 0.10);
  --ghost: rgba(11, 11, 11, 0.04);
  --shadow: 0 1px 2px rgba(11, 11, 11, 0.05), 0 8px 24px rgba(11, 11, 11, 0.04);
  --radius: 12px;
  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --surface-1: #1a1a19;
    --plane: #0d0d0d;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --series-1: #3987e5;
    --series-2: #d95926;
    --good: #0ca30c;
    --wash-1: rgba(57, 135, 229, 0.14);
    --wash-2: rgba(217, 89, 38, 0.14);
    --ghost: rgba(255, 255, 255, 0.06);
    --shadow: none;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --surface-1: #1a1a19;
  --plane: #0d0d0d;
  --text-primary: #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted: #898781;
  --grid: #2c2c2a;
  --axis: #383835;
  --border: rgba(255, 255, 255, 0.10);
  --series-1: #3987e5;
  --series-2: #d95926;
  --wash-1: rgba(57, 135, 229, 0.14);
  --wash-2: rgba(217, 89, 38, 0.14);
  --ghost: rgba(255, 255, 255, 0.06);
  --shadow: none;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--plane);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 20;
  background: var(--surface-1); color: var(--text-primary);
  padding: 10px 16px; border-radius: 0 0 var(--radius) 0;
}
.skip-link:focus { left: 0; }

:where(a) { color: var(--series-1); }

:where(button, input):focus-visible {
  outline: 2px solid var(--series-1);
  outline-offset: 2px;
}

/* ---------- top bar & search ---------- */

.topbar {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 14px 24px;
  background: var(--surface-1);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}

.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.brand-mark { font-size: 20px; }
.brand-name { letter-spacing: -0.01em; }

.search {
  display: flex; gap: 8px; flex: 1 1 380px; position: relative; min-width: 280px;
}

#place-input {
  flex: 1 1 auto; min-width: 0;
  padding: 9px 12px;
  font: inherit; color: var(--text-primary);
  background: var(--plane);
  border: 1px solid var(--border); border-radius: 10px;
}

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 14px; min-height: 40px;
  font: inherit; font-weight: 500;
  color: var(--text-primary); background: var(--plane);
  border: 1px solid var(--border); border-radius: 10px; cursor: pointer;
}
.btn:hover { background: var(--ghost); }
.btn-primary { background: var(--series-1); color: #fff; border-color: transparent; }
.btn-primary:hover { filter: brightness(0.94); }
.btn-icon { padding: 9px 11px; }

.suggestions {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 15;
  margin: 0; padding: 6px; list-style: none;
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  max-height: 320px; overflow-y: auto;
}
.suggestions li {
  padding: 8px 10px; border-radius: 8px; cursor: pointer;
  display: flex; justify-content: space-between; gap: 12px;
}
.suggestions li[aria-selected="true"], .suggestions li:hover { background: var(--ghost); }
.suggestions .sug-sub { color: var(--text-muted); font-size: 13px; }

/* ---------- layout ---------- */

main { max-width: 1160px; margin: 0 auto; padding: 24px; }
.stack { display: flex; flex-direction: column; gap: 28px; }

.status {
  max-width: 1160px; margin: 0 auto; padding: 0 24px;
  color: var(--text-secondary); font-size: 14px; min-height: 0;
}
.status:not(:empty) { padding: 12px 24px 0; }
.status[data-kind="error"] { color: var(--critical); }

.place-head { margin: 8px 0 20px; }
.place-head h1 { margin: 0; font-size: clamp(24px, 4vw, 34px); letter-spacing: -0.02em; }
.place-meta { margin: 4px 0 0; color: var(--text-secondary); font-size: 14px; }

.filterbar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 14px; margin-bottom: 24px;
  background: var(--surface-1);
  border: 1px solid var(--border); border-radius: var(--radius);
}
.filter-note { margin: 0; color: var(--text-muted); font-size: 13px; }

.segmented { display: inline-flex; background: var(--plane); border: 1px solid var(--border); border-radius: 10px; padding: 2px; }
.segmented button {
  font: inherit; font-size: 14px; padding: 6px 12px; min-height: 32px;
  border: 0; background: transparent; color: var(--text-secondary);
  border-radius: 8px; cursor: pointer;
}
.segmented button[aria-checked="true"] { background: var(--surface-1); color: var(--text-primary); font-weight: 600; box-shadow: var(--shadow); }

.card {
  background: var(--surface-1);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow);
}

section > header { margin-bottom: 14px; }
section h2 { margin: 0; font-size: 20px; letter-spacing: -0.01em; }
section .sub { margin: 4px 0 0; color: var(--text-secondary); font-size: 14px; max-width: 78ch; }

#app > section { display: flex; flex-direction: column; gap: 20px; }
#app > section > header { margin-bottom: 0; }

#method dl { margin: 0; display: grid; gap: 14px; }
#method dt { font-weight: 600; }
#method dd { margin: 2px 0 0; color: var(--text-secondary); max-width: 90ch; }

/* ---------- now: hero figure + stat tiles ---------- */

.now-grid { display: grid; grid-template-columns: minmax(240px, 320px) 1fr; gap: 20px; align-items: stretch; }
@media (max-width: 780px) { .now-grid { grid-template-columns: 1fr; } }

.hero { display: flex; flex-direction: column; justify-content: center; gap: 6px; }
.hero-label { color: var(--text-secondary); font-size: 14px; }
.hero-figure { font-size: clamp(48px, 9vw, 68px); font-weight: 600; line-height: 1; letter-spacing: -0.03em; }
.hero-cond { display: flex; align-items: center; gap: 8px; font-size: 16px; color: var(--text-primary); }
.hero-cond .glyph { font-size: 24px; }
.hero-sub { color: var(--text-secondary); font-size: 14px; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 2px; background: var(--border); border-radius: var(--radius); overflow: hidden; }
.tile { background: var(--surface-1); padding: 14px 16px; }
.tile-label { color: var(--text-secondary); font-size: 13px; }
.tile-value { font-size: 22px; font-weight: 600; letter-spacing: -0.01em; margin-top: 2px; }
.tile-delta { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }
.tile-delta[data-dir="up"] { color: var(--good); }
.tile-delta[data-dir="down"] { color: var(--series-1); }

/* ---------- day strip ---------- */

.daystrip { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(96px, 1fr); gap: 2px; overflow-x: auto; background: var(--border); border-radius: var(--radius); }
.day {
  background: var(--surface-1); padding: 12px 10px; text-align: center;
  display: flex; flex-direction: column; gap: 4px; min-width: 96px;
}
.day-name { font-size: 13px; color: var(--text-secondary); }
.day-glyph { font-size: 22px; }
.day-temps { font-size: 14px; font-variant-numeric: tabular-nums; }
.day-temps .hi { font-weight: 600; }
.day-temps .lo { color: var(--text-secondary); }
.day-pop { font-size: 12px; color: var(--text-muted); font-variant-numeric: tabular-nums; }

/* ---------- chart anatomy ---------- */

.chart-card { position: relative; }
.chart-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 4px; }
.chart-title { margin: 0; font-size: 16px; font-weight: 600; }
.chart-sub { margin: 2px 0 0; font-size: 13px; color: var(--text-secondary); }

.legend { display: flex; gap: 14px; flex-wrap: wrap; margin: 8px 0 2px; padding: 0; list-style: none; }
.legend li { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-secondary); }
.legend .key-line { width: 16px; height: 2px; border-radius: 2px; }
.legend .key-rect { width: 12px; height: 12px; border-radius: 3px; }

figure.plot { margin: 0; }
figure.plot svg { display: block; width: 100%; height: auto; overflow: visible; touch-action: pan-y; }
figure.plot svg:focus-visible { outline: 2px solid var(--series-1); outline-offset: 4px; border-radius: 6px; }

.grid-line { stroke: var(--grid); stroke-width: 1; }
.axis-line { stroke: var(--axis); stroke-width: 1; }
.tick-text { fill: var(--text-muted); font-size: 11px; font-family: var(--font); font-variant-numeric: tabular-nums; }
.axis-title { fill: var(--text-secondary); font-size: 11px; font-family: var(--font); }
.point-label { fill: var(--text-secondary); font-size: 11px; font-family: var(--font); font-variant-numeric: tabular-nums; }
.crosshair { stroke: var(--axis); stroke-width: 1; pointer-events: none; }
.mark-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.mark-dot { stroke: var(--surface-1); stroke-width: 2; }
.mark-bar { transition: opacity 120ms ease; }
.mark-bar.dim { opacity: 0.55; }
.hit { fill: transparent; }

.tooltip {
  position: absolute; z-index: 8; pointer-events: none; min-width: 150px;
  background: var(--surface-1); color: var(--text-primary);
  border: 1px solid var(--border); border-radius: 10px;
  box-shadow: var(--shadow); padding: 10px 12px; font-size: 13px;
  opacity: 0; transform: translate(-50%, -100%); transition: opacity 90ms ease;
}
.tooltip[data-show="1"] { opacity: 1; }
.tooltip .tt-head { font-weight: 600; margin-bottom: 6px; }
.tooltip .tt-row { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.tooltip .tt-key { display: inline-block; width: 14px; height: 2px; border-radius: 2px; flex: 0 0 auto; }
.tooltip .tt-name { color: var(--text-secondary); }
.tooltip .tt-val { font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- table view twin ---------- */

details.tableview { margin-top: 12px; border-top: 1px solid var(--border); padding-top: 10px; }
details.tableview summary { cursor: pointer; font-size: 13px; color: var(--text-secondary); }
details.tableview[open] summary { margin-bottom: 10px; }
.tablewrap { max-height: 320px; overflow: auto; }
table.data { border-collapse: collapse; width: 100%; font-size: 13px; font-variant-numeric: tabular-nums; }
table.data th, table.data td { text-align: right; padding: 6px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.data th:first-child, table.data td:first-child { text-align: left; }
table.data thead th { position: sticky; top: 0; background: var(--surface-1); color: var(--text-secondary); font-weight: 600; }

/* ---------- notices & lookups ---------- */

.notice {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 14px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--ghost);
  font-size: 14px; color: var(--text-secondary);
}
.notice .n-icon { flex: 0 0 auto; }
.notice strong { color: var(--text-primary); }
.notice[data-tone="warning"] { border-left: 3px solid var(--warning); }

.lookup { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; margin-top: 16px; }
.lookup label { font-size: 13px; color: var(--text-secondary); display: block; margin-bottom: 4px; }
.lookup input[type="date"] {
  font: inherit; padding: 8px 10px; min-height: 40px; color: var(--text-primary);
  background: var(--plane); border: 1px solid var(--border); border-radius: 10px;
}
.lookup-out { margin-top: 12px; display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 2px; background: var(--border); border-radius: var(--radius); overflow: hidden; }
.lookup-out:empty { display: none; }

.footer { max-width: 1160px; margin: 8px auto 40px; padding: 20px 24px 0; border-top: 1px solid var(--border); color: var(--text-muted); font-size: 13px; }
.footer p { margin: 0; max-width: 92ch; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

.loading { opacity: 0.55; transition: opacity 150ms ease; }
.spinner { display: inline-block; width: 12px; height: 12px; border: 2px solid var(--axis); border-top-color: var(--series-1); border-radius: 50%; animation: spin 700ms linear infinite; vertical-align: -1px; margin-right: 6px; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2s; } * { transition: none !important; } }

