/*
 * swelter
 *
 * A quiet interface for local heat and air readings. The California map is the
 * main visual element; everything around it uses plain type, neutral surfaces,
 * simple rules, and the minimum decoration needed to explain state.
 */

:root {
  color-scheme: light;
  --bg: #f4f6f7;
  --fg: #182126;
  --muted: #5b6870;
  --surface: #ffffff;
  --border: #cbd3d8;
  --accent: #176785;
  --accent-fg: #ffffff;
  --focus: #0645d1;
  --provisional: #4f5d64;
  --line: var(--border);
  --line-strong: #8e9ba2;
  --paper: var(--surface);
  --mist: var(--bg);
  --mist-deep: #e9eef0;
  --soot: var(--fg);
  --soot-soft: var(--muted);
  --air: var(--accent);
  --heat: #a43e2f;
  --canopy: #39705f;
  --signal: var(--accent);
  --heat-wash: #fbefec;
  --air-wash: #e8f2f6;
  --canopy-wash: #eaf3f0;
  --map-land: #e4ebe7;
  --map-line: #73847c;
  --footer-bg: var(--surface);
  --footer-fg: var(--fg);
  --footer-link: var(--accent);
  --radius-xs: 0.15rem;
  --radius-sm: 0.2rem;
  --radius-md: 0.25rem;
  --shadow-soft: none;
  --shadow-lift: none;
  --font-display: system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-body: system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-data: ui-monospace, "SFMono-Regular", Consolas, monospace;
  --max-width: 96rem;

  --severity-ink: #17211f;
  --marker-ink: #14110f;
  --provisional-marker-ink: #2a221c;
  --provisional-marker-a: #e7ddd2;
  --provisional-marker-b: #d9cdbf;
  --aqi-good-bg: #d7f0d0;
  --aqi-moderate-bg: #f2e9b8;
  --aqi-usg-bg: #f6cf9b;
  --aqi-unhealthy-bg: #ef9a9a;
  --aqi-very-unhealthy-bg: #cf93c8;
  --aqi-hazardous-bg: #c79a9a;
  --heat-1-bg: #dbe9f2;
  --heat-2-bg: #e6edcb;
  --heat-3-bg: #f4e3b0;
  --heat-4-bg: #f2c197;
  --heat-5-bg: #e89887;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #111518;
    --fg: #eef2f3;
    --muted: #aeb9be;
    --surface: #191e22;
    --border: #3c464c;
    --accent: #8bc6df;
    --accent-fg: #10242c;
    --focus: #f0d95c;
    --provisional: #bdc7cb;
    --line: var(--border);
    --line-strong: #66747b;
    --paper: var(--surface);
    --mist: var(--bg);
    --mist-deep: #222a2f;
    --soot: var(--fg);
    --soot-soft: var(--muted);
    --air: var(--accent);
    --heat: #f0a092;
    --canopy: #9bcbbd;
    --heat-wash: #322522;
    --air-wash: #1c2b32;
    --canopy-wash: #20302b;
    --map-land: #1d2b25;
    --map-line: #657a70;
    --footer-bg: var(--surface);
    --footer-fg: var(--fg);
    --footer-link: var(--accent);
  }
}

:root[data-contrast="high"] {
  color-scheme: light;
  --bg: #ffffff;
  --fg: #000000;
  --muted: #000000;
  --surface: #ffffff;
  --border: #000000;
  --accent: #003b70;
  --accent-fg: #ffffff;
  --focus: #001fbf;
  --provisional: #000000;
  --line: #000000;
  --line-strong: #000000;
  --paper: #ffffff;
  --mist: #ffffff;
  --mist-deep: #ffffff;
  --soot: #000000;
  --soot-soft: #000000;
  --air: #003b70;
  --heat: #7a180c;
  --canopy: #164c39;
  --heat-wash: #ffffff;
  --air-wash: #ffffff;
  --canopy-wash: #ffffff;
  --map-land: #ffffff;
  --map-line: #000000;
  --footer-bg: #ffffff;
  --footer-fg: #000000;
  --footer-link: #003b70;
}

@media (prefers-color-scheme: dark) {
  :root[data-contrast="high"] {
    color-scheme: dark;
    --bg: #000000;
    --fg: #ffffff;
    --muted: #ffffff;
    --surface: #000000;
    --border: #ffffff;
    --accent: #b8e8ff;
    --accent-fg: #000000;
    --focus: #fff200;
    --provisional: #ffffff;
    --line: #ffffff;
    --line-strong: #ffffff;
    --paper: #000000;
    --mist: #000000;
    --mist-deep: #000000;
    --soot: #ffffff;
    --soot-soft: #ffffff;
    --air: #b8e8ff;
    --heat: #ffd0c7;
    --canopy: #c8f3e5;
    --map-land: #000000;
    --map-line: #ffffff;
    --footer-bg: #000000;
    --footer-fg: #ffffff;
    --footer-link: #b8e8ff;
  }
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 1rem;
}

body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.5;
}

:where(h1, h2, h3, h4, h5) {
  font-family: var(--font-display);
  font-weight: 650;
  line-height: 1.2;
  text-wrap: balance;
}

:where(p, li, dd) {
  text-wrap: pretty;
}

:where(button, select, input) {
  font-family: inherit;
}

:where(button:not(.cell):not(.linklike)) {
  min-height: 2.45rem;
}

:where(.cell, .linklike, summary) {
  min-block-size: 1.5rem;
}

:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 0.2rem solid var(--focus);
  outline-offset: 0.15rem;
}

a {
  color: var(--accent);
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.15em;
}

a:hover {
  text-decoration-thickness: 0.14em;
}

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

.skip-link {
  z-index: 100;
  border-radius: 0;
  box-shadow: none;
}

/* Header */

body > header {
  max-width: none;
  padding: 0.9rem max(1rem, calc((100vw - var(--max-width)) / 2));
  align-items: center;
  gap: 0.75rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.brand {
  flex: 1 1 15rem;
  min-width: 0;
}

h1 {
  color: var(--fg);
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand-mode {
  margin-inline-start: 0.35rem;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0;
}

.tagline {
  margin-top: 0.2rem;
  color: var(--muted);
  font-size: 0.82rem;
}

.observatory-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem 0.8rem;
  align-items: center;
}

.observatory-nav a {
  padding: 0.3rem 0;
  color: var(--muted);
  font-size: 0.86rem;
  text-decoration: none;
}

.observatory-nav a:hover,
.observatory-nav a[aria-current="true"],
.observatory-nav a[aria-current="page"] {
  color: var(--fg);
  text-decoration: underline;
  text-underline-offset: 0.25rem;
}

.header-controls {
  margin-inline-start: auto;
  gap: 0.6rem;
  align-items: end;
}

.header-controls :where(.units, .display, .lang) {
  gap: 0.25rem;
  color: var(--muted);
  font-size: 0.72rem;
}

.header-controls :where(button, select) {
  min-height: 2.15rem;
  padding: 0.28rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--surface);
  color: var(--fg);
  box-shadow: none;
  font-size: 0.78rem;
}

.header-controls button:hover {
  border-color: var(--fg);
}

.header-controls button[aria-pressed="true"] {
  border-color: var(--fg);
  background: var(--fg);
  color: var(--surface);
}

/* Main content */

main {
  width: min(100%, var(--max-width));
  padding: 1.75rem clamp(0.9rem, 2vw, 2rem) 4rem;
}

.section-kicker {
  margin: 0 0 0.35rem;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.offline,
.headline {
  border-radius: var(--radius-xs);
  box-shadow: none;
}

.offline {
  border-inline-start-color: var(--heat);
  background: var(--heat-wash);
}

.headline {
  margin: 0.75rem 0 0;
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--border);
  border-inline-start: 0.2rem solid var(--accent);
  background: var(--surface);
  font-size: 0.9rem;
}

.data-source {
  color: var(--muted);
  font-family: var(--font-data);
  font-size: 0.72rem;
}

[dir="auto"],
.place,
.distribution-label,
.cell {
  unicode-bidi: isolate;
}

.source-switch {
  margin: 0.75rem 0 0;
}

.source-switch a {
  padding: 0.28rem 0;
  border: 0;
  border-radius: 0;
  color: var(--muted);
  font-size: 0.75rem;
  text-decoration: underline;
}

.source-switch a[aria-current="page"] {
  background: transparent;
  color: var(--fg);
  font-weight: 650;
}

/* Current reading */

.now-stage {
  position: relative;
  margin: 0 0 3.5rem;
  padding: 1.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.now-contours,
.now-signal {
  display: none;
}

.now-intro {
  max-width: 44rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
}

.now-intro > h2 {
  margin: 0;
  font-size: clamp(1.8rem, 4vw, 2.5rem);
  letter-spacing: -0.025em;
}

.now-intro > p:last-child {
  max-width: 52ch;
  margin: 0.5rem 0 0;
  color: var(--muted);
}

.now-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(20rem, 0.65fr);
  gap: 2.5rem;
  margin-top: 1.5rem;
}

.now-primary,
.now-find {
  min-width: 0;
}

.now-primary > h3 {
  max-width: 32ch;
  margin: 0;
  font-size: 1.4rem;
}

.now-reading {
  min-height: 5rem;
  margin: 1rem 0 0;
  color: var(--fg);
  font-family: var(--font-data);
  font-size: clamp(2.1rem, 5vw, 3.5rem);
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  line-height: 1.05;
  letter-spacing: -0.035em;
}

.now-status {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  min-height: 1.8rem;
  margin-top: 0.75rem;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 1.65rem;
  padding: 0.15rem 0.45rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  color: var(--fg);
  background: var(--surface);
  font-family: var(--font-data);
  font-size: 0.66rem;
  font-weight: 600;
}

.status-chip[data-state="provisional"],
.status-chip.provisional,
.now-primary[data-provisional="true"] #now-trust {
  border-style: dashed;
}

.status-chip.flagged,
.now-primary[data-flagged="true"] #now-trust {
  border-style: dotted;
  text-decoration: underline dotted;
  text-underline-offset: 0.18em;
}

.primary-link {
  font-weight: 650;
}

.now-find {
  padding-inline-start: 2rem;
  border-inline-start: 1px solid var(--border);
}

.now-find > label {
  font-size: 0.9rem;
}

.now-find .find-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.4rem;
  margin-top: 0.4rem;
}

.now-find #locate {
  width: 100%;
}

/* Inputs and controls */

.controls {
  display: grid;
  grid-template-columns: minmax(15rem, 0.45fr) minmax(24rem, 1.55fr);
  gap: 1rem;
  margin: 0;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  background: var(--surface);
  box-shadow: none;
}

.control {
  min-width: 0;
  gap: 0.35rem;
}

.control > label,
.range-controls label {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 650;
}

.control.time {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.25rem 0.75rem;
  align-items: center;
}

.control.time > label,
.control.time > input {
  grid-column: 1;
}

.control.time > output {
  grid-column: 2;
  grid-row: 1;
  text-align: end;
}

.control.time > button {
  grid-column: 2;
  grid-row: 2;
  min-width: 5.5rem;
}

:where(select, input[type="search"], input[type="number"]) {
  min-height: 2.6rem;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-xs);
  background: var(--surface);
  color: var(--fg);
}

input::placeholder {
  color: var(--muted);
  opacity: 1;
}

input[type="range"] {
  min-height: 1.75rem;
  accent-color: var(--accent);
}

#time-readout {
  color: var(--fg);
  font-family: var(--font-data);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
}

#locate,
#time-play,
#range-reset,
.detail-actions button,
.overview-actions button,
.watch-buttons button,
.settings-actions button,
.cooling-actions button,
.aa-subscribe button {
  padding: 0.45rem 0.7rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-xs);
  background: var(--surface);
  color: var(--fg);
  box-shadow: none;
  font-weight: 600;
  cursor: pointer;
}

:where(
  #locate,
  #time-play,
  #range-reset,
  .detail-actions button,
  .overview-actions button,
  .watch-buttons button,
  .settings-actions button,
  .cooling-actions button,
  .aa-subscribe button
):hover {
  border-color: var(--fg);
  background: var(--mist-deep);
}

.range-controls {
  display: grid;
  grid-template-columns: minmax(9rem, 0.7fr) auto minmax(8rem, 1fr) auto minmax(8rem, 1fr) auto;
  gap: 0.65rem 0.9rem;
  align-items: end;
  padding: 0.85rem 1rem 1rem;
  border: 1px solid var(--border);
  border-top: 0;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  background: var(--surface);
}

.range-title,
.range-readout {
  margin: 0;
}

.range-title {
  font-size: 1rem;
  font-weight: 650;
}

.range-readout,
.range-controls output {
  color: var(--muted);
  font-family: var(--font-data);
  font-size: 0.7rem;
  font-variant-numeric: tabular-nums;
}

.range-note {
  max-width: 44ch;
  margin: 0.3rem 0 0;
  color: var(--muted);
  font-size: 0.72rem;
}

/* Reading workspace */

.explore-section,
.network-section,
.method-section {
  scroll-margin-top: 1rem;
}

.network-section,
.method-section {
  margin-top: 4rem;
}

.section-heading {
  max-width: 48rem;
  margin-bottom: 1rem;
}

.section-heading > h2 {
  margin: 0;
  font-size: clamp(1.65rem, 4vw, 2.15rem);
  letter-spacing: -0.02em;
}

.section-heading > p:last-child {
  max-width: 62ch;
  margin: 0.5rem 0 0;
  color: var(--muted);
}

.workspace-shell {
  display: grid;
  grid-template-areas:
    "main inspector"
    "charts charts"
    "cooling cooling";
  grid-template-columns: minmax(36rem, 1.2fr) minmax(22rem, 0.8fr);
  gap: 1.25rem;
  align-items: start;
  margin-top: 1.25rem;
}

.workspace-shell[data-inspector="empty"] {
  grid-template-areas:
    "main inspector"
    "main charts"
    "cooling cooling";
  grid-template-columns: minmax(32rem, 0.9fr) minmax(34rem, 1.1fr);
}

.workspace-main {
  grid-area: main;
  display: grid;
  gap: 0.5rem;
  min-width: 0;
}

.linked-visuals {
  grid-area: charts;
  display: grid;
  grid-template-columns: minmax(0, 1.8fr) minmax(20rem, 0.7fr);
  gap: 1.25rem;
  align-items: stretch;
  min-width: 0;
}

.workspace-shell[data-inspector="empty"] .linked-visuals {
  grid-template-columns: minmax(0, 1fr);
  align-self: start;
}

.workspace-inspector {
  grid-area: inspector;
  position: sticky;
  top: 0.75rem;
  max-height: calc(100vh - 1.5rem);
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: none;
  scrollbar-color: var(--line-strong) transparent;
  scrollbar-width: thin;
}

.workspace-shell > .cooling {
  grid-area: cooling;
  margin: 0;
}

.workspace-inspector > .section-kicker {
  margin: 0;
  padding: 1rem 1rem 0;
}

.workspace-inspector :where(select, input) {
  min-width: 0;
  max-width: 100%;
}

.inspector-empty {
  margin: 0;
  padding: 0.75rem 1rem 1rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.workspace-inspector .detail {
  margin: 0;
  padding: 1rem;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.workspace-inspector .detail :where(h2, h3, h4) {
  margin-top: 0;
  padding-bottom: 0.65rem;
  border-bottom: 1px solid var(--border);
  font-size: 1.2rem;
}

.viz-card {
  min-width: 0;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: none;
}

.viz-heading {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1rem;
  align-items: baseline;
  justify-content: space-between;
  margin: 0 0 0.8rem;
  padding-bottom: 0.65rem;
  border-bottom: 1px solid var(--border);
}

.viz-heading :where(h2, h3, p) {
  margin: 0;
}

.viz-heading :where(h2, h3) {
  font-size: 1.1rem;
}

.viz-key,
.viz-summary,
.viz-instructions,
.viz-method-note {
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.45;
}

.viz-instructions {
  margin: 0 0 0.7rem;
}

.viz-summary {
  margin: 0.7rem 0 0;
  padding-top: 0.65rem;
  border-top: 1px solid var(--border);
}

.viz-method-note {
  margin: 0.45rem 0 0;
}

.exposure-braid,
.distribution-viz {
  position: relative;
  min-width: 0;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  scrollbar-color: var(--line-strong) transparent;
  scrollbar-width: thin;
}

.exposure-braid {
  isolation: isolate;
  min-height: 15rem;
  background: var(--surface);
}

.exposure-braid > * {
  position: relative;
  z-index: 1;
}

.exposure-braid :where(svg, canvas),
.distribution-viz :where(svg, canvas) {
  display: block;
  width: 100%;
  min-width: 38rem;
  height: auto;
  overflow: visible;
  font-family: var(--font-data);
}

.braid-axis-label,
.braid-time-label {
  fill: var(--muted);
  font-family: var(--font-data);
  font-size: 0.62rem;
  font-variant-numeric: tabular-nums;
}

.braid-axis-label,
.distribution-viz .distribution-rank {
  text-align: end;
}

.braid-time-label.end {
  text-anchor: end;
}

.braid-gridline {
  stroke: var(--border);
  stroke-width: 1;
}

.braid-line {
  fill: none;
  stroke: var(--accent);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.5;
}

.braid-pattern-bg {
  fill: var(--mist-deep);
}

.braid-pattern-line {
  stroke: var(--muted);
  stroke-width: 2;
}

.braid-cursor {
  stroke: var(--heat);
  stroke-dasharray: 4 3;
  stroke-width: 2;
}

.braid-point {
  fill: var(--surface);
  stroke: var(--accent);
  stroke-width: 2;
  cursor: pointer;
}

.braid-hit-target {
  fill: transparent;
  stroke: transparent;
  cursor: pointer;
  pointer-events: all;
}

.braid-point.provisional {
  fill: url("#braid-provisional-pattern");
  stroke-dasharray: 3 2;
}

.braid-point.active {
  stroke: var(--heat);
  stroke-width: 3;
}

.distribution-viz {
  min-height: 12rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.distribution-viz > li {
  margin: 0;
  border-bottom: 1px solid var(--border);
}

.distribution-viz > li:last-child {
  border-bottom: 0;
}

.distribution-viz > li.selected-outlier {
  margin-top: 0.6rem;
  border-top: 2px solid var(--line-strong);
}

.distribution-viz > li > button {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 0.55rem;
  align-items: center;
  width: 100%;
  min-height: 2.7rem;
  padding: 0.4rem 0.3rem;
  border: 0;
  background: transparent;
  color: var(--fg);
  text-align: start;
  cursor: pointer;
}

.distribution-viz > li > button:hover,
.distribution-viz > li > button[aria-pressed="true"] {
  background: var(--mist-deep);
}

.distribution-viz .distribution-label {
  overflow: hidden;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.distribution-viz .distribution-rank,
.distribution-viz .distribution-value {
  color: var(--muted);
  font-family: var(--font-data);
  font-size: 0.68rem;
  font-variant-numeric: tabular-nums;
}

.distribution-viz .distribution-track {
  grid-column: 1 / -1;
  width: 100%;
  height: 0.55rem;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--mist-deep);
}

.distribution-viz .distribution-bar {
  display: block;
  height: 100%;
  background: var(--accent);
}

.distribution-viz li.provisional .distribution-track {
  border-style: dashed;
}

.distribution-viz li.provisional .distribution-bar {
  background-image: repeating-linear-gradient(135deg, transparent 0 4px, rgb(255 255 255 / 0.3) 4px 6px);
}

.viz-empty {
  margin: 0;
  padding: 1.5rem 0.75rem;
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
}

/* Equivalent views */

.view-switcher {
  display: flex;
  width: 100%;
  gap: 0.75rem 1rem;
  align-items: end;
  justify-content: space-between;
}

.views {
  display: inline-flex;
  width: fit-content;
  max-width: 100%;
  gap: 0;
  margin: 0;
  overflow-x: auto;
  border-bottom: 1px solid var(--border);
  background: transparent;
}

.view-switcher .status {
  flex: 1 1 auto;
  margin: 0 0 0.2rem;
  text-align: end;
}

.views [role="tab"] {
  min-width: 5rem;
  min-height: 2.45rem;
  padding: 0.42rem 0.8rem;
  border: 0;
  border-bottom: 0.2rem solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
}

.views [role="tab"][aria-selected="true"] {
  border-bottom-color: var(--accent);
  background: transparent;
  color: var(--fg);
}

.data-surface,
[role="tabpanel"] {
  min-width: 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.status {
  min-height: 1.4rem;
  margin: 0.5rem 0;
  color: var(--muted);
  font-family: var(--font-data);
  font-size: 0.72rem;
}

.hint {
  margin: 0;
  padding: 0.65rem 0.8rem;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  background: var(--surface);
  font-size: 0.78rem;
}

/* Map */

.map-wrap {
  isolation: isolate;
}

.map-wrap.statewide-map {
  width: 100%;
  max-width: min(100%, var(--statewide-map-width));
}

.map {
  height: clamp(32rem, 48vw, 46rem);
  min-height: 0;
  aspect-ratio: auto;
  border: 0;
  border-radius: 0;
  background: var(--mist-deep);
}

.map-controls {
  position: static;
  flex-direction: row;
  gap: 0.25rem;
  justify-content: flex-end;
  padding: 0.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.map-controls button {
  min-width: 2.6rem;
  min-height: 2.6rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-xs);
  color: var(--fg);
  background: var(--surface);
  box-shadow: none;
  font-family: var(--font-data);
}

.map-controls button:hover {
  border-color: var(--fg);
}

.map-controls svg {
  display: block;
  width: 1rem;
  height: 1rem;
  margin: auto;
  fill: none;
  stroke: currentcolor;
  stroke-linecap: round;
  stroke-width: 2.2;
}

.cell {
  --cell-bg: var(--surface);
  --cell-pattern: none;
  --cell-pattern-size: auto;
  isolation: isolate;
  overflow: hidden;
  width: 5.5rem;
  min-width: 3.6rem;
  min-height: 2.5rem;
  border: 0.12rem solid var(--fg);
  border-radius: var(--radius-xs);
  background-color: var(--cell-bg);
  background-image: var(--cell-pattern);
  background-size: var(--cell-pattern-size);
  color: var(--fg);
  box-shadow: none;
  font-family: var(--font-data);
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
}

.cell > :where(.cell-reading, .cell-cat) {
  display: inline-block;
  padding: 0.02rem 0.12rem;
  background: var(--surface);
  color: var(--fg);
}

.cell.aqi-good { --cell-bg: var(--aqi-good-bg); }
.cell.aqi-moderate { --cell-bg: var(--aqi-moderate-bg); }
.cell.aqi-usg { --cell-bg: var(--aqi-usg-bg); }
.cell.aqi-unhealthy { --cell-bg: var(--aqi-unhealthy-bg); }
.cell.aqi-veryunhealthy { --cell-bg: var(--aqi-very-unhealthy-bg); }
.cell.aqi-hazardous { --cell-bg: var(--aqi-hazardous-bg); }
.cell.heat-1 { --cell-bg: var(--heat-1-bg); }
.cell.heat-2 { --cell-bg: var(--heat-2-bg); }
.cell.heat-3 { --cell-bg: var(--heat-3-bg); }
.cell.heat-4 { --cell-bg: var(--heat-4-bg); }
.cell.heat-5 { --cell-bg: var(--heat-5-bg); }

.cell:is(.aqi-moderate, .heat-2) {
  --cell-pattern: radial-gradient(circle, rgb(0 0 0 / 0.32) 1px, transparent 1.2px);
  --cell-pattern-size: 6px 6px;
}

.cell:is(.aqi-usg, .heat-3) {
  --cell-pattern: repeating-linear-gradient(45deg, rgb(0 0 0 / 0.3) 0 2px, transparent 2px 6px);
}

.cell:is(.aqi-unhealthy, .heat-4) {
  --cell-pattern: repeating-linear-gradient(-45deg, rgb(0 0 0 / 0.34) 0 2px, transparent 2px 5px);
}

.cell.aqi-veryunhealthy {
  --cell-pattern: repeating-linear-gradient(0deg, rgb(0 0 0 / 0.4) 0 2px, transparent 2px 5px);
}

.cell:is(.aqi-hazardous, .heat-5) {
  --cell-pattern: repeating-linear-gradient(90deg, rgb(0 0 0 / 0.42) 0 2px, transparent 2px 5px);
}

.cell .cell-cat {
  display: block;
  margin-top: 0.08rem;
  font-size: 0.58rem;
  text-transform: uppercase;
}

.cell.provisional {
  border-style: dashed;
  background-color: var(--mist-deep);
  --cell-pattern: repeating-linear-gradient(135deg, transparent 0 4px, var(--line-strong) 4px 7px);
}

.cell.selected {
  z-index: 4;
  outline: 0.2rem solid var(--focus);
  outline-offset: 0.2rem;
}

.map.dense .cell {
  width: 1.75rem;
  min-width: 1.75rem;
  min-height: 1.75rem;
  padding: 0.08rem;
  border-width: 0.1rem;
  border-radius: 50%;
  font-size: 0.6rem;
  line-height: 1;
}

.map.dense .cell > .cell-reading {
  padding: 0.04rem 0.08rem;
}

.map.dense .cell .cell-cat,
.map .cluster-member:not(.cluster-visible) {
  display: none;
}

.map .cluster-member.cluster-visible {
  display: block;
}

.map.dense .cluster-member.cluster-visible {
  width: 1.5rem;
  min-width: 1.5rem;
  min-height: 1.5rem;
  border-radius: 50%;
  font-size: 0.58rem;
}

.map-cluster {
  position: absolute;
  z-index: 3;
  transform: translate(-50%, 50%);
  min-width: 3rem;
  min-height: 3rem;
  padding: 0.35rem;
  border: 0.15rem solid var(--accent);
  border-radius: 50%;
  color: var(--fg);
  background: var(--surface);
  box-shadow: none;
  font-family: var(--font-data);
  font-size: 0.7rem;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  cursor: zoom-in;
}

.map-cluster:hover {
  border-color: var(--fg);
  background: var(--mist-deep);
}

.cool-center {
  color: var(--accent);
  text-shadow: 0 0 2px var(--surface);
}

/* List and table */

.readings li {
  display: grid;
  grid-template-columns: minmax(9rem, 1.4fr) minmax(7rem, 0.7fr) minmax(8rem, 1fr);
  gap: 0.4rem 0.8rem;
  align-items: baseline;
  padding: 0.75rem 0.85rem;
  border-bottom-color: var(--border);
}

.readings li:hover {
  background: var(--mist-deep);
}

.readings li.selected,
tr.selected :is(th, td) {
  background-color: var(--air-wash);
}

.readings li.selected {
  box-shadow: inset 0.2rem 0 var(--accent);
}

.readings .place {
  font-weight: 650;
  text-align: start;
}

.readings .reading {
  font-family: var(--font-data);
  font-size: 0.86rem;
}

#panel-table {
  overflow-x: auto;
}

table {
  min-width: 42rem;
  font-size: 0.88rem;
}

caption {
  padding: 0.8rem 0.9rem 0.5rem;
  color: var(--muted);
  font-size: 0.75rem;
}

thead {
  background: var(--mist-deep);
}

th,
td {
  padding: 0.7rem 0.8rem;
  border-bottom-color: var(--border);
}

th {
  color: var(--muted);
  font-size: 0.72rem;
}

tbody tr:hover td {
  background-color: var(--mist-deep);
}

td .tag {
  border-radius: var(--radius-xs);
  font-size: 0.7rem;
}

td .tag:is(
  .aqi-good,
  .aqi-moderate,
  .aqi-usg,
  .aqi-unhealthy,
  .aqi-veryunhealthy,
  .aqi-hazardous,
  .heat-1,
  .heat-2,
  .heat-3,
  .heat-4,
  .heat-5
) {
  color: var(--severity-ink);
}

td .tag.flagged {
  text-decoration: underline dotted;
  text-underline-offset: 0.18em;
}

/* Detail, network, and method */

.detail,
.overview,
.alerts,
.area-alerts,
.cooling,
.dataset-truth,
.legend,
.trust {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: none;
}

#detail-body {
  font-family: var(--font-data);
  font-size: 0.86rem;
  font-variant-numeric: tabular-nums;
}

.spark {
  margin: 0.75rem 0;
  padding: 0.6rem 0;
  border-block: 1px solid var(--border);
  color: var(--accent);
  background: transparent;
}

.spark-svg {
  width: 100%;
  max-width: 16rem;
}

.context {
  font-size: 1rem;
  font-weight: 600;
}

.trend,
.compare-result,
.watch-status,
.download-cell {
  font-family: var(--font-data);
  font-size: 0.75rem;
}

.guidance {
  padding-inline-start: 0.7rem;
  border-inline-start: 0.2rem solid var(--accent);
  font-weight: 600;
}

.action-card {
  padding: 0.75rem;
  border-color: var(--border);
  border-inline-start-color: var(--heat);
  border-radius: var(--radius-xs);
  background: var(--heat-wash);
}

.provenance {
  padding: 0.75rem 0;
  border: 0;
  border-block: 1px solid var(--border);
  border-radius: 0;
  background: transparent;
}

.provenance dl {
  grid-template-columns: minmax(5.5rem, auto) 1fr;
  gap: 0.35rem 0.75rem;
}

.provenance :where(dt, dd) {
  font-size: 0.78rem;
}

.provenance dt {
  color: var(--muted);
  font-size: 0.7rem;
}

.compare,
.watch {
  margin: 1rem 0;
  padding-top: 0.8rem;
  border-top: 1px solid var(--border);
}

.watch-heading,
.history-heading,
.action-heading {
  font-size: 1rem;
}

.watch-intro,
.action-note,
.guidance-source {
  font-size: 0.78rem;
}

.detail-actions {
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

.overview,
.alerts,
.area-alerts,
.cooling {
  margin: 1rem 0;
  padding: 1rem;
}

.network-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  align-items: start;
}

.network-grid > * {
  margin: 0;
}

.overview :where(h2, h3),
.alerts :where(h2, h3),
.area-alerts :where(h2, h3),
.cooling :where(h2, h3),
.legend :where(h2, h3) {
  margin-top: 0;
  font-size: 1.15rem;
}

.overview > p {
  margin: 0.45rem 0;
}

.overview-fresh,
.alerts-note,
.aa-intro,
.aa-note,
.cooling-intro,
.cooling-source {
  color: var(--muted);
  font-size: 0.78rem;
}

.method-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 1rem;
  align-items: start;
}

.method-grid > .dataset-truth {
  grid-column: span 4;
}

.method-grid > .legend {
  grid-column: span 8;
  margin-top: 0;
}

.method-grid > .trust {
  grid-column: 1 / -1;
}

.dataset-truth {
  margin: 0;
  padding: 1rem;
}

.dataset-truth :where(h2, h3) {
  font-size: 1.1rem;
}

.dataset-truth dt {
  color: var(--muted);
  font-size: 0.72rem;
}

.legend {
  padding: 1rem;
}

.legend :where(h2, h3) {
  padding-bottom: 0.65rem;
  border-bottom: 1px solid var(--border);
}

.legend-items {
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
  gap: 0.4rem 1rem;
}

.legend-items li {
  min-height: 2.8rem;
  font-size: 0.82rem;
}

.swatch {
  flex: 0 0 1.25rem;
  border-radius: var(--radius-xs);
}

.trust {
  margin-top: 0;
  padding: 1rem;
}

.trust > summary {
  font-size: 1rem;
}

.method-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.4rem 1.5rem;
}

.method-list li {
  font-size: 0.83rem;
}

/* Footer */

body > footer {
  max-width: none;
  padding: 2rem max(1rem, calc((100vw - var(--max-width)) / 2)) 3rem;
  border-top: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: 0.82rem;
}

body > footer a {
  color: var(--accent);
}

body > footer :where(.settings, .shortcuts) {
  max-width: 48rem;
  padding-top: 0.6rem;
  border-top: 1px solid var(--border);
}

/* Responsive */

@media (max-width: 72rem) {
  .workspace-shell {
    grid-template-columns: minmax(0, 1.2fr) minmax(18rem, 0.8fr);
  }

  .workspace-shell[data-inspector="empty"] {
    grid-template-columns: minmax(0, 1fr) minmax(19rem, 1fr);
  }

  .map {
    height: clamp(28rem, 62vw, 40rem);
  }

  .map-wrap.statewide-map {
    max-width: min(100%, 48vw, var(--statewide-map-width));
  }
}

@media (max-width: 64rem) {
  .linked-visuals {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 52rem) {
  body > header {
    align-items: start;
  }

  .observatory-nav {
    order: 3;
    flex: 1 1 100%;
  }

  .header-controls {
    flex: 1 1 100%;
    margin-inline-start: 0;
  }

  .now-grid,
  .controls,
  .network-grid {
    grid-template-columns: 1fr;
  }

  .controls {
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  }

  .now-find {
    padding: 1.25rem 0 0;
    border-top: 1px solid var(--border);
    border-inline-start: 0;
  }

  .range-controls {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .method-grid > .dataset-truth,
  .method-grid > .legend {
    grid-column: 1 / -1;
  }
}

@media (max-width: 46rem) {
  .workspace-shell,
  .workspace-shell[data-inspector="empty"] {
    grid-template-areas:
      "main"
      "inspector"
      "charts"
      "cooling";
    grid-template-columns: 1fr;
  }

  .workspace-inspector {
    position: static;
    max-height: none;
  }

  .map {
    height: clamp(24rem, 68vw, 34rem);
  }

  .map-wrap.statewide-map {
    max-width: min(100%, 64vw, 26rem, var(--statewide-map-width));
  }
}

@media (max-width: 40rem) {
  body > header,
  main,
  body > footer {
    padding-inline: 0.9rem;
  }

  .now-stage {
    padding: 1rem;
  }

  .map {
    height: clamp(24rem, 105vw, 34rem);
  }

  .map-wrap.statewide-map {
    max-width: min(100%, 92vw, 26rem, var(--statewide-map-width));
  }

  .section-heading > h2 {
    font-size: 1.6rem;
  }

  .view-switcher {
    align-items: stretch;
    flex-direction: column;
  }

  .view-switcher .status {
    text-align: start;
  }

  .readings li {
    grid-template-columns: 1fr;
  }

  .method-list {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

@media print {
  .now-stage,
  .detail,
  .legend,
  .overview {
    border: 1px solid #000000;
    background: #ffffff;
    color: #000000;
    box-shadow: none;
  }

  body > footer {
    background: #ffffff;
    color: #000000;
  }
}
