:root {
  /* Neutrals deliberately off the Tailwind stone ramp: a warmer, deeper cast so
     it reads as instrument housing rather than a default dashboard. */
  --bg: #0d0c0b;
  --panel: #16130f;
  --border: #2b2620;
  --text: #ece6da;
  --muted: #938a7c;
  --faint: #6a6154;
  --accent: #fb923c; /* ties to the plume and fire markers on the map */
  --mono: "SFMono-Regular", "SF Mono", "Cascadia Mono", "JetBrains Mono", Consolas, "Liberation Mono", monospace;
  --sans: system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  display: flex;
  height: 100vh;
  overflow: hidden;
}

#map {
  flex: 1;
  height: 100%;
  background: var(--bg);
}

#panel {
  width: 344px;
  flex-shrink: 0;
  padding: 22px 22px 26px;
  overflow-y: auto;
  background: var(--panel);
  border-left: 1px solid var(--border);
}

h1 {
  margin: 0;
  /* Serif headline: the strongest single signal away from the all-sans default,
     and it suits the scientific-instrument register. */
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 600;
  font-size: 27px;
  letter-spacing: -0.01em;
  line-height: 1.05;
}

.tagline {
  margin: 8px 0 18px;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.55;
  max-width: 30ch;
}

.control {
  margin-bottom: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* Uppercase, tracked, monospace: an instrument label, not a form field. */
.control label,
.control-label {
  display: block;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin-bottom: 10px;
  color: var(--faint);
}

.control-label { color: var(--muted); }

.segmented {
  display: flex;
  gap: 0;
  border: 1px solid var(--border);
}

.segmented button {
  flex: 1;
  padding: 8px 4px;
  background: transparent;
  border: 0;
  border-right: 1px solid var(--border);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: color 0.12s, background 0.12s;
}

.segmented button:last-child { border-right: 0; }
.segmented button:hover { color: var(--text); }

.segmented button.active {
  background: var(--accent);
  color: #16130f;
  font-weight: 600;
}

.hint {
  margin: 9px 0 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.45;
}

.time-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

#play {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font-size: 9px;
  cursor: pointer;
  transition: border-color 0.12s, color 0.12s;
}

#play:hover { border-color: var(--accent); color: var(--accent); }

#time-label {
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
}

#time { width: 100%; accent-color: var(--accent); }
#time:disabled { opacity: 0.4; }

.control label { display: block; }

.control output {
  font-family: var(--mono);
  color: var(--text);
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
  text-transform: none;
}

#hours {
  width: 100%;
  margin-top: 2px;
  accent-color: var(--accent);
}

.status {
  margin: 18px 0;
  padding: 8px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.02em;
  color: var(--muted);
}

.status.error { color: #e0623f; }

#ranking {
  list-style: none;
  counter-reset: rank;
  margin: 0 0 20px;
  padding: 0;
}

#ranking li {
  counter-increment: rank;
  display: flex;
  align-items: baseline;
  gap: 9px;
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
  cursor: pointer;
}

#ranking li:hover { color: var(--accent); }

/* Zero-padded rank, monospace: reads as a channel index on a readout. */
#ranking li::before {
  content: counter(rank, decimal-leading-zero);
  color: var(--faint);
  font-family: var(--mono);
  font-size: 10px;
  width: 18px;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

#ranking .name {
  flex: 1;
  letter-spacing: -0.005em;
}

#ranking .cigs {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

#ranking .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
  align-self: center;
}

.legend {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
  font-size: 11px;
  color: var(--muted);
  padding: 16px 0;
  border-top: 1px solid var(--border);
}

.swatch {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
  margin-left: 6px;
}

.legend-title {
  display: block;
  width: 100%;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--faint);
  margin-bottom: 6px;
}

.github-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-top: 14px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-decoration: none;
}

/* The mark is fill="currentColor", so it warms up with the text. */
.github-link:hover { color: var(--accent); }

/* Pinned to the map's bottom-left corner via L.Control, the way a compass rose
   sits on a chart. It floats over a dark basemap, so it carries its own panel. */
.map-legend {
  background: rgba(22, 19, 15, 0.86);
  border: 1px solid var(--border);
  padding: 7px 8px;
  backdrop-filter: blur(3px);
  font-family: var(--mono);
  font-size: 9px;
  color: var(--muted);
  line-height: 1.3;
}

.map-legend-title {
  display: block;
  margin-bottom: 5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--faint);
}

.map-legend img {
  display: block;
  /* GeoMet's legend graphic is a tall strip; cap it so it can't run off a short
     map pane, and keep the light plate it was drawn against. */
  max-height: min(210px, 45vh);
  width: auto;
  background: #f5f0eb;
  border-radius: 4px;
  padding: 3px;
}

/* Was a footer; it now sits under the tagline, so the spacing runs downward. */
.intro {
  margin: 0 0 20px;
  font-size: 11px;
  line-height: 1.6;
  color: var(--muted);
}

.intro p { margin: 0 0 10px; }
.intro p:last-child { margin-bottom: 0; }
.intro strong { color: var(--text); font-weight: 600; }
.caveat { color: var(--faint); }
.intro a { color: var(--accent); text-decoration: none; }
.intro a:hover { text-decoration: underline; }

/* Two translucent discs stacked concentrically. The smaller one sits inside the
   larger, so their alpha compounds toward the middle and the marker reads as a
   glowing dot. Both are absolute: Leaflet already positions the marker root, so
   they anchor to it without needing position:relative (which would break that).
   Shared by lone fires and clusters alike: a cluster is the same dot, just larger
   and carrying a count. */
.fire-icon,
.fire-orb {
  cursor: pointer;
}

.fire-halo,
.fire-core {
  position: absolute;
  border-radius: 50%;
}

.fire-halo {
  inset: 0;
  background: rgba(249, 115, 22, 0.34);
  box-shadow: 0 0 7px rgba(249, 115, 22, 0.45);
}

.fire-core {
  inset: 27%;
  background: rgba(254, 200, 110, 0.55);
}

/* Fires escaping an orb, or being pulled back into one: Leaflet positions markers
   with a transform, so transitioning that property is what carries them. */
.fire-icon.fire-flying {
  transition:
    transform var(--fire-fly, 520ms) cubic-bezier(0.22, 1, 0.36, 1),
    opacity var(--fire-fly, 520ms) ease-in;
}

.fire-icon.fire-emerging {
  animation: fire-emerge var(--fire-fly, 520ms) ease-out;
}

/* Applied after a reflow, so the opacity drop transitions instead of jumping. */
.fire-icon.fire-merging {
  opacity: 0;
}

@keyframes fire-emerge {
  0% { opacity: 0.2; }
  40% { opacity: 1; }
  100% { opacity: 1; }
}

/* The orb swelling up as the flames arrive. Opacity only — the root element's
   transform is Leaflet's. */
.fire-orb.orb-gathering {
  animation: orb-gather var(--fire-fly, 520ms) ease-out;
}

@keyframes orb-gather {
  0% { opacity: 0; }
  55% { opacity: 0.35; }
  100% { opacity: 1; }
}

/* Leaflet already positions the marker element absolutely, so this anchors to it
   without needing position:relative (which would break that positioning). */
.fire-orb .orb-count {
  position: absolute;
  right: -1px;
  bottom: -1px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  box-sizing: border-box;
  border-radius: 8px;
  border: 1px solid var(--accent);
  background: rgba(22, 19, 15, 0.92);
  color: var(--accent);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  line-height: 14px;
  text-align: center;
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  .fire-icon.fire-flying { transition: none; }
  .fire-icon.fire-emerging { animation: none; }
  .fire-orb.orb-gathering { animation: none; }
}

.popup-title { font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.popup-cigs {
  font-family: var(--mono);
  font-size: 21px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-bottom: 2px;
}
.popup-meta { font-size: 12px; color: var(--muted); }

.popup-compare {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  font-size: 11px;
}

.compare-head {
  color: var(--muted);
  margin-bottom: 5px;
}

.compare-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 2px 0;
}

.compare-row em { font-style: normal; color: var(--faint); }
.compare-row b {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.compare-warn {
  margin-top: 6px;
  color: var(--accent);
  line-height: 1.4;
}

.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
  background: var(--panel);
  color: var(--text);
}

.leaflet-popup-content .popup-meta { color: var(--muted); }

@media (max-width: 760px) {
  body { flex-direction: column; }
  #map { height: 45vh; flex: none; }
  #panel { width: 100%; flex: 1; border-left: none; border-top: 1px solid var(--border); }
}
