/*==============================================*\
|| TerraLoc – the furniture on every map          ||
|| css/map-controls.css                           ||
\*==============================================*/

/*
 * ONE STYLESHEET FOR FIVE MAPS.
 *
 * The planner, the live map, Explore, the activity page and the analyzer all
 * build their map through modules/map-render-maplibre.js, so they all get the
 * same controls: zoom and compass, a 3D terrain toggle, a weather toggle and
 * the base-style picker. None of it was styled anywhere a page actually loads
 * (the only rules lived in wp-edit.css, which no map page linked), so every one
 * of them shipped MapLibre's default white squares and, worse, a raw browser
 * <select> sitting in the top-left corner of the map.
 *
 * Everything here is tokens from terraloc-theme.css, so the controls follow
 * the day and night faces without a second list of colours.
 */

/* ------------------------------------------------------------------
   The shared shell: MapLibre's own groups, and ours
   ------------------------------------------------------------------ */

.maplibregl-ctrl-group,
.tl-ctrl-group {
  border-radius: 0.85rem !important;
  border: 1px solid var(--tl-hairline, rgba(0, 0, 0, 0.12));
  background: color-mix(in srgb, var(--tl-paper, #fff) 94%, transparent);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06), 0 4px 12px rgba(0, 0, 0, 0.06);
  overflow: hidden;
}

.maplibregl-ctrl-group button,
.tl-ctrl-group button,
.tl-ctrl-btn {
  width: 2.1rem;
  height: 2.1rem;
  display: grid;
  place-items: center;
  background: transparent;
  border: 0;
  color: var(--tl-ink, #23281F);
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.maplibregl-ctrl-group button + button,
.tl-ctrl-group button + button {
  border-top: 1px solid var(--tl-hairline, rgba(0, 0, 0, 0.1));
}

.maplibregl-ctrl-group button:hover,
.tl-ctrl-group button:hover,
.tl-ctrl-btn:hover {
  background: color-mix(in srgb, var(--tl-cta, #C86B3F) 12%, transparent);
  color: var(--tl-cta, #C86B3F);
}

/* An overlay that is switched on says so, rather than looking like the rest. */
.tl-ctrl-group button[aria-pressed="true"],
.tl-ctrl-btn[aria-pressed="true"],
.tl-ctrl-group button.is-active,
.tl-ctrl-btn.is-active {
  background: var(--tl-cta, #C86B3F);
  color: var(--tl-cta-ink, #fff);
}

/* MapLibre draws its zoom glyphs as background images sized for its own
   button box; ours is smaller, so they need re-centring rather than a
   redraw. */
.maplibregl-ctrl-group button .maplibregl-ctrl-icon {
  background-size: 1.1rem 1.1rem;
  background-position: center;
}

/* ------------------------------------------------------------------
   The base-style picker

   A segmented row, not a <select>: four short words fit side by side, and a
   native dropdown is the one control on the page no theme can reach. Below
   30rem the four will not fit, so the row scrolls sideways rather than
   folding back into a menu.
   ------------------------------------------------------------------ */

/*
  ITS HEIGHT IS A TOKEN, because the floating panels have to open below it.

  The panels on the track page and the planner both anchor to the top left of
  the map, which is exactly where this sits: a panel opened straight on top of
  the base map switch, so choosing Satellite meant closing the panel first.
  They offset by this, and it is declared here rather than measured there,
  because a number copied into another stylesheet is a number that drifts the
  first time the padding changes.
*/
:root {
  --tl-mapstyle-h: 38px;
}

.tl-mapstyle {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  height: var(--tl-mapstyle-h);
  max-width: calc(100vw - 8rem);
  overflow-x: auto;
  scrollbar-width: none;
  border-radius: 9px;
  border: 1px solid var(--tl-hairline, rgba(0, 0, 0, 0.12));
  background: var(--tl-panel, #FAF9F4);
  box-shadow: 0 8px 20px -12px rgba(35, 40, 31, 0.4);
}

.tl-mapstyle::-webkit-scrollbar {
  display: none;
}

.tl-mapstyle-item {
  display: inline-flex;
  align-items: center;
  height: 30px;
  padding: 0 12px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--tl-muted, #5C6253);
  font-size: 0.78rem;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.tl-mapstyle-item:hover,
.tl-mapstyle-item:focus-visible {
  color: var(--tl-ink, #23281F);
  outline: none;
}

/* The live one is ink, not a tint: on a busy hillside a filled dark chip is
   the only marker that reads at a glance. */
.tl-mapstyle-item[aria-pressed="true"] {
  background: var(--tl-ink, #23281F);
  color: var(--tl-paper, #F3F2EC);
}

/* ------------------------------------------------------------------
   Attribution and scale
   ------------------------------------------------------------------ */

/* One short line: the styles credit each owner in a word or two, and the
   links carry the rest. */
.maplibregl-ctrl-attrib {
  border-radius: 999px 0 0 0;
  background: color-mix(in srgb, var(--tl-paper, #fff) 88%, transparent);
  font-size: 0.625rem;
  line-height: 1.6;
}

.maplibregl-ctrl-attrib-inner {
  white-space: nowrap;
}

.maplibregl-ctrl-attrib a {
  color: var(--tl-ink, #23281F);
}

.maplibregl-ctrl-scale {
  border-radius: 0.4rem;
  border: 1px solid var(--tl-hairline, rgba(0, 0, 0, 0.12));
  border-top: 0;
  background: color-mix(in srgb, var(--tl-paper, #fff) 90%, transparent);
  color: var(--tl-ink, #23281F);
  font-size: 0.68rem;
  font-weight: 600;
}

/* ------------------------------------------------------------------
   Night face

   The style picker's tokens flip on their own now that it is real markup
   rather than a native <select> with a chevron baked into a data URI.
   ------------------------------------------------------------------ */

/* MapLibre's zoom and compass glyphs are dark PNG data URIs baked into its own
   stylesheet, so on the night face they need inverting to stay legible. */
[data-bs-theme="dark"] .maplibregl-ctrl-group button .maplibregl-ctrl-icon {
  filter: invert(1) brightness(1.4);
}
