/* Estate explorer. Progressive enhancement keeps the original map/list usable without JS. */
.estate-explorer .explorer-controls {
  display: flex;
  align-items: end;
  flex-wrap: wrap;
  gap: 20px;
  margin-bottom: 24px;
}
.estate-explorer .filters {
  margin: 0;
  gap: 16px;
}
.view-controls {
  display: flex;
  border: 1px solid var(--line);
  padding: 4px;
  gap: 4px;
  margin-left: auto;
}
.view-controls button {
  border: 0;
  background: #fff;
  color: var(--navy);
  padding: 10px 24px;
  min-height: 44px;
  font-size: 14px;
}
.view-controls button[aria-pressed="true"] {
  background: var(--navy);
  color: #fff;
}
.estate-explorer #result-count {
  width: 100%;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}
.map-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.85fr) minmax(250px, 1fr);
  gap: 32px;
  align-items: start;
}
.map-workspace .map-panel {
  padding: 16px;
  min-width: 0;
}
.map-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.zoom-controls {
  display: flex;
  align-items: center;
  gap: 2px;
  border: 1px solid var(--line);
}
.zoom-controls button {
  border: 0;
  background: #fff;
  color: var(--navy);
  font-size: 24px;
  width: 44px;
  height: 44px;
  line-height: 1;
}
.zoom-controls button:disabled {
  opacity: 0.35;
  cursor: default;
}
.zoom-controls output {
  width: 52px;
  text-align: center;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.map-text-button {
  border: 0;
  background: transparent;
  color: var(--navy);
  text-decoration: underline;
  text-underline-offset: 4px;
  min-height: 44px;
  padding: 8px 10px;
  font-size: 12px;
}
.map-expand,
.map-close {
  min-height: 44px;
  border: 1px solid var(--navy);
  color: var(--navy);
  background: #fff;
  padding: 10px 16px;
  font-size: 12px;
  font-weight: 600;
}
.map-expand {
  margin-left: auto;
}
.map-expand:hover,
.map-close:hover {
  background: #edf1f3;
}
.map-text-button:hover {
  background: #fff3e7;
}
.map-enhanced .map-scroll {
  position: relative;
  height: clamp(460px, 65vh, 720px);
  max-height: none;
  overflow: hidden;
  touch-action: pan-y pinch-zoom;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  overscroll-behavior-x: contain;
  background: #f3f5f2;
}
.map-enhanced #estate-map {
  position: absolute;
  left: 0;
  top: 0;
  min-width: 0;
  max-width: none;
  transform-origin: 0 0;
  will-change: transform;
  overflow: visible;
}
.map-enhanced .map-scroll.is-dragging,
.map-enhanced .map-scroll.is-dragging * {
  cursor: grabbing !important;
}
.map-home {
  cursor: pointer;
}
.map-home .map-hit {
  fill: transparent;
  stroke: none;
}
.map-home .map-marker {
  fill: white;
  stroke: var(--navy);
  stroke-width: 1.4;
  vector-effect: non-scaling-stroke;
}
.map-home polygon {
  vector-effect: non-scaling-stroke;
}
.map-home text {
  font-weight: 600;
}
.map-home.is-filtered {
  display: inline;
  opacity: 0.24;
  cursor: default;
}
.map-home.is-filtered:hover polygon {
  fill: #526477;
  fill-opacity: 0.2;
  stroke-width: 2;
}
.map-home.is-selected polygon {
  fill: var(--peach);
  fill-opacity: 0.9;
  stroke: #914900;
  stroke-width: 2.5;
}
.map-home.is-selected .map-marker {
  fill: var(--peach);
  stroke: #914900;
  stroke-width: 2;
}
.map-home:focus-visible .map-marker {
  stroke: #914900;
  stroke-width: 3;
}
.map-workspace .map-hint {
  font-size: 12px;
  margin: 10px 0 0;
  color: var(--muted);
}
.map-workspace .legend {
  font-size: 11px;
  margin: 14px 0 0;
  gap: 12px;
}
.legend .filtered-key i {
  background: #dfe3df;
}
#map-tooltip {
  position: absolute;
  z-index: 3;
  max-width: calc(100% - 16px);
  background: var(--navy);
  color: #fff;
  padding: 9px 12px;
  font-size: 11px;
  pointer-events: none;
  box-shadow: 0 4px 12px #00294322;
}
.map-workspace .selection-panel {
  top: 20px;
  padding: 0;
}
.selection-panel .selected-card {
  position: relative;
}
.selection-close {
  position: absolute;
  right: 8px;
  top: 8px;
  z-index: 2;
  border: 1px solid var(--line);
  width: 44px;
  height: 44px;
  background: white;
  color: var(--navy);
  font-size: 26px;
  line-height: 1;
}
.map-workspace #selection-placeholder {
  padding: 28px 0;
}
.map-workspace #selection-placeholder h2 {
  margin: 24px 0;
  font-size: 34px;
}
.map-workspace #selection-placeholder p {
  font-size: 14px;
}
.map-workspace .selection-info h2 {
  font-size: 36px;
  margin: 20px 0 10px;
}
.selection-type {
  font-size: 15px;
  margin-bottom: 16px;
}
.map-workspace .selection-info .area {
  font-size: 32px;
  margin-bottom: 16px;
}
.map-workspace .selection-link {
  margin-top: 20px;
}
.map-empty {
  background: #fff3e7;
  border-left: 3px solid #a95a17;
  color: var(--navy);
  padding: 16px 20px;
  font-size: 14px;
}
.estate-explorer .house-list {
  padding-block: 20px 50px;
}
.house-actions {
  white-space: nowrap;
}
.house-actions .show-on-map {
  display: block;
  padding-left: 0;
}
.house-list tr.is-selected {
  background: #fff2e5;
}
.map-dialog {
  position: fixed;
  inset: 0;
  padding: 0;
  border: 0;
  max-width: none;
  max-height: none;
  width: 100vw;
  height: 100dvh;
  margin: 0;
  background: #fff;
  color: var(--navy);
}
.map-dialog::backdrop {
  background: #00294377;
}
.map-dialog[open] {
  display: flex;
  flex-direction: column;
}
.map-dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 28px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.map-dialog-header h2 {
  font-size: 21px;
  letter-spacing: -0.02em;
  margin: 0;
}
.map-dialog-header p {
  font-size: 12px;
  margin: 3px 0 0;
}
.map-close span {
  font-size: 20px;
  vertical-align: middle;
  margin-left: 12px;
}
#map-dialog-body {
  flex: 1;
  min-height: 0;
  padding: 20px 28px;
}
.map-dialog .map-workspace {
  height: 100%;
  align-items: stretch;
}
.map-dialog .map-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.map-dialog .map-scroll {
  height: auto;
  flex: 1;
  touch-action: none;
  overscroll-behavior: none;
}
.map-dialog .selection-panel {
  overflow: auto;
  padding-right: 8px;
  position: static;
}
.map-dialog #expand-map {
  display: none;
}
@media (max-width: 1100px) {
  .map-workspace {
    gap: 22px;
    grid-template-columns: minmax(0, 1.6fr) minmax(230px, 1fr);
  }
  .map-toolbar {
    gap: 6px;
  }
  .map-expand {
    padding-inline: 10px;
  }
  .zoom-controls output {
    width: 42px;
  }
}
@media (max-width: 760px) {
  .estate-explorer .lead {
    margin-bottom: 28px;
  }
  .estate-explorer .explorer-controls {
    gap: 16px;
  }
  .estate-explorer .filters {
    width: 100%;
    gap: 12px;
  }
  .estate-explorer .filters label {
    min-width: 0;
  }
  .view-controls {
    margin-left: 0;
    flex: 1;
  }
  .view-controls button {
    flex: 1;
  }
  .estate-explorer #result-count {
    width: auto;
    margin: 0 0 14px auto;
    font-size: 11px;
  }
  .map-workspace {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  .map-workspace .map-panel {
    padding: 10px;
  }
  .map-toolbar {
    gap: 8px;
  }
  .map-expand {
    width: 100%;
    margin: 2px 0 0;
    background: var(--navy);
    color: white;
    min-height: 46px;
  }
  .map-expand:hover {
    background: #154660;
  }
  .map-enhanced .map-scroll {
    height: min(58vh, 500px);
    min-height: 310px;
    cursor: auto;
  }
  .map-workspace .selection-panel {
    position: static;
  }
  .map-workspace #selection-placeholder {
    display: none;
  }
  .map-workspace .selected-card {
    background: #fff;
    border: 1px solid var(--line);
    padding: 16px;
  }
  .map-workspace #selection-content {
    display: grid;
    grid-template-columns: 80px minmax(0, 1fr);
    gap: 12px 16px;
    align-items: start;
  }
  .map-workspace .selection-photo img {
    width: 80px;
    height: 85px;
    aspect-ratio: auto;
    object-fit: cover;
  }
  .map-workspace .selection-info {
    padding-right: 30px;
  }
  .map-workspace .selection-info h2 {
    font-size: 23px;
    margin: 0 0 5px;
  }
  .map-workspace .selection-type {
    font-size: 11px;
    margin: 0 0 6px;
  }
  .map-workspace .selection-info .area {
    font-size: 22px;
    margin: 0 0 6px;
  }
  .map-workspace .selection-info .status {
    font-size: 11px;
  }
  .map-workspace .selection-link {
    grid-column: 1/-1;
    margin: 0;
    min-height: 44px;
    padding: 10px;
  }
  .map-workspace .selection-close {
    right: 6px;
    top: 6px;
    width: 40px;
    height: 40px;
  }
  .estate-explorer .house-list tr {
    padding: 20px 0;
  }
  .house-actions {
    display: flex;
    gap: 20px;
    align-items: center;
    white-space: normal;
  }
  .house-actions .show-on-map {
    display: inline-block;
    font-size: 12px;
  }
  .map-dialog-header {
    padding: 12px 16px;
    padding-top: max(12px, env(safe-area-inset-top));
    gap: 8px;
  }
  .map-dialog-header h2 {
    font-size: 18px;
  }
  .map-dialog-header p {
    font-size: 11px;
  }
  .map-close {
    padding: 8px 10px;
    font-size: 11px;
  }
  .map-close span {
    margin-left: 5px;
  }
  #map-dialog-body {
    padding: 0;
    position: relative;
  }
  .map-dialog .map-workspace {
    display: block;
    height: 100%;
    position: relative;
  }
  .map-dialog .map-panel {
    border: 0;
    padding: 10px 12px;
    height: 100%;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }
  .map-dialog .map-toolbar {
    flex-shrink: 0;
    margin: 0 0 8px;
    justify-content: space-between;
  }
  .map-dialog .map-scroll {
    min-height: 0;
    flex: 1;
    height: auto;
  }
  .map-dialog .legend {
    flex-shrink: 0;
    font-size: 9px;
    gap: 10px;
    margin: 8px 0 0;
  }
  .map-dialog .map-hint {
    flex-shrink: 0;
    font-size: 10px;
    line-height: 1.4;
    margin-top: 7px;
  }
  .map-dialog .selection-panel {
    position: absolute;
    top: auto;
    bottom: 54px;
    left: 12px;
    right: 12px;
    z-index: 4;
    padding: 0;
    max-height: 45%;
    overflow-y: auto;
  }
  .map-dialog .selected-card {
    padding: 12px;
    box-shadow: 0 4px 22px #00294325;
    border: 1px solid #c3ccd2;
  }
  .map-dialog .selection-info h2 {
    font-size: 21px;
  }
  .map-dialog .selection-info .area {
    font-size: 21px;
  }
  .map-dialog .selection-photo img {
    height: 78px;
  }
  .map-dialog #selection-content {
    gap: 8px 12px;
  }
  .map-dialog .selection-link {
    font-size: 13px;
  }
}
@media (max-height: 500px) and (max-width: 760px) {
  .map-dialog .selection-panel {
    left: auto;
    width: 250px;
    max-height: calc(100% - 75px);
    bottom: 45px;
  }
  .map-dialog .selection-photo {
    display: none;
  }
  .map-dialog #selection-content {
    grid-template-columns: 1fr;
  }
}
@media (prefers-reduced-motion: reduce) {
  .map-home polygon {
    transition: none;
  }
}

/* Inline mobile selection is visible immediately, without scrolling to a sidebar. */
@media (max-width: 760px) {
  #map-view .map-enhanced.has-selection .selection-panel {
    position: fixed;
    top: auto;
    left: 12px;
    right: 12px;
    bottom: max(12px, env(safe-area-inset-bottom));
    z-index: 100;
    max-height: 45dvh;
    overflow-y: auto;
    box-shadow: 0 4px 28px #00294330;
    overscroll-behavior: contain;
  }
  #map-view .map-enhanced .selected-card {
    padding: 12px;
    border-color: #c3ccd2;
  }
  .map-enhanced .selected-card:not([hidden]) {
    animation: map-card-enter 180ms ease-out;
  }
  .map-workspace .selection-close { width:44px; height:44px; }
}
@keyframes map-card-enter {
  from { opacity:0; translate:0 12px; }
  to { opacity:1; translate:0 0; }
}
@media (prefers-reduced-motion: reduce) {
  .map-enhanced .selected-card:not([hidden]) { animation:none; }
}
