/**
 * File: map-modes.css
 * Purpose: Relief/outdoor previews, trail legend, and cartographic-label toggle.
 * Placement: Loaded only by map.html after the shared styles.
 * Dependencies: Layer menu primitives defined in styles.css.
 * Public selectors: Preview swatches, .trail-legend, .layer-toggle and basemap attribution logo.
 * Side effects: Shows independent tool legends and reserves measured attribution space below controls.
 */

.layer-swatch-relief {
  background:
    linear-gradient(
      145deg,
      transparent 55%,
      rgba(255, 255, 255, 0.34) 56% 59%,
      transparent 60%
    ),
    radial-gradient(ellipse at 35% 76%, #4e6e43 0 18%, transparent 19%),
    radial-gradient(ellipse at 68% 48%, #899469 0 24%, transparent 25%),
    linear-gradient(145deg, #e8dfbd, #73855f 60%, #c3b586);
}

.layer-swatch-outdoor {
  background:
    linear-gradient(34deg, transparent 43%, #c54d47 44% 49%, transparent 50%),
    repeating-linear-gradient(146deg, transparent 0 5px, #8b6944 6px 8px, transparent 9px 14px),
    linear-gradient(145deg, #b8d0ad, #ece8d7 58%, #91becb);
}

.layer-options {
  margin-top: 0.42rem;
  padding-top: 0.42rem;
  border-top: 1px solid rgba(255, 255, 255, 0.09);
}

.layer-toggle {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.75rem;
  min-height: 3rem;
  padding: 0.42rem 0.55rem;
  border-radius: 0.5rem;
  cursor: pointer;
  transition: background 130ms ease;
}

.layer-toggle:hover {
  background: rgba(255, 255, 255, 0.055);
}

.layer-toggle-copy strong,
.layer-toggle-copy small {
  display: block;
}

.layer-toggle-copy strong {
  font-size: 0.68rem;
}

.layer-toggle-copy small {
  margin-top: 0.12rem;
  color: rgba(255, 255, 255, 0.46);
  font-size: 0.55rem;
  line-height: 1.3;
}

.layer-toggle-control {
  position: relative;
  width: 2.15rem;
  height: 1.18rem;
}

.layer-toggle-control input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.layer-toggle-track {
  position: absolute;
  inset: 0;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  transition: background 150ms ease, border-color 150ms ease;
}

.layer-toggle-track::after {
  position: absolute;
  top: 0.15rem;
  left: 0.16rem;
  width: 0.78rem;
  height: 0.78rem;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.75);
  box-shadow: 0 2px 5px rgba(6, 15, 11, 0.3);
  content: "";
  transition: transform 150ms ease, background 150ms ease;
}

.layer-toggle-control input:checked + .layer-toggle-track {
  border-color: #4285F4;
  background: #4285F4;
}

.layer-toggle-control input:checked + .layer-toggle-track::after {
  background: #ffffff;
  transform: translateX(0.96rem);
}

.layer-toggle:has(input:focus-visible) {
  outline: 2px solid #4285F4;
  outline-offset: -2px;
}

.layer-toggle:has(input:disabled) {
  cursor: wait;
  opacity: 0.55;
}

.trail-legend {
  display: none;
  margin-top: 0.42rem;
  padding: 0.7rem 0.58rem 0.55rem;
  border-top: 1px solid rgba(255, 255, 255, 0.09);
}

body[data-map-tool="outdoor"] .trail-legend {
  display: block;
}

/* Satellite attribution stays present when a thematic tool is drawn above it. */
body.map-page[data-map-base="satellite"] .mapbox-logo { display: block; }

/* Composed credits can wrap on phones; move only floating controls, never the map. */
.map-corner-controls { bottom: max(3.15rem, var(--map-attribution-clearance, 0px)); }
@media (max-width: 44rem) {
  .map-corner-controls { bottom: max(3.05rem, var(--map-attribution-clearance, 0px)); }
}

.trail-legend-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.7rem;
}

.trail-legend-heading strong {
  font-size: 0.67rem;
}

.trail-legend-heading span {
  padding: 0.13rem 0.34rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  color: rgba(255, 255, 255, 0.58);
  font-size: 0.48rem;
  letter-spacing: 0.04em;
}

.trail-legend ul {
  display: grid;
  gap: 0.38rem;
  margin: 0.62rem 0 0;
  padding: 0;
  list-style: none;
}

.trail-legend li {
  display: grid;
  grid-template-columns: 2rem minmax(0, 1fr);
  align-items: center;
  gap: 0.45rem;
  color: rgba(255, 255, 255, 0.76);
  font-size: 0.56rem;
}

.trail-key {
  display: block;
  height: 2px;
  background: currentColor;
}

.trail-key-walk {
  color: #e06b64;
  background: repeating-linear-gradient(90deg, currentColor 0 4px, transparent 4px 7px);
}

.trail-key-track {
  color: #c69a68;
  background: repeating-linear-gradient(90deg, currentColor 0 7px, transparent 7px 11px);
}

.trail-key-cycle {
  color: #50a4d6;
  background: repeating-linear-gradient(90deg, currentColor 0 6px, transparent 6px 9px);
}

.trail-legend > small {
  display: block;
  margin-top: 0.62rem;
  color: rgba(255, 255, 255, 0.4);
  font-size: 0.5rem;
  line-height: 1.35;
}
