/* Property + landmark map.
 *
 * Standalone so palmera.php (which has its own design system and no Bootstrap)
 * can include it without pulling in custom.css. Colours fall back to literals
 * where the brand custom properties may not be defined.
 */

.micasa-map {
  position: relative;
  width: 100%;
  height: 480px;
  border-radius: 12px;
  overflow: hidden;
  background: #eef0f2;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

@media (max-width: 768px) {
  .micasa-map { height: 380px; }
}

/* Fallback content shown until the map takes over, and left in place if it
 * never does (Leaflet blocked, JS off, bad data). */
.micasa-map__fallback {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  height: 100%;
  padding: 1.5rem;
  text-align: center;
  color: #5a6268;
  font-size: 0.95rem;
}

.micasa-map.is-ready .micasa-map__fallback { display: none; }

/* ── Markers ───────────────────────────────────────────────────────────────
 * Leaflet's divIcon default has a white background and border; strip it so the
 * pins below are the only thing drawn. */
.micasa-landmark-marker,
.micasa-property-marker {
  background: transparent;
  border: 0;
}

.micasa-pin,
.micasa-home {
  position: relative;   /* anchors the focus pulse */
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50% 50% 50% 4px;
  transform: rotate(-45deg);
  background: #fff;
  border: 2px solid var(--pin-color, #6c757d);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

/* Counter-rotate so the emoji sits upright inside the teardrop. */
.micasa-pin__glyph,
.micasa-home__glyph {
  transform: rotate(45deg);
  font-size: 16px;
  line-height: 1;
}

.micasa-landmark-marker:hover .micasa-pin {
  transform: rotate(-45deg) scale(1.15);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

/* Properties are the point of the map — bigger, brand green, always on top. */
.micasa-home {
  width: 38px;
  height: 38px;
  border-width: 3px;
  border-color: var(--primary-color, #0b8266);
  background: var(--primary-color, #0b8266);
}

.micasa-home__glyph { font-size: 18px; }

.micasa-property-marker:hover .micasa-home {
  transform: rotate(-45deg) scale(1.1);
}

/* ── Focus mode (single-property maps) ─────────────────────────────────────
 * The basemap goes monochrome while the marker pane keeps its colour, so the
 * property being viewed is the only saturated thing on screen. Filtering the
 * tile pane rather than overlaying a translucent panel keeps the labels legible
 * and costs nothing at runtime. */
.micasa-map.is-focus-mode .leaflet-tile-pane {
  filter: grayscale(1) contrast(0.92) brightness(1.04);
}

/* The focused property: larger, terracotta, and ringed. */
.micasa-map.is-focus-mode .micasa-property-marker.is-focus .micasa-home {
  width: 46px;
  height: 46px;
  border-width: 3px;
  border-color: var(--secondary-color, #e07a52);
  background: var(--secondary-color, #e07a52);
  box-shadow: 0 0 0 7px rgba(224, 122, 82, 0.3), 0 4px 12px rgba(0, 0, 0, 0.35);
}

.micasa-map.is-focus-mode .micasa-property-marker.is-focus .micasa-home__glyph {
  font-size: 22px;
}

/* Expanding ring drawn behind the pin. It inherits the teardrop's -45deg
 * rotation, which is harmless — a circle rotates to itself. */
.micasa-home__pulse {
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 2px solid var(--secondary-color, #e07a52);
  animation: micasa-pulse 2.4s ease-out infinite;
  pointer-events: none;
}

@keyframes micasa-pulse {
  0%   { transform: scale(0.85); opacity: 0.85; }
  70%  { transform: scale(1.75); opacity: 0; }
  100% { transform: scale(1.75); opacity: 0; }
}

/* Motion is decoration here — the size and colour already carry the meaning. */
@media (prefers-reduced-motion: reduce) {
  .micasa-home__pulse { animation: none; opacity: 0.5; }
}

/* Other properties on a focused map: present as context, visibly secondary. */
.micasa-map.is-focus-mode .micasa-property-marker.is-dimmed .micasa-home {
  filter: grayscale(0.85);
  opacity: 0.55;
}

.micasa-map.is-focus-mode .micasa-property-marker.is-dimmed:hover .micasa-home {
  filter: none;
  opacity: 1;
}

/* Landmarks stay readable but recede behind the focused property. */
.micasa-map.is-focus-mode .micasa-landmark-marker .micasa-pin {
  opacity: 0.82;
}

.micasa-map.is-focus-mode .micasa-landmark-marker:hover .micasa-pin {
  opacity: 1;
}

/* One-mile reference ring around the focused property. */
.micasa-focus-ring {
  fill: var(--secondary-color, #e07a52);
  fill-opacity: 0.06;
  stroke: var(--secondary-color, #e07a52);
  stroke-opacity: 0.35;
  stroke-width: 1.5;
  stroke-dasharray: 5 5;
}

/* ── Popups ────────────────────────────────────────────────────────────────*/
.micasa-popup { min-width: 190px; font-size: 0.92rem; line-height: 1.45; }

.micasa-popup__title {
  display: block;
  font-size: 1rem;
  color: #1f2d2b;
  margin-bottom: 0.15rem;
}

.micasa-popup__meta { color: #6c757d; font-size: 0.85rem; }

.micasa-popup__blurb { margin-top: 0.4rem; color: #4a5350; }

.micasa-popup__facts { margin-top: 0.45rem; color: #3d4a47; }

/* A stand-in pin must never read as an exact location. */
.micasa-popup__approx {
  margin-top: 0.4rem;
  font-size: 0.78rem;
  font-style: italic;
  color: #8a7a4a;
}

.micasa-popup__now { color: var(--primary-color, #0b8266); font-weight: 600; }

.micasa-popup__link {
  display: inline-block;
  margin-top: 0.6rem;
  font-weight: 600;
  color: var(--primary-color, #0b8266);
  text-decoration: none;
}

.micasa-popup__link:hover { text-decoration: underline; }

/* Leaflet's own popup chrome, toned to match the site. */
.micasa-map .leaflet-popup-content-wrapper {
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
}

.micasa-map .leaflet-popup-content { margin: 0.85rem 1rem; }

/* ── Legend (Leaflet layers control) ───────────────────────────────────────*/
.micasa-map .leaflet-control-layers {
  border-radius: 10px;
  border: 0;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
  padding: 0.35rem 0.15rem;
}

.micasa-map .leaflet-control-layers-list { font-size: 0.88rem; line-height: 1.9; }

.micasa-map .leaflet-control-layers label { cursor: pointer; padding: 0 0.35rem; }

.micasa-legend__icon { font-size: 1rem; }

/* Attribution is a licence obligation — shrink it, never hide it. */
.micasa-map .leaflet-control-attribution {
  font-size: 0.68rem;
  background: rgba(255, 255, 255, 0.85);
}

/* ── Nearby list (rendered server-side next to the map) ────────────────────*/
.micasa-nearby { list-style: none; padding: 0; margin: 1rem 0 0; }

.micasa-nearby__item {
  display: flex;
  align-items: baseline;
  gap: 0.55rem;
  padding: 0.4rem 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.micasa-nearby__item:last-child { border-bottom: 0; }

.micasa-nearby__icon { font-size: 1.05rem; flex: 0 0 auto; }

.micasa-nearby__name { flex: 1 1 auto; }

.micasa-nearby__distance {
  flex: 0 0 auto;
  color: #6c757d;
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}

.micasa-nearby__note {
  margin-top: 0.6rem;
  font-size: 0.78rem;
  color: #8a9391;
}
