/* Map page layout. Desktop: list on the left, map fills the rest, a draggable
   splitter between them, and a map-only mode. Mobile: map on top, list as a
   bottom sheet. */

body.map-page { overflow: hidden; }
.layout { position: fixed; inset: 0; top: 52px; display: grid; grid-template-columns: var(--panel-w) 6px 1fr; }
.status + .layout { top: 100px; }
.layout.maponly { grid-template-columns: 0 0 1fr; }
.layout.maponly .panel, .layout.maponly .splitter { display: none; }

.topbar #btn-maponly { margin-left: 4px; }

/* The one bold element: the status strip answers "does a warning cover me?" */
.status {
  position: relative; z-index: 3;
  height: 48px; padding: 0 16px;
  display: flex; align-items: baseline; gap: 14px;
  font-family: var(--font-condensed); font-size: 20px; font-weight: 600;
  background: var(--bg-3); border-bottom: 1px solid var(--line);
  white-space: nowrap; overflow: hidden;
}
.status-sub { font-family: var(--font); font-weight: 400; font-size: 14px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.status-idle { color: var(--muted); }
.status-clear { background: #18352a; border-color: #255540; color: #cdeedd; }
.status-watch { background: #3d3414; border-color: #6a5a1e; color: #fff0b0; }
.status-watch .status-sub { color: #e1cf85; }
.status-warn { background: var(--tor); border-color: #ff8c88; color: #fff; }
.status-warn .status-sub { color: #ffe0de; }
.status-warn.kind-svr { background: #9f7d0c; }
.status-warn.kind-ffw { background: #1d7a4b; }
.status-warn.kind-smw { background: #6a48b8; }
.status-warn .countdown { font-variant-numeric: tabular-nums; margin-left: auto; font-size: 24px; }

.panel { display: flex; flex-direction: column; min-height: 0; min-width: 0; background: var(--bg-2); border-right: 1px solid var(--line); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 14px 8px; flex-wrap: wrap; }
.panel-head h2 { font-size: 20px; }
.panel-tools { display: flex; gap: 6px; }
.panel-foot { padding: 10px 14px 14px; font-size: 12.5px; color: var(--faint); display: flex; flex-direction: column; gap: 4px; border-top: 1px solid var(--line); }
.panel-foot #updated { color: var(--muted); }

.splitter { cursor: col-resize; background: var(--line); }
.splitter:hover, .splitter.dragging { background: #55638a; }

.locations { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 14px 8px; }
.locations:empty { display: none; }
.loc { display: inline-flex; align-items: center; gap: 6px; padding: 4px 8px 4px 10px; border: 1px solid var(--line); border-radius: 20px; font-size: 13.5px; background: var(--bg); }
.loc.hit-warn { border-color: var(--tor); background: #4a1d1c; }
.loc.hit-watch { border-color: var(--svr); background: #3d3414; }
.loc button { border: 0; background: transparent; color: var(--muted); padding: 0 2px; cursor: pointer; font-size: 16px; line-height: 1; }
.loc button:hover { color: #fff; }

.warnings { list-style: none; margin: 0; padding: 0 8px 8px; overflow-y: auto; flex: 1; min-height: 0; }
.warning { margin: 0 0 6px; border: 1px solid var(--line); border-left: 5px solid var(--k); border-radius: var(--radius); background: var(--bg); }
.warning.hits-me { box-shadow: 0 0 0 2px var(--k); }
.warning-btn { display: block; width: 100%; text-align: left; border: 0; background: transparent; padding: 10px 12px; cursor: pointer; }
.warning-btn:hover { background: var(--bg-2); }
.warning-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.warning-event { font-family: var(--font-condensed); font-weight: 600; font-size: 17px; color: var(--k); }
.warning-ends { font-variant-numeric: tabular-nums; font-size: 14px; color: var(--muted); white-space: nowrap; }
.warning-ends.soon { color: var(--text); font-weight: 600; }
.warning-area { font-size: 14.5px; color: var(--text); margin-top: 2px; }
.warning-chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 7px; }
.chip { font-size: 12.5px; padding: 2px 7px; border-radius: 4px; background: var(--bg-3); color: var(--text); }
.chip.hot { background: var(--k); color: #0e1320; font-weight: 600; }
.chip.observed { background: var(--tor); color: #fff; font-weight: 600; }
.warning-detail { padding: 0 12px 12px; font-size: 14px; color: var(--muted); border-top: 1px solid var(--line); }
.warning-detail p { margin: 10px 0 0; white-space: pre-line; }
.warning-instr { color: var(--text); }
.warning-meta { font-size: 12.5px; color: var(--faint); }
.empty { padding: 24px 14px; color: var(--muted); font-size: 15px; }
.empty strong { color: var(--text); display: block; font-size: 18px; margin-bottom: 4px; font-family: var(--font-condensed); }

.mapwrap { position: relative; min-width: 0; }
#map { position: absolute; inset: 0; background: #0b0f18; }
.showlist { position: absolute; top: 10px; left: 10px; z-index: 2; }
.showlist[hidden] { display: none; }

/* Layers panel */
.layers { position: absolute; top: 10px; right: 10px; z-index: 2; width: 250px; max-height: calc(100% - 60px); overflow: auto; background: rgba(27,34,50,.95); border: 1px solid var(--line); border-radius: var(--radius); }
.layers-toggle { display: none; }
.layers-body { padding: 6px; }
.layer-row { display: grid; grid-template-columns: 1fr auto; align-items: center; }
.layer-sw { text-align: left; border: 0; background: transparent; color: var(--muted); padding: 7px 8px; border-radius: 4px; font-size: 14px; cursor: pointer; }
.layer-sw::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 2px; border: 1px solid var(--muted); margin-right: 8px; vertical-align: -1px; }
.layer-sw[aria-pressed="true"] { color: var(--text); }
.layer-sw[aria-pressed="true"]::before { background: var(--text); border-color: var(--text); }
.layer-sw:hover { background: rgba(255,255,255,.06); }
.layer-why { border: 1px solid var(--line); background: transparent; color: var(--faint); width: 22px; height: 22px; border-radius: 50%; font-size: 12px; cursor: pointer; margin-right: 4px; }
.layer-why:hover, .layer-why[aria-expanded="true"] { color: var(--text); border-color: var(--muted); }
.layer-help { grid-column: 1 / -1; margin: 0 8px 8px; font-size: 13px; line-height: 1.4; color: var(--muted); }
.layers-sep { height: 1px; background: var(--line); margin: 6px 4px; }
.spotter-row .layer-sw { font-weight: 600; }
.spotter-body { padding-left: 10px; border-left: 2px solid var(--line); margin: 2px 0 4px 10px; }
.site-pick { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; color: var(--muted); padding: 6px 8px; }
.site-pick select { font: inherit; font-size: 13px; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 4px; padding: 4px 6px; max-width: 150px; }
.vel-legend { display: flex; margin: 4px 8px; font-size: 11.5px; }
.vel-legend span { flex: 1; padding: 3px 6px; color: #0e1320; font-weight: 600; }
.vel-in { background: linear-gradient(90deg, #0a5c1c, #3bd85a); border-radius: 3px 0 0 3px; }
.vel-out { background: linear-gradient(90deg, #ff6b57, #7a0d0d); color: #fff !important; text-align: right; border-radius: 0 3px 3px 0; }
.spotter-tip { margin: 6px 8px 4px; font-size: 12.5px; line-height: 1.4; color: var(--muted); }

.legend { position: absolute; left: 10px; bottom: 28px; z-index: 2; display: flex; gap: 10px; font-size: 12.5px; color: var(--muted); background: rgba(27,34,50,.85); padding: 5px 9px; border-radius: var(--radius); }
.legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 2px; background: var(--k); margin-right: 5px; vertical-align: -1px; }
.sheet-handle { display: none; }

.maplibregl-ctrl-attrib { font-size: 10px; background: rgba(20,26,38,.7) !important; color: var(--faint); }
.maplibregl-ctrl-attrib a { color: var(--muted); }
.maplibregl-popup-content { background: var(--bg-2); color: var(--text); border: 1px solid var(--line); font-family: var(--font); padding: 10px 12px; border-radius: var(--radius); max-width: 280px; }
.maplibregl-popup-tip { border-top-color: var(--bg-2) !important; }
.maplibregl-popup-close-button { color: var(--muted); font-size: 18px; }

/* Mobile: map on top, list becomes a bottom sheet, layers collapse to a button */
@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .layout.maponly { grid-template-rows: 1fr 0; }
  .splitter { display: none; }
  .topbar #btn-maponly { display: none; }
  .status { font-size: 17px; height: 44px; gap: 10px; }
  .status + .layout { top: 96px; }
  .status-main { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
  .status-sub { display: none; }
  .status-warn .countdown { font-size: 20px; flex-shrink: 0; }
  .layers { width: auto; max-width: 260px; }
  .layers-toggle { display: block; width: 100%; text-align: left; border: 0; background: transparent; color: var(--text); padding: 8px 10px; font-size: 14px; cursor: pointer; }
  .layers-toggle::after { content: " ▾"; color: var(--muted); }
  .layers-toggle[aria-expanded="true"]::after { content: " ▴"; }
  .layers-body { display: none; }
  .layers.open .layers-body { display: block; }
  .mapwrap { order: 0; }
  /* Two states only: half screen (default) and full-screen map, where the
     list folds to a strip with the grab bar and the warning count. The grab
     bar is the list's own top edge, so nothing on the map can cover it. */
  .panel { order: 1; border-right: 0; border-top: 1px solid var(--line); height: 50vh; transition: height .2s ease; }
  .panel.collapsed { height: 64px; overflow: hidden; }
  .panel.collapsed .panel-tools, .panel.collapsed .pick-hint, .panel.collapsed .locations, .panel.collapsed .impact,
  .panel.collapsed .warnings, .panel.collapsed .panel-foot { display: none; }
  .panel.collapsed .panel-head { padding-top: 0; }
  .legend { bottom: 10px; }
  .sheet-handle { display: block; width: 100%; height: 22px; flex: 0 0 22px; border: 0; background: transparent; cursor: pointer; touch-action: none; }
  .sheet-handle::after { content: ""; display: block; margin: 8px auto 0; width: 40px; height: 4px; border-radius: 2px; background: var(--muted); }
  .sheet-handle:focus-visible { outline-offset: -2px; }
}

/* Place picker and impact panel */
.pick-hint { margin: 0 14px 8px; font-size: 13.5px; color: var(--text); background: var(--bg-3); padding: 6px 10px; border-radius: var(--radius); }
.loc .loc-name { border: 0; background: transparent; color: inherit; font: inherit; padding: 0; cursor: pointer; }
.loc .loc-name:hover { text-decoration: underline; }
.impact { margin: 0 8px 8px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); }
.impact-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px 6px; }
.impact-head h3 { font-size: 18px; }
.impact-line { margin: 0; padding: 8px 12px; border-top: 1px solid var(--line); border-left: 4px solid var(--k, var(--line)); font-size: 14px; line-height: 1.4; cursor: pointer; }
.impact-line strong { color: var(--k, var(--text)); }
.impact-meta { color: var(--faint); font-size: 12px; }
.impact-clear { margin: 0; padding: 8px 12px 12px; color: var(--muted); font-size: 14px; }
.impact-foot { margin: 0; padding: 8px 12px 10px; font-size: 12px; color: var(--faint); border-top: 1px solid var(--line); }
.place-menu { display: flex; flex-direction: column; gap: 6px; }
.place-menu strong { margin-bottom: 2px; }
.place-menu .btn { justify-content: center; }

/* Skip link and keyboard focus */
.skip { position: absolute; left: 8px; top: -40px; z-index: 50; background: #e9433f; color: #fff; padding: 6px 10px; border-radius: 6px; }
.skip:focus { top: 8px; }
:focus-visible { outline: 2px solid #ffffff; outline-offset: 2px; }

/* Time to shelter */
.impact-go { margin: 0 12px 8px; padding: 10px 12px; border-radius: 8px; font-weight: 600; font-size: 15px; background: rgba(255,255,255,.06); }
.impact-go.go-now { background: #e9433f; color: #fff; }
.impact-go.go-soon { background: #f2c230; color: #141a26; }
.impact-go.go-clear { background: rgba(47,176,111,.18); color: #cfeedd; }
.impact-go:empty { display: none; }
.shelter { display: block; font-size: 12.5px; color: var(--muted); margin: 0 12px 10px; }
.shelter input { width: 52px; margin: 0 4px; padding: 3px 6px; border-radius: 6px; border: 1px solid var(--line); background: #0f1420; color: #eef1f6; font: inherit; }

/* Replay */
.replay-body { padding: 4px 0 8px; }
.replay-body input[type=range] { width: 100%; accent-color: #fff; }
.replay-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12.5px; color: var(--muted); }
.status-replay { background: #2a3550; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
