/* Firebreak — black editorial chrome. Near-black surfaces, white type with tight
   tracking on the big things, one orange accent for actions, green only for
   "saved". No monospace; numbers are tabular sans. The fire stays the loudest
   thing on screen. */
:root {
  --bg: #000; --panel: #0a0a0a; --panel-2: #141414;
  --ink: #fff; --muted: #8f8f8f; --dim: #5a5a5a;
  --line: rgba(255, 255, 255, 0.1);
  --accent: #ff4d00; --accent-ink: #0a0a0a;
  --green: #3ddc84; --red: #ff3b3b; --fire: #ff7a1a;
  --sans: Inter, "Inter Variable", ui-sans-serif, system-ui, -apple-system, "Segoe UI",
          Helvetica, Arial, sans-serif;
  --panel-w: 392px;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overflow: hidden; }
body {
  background: var(--bg); color: var(--ink); font-family: var(--sans);
  font-size: 13px; line-height: 1.45; font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; }

#map { position: absolute; inset: 0 var(--panel-w) 0 0; background: var(--bg); }

/* ---- right panel ---- */
#panel {
  position: absolute; top: 0; right: 0; bottom: 0; width: var(--panel-w);
  padding: 22px 22px 14px; display: flex; flex-direction: column; gap: 16px;
  overflow-y: auto; background: var(--panel); border-left: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 9px; }
.brand-mark { width: 10px; height: 10px; background: var(--accent); border-radius: 2px; flex: 0 0 auto; }
#panel h1 { margin: 0; font-size: 20px; font-weight: 600; letter-spacing: -.03em; }
#story { margin: 10px 0 0; font-size: 13.5px; line-height: 1.5; color: var(--muted); letter-spacing: -.005em; }

/* town selector, top-left of the map */
#town-select {
  position: absolute; left: 14px; top: 14px; z-index: 1300;
  background: rgba(10, 10, 10, .9); color: var(--ink);
  border: 1px solid var(--line); border-radius: 6px;
  font: 500 12.5px/1.2 var(--sans); letter-spacing: -.01em;
  padding: 8px 12px; cursor: pointer;
}
#town-select:hover { border-color: rgba(255, 255, 255, .3); }
#town-select[hidden] { display: none; }
body.intro #town-select { display: none; }
body.has-towns #caption { top: 58px; }
body.has-towns .leaflet-top.leaflet-left { top: 44px; }

/* walkthrough caption card: top-left over the map */
#caption {
  position: absolute; left: 14px; top: 14px; z-index: 1200; max-width: 420px;
  padding: 16px 18px 14px; background: rgba(10, 10, 10, .92); border-radius: 8px;
  border: 1px solid var(--line); border-left: 3px solid var(--accent);
}
#caption[hidden] { display: none; }
#caption-text { margin: 0; font-size: 15px; line-height: 1.5; color: var(--ink); letter-spacing: -.01em; }
#caption-btn {
  margin-top: 14px; padding: 10px 16px; cursor: pointer; display: block;
  background: var(--accent); border: none; border-radius: 6px;
  color: var(--accent-ink); font-size: 13.5px; font-weight: 600; letter-spacing: -.01em;
}
#caption-btn:hover { background: #ff6a2b; }
#caption-btn[hidden] { display: none; }
#caption-skip {
  margin-top: 10px; padding: 0; display: block; cursor: pointer;
  background: none; border: none; color: var(--muted); font-size: 12px;
}
#caption-skip:hover { color: var(--ink); }
body.intro #caption, body.intro #point-arrow { display: none; }

/* arrow pointing at the budget slider (pick state) */
/* lives inside the budget block, so it follows the slider when the panel scrolls */
#budget-block { position: relative; }
#point-arrow {
  position: absolute; left: -19px; top: 34px; z-index: 5; color: var(--accent);
  font-size: 19px; line-height: 1; animation: nudge 1.2s ease-in-out infinite;
}
#point-arrow[hidden] { display: none; }
@keyframes nudge { 0%, 100% { transform: translateX(0); } 50% { transform: translateX(8px); } }

/* section labels */
.control-head {
  display: flex; justify-content: space-between; align-items: baseline; gap: 10px;
  font-size: 11.5px; font-weight: 500; text-transform: uppercase; letter-spacing: .08em; color: var(--muted);
}
.control-value { color: var(--ink); font-weight: 500; text-transform: none; letter-spacing: 0; font-size: 12.5px; }
.control, #saved-block, #more { border-top: 1px solid var(--line); padding-top: 14px; }

/* plan toggle — segmented control */
#plan-block[hidden] { display: none; }
.seg {
  display: grid; grid-template-columns: 1fr 1fr; gap: 3px; margin-top: 10px;
  padding: 3px; background: var(--panel-2); border-radius: 8px;
}
.seg button {
  padding: 9px 8px; cursor: pointer; border: none; border-radius: 6px;
  background: none; color: var(--muted); font-size: 12.5px; font-weight: 500; letter-spacing: -.01em;
}
.seg button:hover { color: var(--ink); }
.seg button[aria-selected="true"] { background: var(--ink); color: #000; }
#plan-note { margin: 10px 0 0; font-size: 12.5px; line-height: 1.5; color: var(--muted); }

/* the one big number */
.stat-value {
  font-size: 64px; font-weight: 600; line-height: 1; letter-spacing: -.05em; margin: 8px 0 6px;
}
#stat-sub { margin: 0; font-size: 12.5px; color: var(--muted); }
#stat-line { margin: 10px 0 0; font-size: 12.5px; color: var(--ink); }
#more > summary { cursor: pointer; color: var(--muted); font-size: 12.5px; font-weight: 500; list-style: none; }
#more > summary::before { content: '+'; display: inline-block; width: 16px; color: var(--accent); }
#more[open] > summary::before { content: '\2013'; }
#more > section, #more > details { margin-top: 14px; }
#more footer { margin-top: 14px; }

/* waffle */
#waffle { display: block; margin-top: 12px; }
#waffle-legend { display: flex; gap: 14px; margin-top: 8px; font-size: 11px; color: var(--muted); }
#waffle-legend span { display: flex; align-items: center; gap: 6px; }
.sw { width: 9px; height: 9px; display: inline-block; border-radius: 1px; }
.sw-grey { background: rgba(154, 159, 166, .35); }
.sw-red { background: var(--red); }
.sw-saved { background: rgba(154, 159, 166, .5); outline: 1px solid var(--green); }

/* sliders */
input[type=range] {
  -webkit-appearance: none; appearance: none; width: 100%; height: 22px;
  margin: 10px 0 2px; background: none; cursor: pointer;
}
input[type=range]::-webkit-slider-runnable-track { height: 2px; background: rgba(255, 255, 255, 0.18); border-radius: 1px; }
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 16px; height: 16px; margin-top: -7px;
  background: var(--ink); border: none; border-radius: 50%;
}
input[type=range]::-moz-range-track { height: 2px; background: rgba(255, 255, 255, 0.18); }
input[type=range]::-moz-range-thumb { width: 16px; height: 16px; background: var(--ink); border: none; border-radius: 50%; }
#budget::-webkit-slider-thumb { background: var(--accent); }
#budget::-moz-range-thumb { background: var(--accent); }
#time::-webkit-slider-thumb { background: var(--fire); }
#time::-moz-range-thumb { background: var(--fire); }
#time { margin: 0; }
#budget-value { font-size: 15px; font-weight: 600; letter-spacing: -.02em; }

.ticks { position: relative; height: 14px; font-size: 10.5px; color: var(--dim); }
.ticks span { position: absolute; top: 2px; transform: translateX(-50%); }
.ticks span::before {
  content: ''; position: absolute; left: 50%; top: -9px;
  width: 1px; height: 4px; background: rgba(255, 255, 255, 0.25);
}
.ticks span:first-child { transform: none; }
.ticks span:first-child::before { left: 0; }
.ticks span:last-child { transform: translateX(-100%); }
.ticks span:last-child::before { left: 100%; }
#budget-readout { margin-top: 8px; font-size: 12.5px; color: var(--muted); }

.time-row { display: flex; gap: 10px; align-items: center; margin-top: 8px; }
#play {
  width: 36px; height: 30px; flex: 0 0 auto; font-size: 12px; line-height: 1;
  background: var(--panel-2); color: var(--ink); border: 1px solid var(--line);
  border-radius: 6px; cursor: pointer;
}
#play:hover { border-color: var(--muted); }

/* buttons */
.btn {
  padding: 10px 14px; cursor: pointer; border-radius: 6px; border: 1px solid transparent;
  font-size: 13px; font-weight: 600; letter-spacing: -.01em;
}
.btn-accent { background: var(--accent); color: var(--accent-ink); }
.btn-accent:hover, body.picking .btn-accent { background: #ff6a2b; }
.btn-ghost { background: none; border-color: var(--line); color: var(--muted); font-weight: 500; }
.btn-ghost:hover { color: var(--ink); border-color: var(--muted); }

/* walkthrough dimming: controls not for the current state are dimmed, not hidden. */
body:not([data-flow="pick"]):not([data-flow="done"]):not([data-flow="free"]):not([data-flow="scenario"]) #budget-block {
  opacity: .35; pointer-events: none;
}
body:not([data-flow="free"]):not([data-flow="scenario"]) #time-block,
body:not([data-flow="free"]):not([data-flow="scenario"]) #explore,
body:not([data-flow="done"]):not([data-flow="free"]):not([data-flow="scenario"]) #plan-block {
  opacity: .35; pointer-events: none;
}

/* what-if: ignite anywhere + wind */
#scenario-block[hidden] { display: none; }
.scenario-row { display: flex; gap: 8px; margin-top: 12px; }
#ignite-btn { flex: 1; }
#scenario-reset[hidden] { display: none; }
.control-head.sub { margin-top: 12px; font-size: 10.5px; }
#wind-speed, #wind-dir { margin: 4px 0 0; }
#scenario-note { margin: 10px 0 0; font-size: 12.5px; line-height: 1.5; color: var(--muted); }
body.picking #map { cursor: crosshair; }
body.picking .leaflet-grab, body.picking .leaflet-interactive { cursor: crosshair; }

/* curve (inline SVG) */
#curve { width: 100%; height: auto; display: block; margin-top: 8px; }
.curve-line { fill: none; stroke: var(--green); stroke-width: 1.5; stroke-linejoin: round; }
#curve .grid { stroke: rgba(255, 255, 255, 0.06); stroke-dasharray: 1 3; }
#curve .axis { stroke: rgba(255, 255, 255, 0.14); }
#curve .lbl { fill: var(--muted); font-size: 9px; font-family: var(--sans); }
#curve .mark { stroke: rgba(255, 255, 255, .4); stroke-dasharray: 3 3; }
#curve-dot { fill: var(--accent); stroke: var(--panel); stroke-width: 2; }

#explore, #simplifications { border-top: 1px solid var(--line); padding-top: 12px; }
#explore summary, #simplifications summary {
  cursor: pointer; color: var(--muted); font-size: 11.5px; font-weight: 500;
  text-transform: uppercase; letter-spacing: .08em;
}
#curve-sentence { margin: 8px 0 0; font-size: 12.5px; color: var(--ink); }
#simp-list {
  margin: 8px 0 0; padding-left: 17px; font-size: 12.5px; color: var(--muted);
  line-height: 1.5; max-height: 160px; overflow-y: auto;
}

footer {
  margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line);
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  font-size: 11px; color: var(--dim);
}
#sound { padding: 5px 9px; font-size: 11px; }

/* ---- map overlays ---- */
#legend {
  position: absolute; left: 14px; bottom: 14px; z-index: 1000;
  display: flex; gap: 10px; padding: 7px 10px; font-size: 11px; color: var(--muted);
  background: rgba(10, 10, 10, .9); border: 1px solid var(--line); border-radius: 6px;
}
#legend[hidden] { display: none; }
.chip { display: flex; align-items: center; gap: 5px; }
.chip i { width: 9px; height: 9px; border-radius: 1px; }

#break-tip {
  position: absolute; z-index: 1500; pointer-events: none;
  padding: 6px 10px; font-size: 12px; white-space: nowrap;
  background: rgba(10, 10, 10, .94); color: var(--ink);
  border: 1px solid var(--line); border-radius: 6px;
}
#break-tip[hidden] { display: none; }

.fire-canvas { image-rendering: pixelated; filter: blur(1.2px); }
.glow-canvas { mix-blend-mode: screen; }
.fire-canvas, .glow-canvas, .houses-canvas, .ghost-canvas { pointer-events: none; }

/* satellite dimmed so the fire is the only saturated thing on screen —
   except during the intro, where the map sits undimmed and still */
.leaflet-tile { filter: brightness(0.72) saturate(0.8); transition: filter .8s ease; }
body.intro .leaflet-tile { filter: brightness(0.55) saturate(0.7); }
body.intro #map { inset: 0; }
body.intro #panel, body.intro #legend { display: none; }
body.intro .leaflet-control-container, body.intro .ign { display: none; }

/* ---- intro title card: editorial, bottom-left ---- */
#intro {
  position: fixed; inset: 0; z-index: 2000; cursor: pointer;
  display: flex; align-items: flex-end; justify-content: flex-start;
  padding: 0 0 7vh 5vw; opacity: 1; transition: opacity .6s ease;
  background: linear-gradient(180deg, rgba(0, 0, 0, .1) 0%, rgba(0, 0, 0, .75) 100%);
}
#intro.gone { opacity: 0; pointer-events: none; }
#intro-inner { max-width: 1100px; }
#intro .eyebrow {
  margin: 0 0 6px; color: var(--accent); font-size: 13px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .12em;
}
#intro h1 {
  margin: 0; color: #fff; font-weight: 600;
  font-size: clamp(88px, 15vw, 220px); line-height: .92; letter-spacing: -.06em;
  text-shadow: 0 2px 32px rgba(0, 0, 0, .7);
}
#intro-sub {
  margin: 22px 0 0; max-width: 620px; color: #e6e6e6; font-size: clamp(16px, 1.6vw, 22px);
  line-height: 1.35; letter-spacing: -.02em; text-shadow: 0 1px 12px rgba(0, 0, 0, .9);
}
#intro-run {
  margin-top: 30px; padding: 14px 26px; cursor: pointer;
  background: var(--accent); color: var(--accent-ink);
  border: none; border-radius: 6px; font: 600 15px/1 var(--sans); letter-spacing: -.01em;
}
#intro-run:hover { background: #ff6a2b; }

/* ignition marker: amber dot, 2 s pulse */
.ign { pointer-events: none; }
.ign-dot {
  position: absolute; left: -4px; top: -4px; width: 8px; height: 8px;
  border-radius: 50%; background: #ffd166;
}
.ign-dot::after {
  content: ''; position: absolute; inset: -2px; border-radius: 50%;
  border: 1px solid rgba(255, 209, 102, .9);
  animation: ign-pulse 2s ease-out infinite;
}
@keyframes ign-pulse {
  0% { transform: scale(1); opacity: .9; }
  100% { transform: scale(3.2); opacity: 0; }
}
.ign-label {
  position: absolute; left: 10px; top: -8px; white-space: nowrap;
  font: 500 11.5px/16px var(--sans); letter-spacing: -.01em; color: var(--ink);
  text-shadow: 0 0 4px rgba(0, 0, 0, .9), 0 0 12px rgba(0, 0, 0, .9);
}

/* dark-quiet Leaflet chrome */
.leaflet-container { background: var(--bg); font-family: var(--sans); }
.leaflet-bar { box-shadow: none; border: 1px solid var(--line) !important; border-radius: 6px; }
.leaflet-bar a {
  background: var(--panel); color: var(--ink);
  border-bottom: 1px solid var(--line);
}
.leaflet-bar a:hover, .leaflet-bar a:focus { background: var(--panel-2); }
.leaflet-bar a.leaflet-disabled { background: var(--panel); color: #4a4f58; }
.leaflet-control-attribution {
  background: rgba(10, 10, 10, .7); color: var(--dim);
  font-size: 10px;
}
.leaflet-control-attribution a { color: var(--dim); }

/* Reset view: under the zoom control */
.reset-view {
  display: block; margin-top: 6px; padding: 6px 9px; cursor: pointer;
  background: rgba(10, 10, 10, .9); color: var(--ink);
  border: 1px solid var(--line); border-radius: 6px;
  font: 500 11px/1 var(--sans); letter-spacing: -.01em;
}
.reset-view:hover { border-color: rgba(255, 255, 255, .3); }

#next-note { margin: 10px 0 0; font-size: 12px; color: var(--dim); }
