/* AquaState world layer — day/night observatory. */
:root {
  --world-ground: #081012;
  --world-surface: #0d1719;
  --world-raised: #122023;
  --world-border: #1e3034;
  --world-rule: #17272a;
  --world-text: #edf5f4;
  --world-muted: #9bb0ae;
  --world-faint: #718684;
  --world-teal: #34c9b8;
  --world-teal-ink: #072e2a;
  --world-amber: #e5a23b;
  --world-red: #ef6f72;
  --world-blue: #5ba7e8;
  --world-green: #55c98a;
  --sheet-ground: #f2f5f2;
  --sheet-surface: #ffffff;
  --sheet-ink: #14201d;
  --sheet-muted: #5b6763;
  --sheet-rule: #e3e8e4;
  --sheet-accent: #1b6c80;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body.world-body {
  background: var(--world-ground);
  color: var(--world-text);
  font-family: var(--ds-font);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
.skip-link { position: absolute; left: -999px; top: 0; background: var(--world-teal); color: var(--t-accent-ink); padding: 8px 12px; z-index: 100; }
.skip-link:focus { left: 12px; top: 12px; }
.world-topbar {
  display: flex; align-items: center; gap: 28px;
  min-height: 68px; padding: 0 32px;
  border-bottom: 1px solid var(--world-border);
  background: var(--t-bar);
  position: sticky; top: 0; z-index: 40;
  backdrop-filter: blur(10px);
}
.world-brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--world-text); }
.world-brand svg { width: 30px; height: 30px; color: var(--world-teal); }
.world-brand strong { display: block; font-size: 17px; letter-spacing: -.02em; line-height: 1.1; }
.world-brand small { display: block; font-size: 12px; color: var(--world-faint); letter-spacing: normal; }
.world-nav { display: flex; gap: 4px; margin-left: auto; }
.world-nav a { color: var(--world-muted); text-decoration: none; font-size: 13px; padding: 8px 11px; border-radius: 6px; }
.world-nav a:hover, .world-nav a:focus-visible { color: var(--world-text); background: var(--world-raised); }
.world-nav a.is-active { color: var(--world-teal); background: rgba(52, 201, 184, .08); }
.world-status { display: flex; align-items: center; gap: 7px; color: var(--world-faint); font-size: 13px; white-space: nowrap; }
.live-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--world-teal); box-shadow: 0 0 0 3px rgba(52,201,184,.12); }
.world-main { max-width: 1480px; margin: 0 auto; padding: 32px; }
.world-footer { max-width: 1480px; margin: 0 auto; padding: 22px 32px 40px; display: flex; justify-content: space-between; gap: 20px; color: var(--world-faint); font-size: 13px; border-top: 1px solid var(--world-rule); }
.world-hero { max-width: 940px; padding: 24px 0 34px; }
.world-kicker { margin: 0 0 12px; color: var(--world-teal); font-size: 13px; letter-spacing: normal; }
.world-hero h1 { margin: 0; font-size: clamp(34px, 5vw, 64px); line-height: 1.02; letter-spacing: -.04em; font-weight: 500; }
.world-hero h1 span { color: var(--world-muted); }
.world-lede { max-width: 680px; margin: 18px 0 0; color: var(--world-muted); font-size: 15px; }
.world-placeholder { border: 1px solid var(--world-border); background: var(--world-surface); border-radius: 12px; padding: 28px; color: var(--world-muted); }
.world-placeholder strong { color: var(--world-text); display: block; margin-bottom: 6px; }

/* AquaState world overview — the night observatory. */
.overview-body .world-main { padding-top: 26px; }
.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(300px, .75fr);
  gap: 28px;
  align-items: stretch;
  margin-bottom: 30px;
}
.world-hero { padding: 18px 0 8px; }
.world-hero h1 { font-size: clamp(38px, 4.7vw, 68px); }
.world-hero .world-lede { max-width: 720px; font-size: 16px; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }
.btn-live, .btn-ghost {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 38px; padding: 0 15px; border-radius: 6px;
  font: inherit; font-size: 13px; font-weight: 500; text-decoration: none;
  border: 1px solid transparent; cursor: pointer;
  transition: background .16s ease-out, border-color .16s ease-out, transform .12s ease-out;
}
.btn-live { background: var(--world-teal); color: var(--t-accent-ink); border-color: var(--world-teal); }
.btn-live:hover { background: #4bdccb; }
.btn-live:active, .btn-ghost:active { transform: scale(.98); }
.btn-live:disabled { opacity: .55; cursor: wait; }
.btn-ghost { color: var(--world-text); border-color: var(--world-border); background: transparent; }
.btn-ghost:hover { background: var(--world-raised); border-color: var(--t-border-strong); }
.hero-fineprint { margin: 16px 0 0; color: var(--world-faint); font-size: 13px; max-width: 680px; }

.global-index-card {
  border: 1px solid var(--world-border);
  background: linear-gradient(180deg, var(--t-raised) 0%, var(--t-surface) 100%);
  border-radius: 12px;
  padding: 20px 22px 18px;
  align-self: stretch;
  display: flex; flex-direction: column;
}
.card-topline { display: flex; justify-content: space-between; color: var(--world-faint); font-size: 13px; letter-spacing: normal; }
.tiny { font-size: 12px; color: var(--world-faint); letter-spacing: normal; }
.global-score { margin-top: 8px; font-size: clamp(48px, 5vw, 72px); line-height: 1; font-weight: 400; letter-spacing: -.05em; }
.global-score span { font-size: 16px; color: var(--world-faint); letter-spacing: 0; margin-left: 4px; }
.global-summary { color: var(--world-muted); font-size: 12px; margin: 12px 0 16px; }
.global-facts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; margin: auto 0 14px; }
.global-facts div { border-top: 1px solid var(--world-rule); padding-top: 8px; }
.global-facts dt { color: var(--world-faint); font-size: 12px; letter-spacing: normal; }
.global-facts dd { margin: 2px 0 0; font-size: 18px; font-variant-numeric: tabular-nums; }
.band-bar { display: flex; height: 6px; gap: 2px; border-radius: 3px; overflow: hidden; }
.band { display: block; min-width: 2px; }
.band-resilient { background: #55c98a; }
.band-stable { background: #4aa3a2; }
.band-watch { background: #e5a23b; }
.band-stressed { background: #e07a3f; }
.band-critical { background: #ef6f72; }
.band-labels { display: flex; justify-content: space-between; color: var(--world-faint); font-size: 12px; margin-top: 5px; }

.world-grid { display: grid; grid-template-columns: minmax(0, 1.62fr) minmax(300px, .72fr); gap: 24px; align-items: stretch; }
.map-panel, .rail-panel, .hazard-card, .cascade-panel, .source-strip {
  border: 1px solid var(--world-border);
  background: var(--world-surface);
  border-radius: 12px;
}
.map-panel { overflow: hidden; display: flex; flex-direction: column; }
.map-head { display: flex; gap: 20px; align-items: flex-start; justify-content: space-between; padding: 18px 20px 14px; }
.map-head h2, .rail-head h2 { margin: 0; font-size: 15px; font-weight: 500; letter-spacing: -.01em; }
.panel-sub { margin: 5px 0 0; color: var(--world-faint); font-size: 13px; max-width: 520px; }
.layer-controls { display: flex; flex-wrap: wrap; gap: 4px; justify-content: flex-end; }
.layer-btn {
  border: 1px solid transparent; background: transparent; color: var(--world-muted);
  border-radius: 5px; padding: 5px 8px; font: inherit; font-size: 13px; cursor: pointer;
}
.layer-btn:hover { color: var(--world-text); background: var(--world-raised); }
.layer-btn.is-active { color: var(--world-teal); background: rgba(52, 201, 184, .09); border-color: rgba(52, 201, 184, .2); }
.map-wrap { position: relative; background: var(--t-map-bg); min-height: 540px; }
.world-map { height: 540px; width: 100%; background: var(--t-map-bg); }
.world-left { display: flex; flex-direction: column; gap: 16px; }
.signals-panel { border: 1px solid var(--world-border); background: var(--world-surface); border-radius: 12px; padding: 14px 16px; }
.signals-head { display: flex; justify-content: space-between; gap: 14px; align-items: baseline; margin-bottom: 8px; }
.signals-head h2 { margin: 0; font-size: 14px; font-weight: 500; }
.signals-head span { color: var(--world-faint); font-size: 12px; }
.signals-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; }
.signal-row { display: grid; grid-template-columns: 78px 28px minmax(0, 1fr) 24px; gap: 7px; align-items: center; text-decoration: none; color: var(--world-muted); font-size: 12px; }
.signal-row:hover { color: var(--world-text); }
.signal-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.signal-country { color: var(--world-faint); font-size: 12px; }
.signal-bar { height: 4px; background: var(--t-track); border-radius: 2px; overflow: hidden; }
.signal-bar i { display: block; height: 100%; background: linear-gradient(90deg, #2b6f6a, #e5a23b 60%, #ef6f72); border-radius: 2px; }
.signal-value { text-align: right; font-variant-numeric: tabular-nums; color: var(--world-faint); }
.signals-link { display: inline-block; margin-top: 9px; color: var(--world-teal); text-decoration: none; font-size: 12px; }
.leaflet-container { background: var(--t-map-bg); font-family: inherit; }
.leaflet-control-attribution { background: var(--t-glass) !important; color: var(--t-faint) !important; font-size: 12px !important; }
.leaflet-control-attribution a { color: var(--t-muted) !important; }
.leaflet-bar a { background: var(--t-raised) !important; color: var(--t-text) !important; border-color: var(--t-border) !important; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--t-raised) !important; color: var(--t-text) !important; border: 1px solid var(--t-border-strong); }
.leaflet-popup-content { font-size: 12px; line-height: 1.4; }
.map-fallback { position: absolute; inset: 0; display: flex; flex-direction: column; gap: 6px; align-items: center; justify-content: center; color: var(--world-muted); text-align: center; padding: 30px; }
.country-card {
  position: absolute; left: 18px; bottom: 18px; z-index: 500;
  width: min(280px, calc(100% - 36px));
  background: var(--t-glass);
  border: 1px solid var(--t-border-strong); border-radius: 8px;
  padding: 12px 14px; box-shadow: 0 10px 30px rgba(0,0,0,.25);
}
.country-card strong { display: block; font-size: 14px; }
.country-card .card-score { font-size: 26px; letter-spacing: -.03em; margin: 4px 0 2px; }
.country-card p { margin: 3px 0; color: var(--world-muted); font-size: 13px; }
.country-card a { color: var(--world-teal); font-size: 13px; }
.map-foot { display: flex; justify-content: space-between; gap: 16px; align-items: center; padding: 10px 16px; border-top: 1px solid var(--world-rule); }
.legend { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; color: var(--world-muted); font-size: 12px; }
.legend-item { display: inline-flex; align-items: center; gap: 5px; }
.legend-swatch { width: 9px; height: 9px; border-radius: 2px; display: inline-block; }
.map-source { color: var(--world-faint); font-size: 12px; text-align: right; white-space: nowrap; }

.world-rail { display: flex; flex-direction: column; gap: 18px; }
.rail-panel { padding: 16px; }
.rail-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.rail-switch { display: flex; gap: 2px; background: var(--world-raised); border-radius: 5px; padding: 2px; }
.rail-switch button { border: 0; background: transparent; color: var(--world-faint); font: inherit; font-size: 12px; padding: 4px 7px; border-radius: 4px; cursor: pointer; }
.rail-switch button.is-active { color: var(--world-text); background: var(--t-raised-2); }
.rank-list { display: flex; flex-direction: column; }
.rank-row { display: grid; grid-template-columns: 26px minmax(0, 1fr) auto 7px; gap: 8px; align-items: center; padding: 6px 2px; border-bottom: 1px solid var(--world-rule); text-decoration: none; color: var(--world-text); }
.rank-row:last-child { border-bottom: 0; }
.rank-row:hover { background: rgba(255,255,255,.025); }
.rank-num { color: var(--world-faint); font-size: 12px; font-variant-numeric: tabular-nums; }
.rank-name { font-size: 12px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-name small { display: block; color: var(--world-faint); font-size: 12px; margin-top: 1px; }
.rank-score { font-size: 12px; font-variant-numeric: tabular-nums; }
.status-dot { width: 6px; height: 6px; border-radius: 50%; display: inline-block; }
.status-resilient { background: #55c98a; }
.status-stable { background: #4aa3a2; }
.status-watch { background: #e5a23b; }
.status-stressed { background: #e07a3f; }
.status-critical { background: #ef6f72; }
.status-no_data { background: var(--t-nodata); }
.rail-link { display: inline-block; margin-top: 10px; color: var(--world-teal); text-decoration: none; font-size: 13px; }
.rail-link:hover { text-decoration: underline; }
.event-list { display: flex; flex-direction: column; }
.event-row { display: grid; grid-template-columns: 7px minmax(0, 1fr) auto; gap: 8px; align-items: start; padding: 6px 0; border-bottom: 1px solid var(--world-rule); }
.event-row:last-child { border-bottom: 0; }
.event-dot { width: 6px; height: 6px; border-radius: 50%; margin-top: 4px; }
.event-drought { background: #e5a23b; }
.event-floods { background: #5ba7e8; }
.event-wildfires { background: #ef6f72; }
.event-dustHaze { background: #b18a5c; }
.event-tempExtremes { background: #c084fc; }
.event-title { font-size: 13px; color: var(--world-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.event-country { font-size: 12px; color: var(--world-faint); }
.empty-inline { color: var(--world-faint); font-size: 13px; margin: 8px 0; }

.hazard-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-top: 24px; }
.hazard-card { padding: 17px; text-decoration: none; color: var(--world-text); transition: border-color .16s ease-out, transform .12s ease-out; }
.hazard-card:hover { border-color: var(--t-border-strong); transform: translateY(-1px); }
.hazard-head { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.hazard-label { font-size: 14px; font-weight: 500; }
.hazard-arabic { font-size: 13px; color: var(--world-faint); }
.hazard-value { margin: 12px 0 4px; font-size: 34px; letter-spacing: -.04em; font-variant-numeric: tabular-nums; }
.hazard-value span { font-size: 12px; color: var(--world-faint); letter-spacing: 0; margin-left: 4px; }
.hazard-card p { color: var(--world-muted); font-size: 13px; min-height: 32px; margin: 0 0 12px; }
.hazard-foot { display: flex; justify-content: space-between; color: var(--world-faint); font-size: 12px; border-top: 1px solid var(--world-rule); padding-top: 9px; }

.cascade-panel { display: grid; grid-template-columns: minmax(0, .9fr) minmax(0, 1.4fr); gap: 28px; margin-top: 24px; padding: 24px; }
.cascade-copy h2 { margin: 0 0 8px; font-size: 24px; letter-spacing: -.03em; font-weight: 500; }
.cascade-copy p { color: var(--world-muted); font-size: 12px; max-width: 520px; }
.cascade-steps { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.cascade-step { flex: 1; min-width: 0; border-left: 1px solid var(--world-border); padding-left: 10px; }
.cascade-step span { display: block; color: var(--world-teal); font-size: 12px; margin-bottom: 8px; }
.cascade-step strong { display: block; font-size: 13px; font-weight: 500; }
.cascade-step small { display: block; color: var(--world-faint); font-size: 12px; margin-top: 3px; }
.cascade-arrow { color: var(--t-border-strong); font-size: 16px; }

.source-strip { margin-top: 24px; padding: 20px; }
.source-strip-head { display: flex; justify-content: space-between; gap: 20px; align-items: baseline; margin-bottom: 12px; }
.source-strip-head h2 { margin: 0; font-size: 15px; font-weight: 500; }
.source-strip-head span { color: var(--world-faint); font-size: 12px; }
.source-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.source-item { border-top: 1px solid var(--world-rule); padding-top: 9px; min-width: 0; }
.source-item strong { display: block; font-size: 13px; margin: 4px 0 2px; }
.source-item span { display: block; color: var(--world-faint); font-size: 12px; }
.source-kind { display: inline-block !important; width: fit-content; padding: 1px 5px; border-radius: 3px; font-size: 12px !important; letter-spacing: normal; }
.source-live { color: #55c98a !important; background: rgba(85,201,138,.1); }
.source-error { color: #ef6f72 !important; background: rgba(239,111,114,.1); }
.source-cached { color: #e5a23b !important; background: rgba(229,162,59,.1); }
.source-records { color: var(--world-muted) !important; }
.source-note { color: var(--world-faint); font-size: 12px; margin: 14px 0 0; max-width: 1000px; }

@media (max-width: 1180px) {
  .hero-grid, .world-grid, .cascade-panel { grid-template-columns: 1fr; }
  .world-rail { display: grid; grid-template-columns: 1fr 1fr; }
  .hazard-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .source-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  html, body { overflow-x: hidden; }
  .world-main { width: 100%; overflow-x: clip; }
  .world-topbar { overflow-x: clip; flex-wrap: wrap; }
  .world-brand { min-width: 0; }
  .world-nav { flex-wrap: wrap; width: 100%; margin-left: 0; overflow-x: visible; }
  .world-nav a { flex: 1 1 auto; text-align: center; }
  .world-status { display: none; }
  .hero-grid, .world-grid, .world-left, .world-rail, .cascade-panel, .hazard-grid, .source-grid { min-width: 0; }
  .global-index-card, .map-panel, .rail-panel, .signals-panel, .hazard-card, .source-strip { min-width: 0; max-width: 100%; }
  .world-hero h1 { font-size: 30px; max-width: 100%; overflow-wrap: anywhere; }
  .world-hero .world-lede { font-size: 14px; }
  .layer-controls { max-width: 100%; }
  .map-wrap { flex: none; min-height: 420px; }
  .world-map { height: 420px; min-height: 420px; }
  .map-head { flex-direction: column; }
  .layer-controls { justify-content: flex-start; }
  .world-rail { grid-template-columns: 1fr; }
  .hazard-grid { grid-template-columns: 1fr; }
  .source-grid { grid-template-columns: 1fr 1fr; }
  .cascade-steps { flex-wrap: wrap; }
  .cascade-step { flex-basis: 42%; }
  .cascade-arrow { display: none; }
  .map-foot { flex-direction: column; align-items: flex-start; }
  .map-source { white-space: normal; }
  .global-score { font-size: 56px; }
}
