/* Basemap + terrain layers and their switcher (features/basemaps.js).
   The map view decides WHERE the switcher sits (it is a plain inline block); this file styles the thing itself. */

/* ── Panes ── */
/* Relief overlay: the layer carries its own opacity (~.35); multiply lets the base map's colour show through. */
.leaflet-pane.bm-terrain { mix-blend-mode: multiply; pointer-events: none; }

/* Dark theme: dim the raster a little so it sits with the ink palette. Never inverted — colours stay true. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .leaflet-pane.bm-tiles { filter: brightness(.82) saturate(.92); }
}
:root[data-theme="dark"] .leaflet-pane.bm-tiles { filter: brightness(.82) saturate(.92); }

/* ── Switcher ── */
.bm-switch {
  position: relative;
  display: inline-block;
  font-family: var(--font-sans);
  color: var(--text);
  -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.bm-toggle {
  display: grid; place-items: center;
  width: var(--tap-min); height: var(--tap-min);
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-2);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-float);
  cursor: pointer;
}
.bm-toggle[hidden] { display: none; }
.bm-toggle:active,
.bm-switch.is-open .bm-toggle { background: var(--surface-pressed); }
.bm-toggle:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }

/* Collapsed by default: the panel drops from the button, anchored to its trailing edge. */
.bm-panel {
  display: none;
  position: absolute;
  top: calc(100% + var(--s-2));
  right: 0;
  width: max-content;
  max-width: min(320px, calc(100vw - 2 * var(--gutter)));
  max-height: min(70vh, 520px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: var(--s-2);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-3);
  background: var(--surface);
  box-shadow: var(--shadow-float);
}
.bm-switch.is-open .bm-panel { display: block; }

/* Compare mode: always open, laid out in the flow so the two of you can flick between styles. */
.bm-switch.is-compare { display: block; }
.bm-switch.is-compare .bm-panel {
  display: block;
  position: static;
  width: auto; max-width: none; max-height: none;
}

.bm-group { display: flex; flex-direction: column; }
.bm-group + .bm-group {
  margin-top: var(--s-2);
  padding-top: var(--s-2);
  border-top: 1px solid var(--line);
}
.bm-title {
  padding: var(--s-1) var(--s-2);
  color: var(--text-3);
  font-size: var(--fs-label); line-height: var(--lh-label);
  letter-spacing: .06em; text-transform: uppercase;
}

/* One choice: a radio (base) or a checkbox (overlay) — same row, different mark. */
.bm-row {
  position: relative;
  display: flex; align-items: center; gap: var(--s-3);
  min-height: var(--tap-min);
  padding: var(--s-2);
  border-radius: var(--r-2);
  cursor: pointer;
}
.bm-row:active { background: var(--surface-pressed); }
.bm-row.is-on { background: var(--surface-inset); }

.bm-input {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}
.bm-mark {
  flex: none;
  display: grid; place-items: center;
  width: 20px; height: 20px;
  border: 1.5px solid var(--line-strong);
  border-radius: 50%;
  background: var(--surface);
}
.bm-mark::after {
  content: "";
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--text);
  transform: scale(0);
  transition: transform var(--dur-1) var(--ease-out);
}
.bm-input:checked + .bm-mark { border-color: var(--text); }
.bm-input:checked + .bm-mark::after { transform: scale(1); }
.bm-input[type="checkbox"] + .bm-mark,
.bm-input[type="checkbox"] + .bm-mark::after { border-radius: var(--r-1); }
.bm-input:focus-visible + .bm-mark { outline: 2px solid var(--text); outline-offset: 2px; }

.bm-row-text { display: flex; flex-direction: column; min-width: 0; }
.bm-row-label { font-size: var(--fs-small); line-height: var(--lh-small); font-weight: 600; }
.bm-row-desc { color: var(--text-2); font-size: var(--fs-caption); line-height: var(--lh-caption); }

.bm-offline {
  margin: var(--s-2) 0 0;
  padding: var(--s-2);
  border-top: 1px solid var(--line);
  color: var(--text-2);
  font-size: var(--fs-caption); line-height: var(--lh-caption);
}
.bm-offline[hidden] { display: none; }

@media (prefers-reduced-motion: reduce) {
  .bm-mark::after { transition: none; }
}
