/* ================================================================== */
/* Hero Leaflet map - score-pill pins matching the production app      */
/* Sidebar: enriched listing panel (production MapPinPopup replica)   */
/* ================================================================== */

/* Leaflet container override - system eggshell canvas */
.leaflet-container {
  background: var(--bg, #F6F6F3);
  font-family: "Archivo", -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
}

/* Fill the unified moat map panel - near-fullscreen immersive sizing */
#hero-map {
  height: 100%;
  min-height: 560px;   /* aligns with .map min-height (immersive desktop) */
  width: 100%;
  position: relative;
}
@media (max-width: 980px) {
  #hero-map { min-height: 440px; }
}
@media (max-width: 640px) {
  #hero-map { min-height: 400px; }
}

/* ------------------------------------------------------------------ */
/* Tile theming — eggshell/grey, system tokens.                        */
/* Filter raster tiles only (not pins/overlays/controls).              */
/* ------------------------------------------------------------------ */
.leaflet-tile-pane {
  filter: grayscale(1) sepia(.05) brightness(1.04) contrast(.96);
}
[data-theme="dark"] .leaflet-tile-pane {
  filter: grayscale(1) invert(1) sepia(.10) brightness(.85) contrast(.9);
}

/* ------------------------------------------------------------------ */
/* Strip Leaflet chrome - flat indigo zoom, monochrome attribution     */
/* ------------------------------------------------------------------ */
/* Kill the default blue teardrop marker entirely (we use divIcon pills) */
.leaflet-marker-icon.leaflet-default-icon-path,
img.leaflet-marker-icon[src*="marker-icon"] { display: none !important; }
.leaflet-marker-shadow { display: none !important; }

/* Flat square zoom control in the brand system */
.leaflet-control-zoom {
  border: 1px solid var(--ink, #16130D) !important;
  border-radius: 10px !important;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .22) !important;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .35) !important;
  margin: 0 16px 16px 0 !important;
}
.leaflet-control-zoom a {
  /* high-contrast dark-glass buttons — clearly visible over the dark hero map */
  background: rgba(20, 19, 16, .62) !important;
  color: #F5F3EE !important;
  border: none !important;
  border-radius: 0 !important;
  width: 34px;
  height: 34px;
  line-height: 34px;
  font-size: 18px;
  font-family: "JetBrains Mono", "SF Mono", "Menlo", ui-monospace, monospace;
  font-weight: 700;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  transition: background 120ms ease-out, color 120ms ease-out;
}
.leaflet-control-zoom a:first-child { border-bottom: 1px solid rgba(255, 255, 255, .16) !important; }
.leaflet-control-zoom a:hover {
  background: var(--accent, #E5322B) !important;
  color: #fff !important;
}

/* Monochrome, minimal attribution */
.leaflet-control-attribution {
  background: rgba(246, 246, 243, 0.85) !important;
  color: var(--muted, #8C8C86) !important;
  font-family: "JetBrains Mono", "SF Mono", "Menlo", ui-monospace, monospace;
  font-size: 9px !important;
  letter-spacing: .02em;
  border-radius: 0 !important;
  padding: 2px 7px !important;
  border-top: 1px solid rgba(26, 26, 24, .12);
  border-left: 1px solid rgba(26, 26, 24, .12);
}
.leaflet-control-attribution a {
  color: var(--muted, #8C8C86) !important;
  text-decoration: none;
}

/* Square popup - flat paper block, hard edges */
.leaflet-popup-content-wrapper {
  background: var(--paper, #F1ECE2);
  border-radius: 0;
  border: 1px solid var(--ink, #16130D);
  box-shadow: 3px 3px 0 var(--ink, #16130D);
}

.leaflet-popup-tip {
  background: var(--paper, #F1ECE2);
}

.leaflet-popup-content {
  font-size: 12px;
  margin: 10px 12px;
  color: var(--ink, #16130D);
  font-family: "JetBrains Mono", "SF Mono", "Menlo", ui-monospace, monospace;
}

/* ------------------------------------------------------------------ */
/* Score-pill - verbatim from apartment-pipeline index.css            */
/* ------------------------------------------------------------------ */

.score-pill-wrap {
  background: transparent;
  border: 0;
}

.score-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 11px;
  background: var(--tier);
  color: #fff;
  border: 2px solid #16130D;
  border-radius: 14px;
  font-family: "JetBrains Mono", "SF Mono", "Menlo", ui-monospace, monospace;
  font-weight: 900;
  font-size: 13px;
  line-height: 1;
  white-space: nowrap;
  box-shadow: 2px 2px 0 #16130D;
  cursor: pointer;
  transition: box-shadow 120ms ease-out;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.3);
  position: absolute;
  left: 0;
  top: 0;
  transform: translate(-50%, -50%);
}

.score-pill-num {
  font-variant-numeric: tabular-nums;
}

.score-pill-wrap:hover .score-pill {
  transform: translate(-50%, -50%) translate(-1px, -2px);
  box-shadow: 3px 4px 0 #16130D;
}

/* State flag - small circle overlaid on top-right corner of the pill  */
/* mirrors production .score-pill-flag in index.css                    */
.score-pill-flag {
  position: absolute;
  top: -7px;
  right: -7px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1.5px solid #16130D;
  color: #fff;
  font-family: "JetBrains Mono", "SF Mono", "Menlo", ui-monospace, monospace;
  font-size: 10px;
  font-weight: 900;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 1px 1px 0 #16130D;
}

/* Compact transparent variant for low-score pins (score < 6) */
.score-pill-low {
  background: rgba(255, 255, 255, 0.85);
  color: #333;
  border-width: 1px;
  padding: 2px 7px;
  font-size: 10px;
  font-weight: 700;
  box-shadow: 1px 1px 0 rgba(0, 0, 0, 0.4);
  text-shadow: none;
}

/* ------------------------------------------------------------------ */
/* Pin drop-in animation                                               */
/* ------------------------------------------------------------------ */

/* Opacity-only fade - MUST NOT animate transform on .score-pill-wrap:
   that element is Leaflet's marker icon, positioned by Leaflet via
   transform: translate3d(). A transform animation here overrides Leaflet's
   positioning and collapses every marker to the map origin. */
@keyframes pin-fade {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.score-pill-wrap {
  animation: pin-fade 0.35s ease-out both;
}

/* Stagger via custom property set from JS */
.score-pill-wrap[data-delay] {
  animation-delay: var(--pin-delay, 0ms);
}

@media (prefers-reduced-motion: reduce) {
  .score-pill-wrap {
    animation: none;
  }
}

/* ------------------------------------------------------------------ */
/* Cluster pill - brutalist square pill, score + count                */
/* mirrors production iconCreateFunction in MapView.tsx               */
/* ------------------------------------------------------------------ */

.apt-cluster {
  background: transparent;
  border: 0;
}

.apt-cluster-pill {
  width: 44px;
  height: 36px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-family: "JetBrains Mono", "SF Mono", "Menlo", ui-monospace, monospace;
  border: 1px solid #16130D;
  box-shadow: 2px 2px 0 #16130D;
  line-height: 1;
  color: #fff;
  cursor: pointer;
  transition: transform 120ms ease-out;
}

.apt-cluster-pill:hover {
  transform: translate(-1px, -2px);
}

.apt-cluster-score {
  font-size: 13px;
  font-weight: 700;
}

.apt-cluster-count {
  font-size: 9px;
  opacity: 0.85;
  margin-top: 1px;
}

/* Override the default MarkerCluster.Default.css circles
   so they don't visually clash with our custom pill */
.leaflet-cluster-anim .leaflet-marker-icon,
.leaflet-cluster-anim .leaflet-marker-shadow {
  -webkit-transition: -webkit-transform 0.3s ease-out, opacity 0.3s ease-in;
  -moz-transition: -moz-transform 0.3s ease-out, opacity 0.3s ease-in;
  transition: transform 0.3s ease-out, opacity 0.3s ease-in;
}

.marker-cluster-small,
.marker-cluster-medium,
.marker-cluster-large {
  background-clip: padding-box;
  border-radius: 0 !important;
}

.marker-cluster-small div,
.marker-cluster-medium div,
.marker-cluster-large div {
  border-radius: 0 !important;
}

/* ------------------------------------------------------------------ */
/* Count badge at bottom-left (replicates the SVG .count style)        */
/* ------------------------------------------------------------------ */

.map-count {
  font-family: "JetBrains Mono", "SF Mono", "Menlo", ui-monospace, monospace;
  font-size: 11px;
  letter-spacing: .04em;
  text-transform: uppercase;
  margin-top: 8px;
  color: var(--color-muted, #5A5247);
}

/* ================================================================== */
/* LISTING SIDEBAR - enriched panel (production MapPinPopup replica)  */
/* Brutalist: sharp corners, border-left, var(--paper, #F1ECE2) canvas              */
/* ================================================================== */

/* Transparent overlay behind sidebar - clicking it closes the panel  */
#map-sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1250;
  background: transparent;
  cursor: pointer;
}

#map-sidebar-overlay.sb-overlay-active {
  display: block;
}

/* Sidebar panel — a self-contained LIGHT detail card that DOCKS over the map
   (not a full-height page drawer). Its tokens are pinned locally so the page
   theme can never invert its text (light card, dark ink, always readable). */
#map-sidebar {
  --paper: #F3EFE7;
  --ink: #1a1712;
  --muted: #6b6459;
  --line: rgba(26, 23, 18, .15);
  --surface: #ffffff;
  --color-muted: #6b6459;

  position: absolute;
  top: clamp(76px, 11vh, 112px);
  right: clamp(12px, 2vw, 26px);
  bottom: auto;
  width: 380px;
  max-width: calc(100vw - 24px);
  max-height: min(70vh, 640px);
  z-index: 1300;
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 26px 64px rgba(0, 0, 0, .30);
  overflow-y: auto;
  overflow-x: hidden;
  /* Slide + fade in from the right */
  transform: translateX(calc(100% + 40px));
  opacity: 0;
  transition: transform 300ms cubic-bezier(0.22, 0.61, 0.36, 1), opacity 220ms ease;
  display: flex;
  flex-direction: column;
}

#map-sidebar.sb-open {
  transform: none;
  opacity: 1;
}

@media (prefers-reduced-motion: reduce) {
  #map-sidebar {
    transition: none;
  }
}

/* Mobile: bottom sheet when viewport is narrow */
@media (max-width: 640px) {
  #map-sidebar {
    position: fixed;          /* pin to the viewport — don't scroll away with the page */
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: 100%;
    max-height: 85vh;
    border-left: none;
    border-top: 1px solid var(--line);
    border-radius: 18px 18px 0 0;
    transform: translateY(100%);
    box-shadow: 0 -18px 48px rgba(0, 0, 0, .28);
  }

  #map-sidebar.sb-open {
    transform: translateY(0);
  }

  /* lock the page behind the open sheet so you can't scroll it out from under */
  body.sb-lock { overflow: hidden; }
  /* dim the backdrop so the sheet reads as a modal */
  #map-sidebar-overlay.sb-overlay-active { background: rgba(26, 23, 18, .32); }
}

/* ------------------------------------------------------------------ */
/* Section 1: Header                                                   */
/* ------------------------------------------------------------------ */

.sb-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  padding: 16px 18px 12px;
  flex-shrink: 0;
}

.sb-header-left {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.sb-district {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--accent);
}

.sb-approx {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
}

.sb-close {
  background: none;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}

.sb-close:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ------------------------------------------------------------------ */
/* Section 2: Photo strip                                              */
/* ------------------------------------------------------------------ */

.sb-photos {
  display: flex;
  gap: 6px;
  padding: 0 18px 2px;
  height: 92px;
  flex-shrink: 0;
}

.sb-photo-tile {
  flex: 1;
  background: linear-gradient(160deg, #fff, var(--paper));
  border: 1px solid var(--line);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  position: relative;
  overflow: hidden;
}

.sb-photo-tile-wide {
  flex: 1.6;
}

.sb-photo-glyph {
  opacity: 0.28;
}

.sb-photo-label {
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: center;
}

/* ------------------------------------------------------------------ */
/* Section 3: Title + score row                                        */
/* ------------------------------------------------------------------ */

.sb-title-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px 12px;
}

.sb-title {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 19px;
  letter-spacing: -.01em;
  color: var(--ink);
  line-height: 1.2;
}

.sb-score {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 27px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

/* ------------------------------------------------------------------ */
/* Section 4: Stats dl                                                 */
/* ------------------------------------------------------------------ */

.sb-stats {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 14px;
  row-gap: 8px;
  padding: 6px 18px 14px;
  border-top: 1px solid var(--line);
  margin: 0;
}

.sb-stats dt {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--muted);
  padding-top: 2px;
  white-space: nowrap;
}

.sb-stats dd {
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  margin: 0;
  display: flex;
  flex-direction: column;
}

.sb-sub-line {
  font-size: 11px;
  font-weight: 400;
  color: var(--muted);
  margin-top: 1px;
}

/* ------------------------------------------------------------------ */
/* Section 5: Amenity chips                                            */
/* ------------------------------------------------------------------ */

.sb-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 2px 18px 14px;
}

.sb-chip {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: .04em;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  line-height: 1.5;
  white-space: nowrap;
}

/* Kitchen / neutral */
.sb-chip-neutral { color: var(--muted); border-color: var(--line); }

/* AC, shower, bathtub — carry the brand coral tint */
.sb-chip-blue {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 40%, transparent);
  background: color-mix(in srgb, var(--accent) 7%, var(--surface));
}

/* Outdoor: balcony / terrace — soft green */
.sb-chip-green {
  color: #2f7d32;
  border-color: rgba(47, 125, 50, .38);
  background: rgba(47, 125, 50, .06);
}

/* Washer, view */
.sb-chip-grey { color: var(--muted); border-color: var(--line); }

/* ------------------------------------------------------------------ */
/* Section 6: Reasoning paragraph                                      */
/* ------------------------------------------------------------------ */

.sb-reasoning {
  margin: 4px 18px 14px;
  padding: 2px 0 2px 14px;
  border-left: 2px solid var(--accent);
  font-family: var(--serif);
  font-size: 14.5px;
  font-style: italic;
  color: var(--ink);
  line-height: 1.5;
}

/* ------------------------------------------------------------------ */
/* Section 7: Score breakdown                                          */
/* ------------------------------------------------------------------ */

.sb-breakdown {
  padding: 10px 18px;
  border-top: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .04em;
  color: var(--muted);
  line-height: 1.6;
}

/* ------------------------------------------------------------------ */
/* Section 8: Honest no-link note                                      */
/* ------------------------------------------------------------------ */

.sb-note {
  padding: 10px 18px 16px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .03em;
  color: var(--muted);
  line-height: 1.6;
  margin-top: auto;
  border-top: 1px solid var(--line);
}

/* ================================================================== */
/* FLAT RED CIRCLE PINS (system re-theme)                              */
/* Replaces score-pill teardrops. --accent #E5322B / active #C32219.   */
/* ================================================================== */

.flat-pin-wrap {
  background: transparent;
  border: 0;
}

.flat-pin {
  border-radius: 50%;
  border: 2px solid rgba(0, 0, 0, .22);
  box-shadow: 0 1px 4px rgba(0, 0, 0, .35);
  cursor: pointer;
  transition: transform 120ms ease-out, box-shadow 120ms ease-out;
}

.flat-pin-wrap:hover .flat-pin {
  transform: scale(1.25);
  box-shadow: 0 2px 8px rgba(0, 0, 0, .4);
}

/* Score pills — the offer's score, tier-coloured (green ≥8 · orange ≥6 · grey ·
   red rejected), matching the app. Hero pins set inline size/background per
   state; these are the shared defaults (story map + fallback). */
.flat-pin-score {
  min-width: 34px;
  height: 24px;
  padding: 0 6px;
  background: #E5322B;
  border: none;                 /* drop the brutalist 2px dark ring */
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #FBF6EE;               /* warm cream, not pure white */
  font-family: "JetBrains Mono", "SF Mono", "Menlo", ui-monospace, monospace;
  font-weight: 700;
  font-size: 12px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 2px 7px rgba(22, 19, 13, .22), inset 0 0 0 1px rgba(255, 255, 255, .18);
}
.flat-pin-score.is-active {
  font-size: 13px;
  box-shadow: 0 0 0 3px rgba(251, 246, 238, .92), 0 5px 14px rgba(22, 19, 13, .34);
  /* flip to reveal the score on select, like the app */
  animation: pin-flip .55s ease;
}
@keyframes pin-flip {
  0%   { transform: perspective(240px) rotateY(0deg); }
  100% { transform: perspective(240px) rotateY(360deg); }
}

/* Stagger fade-in — mirrors score-pill-wrap pattern */
@keyframes flat-pin-fade {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.flat-pin-wrap {
  animation: flat-pin-fade 0.35s ease-out both;
}

.flat-pin-wrap[data-delay] {
  animation-delay: var(--pin-delay, 0ms);
}

@media (prefers-reduced-motion: reduce) {
  .flat-pin-wrap {
    animation: none;
  }
}

/* ------------------------------------------------------------------ */
/* Flat cluster circle — red circle with count                         */
/* ------------------------------------------------------------------ */

.flat-cluster-wrap {
  background: transparent;
  border: 0;
}

.flat-cluster {
  background: var(--accent, #E5322B);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "JetBrains Mono", "SF Mono", "Menlo", ui-monospace, monospace;
  font-size: 10px;
  font-weight: 700;
  border: 2px solid rgba(0, 0, 0, .22);
  box-shadow: 0 1px 4px rgba(0, 0, 0, .35);
  cursor: pointer;
  transition: transform 120ms ease-out;
}

.flat-cluster:hover {
  transform: scale(1.2);
}

/* EN overview: clickable city choice pins (coral dot + label pill) */
.choice-pin { display: flex; align-items: center; gap: 7px; cursor: pointer; white-space: nowrap; }
.choice-pin .cp-dot {
  width: 15px; height: 15px; border-radius: 50%; background: var(--accent, #E5322B);
  box-shadow: 0 0 0 5px color-mix(in srgb, var(--accent, #E5322B) 22%, transparent);
  flex: 0 0 auto; transition: transform .15s ease;
}
.choice-pin .cp-label {
  font-family: "JetBrains Mono", ui-monospace, monospace; font-size: .8rem; font-weight: 600;
  letter-spacing: .03em; color: var(--ink, #16130D);
  background: rgba(246,246,243,.9); border: 1px solid rgba(22,19,13,.16);
  padding: 2px 9px; border-radius: 999px;
}
.choice-pin:hover .cp-dot { transform: scale(1.28); }
.choice-pin:hover .cp-label { border-color: var(--accent, #E5322B); color: var(--accent, #E5322B); }
[data-theme="dark"] .choice-pin .cp-label { background: rgba(20,19,16,.82); color: #F5F3EE; border-color: rgba(255,255,255,.2); }
