/*
 * Design brief: this is an instrument, not a landing page. It reads like a
 * night-shift observation console an aurora chaser keeps open in a dark room.
 * That drives every choice below:
 *   - Palette: polar-night ground; one signal colour (cyan) for live, tappable
 *     things; the green->magenta ramp is reserved strictly for forecast data so
 *     colour always means intensity and never decoration.
 *   - Type: a monospaced face for readouts (times, coordinates, labels) because
 *     a console shows numbers in mono; a plain grotesque for the little prose
 *     there is. No display serif, no system-ui autopilot.
 *   - Radius: a two-step scale, both small. Squared edges read as an
 *     instrument; nothing is maximally rounded.
 *   - No glow. Contrast and spacing carry the dark theme.
 */
:root {
  --bg: #06080c;
  --panel: rgba(13, 18, 24, 0.9);
  --border: rgba(150, 180, 205, 0.14);
  --border-strong: rgba(150, 180, 205, 0.28);
  --text: #dfe7ee;
  --muted: #8695a3;
  /* Signal colour: interactive and live elements only. */
  --signal: #5ec8e5;
  /* Data ramp endpoints (see the forecast legend); not for UI chrome. */
  --data-lo: #0b5e4f;
  --data-hi: #a637c9;
  --radius-sm: 2px;
  --radius-md: 6px;
  --mono: ui-monospace, "SFMono-Regular", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: "Inter Tight", "Helvetica Neue", Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

#map {
  position: absolute;
  inset: 0;
  background: #05070b;
}

#topbar {
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: linear-gradient(180deg, rgba(6,8,12,0.9), rgba(6,8,12,0));
  pointer-events: none;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* A live-status square, not a glowing bubble. It blinks slowly to show the
 * feed is refreshing; that motion carries meaning, so it stays. */
.brand .dot {
  width: 8px; height: 8px;
  border-radius: var(--radius-sm);
  background: var(--signal);
  animation: pulse 3.5s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: 0.35; } }
@media (prefers-reduced-motion: reduce) {
  .brand .dot { animation: none; }
}

.status {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  pointer-events: auto;
  backdrop-filter: blur(8px);
}
.status.error { color: #f0968f; }

.panel {
  position: absolute;
  bottom: 20px; left: 16px;
  z-index: 10;
  width: 224px;
  padding: 14px 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  backdrop-filter: blur(10px);
}

.panel h3 {
  margin: 0 0 10px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.scale {
  display: grid;
  grid-template-columns: 18px 1fr;
  align-items: center;
  gap: 4px 8px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 12px;
}

.swatch {
  width: 18px; height: 10px;
  border-radius: var(--radius-sm);
}
/* Matches the colorblind-safe green -> purple ramp in app.js */
.swatch.s0   { background: #0b5e4f; }
.swatch.s25  { background: #1f9e78; }
.swatch.s50  { background: #2f8fb3; }
.swatch.s75  { background: #5b5bd6; }
.swatch.s100 { background: #a637c9; }

.toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  margin: 6px 0;
  cursor: pointer;
}

#clouds-toggle-wrap {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}
.toggle-group-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 4px;
}
/* Band toggles read as a compact sub-list under the group label. */
#clouds-toggle-wrap .toggle { margin: 4px 0 4px 2px; }

.src, .obs {
  margin: 10px 0 0;
  font-size: 11px;
  color: var(--muted);
}
.obs { font-family: var(--mono); }
.src a { color: var(--signal); text-decoration: none; }
.src a:hover { text-decoration: underline; }

/* Sightings popup */
.mapboxgl-popup-content {
  background: #10161e;
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  font-size: 13px;
  max-width: 240px;
}
.mapboxgl-popup-content img {
  width: 100%;
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  display: block;
}
.mapboxgl-popup-content .who { font-weight: 600; }
.mapboxgl-popup-content .when {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  font-family: var(--mono);
}
.mapboxgl-popup-content .hint {
  margin-top: 6px;
  color: var(--signal);
  font-size: 11px;
  font-weight: 600;
}
.mapboxgl-popup-content img { cursor: pointer; }
.mapboxgl-popup-tip { border-top-color: #10161e !important; }

/* ---- Lightbox ------------------------------------------------------------ */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4vmin;
  background: rgba(3, 6, 10, 0.88);
  backdrop-filter: blur(6px);
  animation: lightbox-fade 0.15s ease-out;
}
.lightbox[hidden] { display: none; }
@keyframes lightbox-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}
.lightbox-figure {
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 92vw;
  max-height: 92vh;
}
.lightbox-img {
  max-width: 92vw;
  max-height: 82vh;
  border-radius: var(--radius-md);
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.6);
  transition: opacity 0.2s ease;
  object-fit: contain;
}
.lightbox-caption {
  margin-top: 12px;
  display: flex;
  gap: 12px;
  align-items: baseline;
  flex-wrap: wrap;
  justify-content: center;
  color: #e8eef5;
  font-size: 13px;
  text-align: center;
}
.lightbox-caption .who { font-weight: 600; }
.lightbox-caption time {
  color: var(--muted);
  font-size: 11px;
  font-family: var(--mono);
}
.lightbox-close {
  position: absolute;
  top: 16px;
  right: 20px;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s ease;
}
.lightbox-close:hover { background: rgba(255, 255, 255, 0.22); }
.lightbox-spinner {
  position: absolute;
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255, 255, 255, 0.2);
  border-top-color: var(--signal);
  border-radius: 50%;
  animation: lightbox-spin 0.8s linear infinite;
}
@keyframes lightbox-spin {
  to { transform: rotate(360deg); }
}

/* --- Nearby sighting alerts ------------------------------------------------ */
#notify-wrap hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 12px 0;
}
#notify-wrap h3 {
  margin: 0 0 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Small "?" affordance: keeps the how-it-works text out of the panel and
 * behind a tooltip, revealed on hover or keyboard focus. */
.info {
  appearance: none;
  width: 15px;
  height: 15px;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
  line-height: 1;
  cursor: help;
}
.info:hover, .info:focus-visible { color: var(--signal); border-color: var(--signal); }

/* Tooltip: any element with data-tip. Hidden until hover/focus, positioned
 * above the element, never occupying layout space of its own. */
[data-tip] { position: relative; }
[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  z-index: 20;
  width: max-content;
  max-width: 210px;
  padding: 7px 9px;
  background: #0c1219;
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 400;
  line-height: 1.4;
  letter-spacing: normal;
  text-transform: none;
  white-space: normal;
  opacity: 0;
  transform: translateY(3px);
  pointer-events: none;
  transition: opacity 0.12s ease, transform 0.12s ease;
}
[data-tip]:hover::after,
[data-tip]:focus-visible::after,
[data-tip]:focus-within::after {
  opacity: 1;
  transform: translateY(0);
}
@media (prefers-reduced-motion: reduce) {
  [data-tip]::after { transition: none; transform: none; }
}
.notify-hint {
  margin: 6px 0;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.45;
}
.notify-hint a { color: var(--signal); }
.notify-controls {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 8px 0;
}
.btn {
  appearance: none;
  border: 1px solid var(--border-strong);
  background: rgba(150, 180, 205, 0.06);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.02em;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.btn:hover { background: rgba(150, 180, 205, 0.12); }
.btn.active { border-color: var(--signal); color: var(--signal); }
.btn-ghost { background: transparent; }
.notify-radius {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin: 8px 0;
}
.notify-radius input { width: 100%; margin-top: 4px; accent-color: var(--signal); }
.notify-loc { font-size: 12px; color: var(--text); margin: 8px 0; }
.notify-qr {
  margin: 8px 0;
  background: #fff;
  padding: 8px;
  border-radius: var(--radius-sm);
  width: fit-content;
}
.notify-qr img { display: block; }
.notify-links { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
/* The alert-centre marker: a square target on the map, matched to the signal
 * colour so it reads as "the thing you placed", with a thin ring for contrast
 * against bright forecast cells (contrast, not glow). */
.notify-marker {
  width: 14px;
  height: 14px;
  border-radius: var(--radius-sm);
  background: var(--signal);
  border: 2px solid var(--bg);
  outline: 1px solid var(--border-strong);
  cursor: grab;
}
