/* ==========================================================================
   Property Map Widget
   Reuses map badge, tooltip, and control styles from common/map patterns.
   ========================================================================== */

/* Section heading */
.hr-widget-section {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  margin-bottom: 2rem;
  width: 100%;
}
.hr-widget-section-title {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--hfse-foreground, currentColor);
  white-space: nowrap;
  flex-shrink: 0;
}
.hr-widget-section-line {
  flex: 1;
  height: 1px;
  background-color: currentColor;
  opacity: 0.18;
  display: block;
}
@media (max-width: 640px) {
  .hr-widget-section-title { font-size: 1.25rem; }
  .hr-widget-section { gap: 1rem; margin-bottom: 1.5rem; }
}

/* Container */
.hfse-property-map-container {
  width: 100%;
  position: relative;
  overflow: hidden;
  border-radius: 8px;
  background-color: var(--hfse-background, #eee);
}

/* Map fills container */
.hfse-property-map-container .hfse-map {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1;
}

/* Leaflet tile fix — prevent CSS resets from breaking tile layout */
.leaflet-container {
  width: 100% !important;
  height: 100% !important;
}
.leaflet-pane,
.leaflet-tile,
.leaflet-marker-icon,
.leaflet-marker-shadow,
.leaflet-tile-container,
.leaflet-pane > svg,
.leaflet-pane > canvas,
.leaflet-zoom-box,
.leaflet-image-layer,
.leaflet-layer {
  position: absolute;
  left: 0;
  top: 0;
}
.leaflet-tile {
  -webkit-user-select: none;
  user-select: none;
  -webkit-user-drag: none;
}
.leaflet-tile-container img {
  max-width: none !important;
  max-height: none !important;
  width: 256px;
  height: 256px;
  padding: 0;
  margin: 0;
  border: 0;
}

/* Override Leaflet default icon styles */
.leaflet-div-icon {
  border: none !important;
  background: transparent !important;
}

/* Map marker wrapper */
.hfse-map-marker-wrapper {
  border: none !important;
  background: transparent !important;
}

/* Map badge (marker) styles */
.hfse-map-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--hfse-card-bg, #fff);
  border-radius: 20px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.18);
  cursor: pointer;
  transition: transform 0.1s ease, background 0.15s ease, color 0.15s ease;
  white-space: nowrap;
  transform: translate(-50%, -50%);
  position: relative;
}
.hfse-map-badge-price {
  font-weight: 600;
  font-size: 14px;
  padding: 8px 14px;
  color: var(--hfse-foreground, #222);
}
.hfse-map-badge-price:hover,
.hfse-map-badge-focus {
  background: var(--hfse-foreground, #222);
  color: var(--hfse-card-bg, #fff);
  transform: translate(-50%, -50%) scale(1.08);
}
.hfse-map-badge-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  padding: 0;
}
.hfse-map-badge-icon svg {
  width: 16px;
  height: 16px;
}
.hfse-map-badge-parent-focus {
  z-index: 9999 !important;
}
.hfse-map-badge-parent-focus .hfse-map-badge {
  background: var(--hfse-foreground, #222);
  color: var(--hfse-card-bg, #fff);
  transform: translate(-50%, -50%) scale(1.08);
}

/* Map tooltip (popup) */
.hfse-map-tooltip {
  position: relative;
  width: 300px;
  z-index: 1000002;
}
.hfse-map-tooltip-content {
  border-radius: 10px;
  overflow: hidden;
  background: var(--hfse-card-bg, #fff);
  color: var(--hfse-foreground, #333);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}
.hfse-map-tooltip-content a {
  text-decoration: none;
  color: var(--hfse-foreground, #333);
  display: block;
}
.hfse-map-tooltip-close-btn {
  position: absolute;
  top: 8px;
  left: 8px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 1;
  transition: background 0.15s;
}
.hfse-map-tooltip-close-btn:hover {
  background: rgba(0, 0, 0, 0.7);
}
.hfse-map-tooltip-close-btn svg {
  width: 12px;
  height: 12px;
}

/* Tooltip content sections */
.hfse-property-infowindow-header {
  width: 100%;
  height: 160px;
  position: relative;
  overflow: hidden;
}
.hfse-property-infowindow-header-overlay {
  background: linear-gradient(to bottom, rgba(0,0,0,0.1), transparent);
}
.hfse-property-infowindow-body {
  padding: 12px 15px;
  color: var(--hfse-foreground, #333);
}
.hfse-property-infowindow-body .hfse-property-title {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
  margin: 0 0 4px;
  color: var(--hfse-foreground, #222);
}
.hfse-property-infowindow-body .hfse-property-subtitle {
  font-size: 12px;
  color: var(--hfse-muted-foreground, #555);
  margin: 0 0 6px;
}
.hfse-property-infowindow-price {
  font-size: 14px;
  color: var(--hfse-foreground, #333);
  margin-bottom: 6px;
}
.hfse-property-infowindow-price strong {
  font-weight: 600;
  color: var(--hfse-foreground, #222);
}

/* Tooltip infowindow meta */
.hfse-property-infowindow-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
  font-size: 12px;
  color: var(--hfse-muted-foreground, #555);
}
.hfse-property-infowindow-meta span:not(:last-child)::after {
  content: '\00B7';
  margin-left: 8px;
}

/* Map controls container */
.hfse-map-controls {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  pointer-events: none;
}
.hfse-map-controls > * {
  pointer-events: auto;
}
.hfse-map-controls-left {
  position: absolute;
  top: 10px;
  left: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Map control base */
.map-control {
  background: var(--hfse-card-bg, #fff);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
}
.map-control.control-group {
  display: flex;
  flex-direction: column;
}
.map-control.control-group .map-control-btn:not(:last-child) {
  border-bottom: 1px solid var(--hfse-border, #e5e5e5);
}
.map-control-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
  color: var(--hfse-foreground, #333);
  transition: background 0.15s;
}
.map-control-btn:hover {
  filter: brightness(0.9);
}
.map-control-btn:active {
  filter: brightness(0.8);
}
.map-control.control-group .map-control-btn:first-child {
  border-radius: 4px 4px 0 0;
}
.map-control.control-group .map-control-btn:last-child {
  border-radius: 0 0 4px 4px;
}
.map-control.control-group .map-control-btn:only-child {
  border-radius: 4px;
}

/* Dark mode */
.hfse-property-map-wrapper.dark .hfse-map-badge {
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
}

/* Dark FIRST-PAINT (#900): mirror the .dark badge shadow under the shadow-host
   markers so an auto map paints correct at parse (append-only). */
:host([data-hr-theme="dark"]) .hfse-map-badge {
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
}
@media (prefers-color-scheme: dark) {
  :host([data-hr-scheme="auto"]:not([data-hr-theme])) .hfse-map-badge {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
  }
}

/* UIKit-like utility classes used by tooltip HTML */
.hk-overlay { position: absolute; }
.hk-position-cover { top: 0; right: 0; bottom: 0; left: 0; }
.hk-card { display: block; }
.hk-card-small .hk-card-body { padding: 12px 15px; }
.hk-card-default { background: var(--hfse-card-bg, #fff); }
.hk-display-block { display: block; }
.hk-text-decoration-none { text-decoration: none; }
.hk-h5 { font-size: 14px; font-weight: 600; line-height: 1.3; }
.hk-margin-small-bottom { margin-bottom: 8px; }
.hk-margin-remove-top { margin-top: 0; }
.hk-text-default { font-size: 12px; }

/* Mapbox ToS requires the OFFICIAL logo, unaltered, alongside the text
   attribution when Mapbox tiles render (#858, ported for #1184). Same
   untouched mapbox-gl.css data URI as the explorer's block. */
.hfse-mapbox-logo {
  position: absolute;
  bottom: 4px;
  left: 8px;
  z-index: 1000001;
  display: block;
  width: 88px;
  height: 23px;
  overflow: hidden;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' fill-rule='evenodd' viewBox='0 0 88 23'%3E%3Cdefs%3E%3Cpath id='logo' d='M11.5 2.25c5.105 0 9.25 4.145 9.25 9.25s-4.145 9.25-9.25 9.25-9.25-4.145-9.25-9.25 4.145-9.25 9.25-9.25zM6.997 15.983c-.051-.338-.828-5.802 2.233-8.873a4.395 4.395 0 013.13-1.28c1.27 0 2.49.51 3.39 1.42.91.9 1.42 2.12 1.42 3.39 0 1.18-.449 2.301-1.28 3.13C12.72 16.93 7 16 7 16l-.003-.017zM15.3 10.5l-2 .8-.8 2-.8-2-2-.8 2-.8.8-2 .8 2 2 .8z'/%3E%3Cpath id='text' d='M50.63 8c.13 0 .23.1.23.23V9c.7-.76 1.7-1.18 2.73-1.18 2.17 0 3.95 1.85 3.95 4.17s-1.77 4.19-3.94 4.19c-1.04 0-2.03-.43-2.74-1.18v3.77c0 .13-.1.23-.23.23h-1.4c-.13 0-.23-.1-.23-.23V8.23c0-.12.1-.23.23-.23h1.4zm-3.86.01c.01 0 .01 0 .01-.01.13 0 .22.1.22.22v7.55c0 .12-.1.23-.23.23h-1.4c-.13 0-.23-.1-.23-.23V15c-.7.76-1.69 1.19-2.73 1.19-2.17 0-3.94-1.87-3.94-4.19 0-2.32 1.77-4.19 3.94-4.19 1.03 0 2.02.43 2.73 1.18v-.75c0-.12.1-.23.23-.23h1.4zm26.375-.19a4.24 4.24 0 00-4.16 3.29c-.13.59-.13 1.19 0 1.77a4.233 4.233 0 004.17 3.3c2.35 0 4.26-1.87 4.26-4.19 0-2.32-1.9-4.17-4.27-4.17zM60.63 5c.13 0 .23.1.23.23v3.76c.7-.76 1.7-1.18 2.73-1.18 1.88 0 3.45 1.4 3.84 3.28.13.59.13 1.2 0 1.8-.39 1.88-1.96 3.29-3.84 3.29-1.03 0-2.02-.43-2.73-1.18v.77c0 .12-.1.23-.23.23h-1.4c-.13 0-.23-.1-.23-.23V5.23c0-.12.1-.23.23-.23h1.4zm-34 11h-1.4c-.13 0-.23-.11-.23-.23V8.22c.01-.13.1-.22.23-.22h1.4c.13 0 .22.11.23.22v.68c.5-.68 1.3-1.09 2.16-1.1h.03c1.09 0 2.09.6 2.6 1.55.45-.95 1.4-1.55 2.44-1.56 1.62 0 2.93 1.25 2.9 2.78l.03 5.2c0 .13-.1.23-.23.23h-1.41c-.13 0-.23-.11-.23-.23v-4.59c0-.98-.74-1.71-1.62-1.71-.8 0-1.46.7-1.59 1.62l.01 4.68c0 .13-.11.23-.23.23h-1.41c-.13 0-.23-.11-.23-.23v-4.59c0-.98-.74-1.71-1.62-1.71-.85 0-1.54.79-1.6 1.8v4.5c0 .13-.1.23-.23.23zm53.615 0h-1.61c-.04 0-.08-.01-.12-.03-.09-.06-.13-.19-.06-.28l2.43-3.71-2.39-3.65a.213.213 0 01-.03-.12c0-.12.09-.21.21-.21h1.61c.13 0 .24.06.3.17l1.41 2.37 1.4-2.37a.34.34 0 01.3-.17h1.6c.04 0 .08.01.12.03.09.06.13.19.06.28l-2.37 3.65 2.43 3.7c0 .05.01.09.01.13 0 .12-.09.21-.21.21h-1.61c-.13 0-.24-.06-.3-.17l-1.44-2.42-1.44 2.42a.34.34 0 01-.3.17zm-7.12-1.49c-1.33 0-2.42-1.12-2.42-2.51 0-1.39 1.08-2.52 2.42-2.52 1.33 0 2.42 1.12 2.42 2.51 0 1.39-1.08 2.51-2.42 2.52zm-19.865 0c-1.32 0-2.39-1.11-2.42-2.48v-.07c.02-1.38 1.09-2.49 2.4-2.49 1.32 0 2.41 1.12 2.41 2.51 0 1.39-1.07 2.52-2.39 2.53zm-8.11-2.48c-.01 1.37-1.09 2.47-2.41 2.47s-2.42-1.12-2.42-2.51c0-1.39 1.08-2.52 2.4-2.52 1.33 0 2.39 1.11 2.41 2.48l.02.08zm18.12 2.47c-1.32 0-2.39-1.11-2.41-2.48v-.06c.02-1.38 1.09-2.48 2.41-2.48s2.42 1.12 2.42 2.51c0 1.39-1.09 2.51-2.42 2.51z'/%3E%3C/defs%3E%3Cmask id='clip'%3E%3Crect x='0' y='0' width='100%25' height='100%25' fill='white'/%3E%3Cuse xlink:href='%23logo'/%3E%3Cuse xlink:href='%23text'/%3E%3C/mask%3E%3Cg id='outline' opacity='0.3' stroke='%23000' stroke-width='3'%3E%3Ccircle mask='url(%23clip)' cx='11.5' cy='11.5' r='9.25'/%3E%3Cuse xlink:href='%23text' mask='url(%23clip)'/%3E%3C/g%3E%3Cg id='fill' opacity='0.9' fill='%23fff'%3E%3Cuse xlink:href='%23logo'/%3E%3Cuse xlink:href='%23text'/%3E%3C/g%3E%3C/svg%3E");
  background-repeat: no-repeat;
  cursor: pointer;
}
