/* Leaflet map customizations for hotel pages */

/* Show the mobile "Map" pill only at scrollY === 0.
   Browsers without animation-timeline ignore the rule — pill stays always visible. */
@keyframes map-pill-hide {
  from { opacity: 1; visibility: visible; }
  to   { opacity: 0; visibility: hidden; }
}

@supports (animation-timeline: scroll()) {
  .map-pill-fab {
    animation: map-pill-hide steps(1, jump-end) both;
    animation-timeline: scroll(root);
    animation-range: 0 1px;
  }
}

.custom-map-marker { background: none !important; border: none !important; }

.leaflet-container,
.leaflet-dragging .leaflet-container { cursor: default !important; }

.circle-marker {
  position: relative;
  cursor: pointer;
  animation: marker-drop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.5));
  contain: layout paint;
}


.circle-marker.map-highlight {
  transform: translateY(-1px);
}

@keyframes marker-drop {
  0% { opacity: 0; transform: translateY(-20px) scale(0.8); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

.leaflet-control-attribution {
  background: rgba(255,255,255,0.7) !important;
  font-size: 10px !important;
  padding: 2px 6px !important;
  border-radius: 4px 0 0 0 !important;
}

.leaflet-control-attribution a { color: #71717a !important; }
.leaflet-attribution-flag { display: none !important; }
.leaflet-control-attribution a[href*="leafletjs"] { display: none !important; }
.leaflet-control-attribution span[aria-hidden] { display: none !important; }

.map-label {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  padding: 0 !important;
  color: #52525b;
  font-size: 12px;
  font-weight: 500;
  width: 150px !important;
  line-height: 1.3;
  text-shadow:
    -1px -1px 0 white,
     1px -1px 0 white,
    -1px  1px 0 white,
     1px  1px 0 white,
     0   -1px 0 white,
     0    1px 0 white,
    -1px  0   0 white,
     1px  0   0 white;
  overflow: hidden !important;
  white-space: nowrap !important;
  text-overflow: ellipsis !important;
  pointer-events: auto !important;
  cursor: pointer;
}


.map-label.map-highlight {
  translate: 0 -1px;
}

.map-label::before { display: none !important; }

.world-map-label {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  padding: 0 0 0 4px !important;
  margin: 0 !important;
  color: #52525b;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.3;
  white-space: nowrap !important;
  text-shadow:
    -1px -1px 0 white, 1px -1px 0 white,
    -1px  1px 0 white, 1px  1px 0 white,
     0   -1px 0 white, 0    1px 0 white,
    -1px  0   0 white, 1px  0   0 white;
  pointer-events: auto !important;
  cursor: pointer;
}

.world-map-label::before { display: none !important; }

.world-map .marker-cluster-custom {
  background: #10b981;
  border: 2px solid #34d399;
}

.world-map .leaflet-control-recenter {
  margin-bottom: 5px !important;
}

.world-map .leaflet-control-zoom {
  margin-top: 0 !important;
}

.map-label-current {
  color: #ef4444 !important;
  display: -webkit-box !important;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  white-space: normal !important;
  text-overflow: ellipsis !important;
}

.map-label-other {
  display: -webkit-box !important;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  white-space: normal !important;
  text-overflow: ellipsis !important;
}

/* Z-index: other labels (590) < markers (600) < current label (700 via JS pane) < popup (10001) */
.leaflet-marker-pane { z-index: 600 !important; }
.leaflet-tooltip-pane { z-index: 590 !important; }
.leaflet-popup-pane { z-index: 10001 !important; }

/* Highlighted marker floats above siblings */
.leaflet-marker-icon:has(.map-highlight) {
  z-index: 10000 !important;
}

.leaflet-control-zoom {
  border: 1px solid #e4e4e7 !important;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1) !important;
  border-radius: 8px !important;
  overflow: hidden;
  margin-top: 0 !important;
}

.leaflet-control-zoom a {
  background: #fafafa !important;
  color: #52525b !important;
  border: none !important;
  width: 32px !important;
  height: 32px !important;
  line-height: 32px !important;
  font-size: 16px !important;
  font-weight: 500 !important;
  -webkit-tap-highlight-color: transparent;
  outline: none !important;
}

.leaflet-control-zoom a:hover {
  color: #18181b !important;
}

.leaflet-control-zoom-in {
  border-radius: 8px 8px 0 0 !important;
  position: relative;
}

.leaflet-control-zoom-in::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 6px;
  right: 6px;
  height: 1px;
  background: #d4d4d8;
}

.leaflet-control-zoom-out { border-radius: 0 0 8px 8px !important; }

.leaflet-control-recenter {
  border: 1px solid #e4e4e7 !important;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1) !important;
  border-radius: 8px !important;
  margin-bottom: 6px !important;
}

.leaflet-control-recenter a {
  background: #fafafa !important;
  color: #52525b !important;
  border: none !important;
  width: 32px !important;
  height: 32px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  border-radius: 8px !important;
  -webkit-tap-highlight-color: transparent;
  outline: none !important;
}

.leaflet-control-recenter a:hover {
  color: #18181b !important;
}

/* ─── Marker cluster styles ─── */
.marker-cluster-custom {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(16, 185, 129, 0.85);
  border: 2px solid rgba(167, 243, 208, 0.7);
  color: #fafafa;
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
}

.leaflet-cluster-anim .leaflet-marker-icon,
.leaflet-cluster-anim .leaflet-marker-shadow {
  transition: transform 0.3s ease-out, opacity 0.3s ease-in;
}

.leaflet-cluster-spider-leg {
  stroke: #a1a1aa;
  stroke-opacity: 0.5;
}

/* Suppress marker-drop animation (temp highlight markers + initial map load) */
.no-marker-anim .circle-marker,
.map-init .circle-marker {
  animation: none;
}


/* ─── Place card popup (hover/click preview) ─── */
.map-place-card-popup,
.map-place-card-popup * {
  -webkit-tap-highlight-color: transparent;
}

.map-place-card-popup .leaflet-popup-content-wrapper {
  padding: 0;
  border-radius: 12px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
  overflow: hidden;
}

.map-place-card-popup .leaflet-popup-content {
  margin: 0;
  width: 260px !important;
}

/* Below mode: hide Leaflet's tip and draw a clean up-pointing triangle via
   pseudo-element on the outer popup — wrapper has overflow:hidden which
   would clip a ::before on it. Also zero Leaflet's default margin-bottom
   (reserved for the hidden tip) so the card doesn't overlap the marker. */
.map-place-card-popup--below .leaflet-popup-tip-container {
  display: none;
}

.map-place-card-popup--below.leaflet-popup {
  margin-bottom: 0;
}

.map-place-card-popup--below::before {
  content: "";
  position: absolute;
  top: -10px;
  left: 50%;
  margin-left: -10px;
  width: 0;
  height: 0;
  border-left: 10px solid transparent;
  border-right: 10px solid transparent;
  border-bottom: 10px solid white;
}

.map-place-card-popup .leaflet-popup-close-button {
  top: 4px !important;
  right: 6px !important;
  width: 22px;
  height: 22px;
  display: flex !important;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.9) !important;
  border-radius: 50%;
  color: #52525b !important;
  font-size: 18px !important;
  line-height: 1 !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
  -webkit-tap-highlight-color: transparent;
}

/* Expand touch target to 44×44 without enlarging the visual button */
.map-place-card-popup .leaflet-popup-close-button::after {
  content: "";
  position: absolute;
  inset: -11px;
}

.map-place-card,
.map-place-card * {
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}

.map-place-card {
  display: block;
  color: inherit;
  text-decoration: none;
  cursor: pointer;
}

.map-place-card-body {
  padding: 10px 12px 0;
}

/* When both headline and chips are hidden, the title is the last visible
   element — give the body bottom padding so it doesn't hug the card edge. */
.map-place-card-body:has([data-field="headline"][hidden]):has([data-field="chips"][hidden]) {
  padding-bottom: 10px;
}

.map-place-card-title {
  font-size: 15px;
  font-weight: 600;
  color: #18181b;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.map-place-card-headline {
  font-size: 13px;
  color: #3f3f46;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Mobile adjustments for map controls */
@media (width < 40rem) {
  .leaflet-control-zoom,
  .leaflet-control-recenter {
    position: absolute !important;
    margin: 0 !important;
  }

  .leaflet-control-recenter {
    top: 8px !important;
    right: 8px !important;
  }

  .leaflet-control-zoom {
    top: 50px !important;
    right: 8px !important;
  }

  .leaflet-control-zoom a,
  .leaflet-control-recenter a {
    width: 36px !important;
    height: 36px !important;
    line-height: 36px !important;
    font-size: 16px !important;
  }

  .leaflet-control-recenter a svg {
    width: 16px !important;
    height: 16px !important;
  }

  .world-map .leaflet-control-zoom,
  .world-map .leaflet-control-recenter {
    position: static !important;
    margin: 8px 8px 0 0 !important;
  }

  /* Match the desktop label weight — high-density screens render 500 heavier */
  .map-label,
  .world-map-label {
    font-weight: 400;
  }
}
