/* ═══════════════════════════════════════════════════════════════════════════
   Zombie Wells Risk Map — Design System
   Adapted from reference/style.css — dark earthy Texas/southwestern palette.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Global ─────────────────────────────────────────────────────────────── */

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; }

body {
  font-family: 'IBM Plex Mono', monospace;
  background: #1A1208;
  color: #CFC3A3;
}

#map { width: 100%; height: 100%; }

::selection { background: #C9901A; color: #1A1208; }

a { color: #C9901A; transition: color 0.2s; text-decoration: none; }
a:hover { color: #C44B22; }

button:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 2px solid #C9901A;
  outline-offset: 2px;
}

/* ── Scrollbars ─────────────────────────────────────────────────────────── */

* {
  scrollbar-width: thin;
  scrollbar-color: #8A7A5A #1A1208;
}
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: #1A1208; }
::-webkit-scrollbar-thumb { background: #8A7A5A; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #C9901A; }

/* ── Map tiles — sepia archival overlay ─────────────────────────────────── */

.leaflet-tile-pane {
  filter: sepia(1) brightness(3);
}

/* ── Leaflet zoom controls ──────────────────────────────────────────────── */

.leaflet-bar {
  border: 1px solid #6B5A3A !important;
  box-shadow: none !important;
}
.leaflet-bar a {
  box-sizing: border-box !important;
  width: 35px; height: 35px; line-height: 33px;
  background-color: #2E2010 !important;
  color: #C9901A !important;
  border-bottom: 1px solid #6B5A3A !important;
  font-family: 'IBM Plex Mono', monospace !important;
  font-weight: bold !important;
}
.leaflet-bar a:hover {
  background-color: #3A2518 !important;
  color: #C9901A !important;
}
.leaflet-bar a.leaflet-disabled {
  background-color: #1A1208 !important;
  color: #3A2518 !important;
}

/* Desktop only: move the zoom control to bottom-left so the persistent logo
   can own the top-left corner. Left untouched on mobile — the bottom edge is
   already taken there by the legend strip. */
@media (min-width: 769px) {
  .leaflet-top.leaflet-left {
    top: auto;
    bottom: 0;
  }
  .leaflet-top.leaflet-left .leaflet-control {
    margin-top: 0;
    margin-bottom: 10px;
  }
}

/* ── Persistent brand mark (top-left desktop / top-center mobile) ───────── */

#fhLogo {
  position: absolute; top: 10px; left: 10px; z-index: 1002;
  display: inline-flex; flex-direction: column;
  font-family: 'Unbounded', sans-serif; font-weight: 700;
  line-height: 1; letter-spacing: -0.01em; text-transform: uppercase;
  text-decoration: none;
  /* Symmetric (0-offset) shadow layers only — a directional offset here
     would bleed into the stacked line above/below it on this two-line
     lockup. Layering tight AND large blur radii together gives a defined
     near-edge plus a big dense cloud, without the uneven glyph distortion
     -webkit-text-stroke caused on this bold font. */
  text-shadow: 0 0 2px #3A2518, 0 0 2px #3A2518, 0 0 8px #3A2518, 0 0 8px #3A2518, 0 0 16px #3A2518, 0 0 24px #3A2518;
}
#fhLogo:hover {
  text-shadow: 0 0 2px #6B5A3A, 0 0 2px #6B5A3A, 0 0 8px #6B5A3A, 0 0 8px #6B5A3A, 0 0 16px #6B5A3A, 0 0 24px #6B5A3A;
}
#fhLogo .fh-logo-l1 { color: #CFC3A3; font-size: 36px; }
#fhLogo .fh-logo-l2 { color: #C9901A; font-size: 36px; }

/* ── Address search ─────────────────────────────────────────────────────── */

#searchBox {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
  z-index: 1003; width: 360px; max-width: 70vw;
}
#searchInput {
  width: 100%; padding: 10px 16px; border-radius: 8px;
  background: rgba(46, 32, 16, 0.95); border: 1px solid #3A2518;
  color: #CFC3A3; font-family: 'IBM Plex Mono', monospace;
  font-size: 0.9em; outline: none; transition: border-color 0.2s;
}
#searchInput:focus { border-color: #C9901A; }
#searchInput::placeholder { color: #CFC3A3; font-size: 0.95em; }

#searchResults {
  display: none; margin-top: 4px;
  background: rgba(46, 32, 16, 0.97); border: 1px solid #3A2518;
  border-radius: 8px; overflow: hidden; max-height: 340px; overflow-y: auto;
}
#searchResults.has-results { display: block; }

.sr-item {
  padding: 8px 14px; cursor: pointer; border-bottom: 1px solid #3A2518;
  font-family: 'IBM Plex Mono', monospace; font-size: 0.75em; color: #CFC3A3;
  transition: background 0.15s;
}
.sr-item:last-child { border-bottom: none; }
.sr-item:hover, .sr-item.active { background: #3A2518; }
.sr-item .sr-name { font-weight: 600; color: #C9901A; }
.sr-item .sr-detail { font-size: 0.85em; color: #6B5A3A; margin-top: 1px; }

/* ── Legend ─────────────────────────────────────────────────────────────── */

#legend {
  position: absolute; bottom: 30px; right: 12px;
  background: rgba(26, 18, 8, 0.95);
  border: 1px solid #3A2518;
  padding: 12px 14px; border-radius: 8px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.75em; letter-spacing: 0.05em;
  z-index: 1000; pointer-events: none;
  color: #CFC3A3;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}
#legend .legend-title {
  font-weight: 600; font-size: 0.8em;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: #C9901A; margin-bottom: 6px;
  font-family: 'IBM Plex Mono', monospace;
}
#legend .row { display: flex; align-items: center; gap: 6px; margin: 3px 0; }
#legend .dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
#legend .bar {
  width: 180px; height: 10px; border-radius: 4px; margin: 6px 0;
}
#legend .labels {
  display: flex; justify-content: space-between;
  font-size: 0.7em; color: #6B5A3A; letter-spacing: 0.08em;
}
#legendClose, #legendBtn { display: none; }

/* ── Help button ────────────────────────────────────────────────────────── */

#helpBtn {
  position: absolute; top: 12px; right: 12px;
  width: 32px; height: 32px; border-radius: 4px;
  background: #2E2010; color: #C9901A;
  border: 1px solid #6B5A3A; font-size: 18px;
  font-family: 'IBM Plex Mono', monospace; font-weight: 600;
  cursor: pointer; z-index: 1002;
  line-height: 30px; text-align: center;
  transition: all 0.2s;
}
#helpBtn:hover {
  background: #3A2518;
  color: #C9901A;
  border-color: #C9901A;
}

/* ── Search toggle (mobile only) ────────────────────────────────────────── */

#searchToggle {
  display: none;
  position: absolute; top: 12px; right: 12px;
  width: 32px; height: 32px; border-radius: 4px;
  background: #2E2010; color: #C9901A;
  border: 1px solid #6B5A3A; font-size: 16px;
  font-family: 'IBM Plex Mono', monospace;
  cursor: pointer; z-index: 1002;
  line-height: 30px; text-align: center;
  padding: 0; transition: all 0.2s;
}
#searchToggle:hover, #searchToggle.open {
  background: #3A2518; border-color: #C9901A;
}

/* ── Help overlay & box ─────────────────────────────────────────────────── */

#helpOverlay {
  position: absolute; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.85);
  z-index: 2000; display: none;
  align-items: center; justify-content: center;
  padding: 20px;
}
#helpOverlay.visible { display: flex; }

#helpBox {
  background: #F2EEE3;
  border-radius: 8px;
  max-width: 680px; width: 100%; max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
  color: #1A1208;
  position: relative;
  padding: 28px 32px 24px;
  scrollbar-width: auto;
  scrollbar-color: #A89070 #D4CDB8;
}
#helpBox::-webkit-scrollbar { width: 10px; }
#helpBox::-webkit-scrollbar-track { background: #D4CDB8; }
#helpBox::-webkit-scrollbar-thumb { background: #A89070; }
#helpBox::-webkit-scrollbar-thumb:hover { background: #6B5A3A; }

#helpBox h2 {
  font-family: 'League Gothic', sans-serif; font-weight: 400;
  font-size: 2em; text-transform: uppercase; letter-spacing: 0.03em;
  color: #C44B22;
  margin: 0 0 10px; padding-bottom: 8px;
  text-align: center;
}
#helpBox h3 {
  font-family: 'League Gothic', sans-serif; font-weight: 400;
  font-size: 1.3em; text-transform: uppercase; letter-spacing: 0.03em;
  color: #C44B22;
  margin: 22px 0 8px;
}
#helpBox p, #helpBox li {
  font-family: 'Lora', serif;
  font-size: 0.92em; line-height: 1.75; color: #1A1208;
}
#helpBox p { margin: 0 0 10px; }
#helpBox p:last-child { margin-bottom: 0; }
#helpBox ul { padding-left: 20px; margin: 8px 0; font-family: 'Lora', serif; }
#helpBox li { margin-bottom: 6px; }
#helpBox ul ul { margin: 4px 0; }
#helpBox ul ul li { font-size: 0.95em; margin-bottom: 3px; }
#helpBox b { font-weight: 600; }

/* Three-stat strip. Replaces the old cream "By the numbers" cards — no card
   chrome, just hairlines, so it reads as part of the prose rather than a widget. */
#helpBox .help-stats {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px 20px;
  margin: 16px 0; padding: 14px 0;
  border-top: 1px solid #C9901A; border-bottom: 1px solid #C9901A;
}
#helpBox .help-stat {
  font-family: 'Lora', serif;
  font-size: 0.85em; line-height: 1.4; color: #4A3A28;
  text-align: center;
}
#helpBox .help-stat b {
  display: block; margin-bottom: 2px;
  font-family: 'League Gothic', sans-serif; font-weight: 400;
  font-size: 1.9em; letter-spacing: 0.02em; color: #C44B22;
}
#helpBox .help-tour-btn {
  font-family: 'IBM Plex Mono', monospace; font-size: 0.95em; font-weight: 600;
  background: #C44B22; color: #fff; border: none;
  padding: 10px 28px; border-radius: 6px;
  cursor: pointer; transition: background 0.2s;
}
#helpBox .help-tour-btn:hover { background: #A33A18; }
#helpBox .rule {
  display: inline-block; width: 10px; height: 10px;
  border-radius: 50%; margin-right: 4px;
}
#helpBox code {
  background: #D6CFB4; padding: 1px 5px; border-radius: 3px;
  font-family: 'IBM Plex Mono', monospace; font-size: 0.85em; color: #C44B22;
}
#helpBox .close {
  position: absolute; top: 10px; right: 14px;
  background: none; border: none;
  color: #CFC3A3; font-size: 24px;
  cursor: pointer; line-height: 1;
  transition: color 0.2s;
}
#helpBox .close:hover { color: #C9901A; }

/* Cancels #helpBox's own padding (line 216) for a full-bleed edge — if that
   padding changes, these margins must change to match or a gap/seam appears. */
.fh-help-banner {
  background: #C44B22;
  margin: -28px -32px 14px;
  padding: 20px 32px 16px;
  border-radius: 8px 8px 0 0;
  display: flex; flex-direction: column; align-items: center;
  font-family: 'Unbounded', sans-serif; font-weight: 700;
  line-height: 1; letter-spacing: -0.01em; text-transform: uppercase;
}
.fh-help-banner-logo {
  display: flex; flex-direction: column; align-items: center;
}
.fh-help-banner .fh-logo-l1 { color: #CFC3A3; font-size: 28px; }
.fh-help-banner .fh-logo-l2 { color: #C9901A; font-size: 28px; }
#helpBox .enf { color: #C44B22; }

/* Expandable source citations */
.src-cite { display: block; margin: 0 0 10px 0; }
.src-cite:first-of-type { margin-top: 2px; }
.src-summary { cursor: pointer; font-family: 'Lora', serif; font-size: 0.85em; color: #1A1208; line-height: 1.5; }
.src-summary:hover { color: #C44B22; }
#helpBox .src-note { font-family: 'IBM Plex Mono', monospace; font-size: 0.7em; color: #6B5A3A; line-height: 1.35; margin: 4px 0 0 24px; max-width: 90%; }

/* Bottom credit line */
#helpBox > p:last-of-type {
  color: #6B5A3A;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.75em;
  margin-top: 16px; padding-top: 12px;
  border-top: 1px solid #D6CFB4;
}

/* ── Bottom detail panel ────────────────────────────────────────────────── */

#detail {
  position: absolute; bottom: 8px; left: 8px; max-width: 40vw;
  background: rgba(26, 18, 8, 0.98);
  border: 2px solid #C9901A; border-radius: 8px;
  padding: 14px 18px 16px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.8em;
  color: #CFC3A3;
  z-index: 1003; display: none;
  max-height: 38vh; overflow-y: auto;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.6);
  flex-direction: column;
}
#detail.visible { display: flex; }
#detail::-webkit-scrollbar { width: 8px; }
#detail::-webkit-scrollbar-track { background: #1A1208; }
#detail::-webkit-scrollbar-thumb { background: #8A7A5A; border-radius: 4px; }
#detail::-webkit-scrollbar-thumb:hover { background: #C9901A; }

#detail .close {
  position: sticky; top: 0;
  align-self: flex-start; margin-left: auto; flex-shrink: 0;
  background: rgba(26, 18, 8, 0.98); border: none;
  color: #6B5A3A; font-size: 20px;
  cursor: pointer; line-height: 1; z-index: 1;
  padding: 2px 4px 6px 8px;
  border-radius: 0 0 0 6px;
  margin-top: -8px; margin-right: -8px;
}
#detail .close:hover { color: #C9901A; }

#detail h3 {
  font-family: 'League Gothic', sans-serif; font-weight: 400;
  font-size: 1.4em; text-transform: uppercase; letter-spacing: 0.03em;
  color: #C9901A;
  margin: 0 0 8px;
}
#detail h3 .pin-icon { margin-right: 4px; }

#detail table { width: 100%; border-collapse: collapse; margin: 4px 0; }
#detail td {
  padding: 3px 8px 3px 0; vertical-align: top;
  font-size: 0.85em; border-bottom: 1px solid #3A2518;
}
#detail td.label {
  color: #6B5A3A; white-space: nowrap; width: 100px;
  font-size: 0.75em; letter-spacing: 0.1em; text-transform: uppercase;
}
#detail td:not(.label) { font-variant-numeric: tabular-nums; }

#detail .tier-critical { color: #b01010; font-weight: bold; }
#detail .tier-high    { color: #C44B22; font-weight: bold; }
#detail .tier-medium  { color: #ffaa33; font-weight: bold; }
#detail .tier-low     { color: #ffdd44; }

#detail a[target="_blank"] {
  color: #C9901A;
  border-bottom: 1px dotted #6B5A3A;
  text-decoration: none;
}
#detail a[target="_blank"]:hover { border-bottom-color: #C9901A; }

#detail .apis {
  font-size: 0.75em; word-break: break-all;
  color: #6B5A3A; max-height: 50px; overflow-y: auto; margin-top: 4px;
}
#detail .enf { color: #C44B22; }

/* ── Cluster labels ─────────────────────────────────────────────────────── */

.cluster-label {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  font-family: 'IBM Plex Mono', monospace !important;
  font-weight: 600 !important;
  font-size: 11px !important;
  color: #CFC3A3 !important;
  text-shadow: 0 0 4px #1A1208 !important;
}

/* ── Marker cursor ─────────────────────────────────────────────────────── */

.leaflet-marker-icon { cursor: pointer; }
.selected-pin { background: none; border: none; filter: drop-shadow(0 0 6px rgba(0,0,0,0.8)) drop-shadow(0 0 3px rgba(255,255,255,0.4)); }
.place-icon { background: none; border: none; }
.frac-diamond { background: none; border: none; }

/* ── Hamburger menu & layers panel ──────────────────────────────────────── */

#menuBtn {
  position: absolute; top: 52px; right: 12px;
  width: 32px; height: 32px; border-radius: 4px;
  background: #2E2010; color: #C9901A;
  border: 1px solid #6B5A3A; font-size: 18px;
  font-family: 'IBM Plex Mono', monospace;
  cursor: pointer; z-index: 1002;
  line-height: 30px; text-align: center;
  padding: 0; transition: all 0.2s;
}
#menuBtn:hover, #menuBtn.open {
  background: #3A2518; border-color: #C9901A;
}

/* ── Leaderboard ──────────────────────────────────────────────────────── */

#leaderBtn {
  position: absolute; top: 92px; right: 12px;
  width: 32px; height: 32px; border-radius: 4px;
  background: #2E2010; color: #C9901A;
  border: 1px solid #6B5A3A; font-size: 16px;
  cursor: pointer; z-index: 1002;
  line-height: 30px; text-align: center;
  padding: 0; transition: all 0.2s;
}
#leaderBtn:hover, #leaderBtn.open {
  background: #3A2518; border-color: #C9901A;
}

#tourBtn {
  position: absolute; top: 132px; right: 12px;
  width: 32px; height: 32px; border-radius: 4px;
  background: #2E2010; color: #C9901A;
  border: 1px solid #6B5A3A; font-size: 14px;
  cursor: pointer; z-index: 1002;
  line-height: 30px; text-align: center;
  padding: 0; transition: all 0.2s;
}
#tourBtn:hover { background: #3A2518; border-color: #C9901A; }

#leaderPanel {
  position: absolute; top: 80px; right: 55px; bottom: 40px;
  background: rgba(26, 18, 8, 0.98);
  border: 1px solid #3A2518;
  border-radius: 8px;
  padding: 14px 16px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.75em;
  color: #CFC3A3;
  z-index: 1003;
  display: none;
  width: 440px; max-width: 92vw;
  overflow-y: auto;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.7);
}
#leaderPanel.visible { display: block; }
#leaderPanel::-webkit-scrollbar { width: 6px; }
#leaderPanel::-webkit-scrollbar-track { background: #1A1208; }
#leaderPanel::-webkit-scrollbar-thumb { background: #8A7A5A; border-radius: 3px; }

#leaderList .ldr-row {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 6px; cursor: pointer;
  border-bottom: 1px solid #3A2518;
  transition: background 0.15s;
}
#leaderList .ldr-row:hover { background: #3A2518; }
#leaderList .ldr-rank {
  width: 20px; text-align: right; color: #6B5A3A;
  font-weight: 600; flex-shrink: 0;
}
#leaderList .ldr-score {
  width: 55px; text-align: right; flex-shrink: 0;
  font-weight: 600; font-variant-numeric: tabular-nums;
}
#leaderList .ldr-tier {
  width: 55px; text-align: center; flex-shrink: 0;
  font-size: 0.75em; letter-spacing: 0.05em; text-transform: uppercase;
}
#leaderList .ldr-county {
  width: 70px; flex-shrink: 0; color: #6B5A3A;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.leader-tab {
  background: #3A2518; color: #6B5A3A;
  border: 1px solid #3A2518; border-radius: 4px;
  padding: 4px 10px; font-family: 'IBM Plex Mono', monospace;
  font-size: 0.7em; letter-spacing: 0.05em; text-transform: uppercase;
  cursor: pointer; transition: all 0.2s;
}
.leader-tab.active { background: #C9901A; color: #1A1208; border-color: #C9901A; }
.leader-tab:hover:not(.active) { color: #C9901A; border-color: #6B5A3A; }

#leaderList .ldr-threats {
  margin-left: auto; font-size: 0.8em; color: #6B5A3A;
  white-space: nowrap;
}

#layersPanel {
  position: absolute; top: 92px; right: 55px;
  background: rgba(46, 32, 16, 0.97);
  border: 1px solid #3A2518;
  border-radius: 8px;
  padding: 12px 16px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.75em;
  color: #CFC3A3;
  z-index: 1003;
  display: none;
  min-width: 260px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.6);
}
#layersPanel.visible { display: block; }
.panel-close { display: none; }
#layersPanel .layers-header {
  font-family: 'IBM Plex Mono', monospace;
  font-weight: 600; font-size: 0.85em;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: #C9901A; margin-bottom: 8px;
  display: flex; justify-content: space-between; align-items: center;
  padding-bottom: 6px;
  border-bottom: 1px solid #3A2518;
}

.layer-row {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 0; cursor: pointer;
  font-size: 0.8em; letter-spacing: 0.03em;
  transition: color 0.15s;
}
.layer-row:hover { color: #C9901A; }
.layer-row input[type="checkbox"] {
  -webkit-appearance: none; appearance: none;
  width: 14px; height: 14px; border-radius: 3px;
  background: #D6CFB4; border: 1px solid #3A2518;
  cursor: pointer; flex-shrink: 0;
  display: grid; place-content: center;
  transition: all 0.12s;
}
.layer-row input[type="checkbox"]:checked {
  background: #1A1208; border-color: #C9901A;
}
.layer-row input[type="checkbox"]::before {
  content: ""; width: 8px; height: 8px;
  clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%);
  background: #C9901A;
  transform: scale(0); transition: 120ms transform ease-in-out;
}
.layer-row input[type="checkbox"]:checked::before {
  transform: scale(1);
}
.layer-dot {
  width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
}
.layer-count {
  margin-left: auto; font-size: 0.8em;
}

/* ── Depth range slider ─────────────────────────────────────────────────── */

.depth-slider-container {
  position: relative;
  height: 32px;
  margin: 0 2px;
}

.depth-track {
  position: absolute;
  top: 13px;
  left: 0; right: 0;
  height: 4px;
  border-radius: 2px;
  background: #3A2518;
  pointer-events: none;
}

.depth-range {
  -webkit-appearance: none;
  appearance: none;
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 32px;
  background: transparent;
  margin: 0;
  pointer-events: none;
  z-index: 1;
}

.depth-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #C9901A;
  border: 2px solid #1A1208;
  cursor: pointer;
  pointer-events: auto;
  box-shadow: 0 0 4px rgba(0,0,0,0.5);
  margin-top: -6px;
}

.depth-range::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #C9901A;
  border: 2px solid #1A1208;
  cursor: pointer;
  box-shadow: 0 0 4px rgba(0,0,0,0.5);
}

.depth-range::-webkit-slider-runnable-track {
  -webkit-appearance: none;
  height: 4px;
  background: transparent;
}

.depth-range::-moz-range-track {
  height: 4px;
  background: transparent;
  border: none;
}

.depth-min { z-index: 3; }
.depth-max { z-index: 2; }

.depth-min::-webkit-slider-thumb { z-index: 3; }
.depth-max::-webkit-slider-thumb { z-index: 2; }

.plug-year-min { z-index: 3; }
.plug-year-max { z-index: 2; }

.plug-year-min::-webkit-slider-thumb { z-index: 3; }
.plug-year-max::-webkit-slider-thumb { z-index: 2; }

.radius-range { z-index: 3; }
.radius-range::-webkit-slider-thumb { z-index: 3; }

.depth-labels {
  display: flex;
  justify-content: space-between;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.6em;
  color: #CFC3A3;
  letter-spacing: 0.03em;
  padding: 0 2px;
  margin-bottom: 6px;
}

.depth-range-box {
  margin-left: auto;
  padding: 2px 7px;
  background: #2E2010;
  border: 1px solid #3A2518;
  border-radius: 4px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.7em;
  font-weight: 600;
  color: #C9901A;
  letter-spacing: 0.03em;
  white-space: nowrap;
  transition: all 0.15s;
}

/* ── Responsive ─────────────────────────────────────────────────────────── */

@media (max-width: 768px) {
  body { overflow-x: hidden; }
  /* Legend → full-width bottom strip */
  #legend {
    top: auto; bottom: 8px; left: 8px; right: 8px;
    padding: 7px 10px; font-size: 0.85em;
    pointer-events: auto;               /* desktop sets this to none */
    touch-action: none;                 /* prevent drags from scrolling the page */
    display: flex; flex-wrap: wrap; align-items: center;
    gap: 3px 10px;
  }
  #legend .legend-title { flex: 1 1 auto; order: 0; margin-bottom: 2px; }
  #legend .bar { width: 100% !important; order: 1; margin: 0; }  /* full-width so it aligns with label columns below */
  #legend .legend-numeric {
    order: 2;
    flex-basis: 100%;
    display: grid !important;                     /* override inline display:flex */
    grid-template-columns: repeat(5, 1fr);        /* equal columns align with tier-name row */
    justify-items: center;
    margin-bottom: 1px;
  }
  #legend > .labels:not(.legend-numeric) {
    order: 3;
    flex-basis: 100%;
    display: grid !important;                     /* override inline display:flex */
    grid-template-columns: repeat(5, 1fr);        /* same column widths as numeric row */
    justify-items: center;
    margin-top: 0;
  }  /* hide the numeric 0/1/100/500/2500 row */
  #legend > div:has(.row) { flex-basis: 100%; order: 3; }  /* well-type key on its own line */
  #legend .row { gap: 4px; margin: 1px 0; }
  #legend .dot { width: 8px; height: 8px; }
  #legend .legend-note { display: none; }

  #legendClose {
    order: -1; flex-shrink: 0;
    width: 24px; height: 24px; border-radius: 4px;
    background: #2E2010; color: #C9901A;
    border: 1px solid #6B5A3A;
    font-size: 14px; line-height: 1; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
  }

  #legendBtn {
    display: flex; align-items: center; justify-content: center;
    /* Same z-index as #legend so the detail panel covers the button just as it
       covers the expanded strip, and both reappear when the panel closes. */
    position: absolute; bottom: 8px; right: 10px; z-index: 1000;
    width: 35px; height: 35px; border-radius: 4px;
    background: #2E2010; border: 1px solid #6B5A3A;
    cursor: pointer;
  }

  #detail {
    left: 8px; right: 8px; max-width: none;
    max-height: 45vh; padding: 10px 12px;
  }
  #detail td { font-size: 0.75em; }
  #detail td.label { width: 70px; }

  #helpBox { max-width: 95vw; padding: 16px; max-height: 90vh; }
  /* Cancels the mobile #helpBox padding set on the line above (16px uniform) —
     keep these margins matched to it or the full-bleed edge will gap/seam. */
  .fh-help-banner {
    margin: -16px -16px 12px;
    padding: 14px 16px 12px;
  }
  .fh-help-banner .fh-logo-l1, .fh-help-banner .fh-logo-l2 { font-size: 18px; }
  /* Three columns at 375px leaves ~110px each — stack instead. */
  #helpBox .help-stats { grid-template-columns: 1fr; gap: 10px; }
  #helpBox .help-stat b { font-size: 1.6em; }

  /* top-right button stack: 🔍 ? ☰ ★ */
  #searchToggle {
    display: flex; align-items: center; justify-content: center;
    width: 35px; height: 35px;
    font-size: 16px; top: 10px; right: 10px;
  }
  #helpBtn {
    width: 35px; height: 35px; line-height: 33px;
    font-size: 18px; top: 49px; right: 10px;
  }
  #menuBtn {
    width: 35px; height: 35px; line-height: 33px;
    font-size: 18px; top: 88px; right: 10px;
  }
  #leaderBtn {
    width: 35px; height: 35px; line-height: 33px;
    font-size: 16px; top: 127px; right: 10px;
  }

  #tourBtn {
    width: 35px; height: 35px; line-height: 33px;
    font-size: 13px; top: 166px; right: 10px;
  }

  #fhLogo {
    /* Padding grows the tap target to ~33px (in line with the 32-35px
       sibling controls) without enlarging the visible text; `top` is
       reduced by the padding-top so the text itself still lands at y≈10,
       matching the pre-padding visual position. */
    top: 0; left: 50%; right: auto;
    transform: translateX(-50%);
    flex-direction: row; gap: 5px;
    padding: 10px 12px;
  }
  #fhLogo .fh-logo-l1, #fhLogo .fh-logo-l2 { font-size: 13px; }

  #layersPanel, #leaderPanel { right: 5px; max-width: 95vw; }
  .panel-close { display: block; position: absolute; top: 8px; right: 8px; background: none; border: none; color: #8A7A5A; font-size: 20px; cursor: pointer; z-index: 1; }
  .layers-header { position: relative; }
  /* Tour card: flush full-width bottom bar */
  .tour-card {
    width: 100% !important; left: 0 !important; right: 0 !important; bottom: 0 !important;
    border-radius: 8px 8px 0 0 !important;
  }
  .tour-header { padding: 7px 10px; }
  .tour-body { padding: 10px 14px; }
  .tour-footer { padding: 5px 14px; }
  .tour-btn-primary, .tour-btn-secondary {
    padding: 4px 12px; font-size: 0.75em;
    min-height: 36px; display: flex; align-items: center;
  }

  #searchBox { display: none; }
  #searchBox.visible { display: block; }

  /* Larger touch scrollbars on mobile. Firefox only accepts auto/thin/none,
     so `auto` is the closest lever to the desktop `thin`. */
  * { scrollbar-width: auto; }
  ::-webkit-scrollbar { width: 28px; height: 28px; }
  #detail::-webkit-scrollbar,
  #leaderPanel::-webkit-scrollbar,
  #helpBox::-webkit-scrollbar { width: 28px; height: 28px; }
}

/* ── Guided tour ───────────────────────────────────────────────────── */
.tour-card {
  position: fixed;
  bottom: 30px;
  right: 20px;
  width: 300px;
  background: #F2EEE3;
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  z-index: 2100;
  font-family: 'IBM Plex Mono', monospace;
  overflow: hidden;
}
.tour-card.hidden { display: none; }
.tour-header {
  background: #C44B22;
  color: #fff;
  padding: 10px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75em;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
#tour-step-title {
  flex: 1; text-align: center;
  font-family: 'League Gothic', sans-serif; font-weight: 400;
  font-size: 1.25em; letter-spacing: 0.03em;
}
.tour-close {
  background: none; border: none; color: #fff;
  font-size: 1.3em; cursor: pointer; line-height: 1; padding: 0; opacity: 0.8;
}
.tour-close:hover { opacity: 1; }
.tour-body {
  padding: 16px; font-size: 0.85em; line-height: 1.5;
  color: #1A1208; min-height: 80px;
}
.tour-body h3 {
  font-family: 'League Gothic', sans-serif; font-size: 1.3em;
  letter-spacing: 0.03em; margin: 0 0 8px 0; color: #C44B22;
  text-transform: uppercase;
}
.tour-body p { margin: 0 0 6px 0; }
.tour-body a { color: #C44B22; }
.tour-body svg text { font-family: Arial, Helvetica, sans-serif; }
.tour-body .dot {
  display: inline-block; width: 12px; height: 12px;
  border-radius: 50%; vertical-align: middle; margin-right: 2px;
}
.tour-footer {
  padding: 10px 14px; display: flex; justify-content: space-between;
  border-top: 1px solid #D4CDB8;
}
.tour-btn-primary, .tour-btn-secondary {
  padding: 6px 14px; border-radius: 4px;
  font-family: 'IBM Plex Mono', monospace; font-size: 0.8em;
  cursor: pointer; border: 1px solid;
}
.tour-btn-primary { background: #C44B22; color: #fff; border-color: #C44B22; }
.tour-btn-primary:hover { background: #A33A18; }
.tour-btn-secondary { background: transparent; color: #6B5A3A; border-color: #6B5A3A; }
.tour-btn-secondary:hover { background: #D4CDB8; }
.tour-btn-secondary:disabled { opacity: 0.3; cursor: default; }

#tour-overlay {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.5); z-index: 2050;
}
#tour-overlay.hidden { display: none; }

#tour-spotlight {
  position: fixed; border-radius: 6px;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.55);
  z-index: 2050; pointer-events: none;
  transition: left 0.3s ease, top 0.3s ease, width 0.3s ease, height 0.3s ease;
  animation: spotlight-ring 2.5s ease-out forwards;
}
#tour-spotlight.hidden { display: none; }
@keyframes spotlight-ring {
  0%   { box-shadow: 0 0 0 9999px rgba(0,0,0,0.55), 0 0 0 8px rgba(255,255,255,1), 0 0 30px 20px rgba(255,255,255,0.9), 0 0 60px 40px rgba(255,255,255,0.5); }
  70%  { box-shadow: 0 0 0 9999px rgba(0,0,0,0.55), 0 0 0 8px rgba(255,255,255,1), 0 0 30px 20px rgba(255,255,255,0.9), 0 0 60px 40px rgba(255,255,255,0.5); }
  100% { box-shadow: 0 0 0 9999px rgba(0,0,0,0.55), 0 0 0 2px rgba(201,144,26,0.9), 0 0 8px 4px rgba(201,144,26,0.35); }
}

#tour-bullseye {
  position: fixed; width: 18px; height: 18px; border-radius: 50%;
  background: rgba(201, 144, 26, 0.55);
  box-shadow: 0 0 0 8px rgba(201, 144, 26, 0.25), 0 0 0 16px rgba(201, 144, 26, 0.12);
  transform: translate(-50%, -50%);
  pointer-events: none; z-index: 2060;
}
#tour-bullseye.hidden { display: none; }

.tour-pulse {
  position: fixed; width: 20px; height: 20px; border-radius: 50%;
  background: rgba(196, 75, 34, 0.7);
  transform: translate(-50%, -50%) scale(0.3);
  pointer-events: none; z-index: 9998;
  animation: tour-pulse-anim 0.7s ease-out forwards;
}
@keyframes tour-pulse-anim {
  0%   { transform: translate(-50%, -50%) scale(0.3); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(2.5); opacity: 0; }
}

/* ── Email collection modal ───────────────────────────────────────── */
.email-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(0,0,0,0.7);
  display: flex; align-items: center; justify-content: center;
}
.email-overlay.hidden { display: none; }

.email-box {
  background: #1A1208; border: 1px solid #3A2518; border-radius: 12px;
  padding: 24px 28px 20px; max-width: 440px; width: 90vw;
  box-shadow: 0 8px 40px rgba(0,0,0,0.8);
  position: relative;
}
.email-close {
  position: absolute; top: 8px; right: 12px;
  background: none; border: none; color: #6B5A3A;
  font-size: 1.5em; cursor: pointer; line-height: 1;
}
.email-close:hover { color: #C9901A; }

.email-header { margin-bottom: 16px; }
.email-header h2 {
  font-family: 'Unbounded', sans-serif; font-weight: 700;
  font-size: 1.1em; color: #C9901A; margin: 0 0 4px;
}
.email-header p { color: #8A7A5A; font-size: 0.8em; margin: 0; }

.email-input {
  width: 100%; padding: 10px 14px; border-radius: 8px;
  background: rgba(46,32,16,0.95); border: 1px solid #3A2518;
  color: #CFC3A3; font-family: 'IBM Plex Mono', monospace;
  font-size: 0.9em; outline: none; box-sizing: border-box;
}
.email-input:focus { border-color: #C9901A; }

.email-error { color: #ff4444; font-size: 0.75em; margin-top: 6px; min-height: 1.2em; }

.email-footer { margin-top: 14px; display: flex; gap: 8px; }
.email-btn {
  background: #C9901A; color: #1A1208; border: none;
  border-radius: 8px; padding: 10px 24px;
  font-family: 'IBM Plex Mono', monospace; font-size: 0.85em;
  font-weight: 600; cursor: pointer; transition: background 0.2s;
}
.email-btn:hover { background: #e0a020; }
.email-btn:disabled { opacity: 0.5; cursor: default; }
