/* Keeps the selected-canton outline a constant on-screen width during Leaflet's zoom
   animation, instead of visibly ballooning thick mid-zoom (the whole SVG is CSS-scaled while
   animating) and snapping thin once the path is reprojected at rest. */
.canton-highlight-shape {
  vector-effect: non-scaling-stroke;
}

/* Leaflet makes every interactive vector layer (province/canton polygons, markers) keyboard
   focusable, and clicking one to select it also focuses it — without this, the browser's
   default focus ring draws a plain blue rectangle around the shape's bounding box, which reads
   as a stray blue box sitting on the map. The polygon's own highlight styling already shows
   what's selected, so the native ring is redundant here, not just ugly. */
.leaflet-interactive:focus {
  outline: none;
}

/* The map-style layer switcher's collapsed-state icon (a stacked-layers glyph) ships as a PNG
   in Leaflet's own images/ folder — this vendored copy of Leaflet only ever included the marker
   icons, not that one, since nothing on the site used L.control.layers before. An inline SVG
   here avoids adding a new binary asset (and its @2x variant) just for one small icon. */
.leaflet-control-layers-toggle {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23333' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolygon points='12 3 21 8 12 13 3 8 12 3'/%3E%3Cpolyline points='3 13 12 18 21 13'/%3E%3Cpolyline points='3 18 12 23 21 18'/%3E%3C/svg%3E") !important;
  background-size: 20px 20px;
}

.map-page-header {
  background: var(--color-ink);
  color: var(--color-white);
  padding: var(--space-6) 0 var(--space-5);
}
.map-page-header h1 {
  color: var(--color-white);
  margin-bottom: var(--space-2);
}
.map-page-header p {
  color: rgba(255, 255, 255, 0.75);
  max-width: 620px;
  margin: 0;
}

.province-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-4);
}
.province-chip {
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.06);
  color: var(--color-white);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 40px;
  transition: background-color 150ms ease, border-color 150ms ease;
}
.province-chip:hover {
  background: rgba(255, 255, 255, 0.14);
}
.province-chip[aria-pressed="true"] {
  background: var(--color-gold);
  border-color: var(--color-gold);
  color: var(--color-ink);
}

.canton-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid rgba(255, 255, 255, 0.15);
}
.canton-chip {
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: transparent;
  color: rgba(255, 255, 255, 0.85);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 34px;
  transition: background-color 150ms ease, border-color 150ms ease;
}
.canton-chip:hover {
  background: rgba(255, 255, 255, 0.1);
}
.canton-chip[aria-pressed="true"] {
  background: var(--color-gold);
  border-color: var(--color-gold);
  color: var(--color-ink);
}

.map-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  gap: var(--space-5);
  align-items: start;
  padding: var(--space-5) 0 var(--space-7);
}
@media (max-width: 960px) {
  .map-layout {
    grid-template-columns: 1fr;
  }
}

.map-panel {
  position: sticky;
  top: 84px;
}
@media (max-width: 960px) {
  .map-panel {
    position: static;
  }
}
#cr-map {
  width: 100%;
  height: 560px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-card);
  background: #eef2ee;
}
@media (max-width: 600px) {
  #cr-map {
    height: 380px;
  }
}

.map-legend {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-top: var(--space-3);
  font-size: 0.82rem;
  color: var(--color-text-muted);
  flex-wrap: wrap;
}
.map-legend .swatch {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.map-legend .dot {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  display: inline-block;
}

/* Category filter — a compact toggle-chip bar rather than a plain checkbox list, so a page
   with ten categories still reads as one tidy control instead of a stack of labeled boxes. */
.category-filter-bar {
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  margin-bottom: var(--space-4);
}
.category-filter-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}
.category-filter-label {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-text-muted);
}
.category-filter-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--color-text-muted);
}
.category-filter-linkbtn {
  background: none;
  border: none;
  padding: 0;
  font-size: 0.8rem;
  color: var(--color-gold);
  cursor: pointer;
  text-decoration: underline;
}
.category-filter-linkbtn:hover {
  color: var(--color-ink);
}
.category-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.category-chip {
  --chip-color: var(--color-gold);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1.5px solid var(--color-border);
  background: var(--color-white);
  color: var(--color-text-muted);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.category-chip svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}
.category-chip:hover {
  border-color: var(--chip-color);
}
.category-chip[aria-pressed="true"] {
  background: var(--chip-color);
  border-color: var(--chip-color);
  color: var(--color-white);
}

/* The heading and the m² / sqft switch at its top right; the switch wraps under a long heading. */
.results-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 6px 12px;
  min-width: 0;
}
.results-head h2 { min-width: 0; flex: 1 1 auto; }
.results-area-unit { flex: none; margin-top: 2px; }
.results-panel h2 {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 4px;
}
.results-count {
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--color-text-muted);
}
.results-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.result-card {
  position: relative;
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: var(--space-3);
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-2);
  text-decoration: none;
  color: var(--color-ink);
  transition: box-shadow 180ms ease, border-color 180ms ease;
}
.firesell-badge {
  position: absolute;
  top: 4px;
  left: 4px;
  font-size: 1.3rem;
  line-height: 1;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5));
}
.result-card .verified-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 2;
}
/* On a photo the halo is dark, so the seal reads on any picture. */
.result-card > .verified-badge::after {
  background: radial-gradient(circle, rgba(0, 0, 0, 0.5) 40%, rgba(0, 0, 0, 0) 72%);
}
.result-card:hover {
  box-shadow: var(--shadow-card);
  border-color: var(--color-gold);
}
.result-card img {
  width: 120px;
  height: 96px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  background: var(--color-cream-dim);
}
.result-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.result-conversion {
  color: var(--color-text-muted);
  font-size: 0.78rem;
  margin-top: -2px;
}
.result-conversion:empty {
  display: none;
}
.result-specs {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
  margin-top: 2px;
}
.result-spec {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.8rem;
  color: var(--color-text-muted);
}
.result-spec svg {
  width: 14px;
  height: 14px;
  color: var(--color-gold);
}

/* Leaflet province polygon styling handled inline via JS options,
   but tooltip and popup theming lives here */
.leaflet-popup-content-wrapper {
  border-radius: var(--radius-md);
  font-family: var(--font-body);
}
.leaflet-popup-content {
  margin: 12px 14px;
}
.province-tooltip {
  background: var(--color-ink);
  color: var(--color-white);
  border: none;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.8rem;
  padding: 4px 10px;
  border-radius: 999px;
}
.province-tooltip::before {
  display: none;
}

.airport-div-icon {
  background: none;
  border: none;
}
.airport-marker-icon {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #1565c0;
  border: 2px solid #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}
.airport-marker-icon svg {
  width: 12px;
  height: 12px;
  color: #ffffff;
  transform: rotate(45deg);
}

/* Draw-an-area search (map.js initDrawTool). The toolbar sits under the zoom buttons; while
   drawing, a transparent sheet covers the map and takes the pointer (touch-action: none keeps a
   finger stroke from scrolling the page). */
.draw-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.draw-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 14px 0 11px;
  border-radius: 999px;
  border: 1px solid rgba(47, 59, 52, 0.16);
  background: var(--color-white);
  color: var(--color-ink);
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.16);
  transition: border-color 150ms ease, background-color 150ms ease;
}
.draw-btn svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}
.draw-btn:hover {
  border-color: var(--color-gold);
}
.draw-btn:focus-visible {
  outline: 2px solid var(--color-gold);
  outline-offset: 2px;
}
.draw-btn-primary {
  background: var(--color-ink);
  border-color: var(--color-ink);
  color: var(--color-white);
}
.draw-btn-primary svg {
  color: var(--color-gold);
}
.draw-btn-primary:hover {
  background: #3a4840;
  border-color: #3a4840;
}
.draw-btn-clear svg {
  color: var(--color-text-muted);
}
@media (max-width: 600px) {
  .draw-btn {
    height: 30px;
    padding: 0 11px 0 9px;
    gap: 5px;
    font-size: 0.78rem;
  }
  .draw-btn svg {
    width: 13px;
    height: 13px;
  }
}
.draw-hint {
  position: absolute;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  z-index: 1000;
  max-width: calc(100% - 32px);
  padding: 9px 16px;
  border-radius: 999px;
  background: var(--color-ink);
  color: var(--color-white);
  font-family: var(--font-body);
  font-size: 0.84rem;
  font-weight: 600;
  text-align: center;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
  pointer-events: none;
}
.draw-surface {
  position: absolute;
  inset: 0;
  z-index: 650;
  cursor: crosshair;
  touch-action: none;
}
.area-shape {
  vector-effect: non-scaling-stroke;
}
/* With an area drawn, the faded province shapes stop reacting to hover and clicks, so a click
   inside the area never swaps it for a whole province. */
.has-drawn-area .province-shape {
  pointer-events: none;
}

/* ======================================================================================
   Map page (map.html): find a place without giving up the map.
   One search box for every province and canton, the provinces as one row, and the chosen
   province's cantons behind a single button that opens a sheet (a bottom sheet on phones,
   a centred panel on wider screens), instead of a wall of 20+ chips above the map.
   ====================================================================================== */
.map-locator {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-4);
}
.map-locator .province-chips {
  order: 3;
  flex: 1 1 100%;
  min-width: 0;
  margin-top: 0;
  position: relative; /* map.js centres the chosen chip by its offsetLeft */
}
.map-search {
  position: relative;
  flex: 1 1 240px;
  min-width: 0;
  max-width: 440px;
}
.map-search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  color: rgba(255, 255, 255, 0.7);
  pointer-events: none;
}
.map-search-icon svg { width: 18px; height: 18px; }
#map-search-input {
  width: 100%;
  min-height: 44px;
  padding: 10px 16px 10px 42px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.1);
  color: var(--color-white);
  font-family: var(--font-body);
  font-size: 0.95rem;
}
#map-search-input::placeholder { color: rgba(255, 255, 255, 0.65); }
#map-search-input:focus { outline: 2px solid var(--color-gold); outline-offset: 1px; border-color: var(--color-gold); }
.map-search-list {
  position: absolute;
  z-index: 1100; /* above the Leaflet panes and controls */
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  margin: 0;
  padding: 6px;
  list-style: none;
  background: var(--color-white);
  color: var(--color-text);
  border-radius: var(--radius-md);
  box-shadow: 0 16px 40px -12px rgba(0, 0, 0, 0.45);
  max-height: min(60vh, 360px);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.map-search-list[hidden] { display: none; }
.map-search-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  min-height: 44px;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
}
.map-search-list li[aria-selected="true"],
.map-search-list li[data-i]:hover { background: var(--color-cream); }
.map-search-name { font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.map-search-sub { flex: none; font-size: 0.8rem; color: var(--color-text-muted); }
.map-search-list .map-search-empty { cursor: default; color: var(--color-text-muted); }

.canton-trigger {
  order: 2;
  flex: 0 1 auto;
  min-width: 0;
  max-width: 100%;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 8px 14px 8px 16px;
  border-radius: 999px;
  border: 1px solid var(--color-gold);
  background: transparent;
  color: var(--color-gold-soft);
  font-family: var(--font-body);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
}
.canton-trigger[hidden] { display: none; }
.canton-trigger.is-set { background: var(--color-gold); color: var(--color-ink); }
.canton-trigger-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.canton-trigger svg { width: 16px; height: 16px; flex: none; }

.canton-sheet {
  border: none;
  padding: 0;
  width: min(560px, calc(100vw - 32px));
  max-width: none;
  max-height: min(80vh, 640px);
  max-height: min(80dvh, 640px);
  border-radius: var(--radius-lg);
  background: var(--color-white);
  color: var(--color-text);
  box-shadow: 0 24px 60px -16px rgba(0, 0, 0, 0.5);
}
.canton-sheet[open] { display: flex; flex-direction: column; }
.canton-sheet::backdrop { background: rgba(20, 26, 22, 0.5); }
.canton-sheet-grip { display: none; }
.canton-sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-4) var(--space-2);
}
.canton-sheet-head h2 { margin: 0; font-size: 1.2rem; min-width: 0; overflow-wrap: anywhere; }
.canton-sheet-head .modal-close {
  flex: none;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: var(--color-cream);
  color: var(--color-text);
  cursor: pointer;
}
.canton-sheet-head .modal-close span { display: flex; }
.canton-sheet-head .modal-close svg { width: 20px; height: 20px; }
.canton-sheet-filter {
  margin: 0 var(--space-4) var(--space-2);
  min-height: 44px;
  padding: 8px 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.95rem;
}
.canton-sheet-filter[hidden] { display: none; }
.canton-sheet-list {
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 8px;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: var(--space-2) var(--space-4) max(var(--space-4), env(safe-area-inset-bottom));
}
.canton-sheet .canton-chip {
  min-height: 44px;
  padding: 8px 16px;
  font-size: 0.9rem;
  border-color: var(--color-border);
  background: var(--color-white);
  color: var(--color-text);
}
.canton-sheet .canton-chip:hover { background: var(--color-cream); }
.canton-sheet .canton-chip[aria-pressed="true"] { background: var(--color-gold); border-color: var(--color-gold); color: var(--color-ink); }
.canton-sheet .canton-chip[hidden] { display: none; }

/* Tablets and open foldables: map and results side by side, the map kept in view. */
@media (min-width: 720px) and (max-width: 960px) {
  .map-layout.map-explorer { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .map-explorer .map-panel { position: sticky; top: 84px; }
  .map-explorer #cr-map { height: calc(100vh - 140px); height: calc(100dvh - 140px); min-height: 360px; }
}

/* Phones (and folded cover screens): a short header, provinces in one sideways row, the canton
   sheet rises from the bottom, and the map gets most of the screen. */
@media (max-width: 719px) {
  .map-page-header.is-explorer { padding: var(--space-4) 0 var(--space-3); }
  .map-page-header.is-explorer h1 { font-size: clamp(1.4rem, 6vw, 1.9rem); margin-bottom: var(--space-1); }
  .map-page-header.is-explorer p {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-size: 0.9rem;
  }
  .map-locator { margin-top: var(--space-3); }
  /* Search and the canton button share one line; the button never takes more than half. */
  .map-search { flex: 1 1 150px; max-width: none; }
  .canton-trigger { max-width: 50%; padding-left: 12px; padding-right: 10px; }
  .map-locator .province-chips {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 2px;
  }
  .map-locator .province-chips::-webkit-scrollbar { display: none; }
  .map-locator .province-chips > * { flex: none; }
  .map-explorer { padding-top: var(--space-3); }
  .map-explorer #cr-map { height: 62vh; height: 62svh; min-height: 300px; }

  .canton-sheet {
    width: 100%;
    margin: auto 0 0;
    max-height: 78vh;
    max-height: 78dvh;
    border-radius: 20px 20px 0 0;
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }
  .canton-sheet-grip {
    display: block;
    width: 40px;
    height: 5px;
    margin: 8px auto 0;
    border-radius: 999px;
    background: var(--color-border);
  }
  .canton-sheet-head { padding-top: var(--space-2); }
}
@media (max-width: 719px) and (prefers-reduced-motion: no-preference) {
  .canton-sheet[open] { animation: canton-sheet-up 220ms ease-out; }
}
@keyframes canton-sheet-up { from { transform: translateY(40px); opacity: 0.6; } to { transform: none; opacity: 1; } }

/* Phones held sideways / short screens: the map fills the height. */
@media (max-height: 500px) and (max-width: 960px) {
  .map-explorer #cr-map { height: 82vh; height: 82svh; min-height: 240px; }
  .map-explorer .map-panel { position: static; } /* no room to pin it under the header */
}

/* ---------- Price pins and "Buscar al mover el mapa" (map.js renderPropertyMarkers / initMoveSearch) ---------- */
.price-pin-icon {
  background: none;
  border: 0;
}
.price-pin {
  position: absolute;
  transform: translate(-50%, -100%);
  display: inline-block;
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--color-white);
  color: var(--color-ink);
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.22);
  transition: transform 140ms ease, background 140ms ease, color 140ms ease;
}
.price-pin::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: -5px;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: var(--color-white);
  border-bottom: 0;
}
.price-pin.is-verified {
  box-shadow: 0 0 0 2px var(--color-gold), 0 2px 8px rgba(0, 0, 0, 0.22);
}
.price-pin-icon:hover .price-pin,
.price-pin-icon.is-hot .price-pin {
  background: var(--color-ink);
  color: var(--color-white);
  transform: translate(-50%, -100%) scale(1.12);
  z-index: 2;
}
.price-pin-icon:hover .price-pin::after,
.price-pin-icon.is-hot .price-pin::after {
  border-top-color: var(--color-ink);
}
.price-pin-icon.is-hot {
  z-index: 1000 !important;
}
/* A pill that would cover another one (map.js declutterPins) waits as a small dot, centred on
   its spot, and shows its price again on hover or when its card is hovered. */
.price-pin-icon.is-dot .price-pin {
  width: 12px;
  height: 12px;
  padding: 0;
  font-size: 0;
  background: var(--color-ink);
  border: 2px solid var(--color-gold);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  transform: translate(-50%, -50%);
}
.price-pin-icon.is-dot .price-pin::after {
  display: none;
}
.price-pin-icon.is-dot:hover .price-pin,
.price-pin-icon.is-dot.is-hot .price-pin {
  width: auto;
  height: auto;
  padding: 4px 9px;
  font-size: 0.78rem;
  border: 0;
  transform: translate(-50%, -100%) scale(1.12);
}
.price-pin-icon.is-dot:hover .price-pin::after,
.price-pin-icon.is-dot.is-hot .price-pin::after {
  display: block;
}
.map-panel {
  position: relative;
  top: auto; /* the 84px sticky offset only applies where the panel is sticky (below) */
}
@media (min-width: 961px) {
  .map-panel {
    position: sticky;
    top: 84px;
  }
}

/* ---------- Property search filters (js/map-filters.js) ----------
   One line of pills over the results; each pill opens its own small panel (a sheet from the
   bottom on a phone), "Filtros" opens the full panel, and every filter in use shows as a chip
   with an ×. Everything applies at once, so the pins and the list follow while one picks. */
.results-filters { margin: var(--space-3) 0 var(--space-4); min-width: 0; }
/* The results column never grows to the pills' width: the pill line scrolls inside it. */
.map-layout > .results-panel { min-width: 0; }
.mf-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 2px;
  margin: -2px;
  -webkit-overflow-scrolling: touch;
}
.mf-bar::-webkit-scrollbar { display: none; }
/* Wider than a phone: the pills wrap rather than hide past the edge of the results column. */
@media (min-width: 641px) {
  .mf-bar { flex-wrap: wrap; overflow: visible; }
}
.mf-pill {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 42px;
  max-width: 260px;
  padding: 8px 12px;
  border: 1px solid var(--site-line, var(--color-border));
  border-radius: 999px;
  background: var(--site-surface, var(--color-white));
  color: var(--color-text);
  font: 600 0.9rem/1.2 var(--font-body);
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}
.mf-pill:hover { border-color: var(--color-ink); }
.mf-pill:focus-visible { outline: 2px solid var(--color-gold); outline-offset: 2px; }
.mf-pill-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mf-pill svg { width: 16px; height: 16px; flex: none; }
.mf-chev { display: flex; transition: transform 0.15s ease; }
.mf-pill[aria-expanded="true"] .mf-chev { transform: rotate(180deg); }
.mf-pill[aria-expanded="true"] { border-color: var(--color-ink); box-shadow: 0 0 0 1px var(--color-ink) inset; }
.mf-pill.is-active { background: var(--color-ink); border-color: var(--color-ink); color: var(--color-white); }
.mf-pill.is-active .mf-badge { background: var(--color-gold); color: var(--color-ink); }
.mf-badge {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--color-ink);
  color: var(--color-white);
  font-size: 0.75rem;
  font-weight: 700;
}
.mf-badge[hidden] { display: none; }
.mf-chips { display: flex; flex-wrap: wrap; gap: 6px; min-width: 0; margin-top: 12px; }
.mf-chips[hidden] { display: none; }
.mf-active-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  max-width: 100%;
  padding: 4px 8px 4px 12px;
  border: 1px solid var(--color-gold);
  border-radius: 999px;
  background: #fbf5e2;
  color: var(--color-ink);
  font: 600 0.82rem/1.2 var(--font-body);
  cursor: pointer;
}
.mf-active-chip span { min-width: 0; overflow-wrap: anywhere; text-align: left; }
.mf-active-chip svg { width: 14px; height: 14px; flex: none; }
.mf-active-chip:hover { background: var(--color-gold); }
.mf-clear-all {
  min-height: 34px;
  padding: 4px 10px;
  border: 0;
  background: none;
  color: var(--color-ink);
  font: 600 0.82rem/1.2 var(--font-body);
  text-decoration: underline;
  cursor: pointer;
}
/* The results bar under the filters: the count on the left; the order and "Crear alerta" on the
   right, both 38px pills so they line up. A hairline sets it apart from the filters above. The
   layout follows the width of the results column (a container query), not the screen's. */
.results-filters { container: mfilters / inline-size; }
.mf-results-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--site-line, var(--color-border));
  min-width: 0;
}
.mf-results-bar .results-count { min-width: 0; font: 600 0.95rem/1.3 var(--font-body); color: var(--color-text); }
.mf-results-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; margin-left: auto; min-width: 0; }
.mf-sort {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 38px;
  min-width: 0;
  padding-left: 14px;
  border: 1px solid var(--site-line, var(--color-border));
  border-radius: 999px;
  background: var(--site-surface, var(--color-white));
  transition: border-color 0.15s ease;
}
.mf-sort[hidden] { display: none; }
.mf-sort:hover { border-color: var(--color-ink); }
.mf-sort:focus-within { outline: 2px solid var(--color-gold); outline-offset: 2px; }
.mf-sort label { flex: none; font: 500 0.85rem/1 var(--font-body); color: var(--color-text-muted); cursor: pointer; }
.mf-sort label::after { content: ":"; }
.mf-sort select {
  -webkit-appearance: none;
  appearance: none;
  field-sizing: content;
  height: 100%;
  min-width: 0;
  max-width: 100%;
  padding: 0 34px 0 2px;
  border: 0;
  border-radius: 0 999px 999px 0;
  background: transparent;
  color: var(--color-ink);
  font: 700 0.85rem/1 var(--font-body);
  cursor: pointer;
  outline: none;
}
.mf-sort-chev { position: absolute; right: 12px; top: 50%; display: flex; transform: translateY(-50%); color: var(--color-ink); pointer-events: none; }
.mf-sort-chev svg { width: 15px; height: 15px; }
.mf-alert {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 16px;
  border: 1px solid var(--color-gold);
  border-radius: 999px;
  background: var(--color-gold);
  color: var(--color-ink);
  font: 700 0.85rem/1 var(--font-body);
  white-space: nowrap;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(35, 45, 39, 0.12);
  transition: background-color 0.15s ease, box-shadow 0.15s ease;
}
.mf-alert svg { width: 16px; height: 16px; flex: none; }
.mf-alert:hover { background: var(--color-gold-soft); box-shadow: 0 4px 14px rgba(201, 162, 39, 0.35); }
.mf-alert:focus-visible { outline: 2px solid var(--color-ink); outline-offset: 2px; }
.mf-alert:disabled { opacity: 0.6; cursor: progress; }
/* A narrow results column (phones, a tablet's split view): the count on its own line, then the
   order on the left and "Crear alerta" on the right, across the whole width. */
@container mfilters (max-width: 520px) {
  .mf-results-bar .results-count { flex: 1 0 100%; }
  .mf-results-actions { flex: 1 0 100%; justify-content: space-between; margin-left: 0; }
}
/* Narrower still: the order shows without its "Ordenar:" word (the box keeps it as its label). */
@container mfilters (max-width: 400px) {
  .mf-sort label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}

/* The full panel: a drawer over the results column (the map stays in view beside it) on a
   computer, the whole screen on a phone. */
.mf-drawer, .mf-popover {
  border: 0;
  padding: 0;
  color: var(--color-text);
  background: var(--color-white);
  max-width: none;
  max-height: none;
}
.mf-drawer {
  position: fixed;
  inset: 0 auto 0 0;
  margin: 0;
  width: min(480px, 100vw);
  height: 100vh; height: 100dvh;
  box-shadow: var(--site-shadow-lg, 0 24px 60px rgba(0, 0, 0, 0.25));
}
.mf-drawer[open], .mf-popover[open] { display: flex; flex-direction: column; overflow: hidden; }
.mf-drawer::backdrop { background: rgba(20, 26, 22, 0.25); }
.mf-drawer[open] { animation: mf-slide-in 0.2s ease-out; }
@keyframes mf-slide-in { from { transform: translateX(-24px); opacity: 0; } to { transform: none; opacity: 1; } }
.mf-drawer-head, .mf-popover-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: max(16px, env(safe-area-inset-top)) 20px 12px;
  border-bottom: 1px solid var(--color-cream);
}
.mf-drawer-head h2, .mf-popover-head h2 { margin: 0; font-size: 1.15rem; min-width: 0; }
.mf-drawer .modal-close, .mf-popover .modal-close {
  flex: none;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--color-cream);
  color: var(--color-text);
  cursor: pointer;
}
.mf-drawer .modal-close span, .mf-popover .modal-close span { display: flex; }
.mf-drawer .modal-close svg, .mf-popover .modal-close svg { width: 18px; height: 18px; }
.mf-drawer-body, .mf-popover-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 4px 20px 12px;
  /* The containing block of the hidden labels inside, so they never stretch the dialog itself. */
  position: relative;
}
.mf-chips-drawer { padding: 12px 0 0; }
.mf-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 20px max(12px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--color-cream);
  background: var(--color-white);
}
.mf-foot [data-mf-see] { flex: 1 1 auto; max-width: 280px; margin-left: auto; min-height: 46px; }
.mf-foot .btn { white-space: nowrap; }
.mf-foot [data-mf-reset] { flex: none; }
.mf-foot [data-mf-reset]:disabled { opacity: 0.45; cursor: default; }

/* The small panel under a pill (a non-modal dialog placed by map-filters.js). */
.mf-popover {
  position: fixed;
  margin: 0;
  inset: auto;
  width: min(420px, calc(100vw - 24px));
  max-height: min(70vh, 620px); max-height: min(70dvh, 620px);
  border-radius: 16px;
  box-shadow: var(--site-shadow-lg, 0 24px 60px rgba(0, 0, 0, 0.25));
  z-index: 1200;
}
.mf-popover-head { padding: 14px 16px 10px; }
.mf-popover-head h2 { font-size: 1rem; }
.mf-popover-body { padding: 0 16px 8px; }
.mf-popover .mf-section { border-bottom: 0; padding-bottom: 8px; }
.mf-popover .mf-section > h3 { display: none; }
.mf-popover .mf-foot { padding: 10px 16px 12px; border-radius: 0 0 16px 16px; }
.mf-popover .mf-foot [data-mf-see] { min-height: 40px; }

.mf-section { padding: 18px 0; border-bottom: 1px solid var(--color-cream); min-width: 0; }
.mf-section:last-child { border-bottom: 0; }
.mf-section[hidden], .mf-row[hidden] { display: none; }
.mf-section > h3 { margin: 0 0 12px; font-family: var(--font-body); font-size: 1rem; font-weight: 700; }
.mf-section > h3 label { font: inherit; }
.mf-row + .mf-row { margin-top: 16px; }
.mf-row h4 { margin: 0 0 8px; font-family: var(--font-body); font-size: 0.88rem; font-weight: 600; color: var(--color-text-muted); }
.mf-note { margin: 8px 0 0; font-size: 0.8rem; color: var(--color-text-muted); }
.mf-section-keyword input, .mf-single {
  width: 100%;
  min-height: 46px;
  padding: 10px 14px;
  border: 1px solid var(--color-border);
  border-radius: 12px;
  font: 0.95rem var(--font-body);
}

/* Segmented buttons (Cualquiera · 1+ · 2+ …): a joined row that wraps when it can't fit. */
.mf-seg { display: flex; flex-wrap: wrap; border: 1px solid var(--color-border); border-radius: 12px; overflow: hidden; }
.mf-seg-btn {
  flex: 1 0 auto;
  min-width: 48px;
  white-space: nowrap;
  min-height: 44px;
  padding: 8px 10px;
  border: 0;
  border-left: 1px solid var(--color-border);
  margin-left: -1px;
  background: var(--color-white);
  color: var(--color-text);
  font: 600 0.88rem/1.2 var(--font-body);
  cursor: pointer;
}
.mf-seg-btn:hover { background: var(--color-cream); }
.mf-seg-btn[aria-checked="true"] { background: var(--color-ink); color: var(--color-white); }
.mf-seg-btn:focus-visible { outline: 2px solid var(--color-gold); outline-offset: -2px; position: relative; }

/* Chips (one or several) */
.mf-chip-row, .mf-amenities .amenity-tags { display: flex; flex-wrap: wrap; gap: 8px; }
.mf-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  max-width: 100%;
  padding: 6px 14px;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background: var(--color-white);
  color: var(--color-text);
  font: 600 0.85rem/1.2 var(--font-body);
  cursor: pointer;
}
.mf-chip span { min-width: 0; overflow-wrap: anywhere; text-align: left; }
.mf-chip:hover { border-color: var(--color-ink); }
.mf-chip[aria-pressed="true"], .mf-chip[aria-checked="true"] { background: var(--color-ink); border-color: var(--color-ink); color: var(--color-white); }
.mf-chip:focus-visible { outline: 2px solid var(--color-gold); outline-offset: 2px; }
.mf-amenities .amenity-groups { display: grid; gap: 14px; }
.mf-amenities .amenity-group-title { margin: 0 0 8px; font-family: var(--font-body); font-size: 0.85rem; font-weight: 600; color: var(--color-text-muted); }
.mf-link { margin-top: 10px; padding: 6px 0; border: 0; background: none; color: var(--color-ink); font: 600 0.85rem var(--font-body); text-decoration: underline; cursor: pointer; }
.mf-link[hidden] { display: none; }

/* Min – max boxes */
.mf-minmax { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 8px; }
.mf-minmax input {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--color-border);
  border-radius: 12px;
  font: 0.92rem var(--font-body);
  background: var(--color-white);
}
.mf-dash { color: var(--color-text-muted); }

/* Price histogram + two-handle slider (log scale, map-filters.js renderHistogram) */
.mf-histogram-wrap { margin-bottom: 14px; }
.mf-histogram-wrap[hidden] { display: none; }
.mf-histogram {
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 72px;
  padding: 0 11px;
}
/* A hairline the bars stand on. */
.mf-histogram::after { content: ""; position: absolute; left: 11px; right: 11px; bottom: 0; height: 1px; background: var(--color-cream); }
.mf-hbar {
  flex: 1 1 0;
  min-width: 0;
  border-radius: 4px 4px 1px 1px;
  background: var(--color-cream);
  transition: height 0.25s ease, background-color 0.2s ease, opacity 0.2s ease;
}
.mf-hbar.is-in { background: linear-gradient(180deg, var(--color-gold-soft) 0%, var(--color-gold) 100%); }
.mf-hbar.is-empty { background: transparent; }
.mf-range {
  --lo: 0;
  --hi: 1;
  position: relative;
  height: 28px;
  margin-top: 2px;
}
.mf-range::before, .mf-range::after { content: ""; position: absolute; top: 13px; height: 3px; border-radius: 2px; left: 11px; right: 11px; }
.mf-range::before { background: var(--color-cream); }
.mf-range::after { background: var(--color-ink); left: calc(11px + (100% - 22px) * var(--lo)); right: calc(11px + (100% - 22px) * (1 - var(--hi))); }
.mf-range input[type="range"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 28px;
  margin: 0;
  background: none;
  pointer-events: none;
  -webkit-appearance: none;
  appearance: none;
  z-index: 1;
}
.mf-range input[type="range"]::-webkit-slider-runnable-track { background: none; height: 28px; }
.mf-range input[type="range"]::-moz-range-track { background: none; }
.mf-range input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  pointer-events: auto;
  width: 22px;
  height: 22px;
  margin-top: 3px;
  border-radius: 50%;
  border: 0;
  background: var(--color-white);
  box-shadow: 0 0 0 1px rgba(47, 59, 52, 0.18), 0 2px 6px rgba(47, 59, 52, 0.28);
  cursor: grab;
}
.mf-range input[type="range"]:active::-webkit-slider-thumb { cursor: grabbing; box-shadow: 0 0 0 6px rgba(201, 162, 39, 0.25), 0 2px 6px rgba(47, 59, 52, 0.28); }
.mf-range input[type="range"]::-moz-range-thumb {
  pointer-events: auto;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 0;
  box-shadow: 0 0 0 1px rgba(47, 59, 52, 0.18), 0 2px 6px rgba(47, 59, 52, 0.28);
  background: var(--color-white);
  cursor: grab;
}
.mf-range input[type="range"]:focus-visible::-webkit-slider-thumb { outline: 2px solid var(--color-gold); outline-offset: 2px; }
.mf-scale { display: flex; justify-content: space-between; gap: 8px; padding: 0 2px; font-size: 0.78rem; font-weight: 600; color: var(--color-text-muted); font-variant-numeric: tabular-nums; }

/* Top search box: a listing found by its ID or title. */
.map-search-list li.is-listing { gap: 8px; }
.map-search-icon-sm { display: flex; flex: none; color: var(--color-gold); }
.map-search-icon-sm svg { width: 16px; height: 16px; }

/* Phones: the small panels become sheets from the bottom, the full panel the whole screen. */
@media (max-width: 640px) {
  .mf-popover {
    inset: auto 0 0 0;
    width: 100%;
    max-height: 85vh; max-height: 85dvh;
    border-radius: 20px 20px 0 0;
  }
  .mf-popover::backdrop { background: rgba(20, 26, 22, 0.45); }
  .mf-popover .mf-foot { border-radius: 0; padding-bottom: max(12px, env(safe-area-inset-bottom)); }
  .mf-drawer { width: 100vw; }
  /* A soft fade at the right edge says the pill line goes on: swipe for Tipo and Filtros. */
  .mf-bar { -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 36px), transparent); mask-image: linear-gradient(90deg, #000 calc(100% - 36px), transparent); padding-right: 28px; }
}
/* Dual-screen: the full panel stays on the first screen. */
@media (horizontal-viewport-segments: 2) {
  .mf-drawer { width: env(viewport-segment-width 0 0); }
}
@media (prefers-reduced-motion: reduce) {
  .mf-drawer[open] { animation: none; }
  .mf-pill, .mf-chev, .mf-hbar, .mf-sort, .mf-alert { transition: none; }
}
