/* Layout: a working desk. Picker bar on top; below it a sticky section nav on the left and the page on the right:
   the area header (with story leads) beside its maps, then household costs, what residents think, the climate
   trends behind the costs, and health and air. Each topic is one band: the statement and sources on the left,
   then-and-now comparisons on the right. */
:root {
  --bg: #f7f7f7;
  --surface: #ffffff;
  --ink: #121212;
  --ink-2: #495057;
  --muted: #6c757d;
  --grid: #e6e6e6;
  --axis: #c4c4c4;
  --ring: rgba(18, 18, 18, 0.08);
  --shadow: 0 14px 14px rgba(18, 18, 18, 0.05);
  --accent: #d3194a;          /* crimson: kickers, the selected area, the latest value */
  --warm: #f7951d;            /* orange rule on cards */
  --link: #0d54ad;
  --series-1: #0d54ad;        /* the yearly series */
  --series-2: #e8532b;        /* recent average / second series */
  --hi: #d3194a;              /* record highs (diverging warm pole) */
  --lo: #0d54ad;              /* record lows (diverging cool pole) */
  --map-land: #e8e8e8;
  --map-line: #ffffff;
  --map-area: #d3194a;
  --chip: #efefef;
  --cat-1: #0d54ad; --cat-2: #e8532b; --cat-3: #1a9a6c; --cat-4: #f7951d; --cat-5: #d3194a;
  --font-display: "Source Serif 4", "Lyon Display Web", Georgia, serif;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-data: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #121212; --surface: #1c1c1c; --ink: #f2f2f2; --ink-2: #c4c8cc; --muted: #8f969c;
    --grid: #2b2b2b; --axis: #444444; --ring: rgba(255, 255, 255, 0.10); --shadow: none;
    --accent: #f0587e; --warm: #f7a440; --link: #6fa8f0; --series-1: #5b9be6; --series-2: #f07a52; --hi: #f0587e; --lo: #5b9be6;
    --map-land: #2a2a2a; --map-line: #1c1c1c; --map-area: #f0587e; --chip: #262626;
    --cat-1: #5b9be6; --cat-2: #f07a52; --cat-3: #2bb383; --cat-4: #f7a440; --cat-5: #f0587e;
  color-scheme: dark;
}

* { box-sizing: border-box; }
body {
  margin: 0; font-variant-numeric: tabular-nums; background: var(--bg); color: var(--ink);
  font: 16px/1.5 var(--font-body);
}
a { color: var(--link); text-decoration-color: color-mix(in srgb, var(--link) 35%, transparent); text-underline-offset: 2px; }
a:hover { text-decoration-color: currentColor; }
:focus-visible { outline: 2px solid var(--series-1); outline-offset: 2px; }

.wrap { max-width: 1320px; margin: 0 auto; padding-inline: 20px; }

/* top bar */
.bar { background: var(--surface); border-bottom: 0; box-shadow: var(--shadow); }
.bar::after { content: ""; display: block; height: 6px; background: linear-gradient(90deg, var(--accent), var(--warm)); }
.bar .wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 24px; padding-block: 12px; }
.brand { font: 600 22px/1 var(--font-display); }
.brand small { display: block; margin-top: 4px; font: 400 12px/1.2 var(--font-body); letter-spacing: 0; text-transform: none; color: var(--muted); }

.picker { flex: 1 1 420px; min-width: 0; display: flex; flex-direction: column; gap: 8px; position: relative; }
#q {
  width: 100%; font: 15px var(--font-body); padding: 9px 12px; border-radius: 4.8px;
  border: 1px solid var(--axis); background: var(--surface); color: var(--ink);
}
#results {
  position: absolute; z-index: 10; top: 100%; left: 0; right: 0; margin: 4px 0 0; padding: 4px; list-style: none;
  background: var(--surface); border: 1px solid var(--ring); border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12); max-height: 360px; overflow-y: auto;
}
#results li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 10px; border-radius: 5px; cursor: pointer; }
#results li[aria-selected="true"], #results li:hover { background: var(--chip); }
#results .t { font: 12px var(--font-data); color: var(--muted); white-space: nowrap; }

/* area header */
.area { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 0 24px; padding-block: 28px 8px; align-items: start; scroll-margin-top: 16px; }
.eyebrow { font: 750 13px/1 var(--font-body); letter-spacing: 0.03em; text-transform: uppercase; color: var(--accent); }
h1 { font: 600 clamp(30px, 5vw, 48px)/1.02 var(--font-display); margin: 10px 0 12px; text-wrap: balance; }
.facts-line { color: var(--ink-2); margin: 0 0 6px; }

.maps { justify-self: end; width: 100%; }
.area > .leads { grid-column: 1 / -1; }
.map { background: var(--surface); border: 0; border-top: 4px solid var(--warm); border-radius: 0; box-shadow: var(--shadow); padding: 8px; min-width: 0; }
.map svg { display: block; width: 100%; height: auto; }
.map figcaption { font-size: 12px; color: var(--muted); padding: 4px 4px 0; }

/* story leads */
.leads { margin-top: 20px; background: var(--surface); border: 0; border-top: 4px solid var(--warm); border-radius: 0; box-shadow: var(--shadow); padding: 16px 18px 12px; }
.leads > h2 { font: 600 20px/1.1 var(--font-display); margin: 0 0 10px; }
.leads .group + .group { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--grid); }
.leads .k, .connect .k { font: 600 11px/1 var(--font-body); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }
.leads ol { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 10px; }
.leads li::marker { font: 700 14px var(--font-display); color: var(--accent); }
.leads a.h { font: 600 16px/1.25 var(--font-display); text-decoration: none; }
.leads a.h:hover { text-decoration: underline; }
.leads li p { margin: 2px 0 0; font-size: 14px; color: var(--ink-2); }
.leads .tools { margin: 14px 0 6px; }
.how { font-size: 13px; color: var(--muted); }
.how summary { cursor: pointer; }
.how p { margin: 6px 0 0; max-width: 70ch; }

/* climate connection inside a cost section */
.connect { border-left: 4px solid var(--accent); background: var(--surface); box-shadow: var(--shadow); border-radius: 0; padding: 10px 14px; margin: 0 0 14px; max-width: 62ch; }
.connect p { margin: 0 0 6px; font-size: 14px; line-height: 1.55; }
.connect a { font-size: 13px; font-weight: 600; color: var(--link); text-decoration: none; }

/* page parts: costs, then climate, then context */
.part { padding-block: 44px 4px; border-bottom: 2px solid var(--ink); scroll-margin-top: 16px; }
.part h2 { font: 600 clamp(28px, 4vw, 38px)/1.05 var(--font-display); margin: 0 0 6px; }
.part p { margin: 0 0 12px; font-size: 16px; color: var(--ink-2); max-width: 70ch; }

/* page with sticky section nav */
.layout { display: grid; grid-template-columns: 188px minmax(0, 1fr); gap: 36px; align-items: start; }
.content { min-width: 0; }
nav.side { position: sticky; top: 0; max-height: 100vh; overflow-y: auto; padding: 32px 0 24px; display: flex; flex-direction: column; gap: 1px; }
nav.side .k { font: 600 11px/1.2 var(--font-body); letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); margin: 16px 0 4px 10px; }
nav.side a { font: 500 14px/1.25 var(--font-body); padding: 6px 10px; border-radius: 6px; text-decoration: none; color: var(--ink-2); }
nav.side a:hover { background: var(--chip); color: var(--ink); }
nav.side a[aria-current] { background: var(--chip); color: var(--ink); font-weight: 600; }
nav.side a.geo { font: 600 19px/1.15 var(--font-display); color: var(--ink); padding: 0 10px 10px; margin-bottom: 6px; border-left: 0; border-bottom: 1px solid var(--ring); border-radius: 0; }
nav.side a.geo:hover { background: none; }

/* sections */
section.topic { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 28px; padding-block: 36px; border-bottom: 1px solid var(--ring); scroll-margin-top: 16px; }
section.topic.wide { grid-template-columns: minmax(0, 1fr); }
.topic h2 { font: 600 28px/1.05 var(--font-display); margin: 8px 0 14px; }
.statement { font-size: 17px; line-height: 1.6; max-width: 62ch; margin: 0 0 14px; }
.statement strong { font-weight: 700; }
.statement .up { color: var(--accent); }
.research { border-top: 1px solid var(--ring); margin: 4px 0 14px; padding-top: 10px; max-width: 62ch; }
.research .k { font: 600 11px/1 var(--font-body); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }
.research ul { margin: 0; padding-left: 18px; }
.research li { font-size: 14px; line-height: 1.5; margin-bottom: 6px; }
.research a { color: var(--ink-2); font-size: 13px; }
.note { font-size: 13px; color: var(--muted); max-width: 62ch; margin: 0 0 12px; }
.tools { display: flex; gap: 8px; align-items: center; margin-bottom: 14px; }
.tools button {
  font: 600 12px var(--font-body); letter-spacing: 0.03em; text-transform: uppercase; padding: 7px 14px; border-radius: 4.8px; cursor: pointer;
  border: 1px solid var(--axis); background: var(--surface); color: var(--ink);
}
.tools .ok { font-size: 12px; color: var(--muted); }
.sources { font: 12px/1.5 var(--font-data); color: var(--muted); margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 4px; }
.charts { display: grid; gap: 14px; min-width: 0; }
.charts.two { grid-template-columns: 1fr 1fr; }
.charts.two > .chart:first-child, .charts.two > .chart.wide { grid-column: 1 / -1; }
.chart { background: var(--surface); border: 0; border-top: 4px solid var(--warm); border-radius: 0; box-shadow: var(--shadow); padding: 14px 14px 10px; min-width: 0; }
.chart h3 { font: 600 14px/1.3 var(--font-body); margin: 0; }
.chart .sub { font-size: 12px; color: var(--muted); margin: 2px 0 8px; }
.chart .plot { color: var(--muted); }
.chart .plot svg { display: block; max-width: 100%; height: auto; overflow: visible; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--ink-2); margin: 2px 0 6px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { display: inline-block; width: 14px; height: 3px; border-radius: 2px; }
.legend i.box { height: 10px; width: 10px; }
.legend i.dot { width: 9px; height: 9px; border-radius: 50%; }
/* time comparisons: one column per period, value on top, label underneath */
ol.bars { list-style: none; margin: 12px 0 4px; padding: 0; display: flex; align-items: flex-end; gap: 14px; }
ol.bars li { flex: 0 1 92px; display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-2); text-align: center; }
ol.bars .v { order: 1; }
ol.bars .track { order: 2; height: 120px; width: 100%; display: flex; align-items: flex-end; border-bottom: 1px solid var(--axis); }
ol.bars .track i { display: block; width: 100%; border-radius: 3px 3px 0 0; background: var(--axis); }
ol.bars .l { order: 3; line-height: 1.25; }
ol.bars.items { flex-direction: column; align-items: stretch; gap: 8px; }
ol.bars.items li { display: grid; flex: none; text-align: left; align-items: center; gap: 10px; grid-template-columns: minmax(84px, 26%) minmax(0, 1fr) 52px minmax(96px, auto); }
ol.bars.items .track { height: 14px; border: 0; display: block; }
ol.bars.items .track i { height: 100%; border-radius: 3px; }
ol.bars.items li > * { order: 0; }
ol.bars.items .v { text-align: right; }
ol.bars li.now { color: var(--ink); font-weight: 600; }
ol.bars li.now .track i { background: var(--accent); }
ol.bars .v { font: 600 14px/1 var(--font-data); white-space: nowrap; }
ol.bars .x { font: 12px/1 var(--font-data); color: var(--muted); white-space: nowrap; }
.chart .chg { margin: 8px 0 0; font-size: 13px; color: var(--ink-2); }
.chart .chg.up { color: var(--accent); font-weight: 600; }

/* public opinion: three short lists */
.opinion { display: grid; grid-template-columns: 1fr; gap: 14px; margin: 4px 0 16px; }
.og { background: var(--surface); border: 0; border-top: 4px solid var(--warm); border-radius: 0; box-shadow: var(--shadow); padding: 14px 16px; }
.og h3 { font: 600 17px/1.2 var(--font-display); margin: 0 0 10px; }
.og ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.og li { display: grid; grid-template-columns: 48px 1fr; gap: 8px; align-items: baseline; font-size: 15px; line-height: 1.35; }
.og b { font: 600 20px/1 var(--font-display); color: var(--accent); }

details.table { margin-top: 6px; font-size: 12px; }
details.table summary { cursor: pointer; color: var(--muted); }
details.table .scroll { max-height: 260px; overflow: auto; margin-top: 6px; }
details.table table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
details.table th, details.table td { text-align: left; padding: 3px 8px; border-bottom: 1px solid var(--grid); white-space: nowrap; }
details.table td.n { text-align: right; }
.empty { font-size: 14px; color: var(--muted); }
table.fac { border-collapse: collapse; width: 100%; font-size: 13px; font-variant-numeric: tabular-nums; }
table.fac th { font-weight: 600; text-align: left; color: var(--ink-2); border-bottom: 1px solid var(--axis); padding: 4px 6px; }
table.fac td { padding: 5px 6px; border-bottom: 1px solid var(--grid); vertical-align: top; }
table.fac td.n, table.fac th.n { text-align: right; white-space: nowrap; }
table.fac .kind { color: var(--muted); font-size: 12px; }
.fac-wrap { overflow-x: auto; }

.loading main { opacity: 0.55; transition: opacity 0.2s; }
.msg { padding-block: 40px; color: var(--ink-2); }

/* Plot tooltip */
.plot [aria-label="tip"] { color: var(--ink); }

@media (max-width: 1100px) {
  section.topic { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .area { grid-template-columns: 1fr; }
  .charts.two { grid-template-columns: 1fr; }
  .layout { display: block; }
  nav.side {
    z-index: 5; flex-direction: row; gap: 6px; max-height: none; overflow-x: auto; padding: 10px 20px;
    margin-inline: -20px; background: var(--bg); border-bottom: 1px solid var(--ring);
  }
  nav.side .k { display: none; }
  nav.side a.geo { display: none; }
  nav.side a { white-space: nowrap; border: 0; border-radius: 999px; background: var(--chip); font-size: 13px; }
  nav.side a[aria-current] { background: var(--ink); color: var(--surface); }
  .area, section.topic, .part { scroll-margin-top: 60px; }
}
@media (max-width: 480px) {
  .wrap { padding-inline: 16px; }
  nav.side { margin-inline: -16px; padding-inline: 16px; }
  ol.bars.items li { grid-template-columns: minmax(70px, 30%) minmax(0, 1fr) 48px; }
  ol.bars.items .x { grid-column: 1 / -1; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }

/* Hot days by threshold: paired horizontal bars, then and now, with the change on the right. */
.ladder ol { list-style: none; margin: 8px 0 4px; padding: 0; display: grid; gap: 10px; }
.ladder li { display: grid; grid-template-columns: 112px minmax(0, 1fr) 52px; align-items: center; gap: 10px; font-size: 13px; }
.ladder .k { color: var(--ink-2); font-weight: 600; }
.ladder .pair { display: grid; gap: 3px; }
.ladder .b { display: flex; align-items: center; gap: 6px; }
.ladder .b i { display: block; height: 11px; min-width: 2px; border-radius: 0 2px 2px 0; background: var(--axis); }
.ladder .b.now i { background: var(--accent); }
.ladder .b em { font-style: normal; font-size: 12px; color: var(--muted); white-space: nowrap; }
.ladder .b.now em { color: var(--ink); font-weight: 600; }
.ladder strong { text-align: right; font-size: 13px; }
.ladder strong.up { color: var(--accent); }
.ladder strong.down { color: var(--muted); }
