/* CORSnet slippy map widget styles. Kept free of CORSnet tokens: the widget is generic;
 * the app layer (pages/network.css) colours markers with the theme's status properties. */

.slippy {
  position: relative;
  overflow: hidden;
  touch-action: none;
  cursor: grab;
  background: #aad3df; /* the classic Web-Mercator ocean tone, while tiles load */
  user-select: none;
  -webkit-user-select: none;
  /* A stacking context of its own: tile z-indexes (which order levels while a zoom loads)
   * and the popup's z-index stay inside the map and never leak into the page. */
  isolation: isolate;
}
.slippy:active { cursor: grabbing; }
/* The map is a keyboard region (+ - zoom, arrows pan), so focus must be seen. */
.slippy:focus-visible { outline: 3px solid #1273b1; outline-offset: -3px; }

.slippy-tiles,
.slippy-markers {
  position: absolute;
  inset: 0;
}
/* Tiles are a self-contained layer at the very bottom: their per-level z-indexes must
 * never lift them above the lines, markers or popup that follow. A page can recede the
 * base map with --slippy-tile-fade; the filter stays on this layer so nothing above it
 * is touched. */
.slippy-tiles { z-index: 0; filter: var(--slippy-tile-fade, none); }
.slippy-markers { pointer-events: none; }

/* The segment overlay: one SVG between tiles and markers, no pointer events. Lines are
 * styled by the caller's CSS classes (the app layer owns the colours). */
.slippy-lines {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.slippy-segment { fill: none; }

.slippy-tile {
  position: absolute;
  width: 256px;
  height: 256px;
  max-width: none;
  pointer-events: none;
}

/* A marker: a status-coloured station glyph. The colour comes from the marker's status
 * class, which the app layer maps to the theme's status custom properties. The surface is
 * a custom property so a page can pair it with its palette: a status colour only reads
 * against a surface it was chosen for (a light-theme green on white, a dark-theme green on
 * a dark chip). With no app tokens present it falls back to white. The 2 px halo faces the
 * tile, not the theme: tiles are light in every colourway, and it is the marker's outermost
 * ring against them, so its footprint is 32 px. */
.slippy-marker {
  position: absolute;
  transform: translate(-50%, -50%);
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2px;
  border: 1px solid var(--slippy-marker-edge, rgba(0, 0, 0, .35));
  border-radius: 50% 50% 50% 4px;
  background: var(--slippy-marker-bg, var(--a-raised, #fff));
  color: #555;
  box-shadow: 0 0 0 2px #252a2e, 0 1px 3px rgba(0, 0, 0, .35);
  pointer-events: auto;
  cursor: pointer;
  font: inherit;
  line-height: 0;
}
/* The kind of station is the shape, never the colour: an antenna in a drop for an eDMR1, a mast
 * in a rounded square for a connected station, a crosshair in a circle for a chosen point. */
.slippy-marker-tower { border-radius: 7px; }
.slippy-marker-pin { border-radius: 50%; }
.slippy-marker > svg:first-child { width: 16px; height: 16px; fill: none; stroke: currentColor; }
.slippy-marker:focus-visible { outline: 3px solid #1273b1; outline-offset: 4px; }
.slippy-marker.is-open { box-shadow: 0 0 0 2px #252a2e, 0 0 0 5px #1273b1; }

/* The non-colour cue: a small disc in the status colour with a check, bang or cross. */
.slippy-badge {
  position: absolute;
  right: -5px;
  top: -5px;
  width: 12px;
  height: 12px;
  fill: currentColor;
  stroke: none;
}
.slippy-badge-glyph {
  fill: none;
  stroke: var(--slippy-marker-bg, var(--a-raised, #fff));
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* The station code under the marker, from zoom 8 (the script toggles .slippy-labels). The
 * chip is light ink on the light topo tiles in every colourway, so it never competes with
 * the theme. */
.slippy-caption {
  display: none;
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-top: 5px;
  padding: 0 4px;
  border-radius: 3px;
  background: rgba(255, 255, 255, .88);
  color: #252a2e;
  font: 600 11px/1.35 system-ui, sans-serif;
  white-space: nowrap;
  pointer-events: none;
}
.slippy-labels .slippy-caption { display: block; }

/* Popup: pinned at the marker, plain card look. Content is built by the caller. */
.slippy-popup {
  position: absolute;
  transform: translate(-50%, calc(-100% - 20px));
  min-width: 160px;
  max-width: 220px;
  padding: 8px 10px;
  background: #fff;
  color: #252a2e;
  border: 1px solid rgba(0, 0, 0, .35);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .25);
  pointer-events: auto;
  font: 13px/1.4 system-ui, sans-serif;
  z-index: 3;
}
.slippy-popup::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -6px;
  width: 10px;
  height: 10px;
  margin-left: -5px;
  transform: rotate(45deg);
  background: #fff;
  border-right: 1px solid rgba(0, 0, 0, .35);
  border-bottom: 1px solid rgba(0, 0, 0, .35);
}
.slippy-popup .slippy-popup-title { font-weight: 600; margin: 0 0 2px; }
.slippy-popup .slippy-popup-line { margin: 0; }
.slippy-popup a { color: #045d99; }

.slippy-zoom {
  position: absolute;
  right: 10px;
  top: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 4;
}
.slippy-zoom button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid rgba(0, 0, 0, .35);
  border-radius: 6px;
  background: #fff;
  color: #252a2e;
  cursor: pointer;
}
.slippy-zoom button:hover { background: #f1f1f6; }
.slippy-zoom button:focus-visible { outline: 3px solid #1273b1; outline-offset: 1px; }
.slippy-zoom button[aria-disabled="true"] { opacity: .45; cursor: default; }
/* Fingers need a bigger target than a pointer does. */
@media (pointer: coarse) {
  .slippy-zoom button { width: 40px; height: 40px; }
}

.slippy-attrib {
  /* Plain text over the map: a marker panned beneath it still takes its click. */
  pointer-events: none;
  position: absolute;
  right: 6px;
  bottom: 4px;
  z-index: 4;
  font: 11px/1.3 system-ui, sans-serif;
  color: #252a2e;
  background: rgba(255, 255, 255, .8);
  padding: 1px 6px;
  border-radius: 4px;
}
