/* InvestIdealHome — maps: Leaflet restyled to the paper / ink / gold palette.
   Pairs with /js/map.js. Leaflet's own stylesheet loads at runtime, so the selectors
   below carry extra specificity where they must win. */

/* ---------- Container ---------- */
.ml-map {
  position: relative;
  isolation: isolate;
  width: 100%;
  min-height: 340px;
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--paper-2);
  font-family: var(--font-sans);
}
@media (min-width: 900px) {
  .ml-map { min-height: 440px; }
}
.ml-map.leaflet-container {
  background: var(--paper-2);
  font-family: var(--font-sans);
  font-size: var(--fs-sm);
  line-height: 1.5;
}
.ml-map.leaflet-container a { color: var(--ink); }
.ml-map.ml-map--picker.leaflet-container { cursor: crosshair; }

/* Warm the CARTO light tiles so they sit with the paper palette. */
.ml-map .leaflet-tile-pane {
  filter: sepia(0.18) saturate(0.7) brightness(1.02);
}

/* Loading shimmer (uses .skeleton from base.css) */
.ml-map__shimmer {
  position: absolute;
  inset: 0;
  z-index: 1200;
  border-radius: inherit;
  transition: opacity var(--dur) var(--ease-out);
}
.ml-map__shimmer.is-done { opacity: 0; pointer-events: none; }

/* "Map unavailable" and similar messages */
.ml-map__message {
  position: absolute;
  inset: 0;
  z-index: 1200;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-5);
  margin: 0;
  background: var(--paper-2);
  color: var(--stone);
  font-size: var(--fs-sm);
  text-align: center;
}
.ml-map__message .icon { color: var(--stone-light); }
.ml-map__message p { margin: 0; }

/* Picker hint */
.ml-map__hint {
  position: absolute;
  top: var(--space-4);
  left: 50%;
  z-index: 1100;
  transform: translateX(-50%);
  margin: 0;
  padding: 0.55em 1.1em;
  border-radius: var(--radius-pill);
  background: var(--glass-light);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: var(--ink);
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
  pointer-events: none;
}

/* ---------- Zoom control ---------- */
.ml-map.leaflet-container .leaflet-control-zoom.leaflet-bar {
  margin: 0 var(--space-4) var(--space-4) 0;
  border: 0;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--paper);
  box-shadow: var(--shadow-sm);
}
.ml-map.leaflet-container .leaflet-control-zoom.leaflet-bar a {
  width: 38px;
  height: 38px;
  line-height: 38px;
  background: var(--paper);
  color: var(--ink);
  border: 0;
  border-bottom: 1px solid var(--line);
  font-family: var(--font-sans);
  font-size: 1.125rem;
  font-weight: 400;
  transition: background-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}
.ml-map.leaflet-container .leaflet-control-zoom.leaflet-bar a:last-child { border-bottom: 0; }
.ml-map.leaflet-container .leaflet-control-zoom.leaflet-bar a:hover {
  background: var(--ink);
  color: var(--paper);
}
.ml-map.leaflet-container .leaflet-control-zoom.leaflet-bar a.leaflet-disabled {
  background: var(--paper);
  color: var(--stone-light);
}

/* ---------- Attribution ---------- */
.ml-map .leaflet-control-attribution {
  padding: 2px var(--space-3);
  margin: 0 var(--space-3) var(--space-3) 0;
  border-radius: var(--radius-pill);
  background: rgba(245, 241, 234, 0.8);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: var(--stone);
  font-size: 10.5px;
  letter-spacing: 0.01em;
  line-height: 1.6;
}
.ml-map .leaflet-control-attribution a { color: var(--ink); text-decoration: none; }

/* ---------- Price pills (listings overview) ---------- */
.ml-pin-wrap { background: none; border: 0; }

.map-pin {
  --pin-bg: var(--paper);
  --pin-fg: var(--ink);
  --pin-line: var(--line-strong);
  position: absolute;
  left: 0;
  bottom: 0;
  transform: translate(-50%, -7px);
  transform-origin: 50% 100%;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0.5em 0.9em 0.5em;
  border: 1px solid var(--pin-line);
  border-radius: var(--radius-pill);
  background: var(--pin-bg);
  color: var(--pin-fg);
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  line-height: 1;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition:
    transform var(--dur) var(--ease-out),
    background-color var(--dur-fast) var(--ease-out),
    color var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out),
    box-shadow var(--dur) var(--ease-out);
}
/* Tail: a rotated square whose lower half sits under the pill, forming the pointer. */
.map-pin::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: -5px;
  width: 10px;
  height: 10px;
  background: var(--pin-bg);
  border-right: 1px solid var(--pin-line);
  border-bottom: 1px solid var(--pin-line);
  border-bottom-right-radius: 2px;
  transform: translateX(-50%) rotate(45deg);
  transition: background-color var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out);
}
.map-pin--under_offer::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--status-under_offer);
}
.map-pin--sold {
  --pin-bg: var(--paper-2);
  --pin-fg: var(--stone);
  --pin-line: var(--line);
  box-shadow: none;
}
.map-pin:hover,
.map-pin.is-active {
  --pin-bg: var(--ink);
  --pin-fg: var(--gold-bright);
  --pin-line: var(--ink);
  transform: translate(-50%, -7px) scale(1.08);
  box-shadow: var(--shadow);
}
.map-pin.is-active {
  box-shadow: 0 0 0 4px var(--gold-soft), var(--shadow);
}
.map-pin:focus-visible { outline-offset: 4px; }

/* ---------- Popup (listings overview) ---------- */
.ml-popup .leaflet-popup-content-wrapper {
  padding: 0;
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--white);
  color: var(--ink);
  box-shadow: var(--shadow-lg);
  text-align: left;
}
.ml-popup .leaflet-popup-content {
  width: min(280px, calc(100vw - 80px)) !important;
  margin: 0;
  font-family: var(--font-sans);
  line-height: var(--lh-body);
}
.ml-popup .leaflet-popup-tip-container { width: 30px; height: 14px; }
.ml-popup .leaflet-popup-tip {
  background: var(--white);
  box-shadow: none;
}
/* Leaflet's own rules for popup close buttons and anchors are (0,2,1); these need (0,3,0)+ to win. */
.ml-popup.leaflet-popup .leaflet-popup-close-button {
  top: 12px;
  right: 12px;
  z-index: 2;
  width: 32px;
  height: 32px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--glass-light);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: var(--ink);
  font: 400 20px/1 var(--font-sans);
  text-decoration: none;
  transition: background-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}
.ml-popup.leaflet-popup .leaflet-popup-close-button:hover {
  background: var(--ink);
  color: var(--paper);
}
.ml-popup.leaflet-popup .leaflet-popup-close-button span { display: block; }

.ml-popup__card { width: 100%; }
.ml-popup__media {
  position: relative;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  background: var(--paper-2);
}
.ml-popup__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.9s var(--ease-out);
}
.ml-popup__media .badge {
  position: absolute;
  top: 12px;
  left: 12px;
  box-shadow: var(--shadow-sm);
}
.ml-popup__body { padding: var(--space-4) var(--space-5) var(--space-5); }
.ml-popup__eyebrow {
  margin: 0 0 var(--space-2);
  color: var(--stone);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
}
.ml-popup__title {
  margin: 0;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 350;
  line-height: 1.15;
  letter-spacing: -0.01em;
  font-variation-settings: 'opsz' 48;
}
.ml-popup__price {
  margin: var(--space-2) 0 0;
  color: var(--gold-deep);
  font-family: var(--font-display);
  font-size: 1.125rem;
  font-weight: 400;
}
.ml-popup__specs {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-4);
  margin: var(--space-3) 0 0;
  padding: var(--space-3) 0 0;
  border-top: 1px solid var(--line);
  color: var(--stone);
  font-size: var(--fs-xs);
  list-style: none;
}
.ml-popup__specs li {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.ml-popup__specs .icon {
  width: 15px;
  height: 15px;
  color: var(--gold);
}
.ml-popup__link {
  display: inline-flex;
  margin-top: var(--space-4);
  padding-bottom: 2px;
  color: var(--ink);
  font-size: var(--fs-sm);
  font-weight: 600;
  letter-spacing: 0.02em;
  background: linear-gradient(currentColor, currentColor) left bottom / 100% 1px no-repeat;
  transition: color var(--dur-fast) var(--ease-out), background-size var(--dur) var(--ease-out);
}
.ml-popup.leaflet-popup .ml-popup__link { color: var(--ink); }
.ml-popup.leaflet-popup .ml-popup__link:hover {
  color: var(--gold);
  background-size: 0% 1px;
  background-position: right bottom;
}

/* ---------- Single property pin ---------- */
.ml-house-wrap { background: none; border: 0; }
.ml-house {
  position: relative;
  display: block;
  width: 64px;
  height: 64px;
  color: var(--gold);
}
.ml-house__halo {
  position: absolute;
  inset: 9px;
  border-radius: 50%;
  background: var(--gold);
  opacity: 0;
  animation: ml-pulse 2.8s var(--ease-out) infinite;
}
.ml-house__body {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 46px;
  height: 46px;
  transform: translate(-50%, -50%);
  filter: drop-shadow(0 6px 10px color-mix(in srgb, var(--ink) 28%, transparent));
}
.ml-house__body svg { width: 46px; height: 46px; overflow: visible; }
.ml-house__shape {
  fill: var(--gold);
  stroke: var(--white);
  stroke-width: 1.5;
  stroke-linejoin: round;
}
.ml-house__door { fill: var(--paper); }
@keyframes ml-pulse {
  0%   { transform: scale(0.55); opacity: 0.55; }
  100% { transform: scale(1.9); opacity: 0; }
}

/* ---------- Picker pin ---------- */
.ml-picker-wrap { background: none; border: 0; }
.ml-picker {
  display: block;
  width: 32px;
  height: 42px;
  filter: drop-shadow(0 6px 8px color-mix(in srgb, var(--ink) 30%, transparent));
  transition: transform var(--dur-fast) var(--ease-out);
  transform-origin: 50% 100%;
}
.ml-picker svg { width: 32px; height: 42px; overflow: visible; }
.ml-picker__shape { fill: var(--gold); stroke: var(--white); stroke-width: 1.5; }
.ml-picker__dot { fill: var(--white); }
.leaflet-marker-draggable .ml-picker { cursor: grab; }
.leaflet-marker-draggable:active .ml-picker,
.ml-picker-wrap:hover .ml-picker { transform: scale(1.06); }

/* ---------- Motion ---------- */
@media (prefers-reduced-motion: no-preference) {
  .ml-popup__card:hover .ml-popup__media img { transform: scale(1.03); }
}
@media (prefers-reduced-motion: reduce) {
  .ml-house__halo { animation: none; opacity: 0.22; transform: scale(1.4); }
  .map-pin,
  .map-pin::after,
  .ml-popup__media img,
  .ml-picker,
  .ml-map__shimmer { transition: none; }
  .ml-map__shimmer::after { animation: none; }
}
