:root {
  --bg: #101512;
  --panel-bg: rgba(20, 26, 22, 0.92);
  --panel-border: rgba(255, 255, 255, 0.08);
  --text: #eef2ee;
  --muted: #9fb0a4;
  --ready: #34d399;
  --sold: #f87171;
  --hold: #fbbf24;
  --accent: #d8b46a;
  --radius: 10px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--text);
  min-height: 100vh;
  /* Layered background: a soft gold glow centered behind where the map card
     sits, a dimmer green glow lower-left for depth, a faint grid texture for
     tactility, over the base dark gradient -- replaces the old flat var(--bg)
     fill so the empty space around the card isn't a dead, featureless void. */
  background-color: var(--bg);
  background-image:
    radial-gradient(ellipse 900px 560px at 50% 280px, rgba(216, 180, 106, 0.10), transparent 70%),
    radial-gradient(ellipse 700px 700px at 8% 85%, rgba(52, 211, 153, 0.06), transparent 65%),
    linear-gradient(
      rgba(255, 255, 255, 0.025) 1px, transparent 1px
    ),
    linear-gradient(
      90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px
    ),
    linear-gradient(180deg, #121810, #0c110d 55%, #0a0e0b);
  background-size: auto, auto, 42px 42px, 42px 42px, auto;
  background-attachment: fixed, fixed, fixed, fixed, fixed;
  background-repeat: no-repeat, no-repeat, repeat, repeat, no-repeat;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: linear-gradient(180deg, #14201a, #0f1712);
  border-bottom: 1px solid var(--panel-border);
  position: sticky;
  top: 0;
  z-index: 40;
}

.topbar__brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.topbar__logo {
  flex: none;
  height: 40px;
  width: auto;
}

.topbar__eyebrow {
  display: block;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 2px;
}

.topbar__title h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.topbar__actions {
  display: flex;
  gap: 8px;
}

.chip-btn {
  background: rgba(216, 180, 106, 0.12);
  border: 1px solid rgba(216, 180, 106, 0.35);
  color: var(--accent);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}

.chip-btn--muted {
  background: transparent;
  border-color: var(--panel-border);
  color: var(--muted);
}

.stage {
  position: relative;
  display: flex;
  justify-content: center;
  padding: 24px;
}

.stage__scroll {
  display: flex;
  justify-content: center;
  width: 100%;
}

.stage__inner {
  position: relative;
  max-width: 1100px;
  width: 100%;
  line-height: 0;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow:
    0 20px 60px rgba(0, 0, 0, 0.45),
    0 0 0 1px rgba(216, 180, 106, 0.18),
    0 0 80px rgba(216, 180, 106, 0.08);
  /* We drive pan/pinch-zoom ourselves via Pointer Events (see js/app.js). This
     starts as pan-y (a finger dragging the map at rest scrolls the PAGE
     normally, since there's nothing to pan yet at 1x) and js/app.js switches it
     to none once zoomed in past 1x, so a drag then pans the map instead of
     scrolling the page underneath it. Native pinch-zoom is excluded either way
     (neither value grants "pinch-zoom"), so pinch always reaches our own
     zoom handler instead of the browser's page zoom. */
  touch-action: pan-y;
  cursor: grab;
  user-select: none;
}
.stage__inner.is-panning { cursor: grabbing; }

/* Resized (real width/height, not a CSS transform scale) and translated as one unit
   by the pan/zoom controller -- both the raster background photo and the SVG
   overlay stay perfectly in sync since they're siblings sized relative to this
   wrapper. Zoom deliberately isn't done via `transform: scale()`: on mobile
   Chromium/WebKit a transform-scaled layer can get rasterized into a bitmap
   cached at the scale it was promoted at, so the SVG's vector shapes went
   blurry after a pinch/wheel-zoom until something else forced a repaint.
   Resizing the actual box makes the browser paint the SVG at its true target
   resolution every time. No `will-change: transform` here for the same reason
   -- it invites exactly that kind of premature layer promotion/caching. */
.zoom-target {
  position: relative;
}

.mp-image {
  display: block;
  width: 100%;
  height: auto;
  user-select: none;
  pointer-events: none;
}

/* Real SVG overlay (viewBox = the source image's native pixel size) instead of
   an HTML div positioned with percentages -- unit boxes/tags/numbers are now
   vector shapes that stay crisp at any zoom level instead of the old
   percentage-positioned HTML overlay, which was fine unzoomed but never
   needed to render sharp at 4-6x magnification before. */
.mp-overlay {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

.mp-unit { cursor: pointer; }

.mp-unit__cell {
  fill: rgba(255, 255, 255, 0.08);
  stroke: rgba(255, 255, 255, 0.35);
  stroke-width: 2.2;
  transition: filter 0.12s ease;
}

.mp-unit:hover .mp-unit__cell {
  filter: brightness(1.35) saturate(1.2);
}

.mp-unit__no {
  font-size: 14px;
  font-weight: 700;
  fill: rgba(20, 20, 20, 0.75);
  pointer-events: none;
  text-anchor: middle;
  dominant-baseline: central;
}

.mp-unit--sold .mp-unit__no { display: none; }
.mp-unit--hold .mp-unit__no { display: none; }

.mp-unit__tag,
.mp-unit__tag--img {
  pointer-events: none;
}

.mp-unit__tag-bg {
  /* Hold/"Show Unit" badge fill -- the SOLD stamp is its own image asset
     (assets/sold-tag.svg) and doesn't use this class. */
  fill: rgba(180, 120, 6, 0.92);
}

.mp-unit__tag-text {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.02em;
  fill: #fff;
  text-anchor: middle;
  dominant-baseline: central;
}

/* "Belum Dijual" units: fully inert, no overlay/number/popup -- reads exactly like an
   untouched part of the source drawing (e.g. E2), not a marked, clickable unit. */
.mp-unit--unreleased .mp-unit__cell {
  fill: transparent;
  stroke: transparent;
}
.mp-unit--unreleased:hover .mp-unit__cell { filter: none; }

/* Community facility marker (mosque, etc.) -- transparent by default so the printed
   building label/roofline on the base image stays readable, with a soft gold highlight
   on hover/tap to show it's clickable. Rendered as a real polygon (from data's
   clipPath points) when the building's footprint is irregular, or a plain rect
   otherwise -- not a masked rectangle. */
.mp-facility {
  cursor: pointer;
  fill: rgba(216, 180, 106, 0);
  transition: fill 0.12s ease, filter 0.12s ease;
}
.mp-facility:hover,
.mp-facility:active {
  fill: rgba(216, 180, 106, 0.32);
  filter: brightness(1.1);
}

/* Zoom controls (+/-/reset), floating over the bottom-right corner of the map. */
.zoom-controls {
  position: absolute;
  right: 12px;
  bottom: 12px;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.zoom-controls button {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  border: 1px solid var(--panel-border);
  background: var(--panel-bg);
  color: var(--text);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}
.zoom-controls button:active { transform: scale(0.94); }
.zoom-controls #zoom-reset { font-size: 15px; }

/* Legend panel */
.legend-panel {
  position: fixed;
  left: 20px;
  bottom: 20px;
  background: var(--panel-bg);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(216, 180, 106, 0.22);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  gap: 26px;
  z-index: 30;
  box-shadow: 0 8px 28px rgba(0,0,0,0.45);
  max-width: calc(100vw - 40px);
  overflow-x: auto;
}

.legend-panel.is-hidden { display: none; }

.legend-panel h3 {
  margin: 0 0 8px;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.legend-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.legend-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  white-space: nowrap;
}

.legend-row .swatch {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  border: 1px solid rgba(255,255,255,0.25);
  flex: none;
}

.dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  flex: none;
  display: inline-block;
}
.dot--sold { background: var(--sold); }
.dot--hold { background: var(--hold); }
.dot--unreleased { background: #ffffff; border: 1px solid rgba(255,255,255,0.4); }

/* Unit popup */
.unit-popup__backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 49;
}

.unit-popup {
  position: fixed;
  z-index: 50;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 320px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  background: #ffffff;
  color: #1c2420;
  border-radius: 14px;
  padding: 18px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.5);
}

.unit-popup__render {
  display: block;
  width: calc(100% + 36px);
  height: 170px;
  object-fit: cover;
  /* Bias the crop toward the top: the source photos are portrait-ish (roofline
     near the top, driveway/cars as filler at the bottom), and object-fit's
     default center crop was cutting into the 2nd floor to make room for the
     wide-short popup frame. Cropping from the bottom (driveway/foreground)
     instead keeps the whole house facade in frame. */
  object-position: top;
  margin: -18px -18px 14px;
  border-radius: 14px 14px 0 0;
}
.unit-popup__render[hidden] { display: none; }

/* Facility photos (gates, masjid, gym, etc.) are wide architectural renders, not
   portrait house shots -- "top" (tuned for keeping a roofline in frame above) can crop
   out their whole point. The main entrance render specifically has its "SHAISTANAYA
   CITY" signage sitting in the lower-middle third, invisible under the default top
   crop -- center it instead so the signage/shopfronts stay in frame. */
.unit-popup__render--facility {
  object-position: center;
}

.unit-popup__close {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(2px);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  color: #4a544e;
}

.unit-popup__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  /* Room for the close button, which floats top-right (position:absolute) --
     without this the status badge runs underneath it when there's no render
     image pushing the header down. */
  padding-right: 26px;
  margin-bottom: 6px;
}

.unit-popup__code {
  font-size: 19px;
  font-weight: 800;
}

.unit-popup__cluster {
  font-size: 11.5px;
  color: #7c8a80;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-top: 2px;
}

.status-badge {
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  color: #fff;
}
.status-badge--tersedia { background: var(--ready); }
.status-badge--sold { background: var(--sold); }
.status-badge--hold { background: var(--hold); color: #4a3400; }

.unit-popup__type {
  font-weight: 700;
  font-size: 14.5px;
  margin: 8px 0 2px;
}

.unit-popup__addr {
  font-size: 12.5px;
  color: #626f66;
  padding-left: 18px;
  position: relative;
  margin-bottom: 12px;
}
.unit-popup__addr::before {
  content: "\1F4CD";
  position: absolute;
  left: 0;
  top: 0;
  font-size: 11px;
}

@media (max-width: 860px) {
  .stage {
    flex-direction: column;
    padding: 12px 0 12px 12px;
    align-items: stretch;
  }

  /* The map has ~260 small clickable units -- too small to tap reliably at full-width
     on a phone. Our own pinch-to-zoom (js/app.js) handles that now, so the map just
     fills the viewport width and the user pinches/double-tap-drags in to tap a unit,
     instead of the old forced-min-width + horizontal-scroll workaround. */
  .stage__inner {
    max-width: none;
    border-radius: var(--radius);
  }

  .legend-panel {
    position: static;
    margin: 12px 16px 0;
    max-width: none;
    flex-wrap: wrap;
    gap: 16px;
  }
}
