:root {
  --bg: #0b1020;
  --panel: #151b2e;
  --line: #26304a;
  --text: #e6ebf5;
  --muted: #93a0bb;
  --accent: #3b82f6;
  --hot: #ef4444;
  --warn: #f59e0b;
  --ok: #22c55e;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
  /* Nothing here should rubber-band on a phone mounted in a car. */
  overscroll-behavior: none;
}

#app { height: 100%; }

/* ---------------------------------------------------------------- setup */

#setup {
  max-width: 34rem;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
}

h1 { margin: 0 0 .25rem; font-size: 1.75rem; letter-spacing: -0.02em; }
.lede { margin: 0 0 1.5rem; color: var(--muted); }

label { display: block; margin-bottom: 1rem; font-size: .9rem; color: var(--muted); }
label small { display: block; margin-top: .35rem; color: var(--muted); opacity: .8; font-size: .8rem; }

input, select {
  display: block;
  width: 100%;
  margin-top: .35rem;
  padding: .7rem .75rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: .5rem;
  color: var(--text);
  /* 16px minimum, or iOS zooms the whole page on focus. */
  font-size: 16px;
}

input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.row { display: flex; gap: .75rem; }
.row label { flex: 1; }

button {
  width: 100%;
  padding: .9rem;
  background: var(--accent);
  border: 0;
  border-radius: .5rem;
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
}
button:disabled { opacity: .5; }

details { margin-top: 1.5rem; color: var(--muted); font-size: .875rem; }
summary { cursor: pointer; padding: .5rem 0; }
details ul { margin: .5rem 0 0; padding-left: 1.1rem; }
details li { margin-bottom: .5rem; }

/* ---------------------------------------------------------------- live */

#live {
  display: grid;
  /* Map takes whatever is left; the readout and controls stay pinned and thumb-reachable. */
  grid-template-rows: 1fr auto auto auto;
  height: 100%;
  gap: 0;
}

/* An id selector outranks the user-agent [hidden] rule, so display:grid would otherwise
   keep the live view on screen underneath the setup form. */
#setup[hidden], #live[hidden] { display: none; }

#map { width: 100%; height: 100%; background: #0e1424; }

#readout { padding: .6rem .9rem; background: var(--panel); border-top: 1px solid var(--line); }

#signal-bar {
  height: .55rem;
  background: #1f2942;
  border-radius: 99px;
  overflow: hidden;
}
#signal-fill {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--accent), var(--hot));
  transition: width .12s linear;
}

.readout-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-top: .4rem;
  font-variant-numeric: tabular-nums;
}
.readout-row.muted { font-size: .8rem; color: var(--muted); }

#trend { font-weight: 600; }
#trend.warmer { color: var(--hot); }
#trend.colder { color: var(--accent); }
#trend.steady { color: var(--muted); }

#marker { border-radius: 0; }

/* ---------------------------------------------------------------- signal picker */

#signals:empty { display: none; }
#signals {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .4rem;
  padding: .5rem .9rem;
  background: var(--panel);
  border-top: 1px solid var(--line);
  font-size: .8rem;
}
#signals .label { color: var(--muted); margin-right: .1rem; }

/* Buttons, not a select: the whole point is that the choice is visible without a tap. A hunter
   glancing down at a phone on a mount has to see WHICH signal is being tracked, and a collapsed
   dropdown shows that only after you open it. */
.signal-chip {
  /* The global button rule is a full-width block accent button; this is none of those. */
  width: auto;
  margin: 0;
  /* 2.5rem tall because this gets tapped one-handed, on a phone clamped to a windscreen, by
     someone who has just pulled over. The text only needs 27px; the finger needs 40. */
  min-height: 2.5rem;
  display: inline-flex;
  align-items: center;
  padding: .3rem .8rem;
  font-size: .8rem;
  font-weight: 500;
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  font-variant-numeric: tabular-nums;
}
.signal-chip:hover { border-color: var(--muted); }
.signal-chip[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
/* Leftovers are not a claimed transmitter, and must not look like one. */
.signal-chip.unexplained { color: var(--muted); border-style: dashed; }
.signal-chip.unexplained[aria-pressed="true"] { color: #fff; }

/* ---------------------------------------------------------------- warnings */

#warnings:empty { display: none; }
#warnings { max-height: 30vh; overflow-y: auto; }

.warning {
  padding: .55rem .9rem;
  font-size: .8rem;
  border-top: 1px solid var(--line);
}
.warning.info  { background: #16223b; color: var(--muted); }
.warning.warn  { background: #3a2c10; color: #fcd9a1; }
.warning.error { background: #3d1418; color: #ffc9cc; }

/* ---------------------------------------------------------------- map marks */

.node-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .85);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .5);
}
/* A node that stopped reporting must not look live. */
.node-dot.stale { opacity: .35; border-style: dashed; }
.node-dot.self  { width: 20px; height: 20px; border-color: #fff; border-width: 3px; }
/* AGC could not be disabled — position only, readings unused. */
.node-dot.unusable { border-color: var(--warn); border-style: dotted; }

.map-pin {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--panel);
  border: 2px solid var(--muted);
  color: var(--text);
  font-size: .8rem;
  font-weight: 700;
}
.pin-clear   { border-color: var(--ok); color: var(--ok); }
.pin-suspect { border-color: var(--hot); color: var(--hot); }

/* Your own GPS fix, drawn locally rather than from the stream — see HuntMap.setSelfPosition.
   Labelled because on a five-dot map the only one you need to find instantly is yourself. */
/* The container must be exactly the dot, and nothing else may affect its size.
   MapLibre centres a marker's ELEMENT on the coordinate. Laid out as a flex row -- dot then
   label -- the element's centre falls between the two, so the dot is drawn half a label-width
   to the LEFT of where you actually are, and the error changes with the length of your
   callsign. Label and arrow are therefore absolutely positioned: visible, but weightless. */
.self-fix {
  position: relative;
  width: 16px;
  height: 16px;
}
.self-fix-dot {
  position: absolute;
  inset: 0;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #2563eb;
  border: 3px solid #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .4);
}
.self-fix-label {
  position: absolute;
  left: 24px;
  top: 50%;
  transform: translateY(-50%);
  font-size: .75rem;
  font-weight: 700;
  color: var(--text);
  background: var(--panel);
  border-radius: 4px;
  padding: 1px 5px;
  white-space: nowrap;
}

.pin-popup { display: grid; gap: 8px; color: #111; }
/* Comfortably tappable with a thumb in a moving car. */
.pin-delete {
  min-height: 34px;
  border: 1px solid var(--hot);
  border-radius: 4px;
  background: #fff;
  color: var(--hot);
  font-weight: 600;
}

/* Facing indicator. Hidden until a real heading arrives — an arrow frozen at north reads as
   information when it is actually the absence of it. Rotated about the dot's centre, so the
   tip points where the phone points. */
.self-fix-arrow {
  display: none;
  position: absolute;
  left: 50%;
  top: 50%;
  width: 0;
  height: 0;
  margin: -26px 0 0 -7px;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-bottom: 14px solid #2563eb;
  transform-origin: 7px 26px;
  pointer-events: none;
}
#heading-readout {
  font-size: .8rem;
  color: var(--muted);
  padding: 2px 0;
}

/* The compass is built and styled entirely in map.js attachCompass(), with inline
   attributes, so a stale stylesheet cannot break it. Nothing for it lives here. */
#map { position: relative; }

/* Caption for the occupancy surface. Deliberately plain text next to the map rather than an
   overlay on it: the number that matters is the spread, and it has to be readable at a glance
   without competing with the thing it is qualifying. */
#estimate-status {
  font-size: .8rem;
  color: var(--muted);
  padding: 2px 0;
}

/* The peak marker, drawn only when the spread is small enough to deserve it. */
.fox-peak {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #f5a45e;
  color: #2a1206;
  border: 2px solid #fff;
  font-weight: 800;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .5);
}

/* Provisional fix: the solver's best guess, drawn so it cannot be read as a precise one.
   Hollow rather than solid, and always accompanied by a dashed ring of radius spread_m. */
.fox-peak.weak {
  background: transparent;
  color: #f5a45e;
  border: 2px dashed #f5a45e;
  box-shadow: none;
  font-weight: 700;
}
