/*
 * MapLibre's popup and controls ship a fixed light palette, so in dark mode
 * they arrive as bright white cards on a dark map. These follow the app's
 * theme instead. They read the semantic tokens (application.css), which the
 * `.dark` class on <html> redefines, so one rule serves both modes.
 *
 * Plain CSS rather than Tailwind classes on purpose: popup markup is built in
 * Ruby and injected with setHTML, so it is never scanned by Tailwind and any
 * utility classes in it would be purged.
 */
.lo-popup {
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 13px;
  line-height: 1.45;
  color: var(--color-ink);
}
.lo-popup-title { font-weight: 600; font-size: 14px; }
.lo-popup-muted { color: var(--color-muted); }
.lo-popup-strong { margin-top: 4px; font-weight: 600; }
/* 44px tall: the link IS the action on a card that opens from a tap, and a
   13px line of text is a 17px target. Flex so the text stays vertically
   centred in the taller box rather than riding its top edge. */
.lo-popup-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--color-link);
  font-weight: 600;
  text-decoration: none;
}
.lo-popup-link:hover { text-decoration: underline; }

.maplibregl-popup-content {
  border-radius: 12px;
  /* Right padding leaves room for the close button rather than letting it sit
     on top of the text. */
  padding: 14px 52px 14px 16px;
  background: var(--color-surface);
  color: var(--color-ink);
  border: 1px solid var(--color-line);
  box-shadow: 0 8px 24px rgb(0 0 0 / 18%);
  min-width: 200px;
}
/* The little arrow is a separate element and has to be recoloured too, or it
   stays white and floats under a dark card. */
.maplibregl-popup-anchor-top .maplibregl-popup-tip { border-bottom-color: var(--color-surface); }
.maplibregl-popup-anchor-bottom .maplibregl-popup-tip { border-top-color: var(--color-surface); }
.maplibregl-popup-anchor-left .maplibregl-popup-tip { border-right-color: var(--color-surface); }
.maplibregl-popup-anchor-right .maplibregl-popup-tip { border-left-color: var(--color-surface); }

/*
 * MapLibre's close button is a ~12px glyph tucked into the corner. This is an
 * app used on a boat with wet gloves, so it gets a real 44px target, and
 * enough contrast to find. (It was 32px, under the 44px floor every other
 * tap target here meets.)
 */
.maplibregl-popup-close-button {
  width: 44px;
  height: 44px;
  top: 4px;
  right: 4px;
  border-radius: 8px;
  font-size: 22px;
  line-height: 1;
  color: var(--color-muted);
  transition: background-color 120ms ease, color 120ms ease;
}
.maplibregl-popup-close-button:hover,
.maplibregl-popup-close-button:focus-visible {
  background: var(--color-ground);
  color: var(--color-ink);
}
.dark .maplibregl-popup-content { box-shadow: 0 8px 24px rgb(0 0 0 / 45%); }

.dark .maplibregl-ctrl-group {
  background: var(--color-surface);
  box-shadow: 0 0 0 1px var(--color-line);
}
.dark .maplibregl-ctrl-group button + button { border-top-color: var(--color-line); }
.dark .maplibregl-ctrl-group button .maplibregl-ctrl-icon { filter: invert(1) brightness(1.6); }
.dark .maplibregl-ctrl-attrib,
.dark .maplibregl-ctrl-scale {
  background: rgb(42 42 45 / 85%);
  color: var(--color-muted);
  border-color: var(--color-line);
}
.dark .maplibregl-ctrl-attrib a { color: var(--color-link); }
