:root {
  color-scheme: dark;
  --ink: #f2f2f2;
  --dim: #8a8a8a;
  --paper: #000;
  --amber: #ffb000;
  --line: #333;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

* {
  box-sizing: border-box;
}

/* The page is exactly one screen tall and never scrolls: the globe and controls fill what the footer leaves. */
html,
body {
  height: 100%;
  overflow: hidden;
}

/* A live hunt (spectrogram, map, aircraft list, the guess) is taller than a phone, so that view scrolls. */
html:has(.live:not([hidden])),
html:has(.live:not([hidden])) body {
  height: auto;
  min-height: 100%;
  overflow: visible;
}

body {
  display: flex;
  flex-direction: column;
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.5;
}

a {
  color: var(--ink);
}

[hidden] {
  display: none !important;
}

.hunt {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: min(100%, 110ch);
  flex: 1;
  min-height: 0;
  margin: 0 auto;
  padding: 16px;
}

.hunt h1,
.hunt h2 {
  margin: 0 0 6px;
  font-size: inherit;
  font-weight: normal;
  color: var(--dim);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.hunt p {
  margin: 0 0 10px;
  max-width: 80ch;
}

.banner {
  margin: 0 0 8px;
  color: var(--amber);
}

pre {
  margin: 0;
  font: inherit;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

pre.table {
  white-space: pre;
  overflow-x: auto;
}

.muted {
  color: var(--dim);
}

.small {
  font-size: 0.85em;
}

.status {
  margin: 0;
  min-height: 1.5em;
}

.error {
  color: var(--amber);
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin: 12px 0;
}

.controls label {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* A flat square track and a square amber thumb, to match the square buttons. */
input[type="range"] {
  appearance: none;
  -webkit-appearance: none;
  height: 16px;
  margin: 0;
  background: transparent;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 0;
  background: var(--line);
}

input[type="range"]::-moz-range-track {
  height: 4px;
  border-radius: 0;
  background: var(--line);
}

input[type="range"]::-moz-range-progress {
  height: 4px;
  background: var(--amber);
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 16px;
  margin-top: -6px; /* centre on the 4px track */
  border: 0;
  border-radius: 0;
  background: var(--amber);
}

input[type="range"]::-moz-range-thumb {
  width: 12px;
  height: 16px;
  border: 0;
  border-radius: 0;
  background: var(--amber);
}

input[type="range"]:focus-visible {
  outline: 1px solid var(--amber);
  outline-offset: 4px;
}

button {
  padding: 8px 12px;
  border: 1px solid var(--dim);
  background: transparent;
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}

button:hover:not(:disabled) {
  border-color: var(--ink);
}

/* The one call to action on the home page fills amber on hover. */
.intro button:hover:not(:disabled) {
  border-color: var(--amber);
  background: var(--amber);
  color: var(--paper);
}

button:disabled {
  color: var(--dim);
  cursor: default;
}

button:focus-visible,
input:focus-visible {
  outline: 1px solid var(--ink);
  outline-offset: 2px;
}

.panels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* On phones the panels stack, so each is shorter to keep the spectrogram, map and buttons on one screen,
   and the guess with its pin prompt moves up under the map, where the pin is dropped. */
@media (max-width: 760px) {
  .panels {
    grid-template-columns: 1fr;
  }

  .panels .spectrogram canvas {
    height: 180px;
  }

  .panels .map {
    height: 280px;
  }

  .live {
    display: flex;
    flex-direction: column;
  }

  .live > .reveal {
    order: 1;
    margin-top: 12px;
  }

  .live > .controls,
  .live > pre {
    order: 2;
  }
}

.spectrogram {
  position: relative;
  margin: 0;
}

.spectrogram canvas {
  display: block;
  width: 100%;
  height: 320px;
  border: 1px solid var(--line);
}

.spectrogram .overlay {
  position: absolute;
  inset: 0 0 auto 0;
  pointer-events: none;
  border-color: transparent;
}

.map {
  height: 320px;
  border: 1px solid var(--line);
  background: #111;
}

.map.pinning {
  cursor: crosshair;
}

/* Inverted OSM tiles so the map sits in the black page; overlays stay in true colour. */
.osm-tiles {
  filter: invert(1) hue-rotate(180deg) brightness(0.85) contrast(0.9);
}

.heatmap {
  image-rendering: pixelated;
}

.leaflet-container {
  font: inherit;
  background: #111;
}

.leaflet-control-attribution {
  background: rgba(0, 0, 0, 0.7) !important;
  color: var(--dim);
}

.leaflet-control-attribution a,
.leaflet-bar a {
  color: var(--ink) !important;
  background: #000 !important;
}

.map-label {
  background: #000;
  color: var(--ink);
  border: 1px solid var(--dim);
  box-shadow: none;
  font: inherit;
}

.reveal {
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

/* Small print at the bottom. It wraps rather than truncating, so the credits (DB-IP's included) stay readable. */
footer {
  flex: none;
  color: var(--dim);
  font-size: 10px;
  line-height: 1.4;
  padding: 4px 12px 6px;
}

footer a {
  color: var(--dim);
}

.footnote-toggle {
  display: none;
}

/* While a hunt is live the small print gets out of the way: a button in the corner that pops it up. */
body:has(.live:not([hidden])) footer {
  position: fixed;
  right: 12px;
  bottom: 12px;
  z-index: 10;
  padding: 0;
}

body:has(.live:not([hidden])) .footnote-toggle {
  display: block;
  margin-left: auto;
  padding: 4px 10px;
  background: var(--paper);
  color: var(--dim);
}

body:has(.live:not([hidden])) .footnote-body {
  display: none;
  position: absolute;
  right: 0;
  bottom: calc(100% + 6px);
  width: min(440px, calc(100vw - 24px));
  padding: 10px 12px;
  border: 1px solid var(--line);
  background: var(--paper);
}

body:has(.live:not([hidden])) footer.open .footnote-body {
  display: block;
}

/* When the globe is held back by the screen's width (phones), the spare height is split above and below,
   so the sign, globe and controls sit together in the middle instead of leaving a hole over the footer. */
.intro {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-block: auto;
}

.intro .controls {
  justify-content: center;
}

/* The name over the globe, as an LED dot-matrix sign (drawn by the marquee controller). */
.hunt .title {
  margin: 0 0 6px;
}

/* The marquee controller sizes these canvases itself, from the text and the room available. */
.title canvas,
.subtitle canvas {
  display: block;
}

/* "recording period:" and its value sit together on one line, a little closer than the other controls. */
.cap-label {
  display: flex;
  gap: 6px;
  align-items: center;
  white-space: nowrap;
}

.hunt .subtitle {
  margin: 0 0 6px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Square: 280 columns x 168 rows of 0.6em-wide cells. Fits both the width and the height of the window. */
.globe {
  position: relative;
}

.globe canvas {
  display: block;
  width: min(calc(100vw - 32px), var(--globe-max, calc(100dvh - 200px)), 900px); /* --globe-max: what the fit controller measured */
  aspect-ratio: 1;
}

/* The starfield sits behind everything and never takes clicks. */
.sky {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: -1;
  pointer-events: none;
}

/* The planes ride on a 2D canvas laid exactly over the globe. */
.globe .planes {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

/* The globe can be grabbed and spun. touch-action keeps a drag on it from scrolling the page on phones. */
.globe canvas:not(.planes) {
  cursor: grab;
  touch-action: none;
}

.globe canvas.grabbing {
  cursor: grabbing;
}
