html,
body {
  height: 100%;
  margin: 0;
  padding: 0;
}

/* The page is a column: the map takes the space that is left, and the player
   bar sits below it. The Leaflet attribution then rests just above the bar. */
body {
  font-family:
    system-ui,
    -apple-system,
    "Segoe UI",
    Roboto,
    sans-serif;
  background: #eee;
  display: flex;
  flex-direction: column;
}

#map {
  flex: 1 1 auto;
  /* Without this a flex child refuses to shrink below its content height. */
  min-height: 0;
}

#player-bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px 14px;
  background: #1b1b1b;
  color: #fff;
  border-top: 2px solid #000;
}

#player-station {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 0 1 auto;
}

#player-name {
  font-size: 0.95rem;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#player-meta {
  font-size: 0.75rem;
  color: #b6b6b6;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#player-controls {
  flex: 1 1 auto;
  min-width: 0;
}

/* Plyr paints its controls dark on light by default. Invert for the bar. */
#player-bar .plyr--audio .plyr__controls {
  background: transparent;
  color: #fff;
  padding: 0;
}

#player-bar .plyr--audio .plyr__control svg {
  fill: #fff;
}

#player-bar .plyr--audio .plyr__control:hover {
  background: #c1272d;
}

#player-bar .plyr {
  --plyr-color-main: #c1272d;
  --plyr-audio-controls-background: transparent;
  --plyr-audio-control-color: #fff;
  --plyr-range-track-background: #555;
}

/* A station with no stream: dim the bar and block the controls. */
#player-bar.is-silent #player-controls {
  opacity: 0.35;
  pointer-events: none;
}

#player-note {
  font-size: 0.75rem;
  color: #ffb4b4;
  white-space: nowrap;
}

/* Marker: a round pin with a tail, drawn in CSS. No image files. */
.station-pin {
  background: none;
  border: 0;
}

.station-pin__body {
  width: 26px;
  height: 26px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  background: #c1272d;
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
}

.station-pin__body::after {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #fff;
}

.station-pin:focus-visible .station-pin__body {
  outline: 3px solid #000;
  outline-offset: 2px;
}

/* Direction marker: an arrow on the edge of the map for a station outside
   the view, in the style of Grand Theft Auto 1. Drawn in CSS. No image
   files. */
.direction-layer {
  position: absolute;
  inset: 0;
  /* Above every map pane, and below the Leaflet controls at 1000. */
  z-index: 900;
  overflow: hidden;
  /* The overlay must not swallow a drag. Each arrow takes its own clicks. */
  pointer-events: none;
}

.direction-marker {
  position: absolute;
  display: none;
  /* Keep EDGE_INSET in app.js at half this size or more. An arrow that is
     wider than twice the inset hangs over the edge of the map. */
  width: 38px;
  height: 38px;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  pointer-events: auto;
  /* The script sets left and top to the point on the edge. This centres the
     arrow on that point. */
  transform: translate(-50%, -50%);
}

.direction-marker.is-visible {
  display: block;
}

.direction-marker:hover,
.direction-marker:focus-visible {
  transform: translate(-50%, -50%) scale(1.2);
}

.direction-marker:focus-visible {
  outline: 3px solid #000;
  outline-offset: 2px;
}

/* A solid dart that points east at zero degrees. The script turns it to the
   bearing of the station. The white glow keeps it legible over any tile.

   The dart is long and narrow on purpose. A tip that reaches much further
   from the notch than the two tails do gives the shape one clear direction.
   A fatter dart reads well north, south, east and west, but it turns into an
   ambiguous blob on the diagonals. */
.direction-marker__arrow {
  display: block;
  width: 100%;
  height: 100%;
  clip-path: polygon(100% 50%, 10% 80%, 34% 50%, 10% 20%);
  background: #c1272d;
  filter: drop-shadow(0 0 1.5px #fff) drop-shadow(0 0 2px rgba(0, 0, 0, 0.55));
}

/* Popup */
.station-popup {
  min-width: 190px;
}

.station-popup__name {
  margin: 0 0 2px;
  font-size: 1.05rem;
  line-height: 1.25;
}

.station-popup__meta {
  margin: 0 0 8px;
  font-size: 0.8rem;
  color: #555;
}

.station-popup__description {
  margin: 0 0 8px;
  font-size: 0.85rem;
  line-height: 1.35;
  color: #222;
}

.station-popup__links {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.station-popup__links a {
  font-size: 0.9rem;
}

.station-popup__none {
  margin: 0;
  font-size: 0.85rem;
  color: #666;
}

.station-popup__note {
  margin: 8px 0 0;
  font-size: 0.72rem;
  color: #777;
}

/* Shown only when Leaflet fails to load. */
#load-error {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  text-align: center;
  font-size: 1rem;
  color: #333;
}

#load-error.is-visible {
  display: flex;
}
