/*
 * One look for all OpenLayers controls: zoom, rotate, attribution, layer switcher,
 * location controls and GPS button.
 *
 * The module ships neutral defaults. A theme sets the custom properties on :root
 * to match its design. :where() keeps these defaults at zero specificity, so a
 * theme's :root rule always wins, whatever the stylesheet order.
 */
:where(:root) {
  --geolocation-ol-control-bg: rgba(255,255,255,.4);
  --geolocation-ol-control-fg: #1a1a1a;
  --geolocation-ol-control-border: unset;
  --geolocation-ol-control-radius: .25rem;
  --geolocation-ol-control-shadow: 0 1px 3px rgb(0 0 0 / 30%);
  --geolocation-ol-control-padding: .375rem;
  --geolocation-ol-control-gap: .375rem;
  --geolocation-ol-control-font-size: 1rem;
  --geolocation-ol-control-target: 28px;
  --geolocation-ol-control-accent: #4c6b95;
  --geolocation-ol-control-accent-fg: #fff;
  --geolocation-ol-control-accent-hover: #152b47;
  --geolocation-ol-control-focus: #1a1a1a;
  --geolocation-ol-map-focus: #1a1a1a;
}

/* Container: the same surface for every control. */
.ol-control,
.ol-attribution:not(.ol-collapsed) {
  background-color: var(--geolocation-ol-control-bg);
  color: var(--geolocation-ol-control-fg);
  border: 1px solid var(--geolocation-ol-control-border);
  border-radius: var(--geolocation-ol-control-radius);
  box-shadow: var(--geolocation-ol-control-shadow);
  padding: var(--geolocation-ol-control-padding);
  font-size: var(--geolocation-ol-control-font-size);
}

.ol-control:hover {
  background-color: var(--geolocation-ol-control-bg);
}

/* Buttons: the same size, colour and focus ring for every control. */
.ol-control button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: var(--geolocation-ol-control-target);
  min-height: var(--geolocation-ol-control-target);
  border: 1px solid var(--geolocation-ol-control-accent);
  border-radius: var(--geolocation-ol-control-radius);
  background-color: var(--geolocation-ol-control-accent);
  color: var(--geolocation-ol-control-accent-fg);
  font: inherit;
  font-size: var(--geolocation-ol-control-font-size);
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
}

.ol-control button:hover {
  background-color: var(--geolocation-ol-control-accent-hover);
  border-color: var(--geolocation-ol-control-accent-hover);
}

.ol-control button:focus-visible {
  outline: 3px solid var(--geolocation-ol-control-focus);
  outline-offset: 2px;
}

.ol-control button:disabled {
  opacity: .6;
  cursor: progress;
}

.ol-control button .bi,
.ol-control button [class^="maki-"] {
  font-size: 1.25rem;
  line-height: 1;
}

/* Zoom buttons keep the same square target as the other buttons. */
.ol-zoom button {
  width: var(--geolocation-ol-control-target);
  height: var(--geolocation-ol-control-target);
}

.ol-zoom > * + * {
  margin-block-start: var(--geolocation-ol-control-gap);
}

/* Visually hidden text: accessible names of icon-only controls. */
.geolocation-ol-control-label {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* Keyboard focus on the map itself. */
.geolocation-map-widget .geolocation-openlayers-keyboard-navigation:focus {
  outline: 3px solid var(--geolocation-ol-map-focus);
  outline-offset: -4px;
}

/*
 * ol-ext hides the layer inputs (display: none), so they cannot be reached by keyboard.
 * Keep them focusable but visually hidden. The label shows the focus ring.
 */
.ol-control.ol-layerswitcher input.ol-visibility {
  display: block;
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  opacity: 0;
  overflow: hidden;
}

.ol-control.ol-layerswitcher input.ol-visibility:focus-visible + label {
  outline: 3px solid var(--geolocation-ol-control-focus);
  outline-offset: 2px;
}

/*
 * ol-ext clips the layer switcher (overflow: hidden), which cuts the focus ring of its
 * toggle. Collapsed, the switcher is only that toggle, so let the ring show.
 */
.ol-control.ol-layerswitcher.ol-collapsed {
  overflow: unset;
}
