/*
 * Map chrome for the reset map. Sits on top of the vendored Leaflet stylesheets
 * and repaints them in the route-tape palette (see the design system, §4).
 *
 * Linked by app/views/shared/_map_assets.html.erb, which picks up every
 * app/assets/stylesheets/leaflet*.css in sorted order — so this file, sorting
 * last, is the one that gets to override the vendored rules.
 */

:root {
  --tape-fresh:   #E23D28;
  --tape-recent:  #E08A3C;
  --tape-fading:  #A79A84;
  --tape-stale:   #C9C2B6;
  --tape-unknown: #7C776E;
}

/* ---------------------------------------------------------------- container */

/* The controller stamps `reset-map` onto the element Leaflet initialises in, so
   `.reset-map` IS the `.leaflet-container`.
   Sizing is deliberately left alone: the view owns the box (the map pages use
   `.map-canvas absolute inset-0`, the gym page a fixed height), and Leaflet sets
   `position` itself if the container is static. Setting either here would fight
   the Tailwind utilities on the same element. */
.reset-map {
  background-color: #2C3338; /* --graphite: shows through while tiles load */
  font-family: "IBM Plex Sans", ui-sans-serif, system-ui, sans-serif;

  /* Leaflet stacks its panes from z-index 400 up to 1000. Without a stacking
     context of its own the map would paint over anything laid on top of it —
     the hero's search console, the legend cards — so trap those z-indexes here. */
  isolation: isolate;
}

.reset-map:focus-visible {
  outline: 2px solid var(--tape-fresh);
  outline-offset: 2px;
}

/* Mute the raster tiles a touch so the tape-coloured pins stay the loudest
   thing on the page. */
.reset-map .leaflet-tile-pane {
  filter: saturate(0.55) contrast(0.92) brightness(1.02);
}

/* ------------------------------------------------------------------- chrome */

.reset-map .leaflet-bar,
.reset-map .leaflet-control-zoom {
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  box-shadow: none;
}

.reset-map .leaflet-bar a,
.reset-map .leaflet-bar a:hover {
  background-color: #2C3338;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  color: #F2EFE9;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
}

.reset-map .leaflet-bar a:hover {
  background-color: #3D454B;
}

.reset-map .leaflet-bar a:focus-visible {
  outline: 2px solid var(--tape-fresh);
  outline-offset: -2px;
}

.reset-map .leaflet-control-attribution {
  background: rgba(44, 51, 56, 0.88);
  color: #E6E1D7;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 10px;
  letter-spacing: 0.01em;
  padding: 2px 6px;
}

.reset-map .leaflet-control-attribution a {
  color: #F2EFE9;
  text-decoration: underline;
}

/* --------------------------------------------------------------- pin labels */

/* A preview map that opens the full one when clicked. Pins keep their own
   pointer, so a click on a pin still means "show me this gym". */
.reset-map--explorable { cursor: pointer; }

/* ------------------------------------------------------------------- pins */

/* A drop shadow lifts the white ring off the tile, so a pin stays findable over
   dense city cartography as well as open parkland. Applied to the SVG pane
   rather than per-path so the browser composites it once. */
.reset-map .leaflet-overlay-pane svg { filter: drop-shadow(0 1px 2px rgba(26, 29, 32, 0.45)); }

.reset-pin {
  cursor: pointer;
  transition: r 120ms ease, stroke-width 120ms ease;
}

/* Grow on hover and keyboard focus: a bigger target once you are already near
   it, and a visible answer to "is this thing clickable". */
.reset-map .reset-pin:hover,
.reset-map .reset-pin:focus-visible {
  r: 12;
  stroke-width: 4;
}

@media (prefers-reduced-motion: reduce) {
  .reset-pin { transition: none; }
}

/* Coarse pointers get a larger pin outright, since there is no hover to grow it. */
@media (pointer: coarse) {
  .reset-map .reset-pin { r: 11; }
}

.reset-map .leaflet-interactive:focus-visible {
  outline: 2px solid #F2EFE9;
  outline-offset: 2px;
}

/* ------------------------------------------------------------------ popups */

.reset-map .leaflet-popup-content-wrapper {
  background: #F2EFE9;
  border-radius: 8px;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.18);
  color: #1A1D20;
  padding: 0;
}

.reset-map .leaflet-popup-content {
  margin: 0;
  min-width: 200px;
  width: auto !important;
}

.reset-map .leaflet-popup-tip {
  background: #F2EFE9;
  box-shadow: none;
}

.reset-map .leaflet-popup-close-button {
  color: #7C776E;
  padding: 6px 6px 0 0;
}

.gym-popup {
  padding: 12px 14px 12px;
}

.gym-popup__tape {
  border-radius: 2px;
  display: block;
  height: 4px;
  margin-bottom: 9px;
  width: 44px;
}

.gym-popup__tape--fresh   { background: var(--tape-fresh); }
.gym-popup__tape--recent  { background: var(--tape-recent); }
.gym-popup__tape--fading  { background: var(--tape-fading); }
.gym-popup__tape--stale   { background: var(--tape-stale); }
.gym-popup__tape--unknown { background: transparent; border: 1px dashed var(--tape-unknown); }

.gym-popup__name {
  font-family: "Archivo", ui-sans-serif, system-ui, sans-serif;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin: 0 0 2px;
  text-transform: uppercase;
}

.gym-popup__place {
  color: #7C776E;
  font-size: 12px;
  margin: 0 0 8px;
}

.gym-popup__freshness {
  display: block;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 11px;
  letter-spacing: 0.02em;
  margin: 0 0 10px;
}

.gym-popup__freshness--fresh   { color: #B82D1B; }
.gym-popup__freshness--recent  { color: #A0602A; }
.gym-popup__freshness--fading,
.gym-popup__freshness--stale,
.gym-popup__freshness--unknown { color: #7C776E; }

.leaflet-container a.gym-popup__link {
  background: #E23D28;
  border-radius: 4px;
  color: #FFFFFF;
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 10px;
  text-decoration: none;
}

.leaflet-container a.gym-popup__link:hover { background: #B82D1B; }

.leaflet-container a.gym-popup__link:focus-visible {
  outline: 2px solid #1A1D20;
  outline-offset: 2px;
}

/* Secondary, quieter than the primary action: the gym's own site. */
.leaflet-container a.gym-popup__site {
  color: #7C776E;
  display: inline-block;
  font-size: 12px;
  margin-left: 8px;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.leaflet-container a.gym-popup__site:hover { color: #B82D1B; }

.leaflet-container a.gym-popup__site:focus-visible {
  outline: 2px solid #1A1D20;
  outline-offset: 2px;
}

/* ---------------------------------------------------------------- clusters */

.reset-cluster {
  align-items: center;
  background: #2C3338;
  border-radius: 999px;
  box-shadow: 0 0 0 4px rgba(44, 51, 56, 0.28);
  color: #F2EFE9;
  display: flex;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 12px;
  font-weight: 500;
  height: 34px;
  justify-content: center;
  width: 34px;
}

.reset-cluster--lg { font-size: 13px; height: 42px; width: 42px; }
.reset-cluster--xl { font-size: 13px; height: 50px; width: 50px; }

.reset-cluster--fresh   { border: 3px solid var(--tape-fresh); }
.reset-cluster--recent  { border: 3px solid var(--tape-recent); }
.reset-cluster--fading  { border: 3px solid var(--tape-fading); }
.reset-cluster--stale   { border: 3px solid var(--tape-stale); }
.reset-cluster--unknown { border: 1px dashed var(--tape-unknown); }

/* ------------------------------------------------------------------ legend */

.reset-map__legend {
  background: rgba(44, 51, 56, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  color: #E6E1D7;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 10px;
  letter-spacing: 0.02em;
  line-height: 1.6;
  padding: 8px 10px;
}

.reset-map__legend dl { display: grid; gap: 2px 8px; grid-template-columns: 10px auto; margin: 0; }
.reset-map__legend dt { border-radius: 2px; height: 10px; margin-top: 3px; width: 10px; }
.reset-map__legend dd { margin: 0; }
.reset-map__legend .is-fresh   { background: var(--tape-fresh); }
.reset-map__legend .is-recent  { background: var(--tape-recent); }
.reset-map__legend .is-fading  { background: var(--tape-fading); }
.reset-map__legend .is-stale   { background: var(--tape-stale); }
.reset-map__legend .is-unknown { background: transparent; border: 1px dashed var(--tape-unknown); }

/* ------------------------------------------------------------------ status */

.reset-map__status {
  background: rgba(44, 51, 56, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  color: #E6E1D7;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 11px;
  padding: 6px 10px;
}

.reset-map__status[hidden] { display: none; }

@media (prefers-reduced-motion: reduce) {
  .reset-map .leaflet-fade-anim .leaflet-tile,
  .reset-map .leaflet-zoom-anim .leaflet-zoom-animated {
    transition: none !important;
  }
}
