/*
 * Map page styles.
 *
 * Tokens, reset, nav and button classes all come from /css/app.css, the same
 *   stylesheet every other page loads. What is left here is the map itself:
 *   the full-bleed canvas, and the MapLibre chrome (popups, controls) dressed
 *   to match the rest of the site.
 */

html,
body {
  height: 100%;
  overflow: hidden;
}

.map {
  position: fixed;
  inset: 0;
}

.map-error {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1001;
  padding: 0.75rem 1rem;
  background-color: var(--status-late);
  color: #fff;
  font-size: 0.875rem;
}

/* Popups */

.maplibregl-popup-content {
  padding: 0.75rem;
  border-radius: var(--r-md);
  background-color: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-3);
}

/*
 * The tip is a CSS triangle, so its color lives on whichever border faces the
 *   popup — which depends on where the popup sits relative to its anchor.
 */
.maplibregl-popup-anchor-top .maplibregl-popup-tip,
.maplibregl-popup-anchor-top-left .maplibregl-popup-tip,
.maplibregl-popup-anchor-top-right .maplibregl-popup-tip {
  border-bottom-color: var(--surface);
}

.maplibregl-popup-anchor-bottom .maplibregl-popup-tip,
.maplibregl-popup-anchor-bottom-left .maplibregl-popup-tip,
.maplibregl-popup-anchor-bottom-right .maplibregl-popup-tip {
  border-top-color: var(--surface);
}

.maplibregl-popup-anchor-left .maplibregl-popup-tip {
  border-right-color: var(--surface);
}

.maplibregl-popup-anchor-right .maplibregl-popup-tip {
  border-left-color: var(--surface);
}

.map-popup {
  text-align: center;
  min-width: 12rem;
}

.map-popup-name {
  font-size: 1.0625rem;
}

.map-popup-code {
  color: var(--text-muted);
  font-size: 0.8125rem;
}

.map-popup-routes {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.375rem;
  margin-top: 0.625rem;
}

/* The same pill the arrivals pages use; route colors are set inline. */
.map-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.25rem;
  padding: 0.25rem 0.75rem;
  border: 1px solid transparent;
  border-radius: var(--r-pill);
  font-size: 0.8125rem;
  font-weight: 700;
  line-height: 1.4;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

/* Display comes from .btn — setting it here too would be an order-dependent tie */
.map-popup-action {
  margin-top: 0.75rem;
}

/* Controls */

.maplibregl-ctrl-group {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  box-shadow: var(--shadow-2);
}

.maplibregl-ctrl-group button {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: var(--r-pill);
  background-color: transparent;
}

.maplibregl-ctrl-group button:hover {
  background-color: var(--surface-2);
}

/*
 * MapLibre's control glyphs are background images with their colors baked in,
 *   dark marks meant for a light control. Inverting is the only way to recolor
 *   them without shipping replacement icons, and it is safe because they are
 *   monochrome.
 */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .maplibregl-ctrl-icon {
    filter: invert(1);
  }
}

:root[data-theme="dark"] .maplibregl-ctrl-icon {
  filter: invert(1);
}

.maplibregl-ctrl-attrib {
  background-color: var(--surface) !important;
  color: var(--text-muted);
  border-radius: var(--r-sm);
  font-size: 10px;
}

.maplibregl-ctrl-attrib a {
  color: var(--text-muted);
}

.maplibregl-ctrl-attrib a:hover {
  text-decoration: underline;
}

.maplibregl-ctrl-attrib-button {
  background-color: var(--surface);
  border-radius: 50%;
}
