/* Four map-marker families share one scale, palette and text hierarchy. */
:root {
  --map-photo-size: 84px;
  --map-marker-size: 36px;
  --map-landmark-size: 32px;
  --map-park-size: 20px;
  --map-selection-scale: 1.4;
  --map-photo-radius: 18px;
  --map-icon-border: 2px;
  --map-category-orange: #ff8c24;
  --map-category-green: #299d50;
  --map-category-water: #3d9cbe;
  --map-category-peak: #4a9a60;
  --map-category-green-top: #50bb74;
  --map-category-green-bottom: #238c48;
  --map-category-water-top: #65bdd8;
  --map-category-water-bottom: #2d8dac;
  --map-category-peak-top: #79b58a;
  --map-category-peak-bottom: #3d8a53;
  --map-water-label-color: #236d91;
  --map-category-outline: #fff;
  --map-selection-color: var(--blue,#087cf1);
  --map-selection-ring: 0 0 0 3px var(--map-selection-color);
  --map-label-size: 12px;
  --map-label-weight: 550;
  --map-label-color: #292d32;
  --map-label-halo: rgb(255 255 255 / 96%);
  --map-label-font: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --map-marker-shadow: 0 2px 6px rgb(25 42 52 / 18%);
  --map-context-shadow: 0 2px 5px rgb(30 71 49 / 24%);
  --map-marker-motion: 180ms cubic-bezier(.22, .8, .22, 1);
}

#map {
  cursor: default;
  --map-label-base: 12px;
  --map-label-size: 12px;
  --map-label-weight: 550;
}

#map .leaflet-marker-icon {
  cursor: pointer;
}

/* The camera/layout owner sets actual dimensions, including selected growth. */
#map :is(.photo-marker, .photo-cluster) {
  --map-photo-frame: var(--map-category-outline);
}
/* Idle geometry commits together, so enlargement never separates a photo from its map tip. */
#map :is(.photo-marker, .photo-cluster):not(:is(.is-preview, .is-photo-preview, .is-photo-closing)) {
  --marker-resize-duration: 0s;
}
#map .photo-marker:not(:is(.is-preview, .is-photo-preview, .is-photo-closing)) > .photo-pin,
#map .photo-cluster:not(:is(.is-preview, .is-photo-preview, .is-photo-closing)) > .photo-stack,
#map .photo-marker:not(:is(.is-preview, .is-photo-preview, .is-photo-closing)) > .photo-pin > img,
#map .photo-cluster:not(:is(.is-preview, .is-photo-preview, .is-photo-closing)) > .photo-stack > img {
  transition-property: box-shadow, opacity;
}
#map .photo-marker.is-selected > .photo-map-pointer::before {
  background: var(--map-selection-color);
}
#map .photo-pin {
  filter: none;
}
#map .photo-marker:not(:is(.is-preview, .is-photo-preview, .is-photo-closing)) > .photo-pin {
  transform: none;
}
#map .photo-marker:not(:is(.is-photo-preview, .is-photo-closing)) > .photo-pin > img,
#map .photo-cluster:not(:is(.is-photo-preview, .is-photo-closing)) > .photo-stack > img {
  border-color: var(--map-photo-frame);
  border-radius: var(--photo-radius, var(--map-photo-radius));
  box-shadow: var(--map-marker-shadow);
}
#map .photo-marker:not(:is(.is-photo-preview, .is-photo-closing)) > .photo-pin > img {
  object-fit: cover;
}
#map .photo-cluster:not(:is(.is-photo-preview, .is-photo-closing)) > .photo-stack > img {
  left: 50%;
  top: 50%;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
#map .photo-cluster:not(:is(.is-photo-preview, .is-photo-closing)) > .photo-stack > img:nth-of-type(1) {
  transform: translate(-54%, -53%) rotate(-4deg);
}
#map .photo-cluster:not(:is(.is-photo-preview, .is-photo-closing)) > .photo-stack > img:nth-of-type(2) {
  transform: translate(-47%, -52%) rotate(3deg);
}
#map .photo-cluster:not(:is(.is-photo-preview, .is-photo-closing)) > .photo-stack > img:last-of-type {
  transform: translate(-50%, -50%);
}
#map .photo-marker.is-selected:not(:is(.is-photo-preview, .is-photo-closing)) > .photo-pin > img,
#map .photo-cluster.is-selected:not(:is(.is-photo-preview, .is-photo-closing)) > .photo-stack > img:last-of-type {
  box-shadow: var(--map-selection-ring), 0 4px 10px rgb(25 42 52 / 22%);
}

/* Photograph captions keep a quiet surface; icon captions use map halos. */
#map :is(.photo-marker, .photo-cluster):not(:is(.is-preview, .is-photo-preview))
  :is(.pin-label, .cluster-label) {
  border: 0;
  padding: 4px 7px;
  border-radius: 8px;
  background: rgb(255 255 255 / 97%);
  color: var(--map-label-color);
  font: var(--map-label-weight) var(--map-label-size)/1.2 var(--map-label-font);
  box-shadow: 0 1px 3px rgb(25 42 52 / 7%);
}
#map :is(.photo-marker, .photo-cluster).is-selected :is(.pin-label, .cluster-label) {
  background: var(--map-category-outline);
  color: var(--map-selection-color);
  font-weight: 600;
}
#map :is(.photo-marker, .photo-cluster).is-selected .marker-title {
  color: var(--map-selection-color);
}
#map :is(.photo-marker, .photo-cluster).is-selected:not(:is(.is-preview, .is-photo-preview, .is-photo-closing))
  .marker-idle-rating .marker-rating-star {
  color: currentColor;
}
#map .photo-stack .cluster-count {
  min-width: 22px;
  height: 22px;
  border: var(--map-icon-border) solid var(--map-category-outline);
  background: #fff;
  color: var(--map-label-color);
  font-size: 12px;
  font-weight: 600;
  box-shadow: var(--map-marker-shadow);
}
#map .photo-cluster.is-selected .cluster-count {
  background: var(--map-selection-color);
  color: white;
}

/* Collection results outside the active filter remain the second family. */
#map .compact-map-badge {
  box-sizing: border-box;
  border: 3px solid var(--map-category-outline);
  background: linear-gradient(#ffa346, #f76c15);
  box-shadow: 0 2px 5px #5736173c;
  font: 750 17px/1 var(--map-label-font);
  transition: box-shadow var(--map-marker-motion), background-color var(--map-marker-motion);
}
#map .compact-map-badge > .atlas-map-glyph {
  display: block;
  width: 74%;
  height: 74%;
  color: #fff;
  pointer-events: none;
}
#map .compact-map-marker.is-selected .compact-map-badge {
  box-shadow: var(--map-selection-ring), var(--map-marker-shadow);
  font-size: calc(var(--map-marker-current-size, calc(var(--map-marker-size) * var(--map-selection-scale))) * .47);
}
#map .compact-map-caption,
#map .atlas-landmark-label {
  color: var(--map-label-color);
  font: var(--map-label-weight) var(--map-label-size)/1.2 var(--map-label-font);
  -webkit-text-stroke: 3px var(--map-label-halo);
  paint-order: stroke fill;
  text-shadow: none;
}
#map .compact-map-caption {
  top: calc(100% + 5px);
  max-width: min(128px, 30vw);
  text-wrap: balance;
}
#map .compact-map-caption small {
  display: block;
  flex: 0 0 auto;
  margin-top: 2px;
  font-size: 10.5px;
  font-weight: 500;
  line-height: 1.2;
}
#map :is(.photo-marker, .photo-cluster):not(.is-selected) > [data-context-kind="water"] :is(.pin-label, .cluster-label),
#map .compact-map-marker:not(.is-selected) > [data-context-kind="water"] .compact-map-caption {
  color: var(--map-water-label-color);
}
#map .compact-map-marker:focus-visible {
  outline: 2px solid var(--map-selection-color);
  outline-offset: 3px;
}

/* Uncollected search results use the same landmark/context circles. */
#map .explore-marker-inner {
  width: 100%;
  height: 100%;
}
#map .explore-marker .explore-thumbnail,
#map .explore-marker .explore-category-icon {
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  border: var(--map-icon-border) solid var(--map-category-outline);
  border-radius: 50%;
  box-shadow: var(--map-marker-shadow);
}
#map .explore-context-icon {
  display: grid;
  place-items: center;
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  border: var(--map-icon-border) solid var(--map-category-outline);
  border-radius: 50%;
  background: linear-gradient(var(--map-category-green-top), var(--map-category-green-bottom));
  box-shadow: var(--map-context-shadow);
}
#map :is(.atlas-landmark-emblem, .explore-category-icon, .explore-context-icon) > .atlas-map-glyph {
  display: block;
  inline-size: 72%;
  block-size: 72%;
  color: #fff;
  pointer-events: none;
}
#map .explore-context-icon[data-context-kind="peak"] {
  background: linear-gradient(var(--map-category-peak-top), var(--map-category-peak-bottom));
}
#map .explore-context-icon[data-context-kind="water"] {
  background: linear-gradient(var(--map-category-water-top), var(--map-category-water-bottom));
}
/* The small painted circle keeps a comfortable transparent target around it. */
#map :is(.atlas-park-marker, .explore-context-marker)::before {
  position: absolute;
  inset: -2px;
  border-radius: 50%;
  content: '';
}
#map .explore-marker.is-selected :is(.explore-thumbnail, .explore-category-icon, .explore-context-icon) {
  box-shadow: var(--map-selection-ring), var(--map-marker-shadow);
}
#map .explore-context-marker.is-selected .explore-context-icon {
  border-width: calc(var(--map-icon-border) * var(--map-selection-scale));
}
#map .explore-marker-label {
  display: flex;
  top: calc(100% + 5px);
  left: 50%;
  translate: -50% 0;
  flex-direction: column;
  gap: 0;
  width: max-content;
  max-width: min(128px, 30vw);
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
  color: var(--map-label-color);
  font: var(--map-label-weight) var(--map-label-size)/1.2 var(--map-label-font);
  text-align: center;
  text-wrap: balance;
  white-space: normal;
  box-shadow: none;
  -webkit-text-stroke: 3px var(--map-label-halo);
  paint-order: stroke fill;
}
#map .explore-marker-name {
  display: -webkit-box;
  overflow: hidden;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
#map .explore-marker-label > .explore-rating { display: none; }
#map .explore-context-marker .explore-marker-label {
  top: 50%;
  left: calc(100% + 5px);
  translate: 0 -50%;
  align-items: flex-start;
  text-align: left;
}
#map .explore-marker:not(.is-selected):is([data-context-kind="water"], [data-caption-kind="water"]) .explore-marker-label {
  color: var(--map-water-label-color);
}
#map .explore-marker:focus-visible {
  outline: 2px solid var(--map-selection-color);
  outline-offset: 3px;
}

/* Keep the selected card caption white without shifting its measured bounds. */
#map :is(.compact-map-marker, .atlas-landmark, .explore-marker).is-selected
  :is(.compact-map-caption, .atlas-landmark-label, .explore-marker-label) {
  background: var(--map-category-outline);
  border-radius: 4px;
  box-shadow: 0 0 0 2px var(--map-category-outline);
  color: var(--map-selection-color);
  font-weight: 600;
  -webkit-text-stroke: 0;
}

/* Service icons and plain geography share the same typographic rhythm. */
#map .atlas-neighborhood-label > span {
  color: #3c4750;
  font: 450 11px/1.2 var(--map-label-font);
  -webkit-text-stroke: 3px var(--map-label-halo);
}
#map .atlas-tourist-zone-label > span {
  color: var(--zone-label-color, #555d66);
  font: 500 12px/1.2 var(--map-label-font);
  -webkit-text-stroke: 3px var(--map-label-halo);
}
#map .atlas-neighborhood-label:focus-visible > span,
#map .atlas-neighborhood-label:hover > span {
  color: var(--map-selection-color);
}
#map .atlas-neighborhood-label[aria-pressed="true"] > span {
  color: var(--map-selection-color);
  font-weight: 550;
}

/* Use measured free space for complete idle names, preserving the map anchor. */
#map :is(.photo-marker, .photo-cluster)[data-map-caption-mode="full"]:not(:is(.is-preview, .is-photo-preview))
  :is(.pin-label, .cluster-label),
#map :is(.compact-map-marker, .explore-marker)[data-map-caption-mode="full"]
  :is(.compact-map-caption, .explore-marker-label) {
  width: var(--map-caption-width);
  max-width: var(--map-caption-width);
  white-space: normal;
  overflow-wrap: anywhere;
  hyphens: none;
  text-wrap: balance;
}
#map :is(.photo-marker, .photo-cluster)[data-map-caption-mode="full"]:not(:is(.is-preview, .is-photo-preview))
  .marker-title {
  width: 100%;
  max-width: none;
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
}
#map :is(.photo-marker, .photo-cluster)[data-map-caption-mode="full"]:not(:is(.is-preview, .is-photo-preview))
  .marker-idle-name,
#map .explore-marker[data-map-caption-mode="full"] .explore-marker-name {
  overflow: visible;
  text-overflow: clip;
  white-space: normal;
  overflow-wrap: anywhere;
  hyphens: none;
  text-wrap: balance;
  -webkit-line-clamp: unset;
}
#map .explore-marker[data-map-caption-mode="full"] .explore-marker-name {
  display: block;
}

@media (prefers-reduced-motion: reduce) {
  #map .compact-map-badge { transition: none; }
}
