/* =========================================================================
   map.css — Mapa interactivo embebido.
   Soporta dos variantes mediante clase sobre #map-stage:
     - .is-light  →  fondo cálido (cream/sand), líneas verdes/tierra (default)
     - .is-dark   →  fondo oscuro estilo Google Maps nocturno (legacy)
   Y un modificador opcional .is-embed que esconde controles "completos".
   ========================================================================= */

/* ─── Variables base ───────────────────────────────────────────────────── */
#map-stage {
  --paper:   #FBF7F0;
  --cream:   #F1E9D8;
  --sand:    #E9DFC8;
  --line:    #E4D9C2;
  --ink:     #1F1B16;
  --muted:   #5F564A;
  --moss:    #5C7A50;
  --forest:  #2F4A35;
  --terra:   #B5612F;
  --clay:    #C99A6B;
  --warn:    #D89A3C;
  --danger:  #B5404F;
  user-select: none;
}

/* ─── Layout común ─────────────────────────────────────────────────────── */
#map-stage .viewport { overflow: hidden; cursor: grab; }
#map-stage .viewport.dragging { cursor: grabbing; }

#map-stage .world {
  position: absolute; top: 0; left: 0;
  transform-origin: 0 0;
  will-change: transform;
}
#map-stage .plan-img {
  display: block;
  pointer-events: none;
  user-select: none;
}
#map-stage .overlay {
  position: absolute; top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  overflow: visible;
}

/* ─── Variante CLARA — el look "ilustrado" (default) ───────────────────── */
.map-frame {
  background:
    radial-gradient(circle at 20% -10%, rgba(92,122,80,0.10), transparent 55%),
    radial-gradient(circle at 110% 110%, rgba(201,154,107,0.14), transparent 55%),
    linear-gradient(180deg, #F4EEDD 0%, #ECE3CB 100%);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow:
    0 1px 0 rgba(31, 27, 22, 0.05),
    0 28px 60px -28px rgba(47, 74, 53, 0.30);
  overflow: hidden;
  position: relative;
}

.map-frame::after {
  /* viñeta clara que da sensación de mapa "papel" */
  content: "";
  position: absolute; inset: 0;
  pointer-events: none;
  border-radius: 22px;
  box-shadow: inset 0 0 100px rgba(120, 90, 40, 0.10);
}

#map-stage {
  position: relative;
  height: 70vh;
  min-height: 520px;
  color: var(--ink);
}

.map-frame--embed #map-stage {
  height: 460px;
  min-height: 360px;
}
@media (min-width: 1024px) {
  .map-frame--embed #map-stage { height: 540px; }
}

/* Aplicación de la variante clara al PNG del plan */
#map-stage.is-light .plan-img {
  /* El PNG original es line-art negro/naranja sobre fondo blanco.
     Lo desaturamos un poco y le damos warmth para integrarlo con el cream. */
  filter:
    saturate(0.78)
    contrast(0.92)
    brightness(1.04)
    sepia(0.18)
    hue-rotate(-12deg);
  mix-blend-mode: multiply;
}

/* Lotes — versión clara (verde moss) */
#map-stage.is-light .lot { pointer-events: auto; cursor: pointer; transition: filter .15s; }
#map-stage.is-light .lot-fill {
  fill: rgba(92, 122, 80, 0.00);
  stroke: rgba(47, 74, 53, 0.45);
  stroke-width: 1.4;
  transition: fill .15s, stroke .15s, filter .15s;
}
#map-stage.is-light .lot:hover .lot-fill,
#map-stage.is-light .lot.active .lot-fill {
  fill: rgba(92, 122, 80, 0.28);
  stroke: var(--forest);
  stroke-width: 1.8;
  filter: drop-shadow(0 0 6px rgba(92, 122, 80, 0.45));
}
#map-stage.is-light .lot-num {
  /* Números visibles siempre, con halo claro alrededor para legibilidad
     sobre el plano. Al hacer hover/active se ponen 100% forest. */
  font: 600 17px 'JetBrains Mono', monospace;
  fill: var(--forest);
  fill-opacity: 0.88;
  pointer-events: none;
  text-anchor: middle;
  dominant-baseline: middle;
  transition: fill-opacity .15s, font-size .15s;
  paint-order: stroke;
  stroke: rgba(255, 253, 248, 0.92);
  stroke-width: 3.5;
}
#map-stage.is-light .lot:hover .lot-num,
#map-stage.is-light .lot.active .lot-num {
  fill-opacity: 1;
  font-size: 19px;
}

/* Tooltip claro */
#map-stage.is-light .tooltip {
  position: fixed;
  min-width: 220px;
  padding: 14px 16px;
  background: linear-gradient(180deg, rgba(255, 253, 248, 0.98), rgba(241, 233, 216, 0.98));
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 18px 40px -18px rgba(47, 74, 53, 0.45);
  backdrop-filter: blur(8px);
  pointer-events: none;
  transform: translate(-50%, calc(-100% - 14px));
  opacity: 0;
  transition: opacity .12s;
  z-index: 30;
  color: var(--ink);
}
#map-stage.is-light .tooltip[data-show="true"] { opacity: 1; }
#map-stage.is-light .tt-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; gap: 12px; }
#map-stage.is-light .tt-lot { font: 500 11px 'JetBrains Mono', monospace; letter-spacing: 0.16em; color: var(--moss); }
#map-stage.is-light .tt-status {
  font: 500 10px 'JetBrains Mono', monospace;
  padding: 3px 9px;
  border-radius: 999px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
#map-stage.is-light .tt-status[data-s="free"]     { color: var(--forest); background: rgba(92,122,80,0.16); }
#map-stage.is-light .tt-status[data-s="reserved"] { color: #8B5A1F;       background: rgba(216,154,60,0.18); }
#map-stage.is-light .tt-status[data-s="sold"]     { color: #8C2E3A;       background: rgba(181,64,79,0.16); }
#map-stage.is-light .tt-name { font: 500 15px 'Fraunces', serif; margin-bottom: 4px; color: var(--forest); }
#map-stage.is-light .tt-phone { font: 500 12px 'JetBrains Mono', monospace; color: var(--muted); }
#map-stage.is-light .tt-hint { margin-top: 10px; font-size: 10px; color: var(--muted); letter-spacing: 0.18em; text-transform: uppercase; opacity: 0.7; }

/* Zoom buttons */
#map-stage .zoom-controls {
  position: absolute; right: 12px; bottom: 12px;
  display: flex; flex-direction: column; gap: 6px;
  z-index: 15;
}
#map-stage.is-light .zoom-controls button {
  width: 40px; height: 40px;
  background: rgba(255, 253, 248, 0.95);
  backdrop-filter: blur(8px);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--forest);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all .2s ease;
  box-shadow: 0 6px 16px -8px rgba(47, 74, 53, 0.25);
}
#map-stage.is-light .zoom-controls button:hover {
  background: var(--paper);
  border-color: var(--moss);
  color: var(--forest);
  transform: translateY(-1px);
}
#map-stage.is-light .zoom-controls button:active { transform: translateY(0); }

/* Buscador */
#map-stage .map-search {
  position: absolute;
  top: 12px; left: 12px; right: 12px;
  z-index: 18;
}
@media (min-width: 768px) {
  #map-stage .map-search { left: auto; width: 17rem; }
}
#map-stage.is-light .map-search {
  background: rgba(255, 253, 248, 0.95);
  backdrop-filter: blur(8px);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 12px;
  box-shadow: 0 12px 24px -16px rgba(47, 74, 53, 0.30);
}
#map-stage.is-light .map-search label {
  display: block;
  font: 500 10px 'JetBrains Mono', monospace;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 4px;
}
#map-stage.is-light .map-search input {
  width: 100%;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 7px 11px;
  font: 500 13px 'JetBrains Mono', monospace;
  color: var(--ink);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
#map-stage.is-light .map-search input:focus {
  border-color: var(--moss);
  box-shadow: 0 0 0 3px rgba(92, 122, 80, 0.18);
}

/* CTA del embed */
#map-stage.is-embed .map-embed-cta {
  position: absolute;
  bottom: 16px; left: 16px;
  z-index: 20;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(47, 74, 53, 0.92);
  color: var(--paper);
  font: 500 13px 'Inter', system-ui, sans-serif;
  text-decoration: none;
  backdrop-filter: blur(6px);
  border: 1px solid rgba(255, 253, 248, 0.15);
  box-shadow: 0 10px 26px -10px rgba(47, 74, 53, 0.65);
  transition: transform .2s ease, background .2s ease;
}
#map-stage.is-embed .map-embed-cta:hover {
  background: var(--forest);
  transform: translateY(-1px);
}
#map-stage.is-embed .map-embed-cta span { transition: transform .2s ease; }
#map-stage.is-embed .map-embed-cta:hover span { transform: translateX(3px); }

/* ─── Variante OSCURA (legacy) ─────────────────────────────────────────── */
#map-stage.is-dark {
  background:
    radial-gradient(1200px 600px at 20% -10%, rgba(124,246,210,0.06), transparent 60%),
    radial-gradient(900px 500px at 110% 110%, rgba(90,184,255,0.06), transparent 60%),
    linear-gradient(180deg, #07090d, #0c1117);
  color: #e6edf3;
}
#map-stage.is-dark .plan-img {
  filter: invert(0.92) hue-rotate(180deg) brightness(1.05) contrast(1.05) saturate(1.15);
}
#map-stage.is-dark .lot { pointer-events: auto; cursor: pointer; }
#map-stage.is-dark .lot-fill {
  fill: rgba(124,246,210,0.0);
  stroke: rgba(124,246,210,0.55);
  stroke-width: 1.2;
  transition: fill .15s, stroke .15s, filter .15s;
}
#map-stage.is-dark .lot:hover .lot-fill,
#map-stage.is-dark .lot.active .lot-fill {
  fill: rgba(124,246,210,0.22);
  stroke: #7cf6d2;
  filter: drop-shadow(0 0 6px rgba(124,246,210,0.55));
}
#map-stage.is-dark .lot-num {
  font: 600 16px 'JetBrains Mono', monospace;
  fill: rgba(255,255,255,0);
  pointer-events: none;
  text-anchor: middle;
  dominant-baseline: middle;
  paint-order: stroke;
  stroke: rgba(0,0,0,0.6);
  stroke-width: 3;
}
#map-stage.is-dark .lot:hover .lot-num,
#map-stage.is-dark .lot.active .lot-num { fill: rgba(255,255,255,0.95); }

/* ─── Modal del lote (claro y elegante) ────────────────────────────────── */
.lotmodal {
  position: fixed; inset: 0;
  display: none;
  align-items: center; justify-content: center;
  z-index: 70;
  pointer-events: auto;
  opacity: 1;
}
.lotmodal[data-show="true"] { display: flex; }
.lotmodal-backdrop {
  position: absolute; inset: 0;
  background: rgba(31, 27, 22, 0.50);
  backdrop-filter: blur(6px);
}
.lotmodal-card {
  position: relative;
  width: min(640px, 92vw);
  background: linear-gradient(180deg, #FFFDF8 0%, #F8F1E0 100%);
  border: 1px solid #E4D9C2;
  border-radius: 22px;
  box-shadow:
    0 30px 80px rgba(31, 27, 22, 0.30),
    0 0 0 1px rgba(255, 253, 248, 0.6) inset;
  padding: 30px 30px 26px;
  color: #1F1B16;
  animation: lotmodalPop .25s cubic-bezier(.2,.9,.3,1.2);
}
@keyframes lotmodalPop {
  from { transform: translateY(10px) scale(.97); opacity: 0; }
  to   { transform: none; opacity: 1; }
}
.lotmodal-close {
  position: absolute; top: 16px; right: 16px;
  width: 34px; height: 34px;
  background: rgba(241, 233, 216, 0.5);
  border: 1px solid #E4D9C2;
  border-radius: 10px;
  color: #5F564A; font-size: 19px;
  cursor: pointer;
  transition: all .15s ease;
}
.lotmodal-close:hover {
  color: #2F4A35; border-color: #5C7A50;
  background: #F8F1E0;
}
.lotmodal-eyebrow {
  font: 500 11px 'JetBrains Mono', monospace;
  letter-spacing: 0.22em;
  color: #5C7A50;
}
.lotmodal-header h2 {
  font-family: 'Fraunces', serif;
  font-size: 28px; font-weight: 500; margin: 8px 0 10px;
  letter-spacing: -0.01em;
  color: #2F4A35;
  line-height: 1.15;
}
.status-pill {
  display: inline-block;
  font: 500 10px 'JetBrains Mono', monospace;
  letter-spacing: 0.18em;
  padding: 4px 10px;
  border-radius: 999px;
  text-transform: uppercase;
}
.status-pill[data-s="free"]     { color: #2F4A35; background: rgba(92,122,80,0.16); }
.status-pill[data-s="reserved"] { color: #8B5A1F; background: rgba(216,154,60,0.18); }
.status-pill[data-s="sold"]     { color: #8C2E3A; background: rgba(181,64,79,0.16); }
.lotmodal-grid {
  margin-top: 22px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 26px;
}
.lotmodal-grid .lotmodal-field.full { grid-column: 1 / -1; }
.lotmodal-field {
  display: flex; flex-direction: column; gap: 4px;
  padding-bottom: 12px;
  border-bottom: 1px solid #E4D9C2;
}
.lotmodal-field label {
  font: 500 10px 'JetBrains Mono', monospace;
  letter-spacing: 0.16em;
  color: #5F564A;
  text-transform: uppercase;
}
.lotmodal-field span, .lotmodal-field a {
  font-size: 14px; color: #1F1B16; text-decoration: none;
}
.lotmodal-field a {
  color: #2F4A35;
  font-weight: 500;
  display: inline-flex; align-items: center; gap: 6px;
}
.lotmodal-field a:hover { color: #5C7A50; text-decoration: underline; }
.lotmodal-field a::after { content: "↗"; font-size: 11px; opacity: .7; }

.lotmodal-claim {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid #E4D9C2;
}
.lotmodal-claim p {
  font-size: 13px;
  color: #5F564A;
  margin-bottom: 12px;
}

@media (max-width: 640px) {
  .lotmodal-grid { grid-template-columns: 1fr; }
  .lotmodal-card { padding: 22px 20px 18px; }
}

/* ─── Modal: campos privados con placeholder difuminado ─────────────── */
.lotmodal-masked {
  display: inline-block;
  color: rgba(31, 27, 22, 0.45);
  filter: blur(3.5px);
  font-family: 'JetBrains Mono', monospace;
  font-size: 13.5px;
  letter-spacing: 0.04em;
  pointer-events: none;
  user-select: none;
}
.lotmodal-field.is-masked label {
  opacity: 0.75;
}
.lotmodal-field.is-masked .lotmodal-value { display: none; }

/* Apellido difuminado inline (mostrado al lado del nombre) */
.lotmodal-masked-inline {
  display: inline-block;
  color: rgba(31, 27, 22, 0.55);
  filter: blur(4px);
  font-family: inherit;
  letter-spacing: 0.04em;
  pointer-events: none;
  user-select: none;
}

.lotmodal-private-hint {
  margin-top: 18px;
  padding: 12px 14px;
  background: rgba(255, 253, 248, 0.6);
  border: 1px dashed rgba(92, 122, 80, 0.45);
  border-radius: 12px;
  font-size: 13px;
  color: #5F564A;
  text-align: center;
}
.lotmodal-private-hint a {
  color: #2F4A35;
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.lotmodal-private-hint a:hover { color: #5C7A50; }
.lotmodal-private-hint-sep {
  margin: 0 6px;
  color: #C9BFA8;
}
