/* Leaflet integration styles. All brand values come from brand.css. */

.leaflet-container { font-family: var(--font-sans); }

.leaflet-container a { color: var(--color-soup-500) !important; }

.map-container {
  box-shadow: var(--shadow-card);
  position: relative;
  height: 100%;
  min-height: 500px;
  border-radius: var(--radius-card);
  overflow: hidden;
  /* Stacking context: Leaflet's internal panes run z-index 400–700, which
     otherwise paint OVER the sticky navbar (z-50) when the page scrolls.
     z-index: 0 traps them inside this box. NOTE: the map div and Leaflet's
     .leaflet-container are the SAME node (Leaflet mounts on this element),
     so descendant selectors like `.map-container .leaflet-container` never
     match — style this class directly. */
  z-index: 0;
}

/* Branded pins (SVG divIcons built in map_controller.js — keep the shapes in
   sync with app/views/festivals/_pin_icon.html.erb, the map legend's
   server-side copy). */
.festival-pin { background: transparent; border: none; }
.festival-pin svg { filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.3)); }

/* Sidebar map on event pages (legacy used an explicit 300px height). */
.map-container--compact {
  min-height: 300px;
  height: 300px;
}

/* A map embedded between a card's heading and directions footer. */
.map-container--inset {
  min-height: 260px;
  height: 260px;
  border-radius: 0;
  box-shadow: none;
}

/* Style for map popups */
.map-popup {
  padding: 20px;
  text-align: left;
  transition: all 0.3s ease;
  border-radius: var(--radius-card);
}

.map-popup:hover { background-color: var(--color-cream); }

.map-popup h5 {
  font-size: 0.8125rem;
  line-height: 1.3;
  font-weight: 600;
  font-family: var(--font-sans);
  color: var(--color-broth-600);
  margin: 0 0 0.35rem;
  text-shadow: none;
}

.map-popup h6 {
  font-size: 1rem;
  line-height: 1.4;
  color: var(--color-ink);
  font-family: var(--font-sans);
  font-weight: 500;
  margin: 0 0 0.5rem;
  text-shadow: none;
}

.map-popup .small { color: var(--color-ink); opacity: 0.85; font-size: 0.85rem; }

.map-popup .popup-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.map-popup .popup-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
  padding: 0.35rem 0.85rem;
  border-radius: var(--radius-legacy);
  border: 1px solid var(--color-soup-500);
  color: var(--color-soup-500);
  background-color: transparent;
  text-decoration: none;
  box-shadow: var(--shadow-card);
  transition: all 0.3s ease;
}

.map-popup .popup-btn:hover {
  color: white !important;
  background-color: var(--color-soup-500);
  border-color: var(--color-soup-500);
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

/* Override Leaflet's default popup styles */
.leaflet-popup-content-wrapper {
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 0;
}

.leaflet-popup-content { margin: 0; min-width: 200px; }
.leaflet-popup-close-button { z-index: 10; }

/* Map zoom controls */
.leaflet-control-zoom {
  border: none !important;
  box-shadow: var(--shadow-chip) !important;
}

.leaflet-control-zoom a {
  color: var(--color-ink) !important;
  background-color: white !important;
  border: none !important;
}

.leaflet-control-zoom a:hover { background-color: var(--color-cream) !important; }

/* Map attribution */
.leaflet-control-attribution {
  font-size: 10px !important;
  background-color: rgba(255, 255, 255, 0.8) !important;
}

/* Mobile map touch overlay */
.map-touch-overlay {
  position: absolute;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.1);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 0.3s ease;
}

.map-touch-overlay.active { background-color: transparent; }

.map-touch-message {
  background-color: white;
  color: var(--color-ink);
  padding: 8px 15px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-card);
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.map-exit-button {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background-color: var(--color-soup-500);
  color: white;
  padding: 6px 14px;
  border-radius: 30px;
  font-size: 13px;
  opacity: 0.85;
  box-shadow: var(--shadow-stamp);
  cursor: pointer;
  z-index: 1001;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.map-exit-button:hover {
  opacity: 1;
  transform: translateX(-50%) translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

@media (min-width: 992px) {
  .map-touch-overlay,
  .map-exit-button { display: none; }
}

/* Events list next to the map: independently scrollable on desktop, with
   the brand scrollbar (scrollbar-brand, brand.css) */
.events-list-container { transition: all 0.3s ease; }

@media (min-width: 992px) {
  .events-list-container {
    overflow-y: auto;
    overflow-x: hidden;
    max-height: 70vh;
    padding-right: 4px;
  }
}

@media (max-width: 991.98px) {
  .events-list-container { overflow: visible; max-height: none; }
}

/* User location marker (pulsing coral dot) */
.user-location-marker-wrapper { background: transparent; }

.user-location-marker {
  background-color: var(--color-soup-500);
  border: 2px solid white;
  border-radius: 50%;
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--color-soup-500) 40%, transparent);
  height: 100%;
  width: 100%;
  position: relative;
  animation: sf-pulse 1.5s infinite;
}

@keyframes sf-pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--color-soup-500) 70%, transparent); }
  70% { box-shadow: 0 0 0 10px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

@media (prefers-reduced-motion: reduce) {
  .user-location-marker { animation: none; }
}

/* A festival drawn as a dot rather than a pin (map_controller.js isDot, and
   the /map legend): sage once held with no next date in sight, ochre while
   a next edition is expected (the estimated-date colour). */
.festival-dot {
  border-radius: 9999px;
  background: var(--color-sage-400);
  border: 2px solid #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.festival-dot--series { background: var(--color-ochre); }

/* The /map page's full-screen map (atlas_controller.js): edge to edge, no
   card chrome. Its own stacking context keeps Leaflet's panes (z 400–1000)
   under the rail and the panel drawn over it. */
.atlas-canvas {
  z-index: 0;
  background: var(--color-cream);
}
