/* /explore/ : gridded explorer on the shared design tokens (docs/DESIGN.md 5.18). Light by default like the rest of the site; the
 * basemap and the colormap variants follow the theme. Layout: fixed-height app, left control panel (320 px) + map; below 800 px
 * the panel is a bottom sheet whose collapsed strip shows the kicker, the metric name and a 44 px Controls button. */
body.explore { overflow: hidden; height: 100dvh; display: flex; flex-direction: column; }
body.explore .foot { display: none; }
.exploremain { flex: 1; min-height: 0; }
.xp { display: grid; grid-template-columns: 320px 1fr; height: 100%; background: var(--bg); }
.xp-panel { border-right: 1px solid var(--border); overflow-y: auto; padding: var(--s5) var(--s4) var(--s6); display: flex; flex-direction: column; gap: var(--s5); background: var(--surface); scrollbar-width: thin; }
.xp-panel > * { flex: none; }
.xp-head h1 { font-size: var(--t-5); line-height: 1.25; margin: 6px 0 8px; }
.xp-kicker { margin: 0; display: flex; align-items: center; gap: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.xp-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent, var(--accent-heat)); display: inline-block; }
.xp-sheet-metric { display: none; }
.xp-sub { color: var(--text-2); font-size: var(--t-2); margin: 0; line-height: 1.5; }
.xp-status { display: flex; align-items: center; gap: 8px; color: var(--muted); margin: 0; min-height: 18px; font-size: var(--t-1); }
.xp-status.done .xp-spin { display: none; }
.xp-status.error { color: var(--negative); }
.xp-spin { width: 10px; height: 10px; border: 1.5px solid var(--border); border-top-color: var(--text); border-radius: 50%; animation: xp-spin .9s linear infinite; flex: none; }
@keyframes xp-spin { to { transform: rotate(360deg); } }
.xp-sec { border-top: 1px solid var(--border); padding-top: var(--s3); display: grid; gap: 10px; }
.xp-sec.xp-about { color: var(--muted); gap: 4px; font-size: var(--t-1); }
.xp-sec.xp-about p { margin: 0; line-height: 1.5; }
.xp-lab { margin: 0; border: 0; padding: 0; }
.xp-labrow { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s2); }
.xp-val { color: var(--text); font-size: var(--t-2); font-weight: 600; font-variant-numeric: tabular-nums; }
.xp-mini { background: transparent; border: 0; color: var(--brand); font: inherit; font-size: var(--t-2); padding: 4px 6px; cursor: pointer; margin-left: 2px; border-radius: var(--r-1); position: relative; }
.xp-mini::after { content: ""; position: absolute; inset: -8px; }
.xp-mini:hover { text-decoration: underline; }

/* metric chips (shared .chip) stacked; selected fill follows the domain */
.xp-seg { display: flex; flex-direction: column; align-items: stretch; gap: 6px; }
.xp-seg .chip { justify-content: flex-start; text-align: left; }
.xp-seg .chip[data-domain="heat"][aria-checked="true"] { background: var(--accent-heat); border-color: var(--accent-heat); }
.xp-seg .chip[data-domain="night"][aria-checked="true"] { background: var(--accent-night); border-color: var(--accent-night); }
:root[data-theme="dark"] .xp-seg .chip[aria-checked="true"] { color: var(--bg); }
.xp-explain { margin: 0; font-size: var(--t-2); color: var(--text-2); line-height: 1.5; }

/* period: segmented control + play button + scrubber */
.xp-period { display: flex; align-items: center; gap: 10px; }
.xp-play { flex: none; width: 36px; height: 36px; border-radius: var(--r-1); border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; display: grid; place-items: center; position: relative; }
.xp-play::after { content: ""; position: absolute; inset: -4px; }
.xp-play:hover { border-color: var(--brand); color: var(--brand); }
.xp-play .ico { width: 16px; height: 16px; }
.xp-play:disabled, #xperiod:disabled { opacity: .4; cursor: default; }
.xp-play .pause { display: none; }
.xp-play[aria-pressed="true"] .pause { display: block; } .xp-play[aria-pressed="true"] .play { display: none; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; border: 1px solid var(--border); border-radius: var(--r-1); overflow: hidden; background: var(--surface); }
.seg button { font: inherit; font-size: var(--t-2); background: transparent; border: 0; border-left: 1px solid var(--border); color: var(--text-2); padding: 8px 4px; min-height: 36px; cursor: pointer; white-space: nowrap; font-variant-numeric: tabular-nums; }
.seg button:first-child { border-left: 0; }
.seg button:hover { color: var(--text); background: var(--surface-2); }
.seg button[aria-pressed="true"] { background: var(--surface-2); color: var(--text); font-weight: 600; }
.seg button:focus-visible { outline-offset: -2px; border-radius: 0; }
input[type="range"].xp-range { width: 100%; accent-color: var(--brand); height: 28px; margin: 0; background: transparent; }

/* colormaps */
.xp-cmaps { display: grid; gap: 4px; }
.xp-cmaps button { display: grid; grid-template-columns: 1fr 72px; align-items: center; gap: 10px; background: transparent; border: 1px solid transparent; border-radius: var(--r-1); padding: 6px 8px; min-height: 36px; cursor: pointer; color: var(--text-2); font: inherit; text-align: left; }
.xp-cmaps button:hover { background: var(--surface-2); color: var(--text); }
.xp-cmaps button[aria-checked="true"] { border-color: var(--brand); color: var(--text); }
.xp-cmaps button i { display: block; height: 10px; border-radius: var(--r-1); }
.xp-cmaps button span { font-size: var(--t-2); }
.xp-cmaps button small { color: var(--muted); font-size: var(--t-1); margin-left: 4px; }

/* dual range (clim) */
.xp-dual { position: relative; height: 32px; }
.xp-dual-track { position: absolute; left: 0; right: 0; top: 14px; height: 4px; background: var(--border); border-radius: var(--r-pill); }
.xp-dual-fill { position: absolute; top: 0; height: 100%; background: var(--brand); border-radius: var(--r-pill); }
.xp-dual input[type="range"] { position: absolute; left: 0; right: 0; top: 0; width: 100%; height: 32px; margin: 0; -webkit-appearance: none; appearance: none; background: transparent; pointer-events: none; }
.xp-dual input[type="range"]::-webkit-slider-runnable-track { background: transparent; height: 32px; }
.xp-dual input[type="range"]::-moz-range-track { background: transparent; height: 32px; }
.xp-dual input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; pointer-events: auto; width: 16px; height: 16px; border-radius: 50%; background: var(--brand); border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--brand); margin-top: 8px; cursor: ew-resize; }
.xp-dual input[type="range"]::-moz-range-thumb { pointer-events: auto; width: 12px; height: 12px; border-radius: 50%; background: var(--brand); border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--brand); cursor: ew-resize; }
.xp-dual input[type="range"]:focus-visible { outline: 0; }
.xp-dual input[type="range"]:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 3px var(--focus); }

/* switches 36 x 20 */
.xp-toggles { gap: 12px; }
.xp-switch { display: grid; grid-template-columns: 36px 1fr; align-items: start; gap: 10px; font-size: var(--t-2); color: var(--text); cursor: pointer; line-height: 1.4; min-height: 44px; }
.xp-switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.xp-switch small { display: block; color: var(--muted); font-size: var(--t-1); margin-top: 1px; }
.xp-knob { position: relative; width: 36px; height: 20px; border-radius: var(--r-pill); background: var(--border); transition: background .15s; margin-top: 0; }
.xp-knob::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--surface); transition: transform .15s; }
.xp-switch input:checked + .xp-knob { background: var(--brand); }
.xp-switch input:checked + .xp-knob::after { transform: translateX(16px); }
.xp-switch input:focus-visible + .xp-knob { outline: 2px solid var(--focus); outline-offset: 2px; }

/* jump */
.xp-jump { position: relative; }
.xp-jump input { width: 100%; font: inherit; font-size: var(--t-3); padding: 10px 12px; min-height: 44px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-1); color: var(--text); }
.xp-jump input:focus { border-color: var(--brand); outline: 2px solid var(--focus); outline-offset: 2px; }
.xp-jumplist { position: absolute; z-index: 30; left: 0; right: 0; top: 100%; margin: 4px 0 0; padding: 4px; list-style: none; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-2); box-shadow: var(--shadow-1); max-height: 220px; overflow-y: auto; }
.xp-jumplist li { padding: 8px 10px; min-height: 36px; cursor: pointer; font-size: var(--t-2); display: flex; justify-content: space-between; gap: 8px; border-radius: var(--r-1); align-items: center; }
.xp-jumplist li:hover, .xp-jumplist li[aria-selected="true"] { background: var(--surface-2); }
.xp-jumplist li small { color: var(--muted); font-family: var(--mono); font-size: var(--t-1); }
.xp-perf { color: var(--muted); margin: 0 0 2px; font-size: var(--t-1); }

/* map side */
.xp-map { position: relative; min-height: 0; background: var(--bg); }
#map { position: absolute; inset: 0; }
.xp [hidden] { display: none !important; }
.xp-msg { position: absolute; inset: 0; z-index: 8; display: grid; place-content: center; padding: var(--s5); background: color-mix(in srgb, var(--bg) 88%, transparent); text-align: left; }
.xp-msg h2 { font-size: var(--t-5); margin: 0 0 8px; }
.xp-msg p { max-width: 52ch; color: var(--text-2); margin: 0; }
/* readout and legend: floating cards (r-2, shadow-1, surface at 94 %) */
.xp-readout { position: absolute; top: 12px; right: 12px; z-index: 6; width: 268px; background: color-mix(in srgb, var(--surface) 94%, transparent); border: 1px solid var(--border); border-radius: var(--r-2); padding: 12px 16px 10px 14px; box-shadow: var(--shadow-1); pointer-events: none; }
.xp-readout.pinned { pointer-events: auto; border-color: var(--brand); }
.xp-readout.pinned .xp-read-top { padding-right: 34px; }
.xp-unpin { position: absolute; top: 2px; right: 2px; width: 36px; height: 36px; background: transparent; border: 0; color: var(--muted); font-size: 18px; cursor: pointer; line-height: 1; border-radius: var(--r-1); }
.xp-unpin:hover { color: var(--text); background: var(--surface-2); }
.xp-read-top { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 2px 8px; color: var(--muted); margin-bottom: 4px; font-size: var(--t-1); min-width: 0; }
.xp-read-top > span { white-space: nowrap; }
.xp-read-k { font-family: var(--mono); text-transform: uppercase; letter-spacing: var(--track); }
.xp-read-ll { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.xp-read-v { font-family: var(--font-head); font-size: var(--t-6); font-weight: 700; letter-spacing: -.03em; line-height: 1.1; display: flex; align-items: baseline; gap: 8px; margin-bottom: 6px; font-variant-numeric: tabular-nums; }
.xp-read-u { color: var(--muted); font-weight: 500; font-family: var(--mono); font-size: var(--t-1); text-transform: uppercase; letter-spacing: var(--track); }
.xp-spark { width: 100%; height: auto; display: block; overflow: visible; }
.xp-spark .ln { fill: none; stroke: var(--text); stroke-width: 1.5; stroke-linejoin: round; }
.xp-spark .ax { stroke: var(--border); stroke-width: 1; }
.xp-spark .pt { fill: var(--surface); stroke: var(--text); stroke-width: 1.5; }
.xp-spark .pt.cur { fill: var(--accent, var(--accent-heat)); stroke: var(--accent, var(--accent-heat)); }
.xp-spark text { font-family: var(--font); font-size: 10px; fill: var(--muted); }
.xp-spark text.v { fill: var(--text); font-weight: 600; }
.xp-read-county { margin: 6px 0 0; font-size: var(--t-2); color: var(--text-2); }
.xp-read-county a { color: var(--brand); font-weight: 600; }
.xp-legend { position: absolute; left: 12px; bottom: 28px; z-index: 6; width: 300px; background: color-mix(in srgb, var(--surface) 94%, transparent); border: 1px solid var(--border); border-radius: var(--r-2); padding: 10px 12px 8px; box-shadow: var(--shadow-1); }
.xp-legend-top { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 6px; font-size: var(--t-2); font-weight: 600; }
.xp-legend-unit { color: var(--muted); font-weight: 500; align-self: center; font-family: var(--mono); font-size: var(--t-1); text-transform: uppercase; letter-spacing: var(--track); }
#xlegend-bar { display: block; width: 100%; height: 10px; border-radius: var(--r-1); image-rendering: auto; }
.xp-legend-ticks { display: flex; justify-content: space-between; color: var(--muted); margin-top: 3px; font-family: var(--mono); font-size: var(--t-1); font-variant-numeric: tabular-nums; }
.xp-legend-explain { margin: 6px 0 0; font-size: var(--t-1); color: var(--text-2); line-height: 1.4; }
.xp-attrib { position: absolute; left: 12px; bottom: 6px; z-index: 5; color: var(--text-2); font-size: var(--t-1); background: color-mix(in srgb, var(--surface) 88%, transparent); padding: 1px 6px; border-radius: var(--r-1); }
.xp-attrib a { color: var(--text-2); }
.xp-sheet-btn { display: none; }
.maplibregl-canvas { cursor: crosshair; }

@media (max-width: 800px) {
  body.explore { height: 100dvh; }
  .xp { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .xp-map { order: -1; }
  .xp-panel { position: absolute; left: 0; right: 0; bottom: 0; z-index: 12; max-height: 42dvh; border-right: 0; border-top: 1px solid var(--border); border-radius: var(--r-2) var(--r-2) 0 0; padding: 22px var(--s4) var(--s5); gap: var(--s4); background: var(--surface); box-shadow: var(--shadow-1); transform: translateY(calc(100% - 64px)); transition: transform .22s ease, max-height .22s ease; }
  .xp-panel::before { content: ""; position: absolute; top: 8px; left: 50%; width: 40px; height: 4px; margin-left: -20px; border-radius: var(--r-pill); background: var(--border); }
  .xp-panel.open { transform: none; max-height: 70dvh; }
  .xp-head h1 { font-size: var(--t-4); margin: 0 0 4px; }
  .xp-sheet-metric { display: block; margin: 2px 0 0; font-size: var(--t-3); font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: calc(100% - 110px); }
  .xp-panel.open .xp-sheet-metric { display: none; }
  .xp-head .xp-sub { display: none; }
  .xp-panel.open .xp-head .xp-sub { display: block; }
  .xp-sheet-btn { display: inline-flex; position: absolute; right: 12px; top: 10px; z-index: 13; min-height: 44px; }
  .xp-head h1 { max-width: calc(100% - 110px); }
  .xp-kicker { max-width: calc(100% - 110px); }
  .xp-readout { top: 8px; right: 8px; left: 8px; width: auto; padding: 8px 12px 6px 10px; display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
  .xp-readout .xp-read-top { grid-column: 1 / -1; }
  .xp-spark { max-height: 54px; }
  .xp-legend { left: 8px; right: 8px; bottom: 72px; width: auto; padding: 5px 10px 4px; }
  .xp-legend-top { margin-bottom: 4px; font-size: var(--t-1); }
  .xp-legend-top #xlegend-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
  #xlegend-bar { height: 8px; }
  .xp-legend-ticks { margin-top: 2px; }
  .xp-legend-ticks span:not(:first-child):not(:last-child) { display: none; }
  .xp-legend-explain { display: none; }
  .xp-attrib { display: none; }
  .exploremain { position: relative; }
  .xp-map .maplibregl-ctrl-bottom-right { bottom: 64px; }
}
@media (prefers-reduced-motion: reduce) { .xp-panel, .xp-knob, .xp-knob::after { transition: none; } .xp-spin { animation-duration: 2s; } }
