/* Explorer V3. Mobile first: a full-screen map with a draggable bottom sheet; from 900px the
   sheet becomes a fixed left panel. Map colours are the June Explorer's viridis ramp. */
:root {
  --bg: #0b1220; --panel: #0f1829; --panel-2: #142039; --line: #22324b; --line-2: #2e4262;
  --ink: #f3f6fb; --ink-2: #b4c0d3; --muted: #8391a8; --accent: #818cf8; --accent-2: #6366f1;
  --v-mid: #21918c; --v-hi: #5ec962;
  --none: #162038;
  --sheet-peek: 164px; --radius: 14px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font-family: var(--font);
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; }
body { overflow: hidden; overscroll-behavior: none; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
.num { font-variant-numeric: tabular-nums; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.app { position: fixed; inset: 0; }
.stage { position: absolute; inset: 0; }
#map { position: absolute; inset: 0; background: radial-gradient(900px 600px at 60% 20%, #0c1631 0, #070d1f 70%); }
.leaflet-container { background: transparent; font-family: var(--font); cursor: default; }
.leaflet-container.hovering { cursor: pointer; }
.leaflet-control-zoom { border: 1px solid var(--line-2) !important; border-radius: 10px !important; overflow: hidden; }
.leaflet-control-zoom a { background: var(--panel) !important; color: var(--ink) !important; border-color: var(--line) !important;
  width: 38px !important; height: 38px !important; line-height: 38px !important; font-size: 20px !important; }
.leaflet-control-zoom a:hover { background: var(--panel-2) !important; }

/* ---- top bar: search + state chips ------------------------------------------------ */
.topbar { position: absolute; z-index: 800; top: calc(10px + env(safe-area-inset-top)); left: 12px; right: 12px;
  display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.topbar > * { pointer-events: auto; }
.search { position: relative; }
.search input { width: 100%; height: 46px; border-radius: 12px; border: 1px solid var(--line-2);
  background: rgba(15, 24, 41, .94); padding: 0 14px 0 40px; font-size: 16px; color: var(--ink);
  box-shadow: 0 8px 30px rgba(0, 0, 0, .35); backdrop-filter: blur(8px); }
.search input::placeholder { color: var(--muted); }
.search svg { position: absolute; z-index: 1; left: 13px; top: 14px; width: 18px; height: 18px; stroke: var(--muted); fill: none;
  stroke-width: 2; pointer-events: none; }
.results { position: absolute; top: 52px; left: 0; right: 0; margin: 0; padding: 6px; list-style: none;
  background: var(--panel); border: 1px solid var(--line-2); border-radius: 12px; box-shadow: 0 14px 40px rgba(0,0,0,.45);
  max-height: 50vh; overflow-y: auto; }
.results li { padding: 10px 10px; border-radius: 8px; display: flex; justify-content: space-between; gap: 10px; cursor: pointer; font-size: 14px; }
.results li span { color: var(--muted); font-size: 12px; white-space: nowrap; }
.results li[aria-selected="true"], .results li:hover { background: var(--panel-2); }
.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: 0 0 auto; min-height: 36px; padding: 0 13px; border-radius: 999px; border: 1px solid var(--line-2);
  background: rgba(15, 24, 41, .92); color: var(--ink-2); font-size: 13px; font-weight: 600; white-space: nowrap;
  box-shadow: 0 4px 16px rgba(0,0,0,.25); }
.chip.on { background: var(--accent-2); border-color: var(--accent-2); color: #fff; }

.tools { position: absolute; z-index: 800; right: 12px; display: flex; flex-direction: column; gap: 8px;
  bottom: calc(var(--sheet-peek) + 16px + env(safe-area-inset-bottom)); }
.tool { width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--line-2); background: rgba(15,24,41,.94);
  display: grid; place-items: center; box-shadow: 0 6px 20px rgba(0,0,0,.3); }
.tool svg { width: 20px; height: 20px; stroke: var(--ink-2); fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.hint { position: absolute; z-index: 700; left: 50%; transform: translateX(-50%); bottom: calc(var(--sheet-peek) + 18px);
  background: rgba(15,24,41,.92); border: 1px solid var(--line-2); border-radius: 999px; padding: 8px 14px; font-size: 12px;
  color: var(--ink-2); white-space: nowrap; pointer-events: none; transition: opacity .25s; }
.hint[hidden] { display: block; opacity: 0; }
.toast { position: absolute; z-index: 900; left: 50%; top: 50%; transform: translate(-50%, -50%); background: var(--panel);
  border: 1px solid var(--line-2); padding: 12px 18px; border-radius: 12px; font-size: 14px; box-shadow: 0 14px 40px rgba(0,0,0,.5); }
.tip { position: absolute; z-index: 850; pointer-events: none; background: rgba(9, 15, 27, .96); border: 1px solid var(--line-2);
  border-radius: 10px; padding: 8px 11px; font-size: 12px; line-height: 1.35; max-width: 260px; box-shadow: 0 10px 30px rgba(0,0,0,.45); }
.tip b { display: block; font-size: 13px; color: var(--ink); }
.tip span { color: var(--ink-2); }
.loading { position: absolute; inset: 0; z-index: 950; display: grid; place-items: center; background: var(--bg);
  color: var(--ink-2); font-size: 14px; transition: opacity .35s; }
.loading.gone { opacity: 0; pointer-events: none; }
.loading .spin { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--line-2); border-top-color: var(--accent);
  animation: spin .8s linear infinite; margin: 0 auto 12px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- map labels ------------------------------------------------------------------- */
.lbl { position: absolute; transform: translate(-50%, -50%); white-space: nowrap; pointer-events: none; font-weight: 600;
  color: #eef3fb; text-shadow: 0 0 3px #0b1220, 0 0 3px #0b1220, 0 1px 2px #0b1220; letter-spacing: .01em; }
.lbl.county { font-size: 11px; color: #dbe5f5; text-transform: uppercase; letter-spacing: .06em; opacity: .9; }
.lbl.place { font-size: 12px; }
.lbl.place.big { font-size: 13px; font-weight: 700; }
.lbl.place::before { content: ""; display: inline-block; width: 4px; height: 4px; border-radius: 50%; background: #fff;
  margin-right: 5px; vertical-align: middle; box-shadow: 0 0 0 1.5px #0b1220; }

/* ---- the sheet / panel ------------------------------------------------------------- */
.panel { position: absolute; z-index: 820; left: 0; right: 0; bottom: 0; height: calc(92dvh - env(safe-area-inset-top));
  background: var(--panel); border-top: 1px solid var(--line-2); border-radius: 18px 18px 0 0;
  box-shadow: 0 -12px 40px rgba(0,0,0,.45); display: flex; flex-direction: column;
  transform: translateY(calc(100% - var(--sheet-peek) - env(safe-area-inset-bottom))); transition: transform .28s cubic-bezier(.2,.8,.2,1);
  touch-action: none; }
.panel.dragging { transition: none; }
.panel.half { transform: translateY(48%); }
.panel.full { transform: translateY(0); }
.grab { flex: 0 0 auto; padding: 8px 16px 0; touch-action: none; cursor: grab; }
.grab .bar { width: 44px; height: 5px; border-radius: 3px; background: var(--line-2); margin: 0 auto 8px; }
.scroll { flex: 1 1 auto; overflow-y: auto; overscroll-behavior: contain; padding: 0 16px calc(24px + env(safe-area-inset-bottom));
  touch-action: pan-y; }
.brand { display: none; }
.layer-btn { width: 100%; text-align: left; background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 12px;
  padding: 10px 40px 10px 12px; position: relative; min-height: 54px; }
.layer-btn .g { display: block; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; font-weight: 700; }
.layer-btn .n { display: block; font-size: 15px; font-weight: 700; margin-top: 2px; }
.layer-btn::after { content: ""; position: absolute; right: 16px; top: 50%; width: 8px; height: 8px; margin-top: -6px;
  border-right: 2px solid var(--ink-2); border-bottom: 2px solid var(--ink-2); transform: rotate(45deg); }
.legend { margin: 10px 2px 0; }
.ramp { display: flex; gap: 12px; align-items: flex-start; }
.ramp .rg { flex: 1; min-width: 0; }
.ramp .bar { height: 12px; border-radius: 4px; }
.ramp .ends { display: flex; justify-content: space-between; font-size: 11px; color: var(--ink-2); margin-top: 5px; }
.ramp .nd { display: flex; flex-direction: column; align-items: center; gap: 5px; font-size: 11px; color: var(--muted); white-space: nowrap; }
.ramp .nd i { display: block; width: 26px; height: 12px; border-radius: 3px;
  background: repeating-linear-gradient(135deg, var(--none), var(--none) 3px, #2c3a5e 3px, #2c3a5e 6px); }
.meta { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; margin: 8px 2px 0; font-size: 11px; color: var(--muted); }
.badge { border: 1px solid var(--line-2); border-radius: 999px; padding: 2px 8px; color: var(--ink-2); font-weight: 600; }
.desc { font-size: 13px; line-height: 1.5; color: var(--ink-2); margin: 10px 2px 0; }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-top: 14px; }
.stat { background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.stat b { display: block; font-size: 19px; letter-spacing: -.01em; }
.stat span { font-size: 11px; color: var(--muted); }
.quick { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.quick button { border: 1px solid var(--line-2); background: transparent; color: var(--ink-2); border-radius: 999px;
  padding: 7px 11px; font-size: 12px; min-height: 34px; }
.quick button.on { border-color: var(--accent); color: #fff; background: rgba(99,102,241,.18); }
.sec { margin-top: 18px; }
.sec h2 { font-size: 12px; text-transform: uppercase; letter-spacing: .09em; color: var(--muted); margin: 0 0 8px; font-weight: 700; }

.card { margin-top: 14px; background: var(--panel-2); border: 1px solid var(--line-2); border-radius: var(--radius); padding: 14px; position: relative; }
.card .x { position: absolute; right: 8px; top: 8px; width: 36px; height: 36px; border: 0; border-radius: 10px; background: transparent;
  color: var(--muted); font-size: 20px; line-height: 1; }
.card .eyebrow { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; font-weight: 700; padding-right: 36px; }
.card h3 { margin: 4px 0 0; font-size: 20px; letter-spacing: -.01em; padding-right: 36px; }
.focus { margin-top: 12px; padding: 12px; border-radius: 12px; background: rgba(33, 145, 140, .14); border: 1px solid rgba(33, 145, 140, .45); }
.focus span { font-size: 12px; color: var(--ink-2); }
.focus b { display: block; font-size: 26px; margin-top: 2px; letter-spacing: -.02em; }
.focus em { font-style: normal; font-size: 12px; color: var(--ink-2); }
.trio { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 10px; }
.trio div { background: rgba(255,255,255,.03); border: 1px solid var(--line); border-radius: 10px; padding: 8px; }
.trio b { display: block; font-size: 15px; }
.trio span { font-size: 10.5px; color: var(--muted); line-height: 1.25; display: block; }
.wave { margin-top: 12px; }
.wave-top { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-bottom: 6px; }
.wave svg { width: 100%; height: 70px; display: block; }
.wave rect { fill: var(--v-mid); }
.wave rect:hover { fill: var(--v-hi); }
.wave text { fill: var(--muted); font-size: 9px; }
.ctx { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; margin-top: 12px; font-size: 12.5px; }
.ctx div { display: flex; justify-content: space-between; gap: 8px; border-bottom: 1px solid var(--line); padding: 6px 0; }
.ctx span { color: var(--muted); }
@media (max-width: 420px) { .ctx { grid-template-columns: 1fr; gap: 0; } }
.cta { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.cta a { display: flex; align-items: center; justify-content: center; min-height: 46px; border-radius: 12px; text-decoration: none;
  font-weight: 700; font-size: 14px; border: 1px solid var(--line-2); color: var(--ink); background: rgba(255,255,255,.03); }
.cta a.primary { background: var(--accent-2); border-color: var(--accent-2); color: #fff; }
.cta .row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.zoomin { margin-top: 8px; width: 100%; min-height: 40px; border-radius: 10px; border: 1px dashed var(--line-2); background: transparent; color: var(--ink-2); font-size: 13px; }

.rank { list-style: none; margin: 0; padding: 0; counter-reset: r; }
.rank li { counter-increment: r; }
.rank button { width: 100%; display: grid; grid-template-columns: 26px 1fr auto; gap: 8px; align-items: center; text-align: left;
  background: transparent; border: 0; border-bottom: 1px solid var(--line); padding: 10px 2px; min-height: 44px; font-size: 13.5px; }
.rank button::before { content: counter(r); color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.rank button .nm { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank button small { color: var(--muted); font-size: 12px; margin-left: 5px; }
.rank button b { font-variant-numeric: tabular-nums; }
.trio div.hl { border-color: rgba(33, 145, 140, .6); background: rgba(33, 145, 140, .14); }
.rankline { margin: 8px 2px 0; font-size: 12px; color: var(--ink-2); }
.lbl.state { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .12em; color: #fff; }
.rank button:hover { background: rgba(255,255,255,.03); }
.method { margin-top: 20px; font-size: 12px; line-height: 1.55; color: var(--muted); }
.method a { color: var(--ink-2); }

/* ---- layer picker ------------------------------------------------------------------ */
.picker { position: absolute; z-index: 900; inset: 0; background: rgba(5, 9, 17, .6); display: flex; align-items: flex-end; }
.picker[hidden] { display: none; }
.picker-box { width: 100%; max-height: 88dvh; background: var(--panel); border-radius: 18px 18px 0 0; border-top: 1px solid var(--line-2);
  display: flex; flex-direction: column; box-shadow: 0 -20px 60px rgba(0,0,0,.5); }
.picker-head { display: flex; gap: 8px; padding: 14px 14px 10px; border-bottom: 1px solid var(--line); }
.picker-head input { flex: 1; height: 44px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--panel-2); padding: 0 12px; font-size: 16px; }
.picker-head button { border: 1px solid var(--line-2); background: transparent; border-radius: 10px; padding: 0 14px; min-height: 44px; color: var(--ink-2); }
.picker-list { overflow-y: auto; padding: 6px 14px calc(18px + env(safe-area-inset-bottom)); }
.picker-list h4 { margin: 14px 2px 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .09em; color: var(--muted); }
.opt { width: 100%; text-align: left; display: flex; justify-content: space-between; align-items: center; gap: 10px; background: transparent;
  border: 0; border-radius: 10px; padding: 11px 10px; min-height: 46px; font-size: 14px; }
.opt:hover, .opt:focus-visible { background: var(--panel-2); }
.opt.on { background: rgba(99,102,241,.16); color: #fff; }
.opt small { color: var(--muted); font-size: 11px; white-space: nowrap; }
.opt[disabled] { opacity: .45; cursor: not-allowed; }

/* ---- desktop ------------------------------------------------------------------------- */
@media (min-width: 900px) {
  :root { --sheet-peek: 0px; }
  .stage { left: 400px; }
  .panel { top: 0; bottom: 0; left: 0; right: auto; width: 400px; height: auto; transform: none !important; border-radius: 0;
    border-top: 0; border-right: 1px solid var(--line-2); box-shadow: none; touch-action: auto; }
  .grab { display: none; }
  .scroll { padding: 0 20px 28px; touch-action: auto; }
  .brand { display: flex; align-items: center; gap: 12px; padding: 18px 0 4px; }
  .brand svg { width: 34px; height: 34px; flex: 0 0 auto; }
  .brand .t { font-weight: 800; font-size: 16px; letter-spacing: -.01em; }
  .brand .s { font-size: 12px; color: var(--muted); }
  .brand a { color: inherit; text-decoration: none; }
  .topbar { top: 14px; left: 14px; right: auto; width: min(520px, calc(100% - 90px)); }
  .tools { top: 14px; bottom: auto; right: 14px; }
  .hint { bottom: 22px; }
  .picker { align-items: stretch; justify-content: flex-start; background: rgba(5,9,17,.35); }
  .picker-box { width: 400px; max-height: none; height: 100%; border-radius: 0; border-top: 0; border-right: 1px solid var(--line-2); }
  .stats { grid-template-columns: repeat(2, 1fr); }
}
@media (prefers-reduced-motion: reduce) { .panel, .loading, .hint { transition: none; } .loading .spin { animation: none; } }
.state-links { display: flex; flex-wrap: wrap; gap: 6px; }
.state-links h2 { width: 100%; }
.state-links a { border: 1px solid var(--line-2); border-radius: 999px; padding: 6px 12px; font-size: 12.5px; color: var(--ink-2); text-decoration: none; }
.state-links a:hover { color: #fff; border-color: var(--accent); }
