/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; }

:root {
  --accent:   #01f3b3;              /* teal — casas de apuestas */
  --accent2:  #494949;              /* gris oscuro — colegios */
  --red:      #dc2626;              /* rojo — locales que incumplen */
  --bg:       #fafaf9;              /* blanco cálido */
  --bg2:      #ffffff;
  --text:     #1c1917;              /* negro cálido */
  --muted:    #78716c;
  --border:   rgba(1,243,179,0.25);
  --shadow:   0 4px 24px rgba(0,0,0,0.10);
  --shadow-lg: 0 12px 48px rgba(0,0,0,0.14);
  --card-w:   360px;
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, Ubuntu, 'Helvetica Neue', Arial, sans-serif;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  scrollbar-width: none;
}
html::-webkit-scrollbar,
body::-webkit-scrollbar { display: none; }

/* ── Mapa fijo ── */
#map {
  position: fixed;
  inset: 0;
  z-index: 1;
}

/* ── Leyenda en header ── */
.header-leyenda {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-left: 24px;
  padding-left: 24px;
  border-left: 1px solid rgba(0,0,0,0.1);
}
.ley-item {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}
.ley-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 0 1.5px rgba(0,0,0,0.12);
}

/* ── MODO SCROLL ── */
#story {
  position: relative;
  z-index: 10;
  pointer-events: none;
}

/* Header del artículo */
.story-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 12px 24px;
  background: rgba(250,250,249,0.88);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(0,0,0,0.08);
  pointer-events: all;
}
.header-ml-btn {
  margin-left: auto;
  background: var(--accent);
  color: #000;
  border: 1px solid rgba(0,0,0,0.75);
  border-radius: 999px;
  padding: 6px 16px;
  font-size: 12px;
  font-weight: 700;
  font-family: var(--font);
  cursor: pointer;
  letter-spacing: 0.01em;
  white-space: nowrap;
  transition: opacity 0.15s, transform 0.15s;
}
.header-ml-btn:hover {
  opacity: 0.85;
  transform: translateY(-1px);
}

.dot-accent {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px rgba(249,115,22,0.5);
  flex-shrink: 0;
}
.header-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

/* ── Steps ── */
#steps-container {
  padding: 0 0 0 40px;
}

.step {
  min-height: 100vh;
  display: flex;
  align-items: center;
  padding: 80px 0;
  pointer-events: none;
}

/* Las cards tienen pointer-events para poder scrollear sobre ellas */
.card {
  pointer-events: all;
  width: var(--card-w);
  background: rgba(255,255,255,0.94);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 16px;
  padding: 28px 28px 24px;
  box-shadow: var(--shadow-lg);
  /* Animación de entrada */
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}
.card.visible {
  opacity: 1;
  transform: translateY(0);
}
.card.active {
  border-color: var(--accent);
  box-shadow: var(--shadow-lg), 0 0 0 1px var(--accent), 0 0 24px rgba(249,115,22,0.12);
}

.card-tag {
  display: block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
  margin-bottom: 10px;
}

.card h2 {
  margin: 0 0 12px;
  font-size: 22px;
  font-weight: 800;
  line-height: 1.25;
  letter-spacing: -0.02em;
  color: var(--text);
}

.card p {
  margin: 0;
  font-size: 14px;
  line-height: 1.6;
  color: var(--muted);
}
.card p + p {
  margin-top: 10px;
}
.card p strong {
  color: var(--text);
  font-weight: 700;
}
.card p em {
  color: var(--text);
}

/* Stat block */
.card-stat {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid rgba(0,0,0,0.07);
}
.stat-num {
  font-size: 36px;
  font-weight: 900;
  letter-spacing: -0.04em;
  color: var(--accent);
  line-height: 1;
}
.card-stat-warn .stat-num { color: #dc2626; }
.card-stat-ok  .stat-num { color: #16a34a; }
.stat-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

/* Legend renta */
.card-legend {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid rgba(0,0,0,0.07);
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
}
.legend-item::before {
  content: '';
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  background: var(--c, #888);
}
.legend-arrow {
  font-size: 14px;
  color: var(--muted);
}

/* ── CTA Mapa Libre ── */
#mapa-libre-cta {
  min-height: 100vh;
  display: flex;
  align-items: center;
  padding: 0 0 0 40px;
  pointer-events: none;
}
.cta-card {
  pointer-events: all;
  width: var(--card-w);
  background: rgba(255,255,255,0.96);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 16px;
  padding: 32px 28px;
  box-shadow: var(--shadow-lg);
}
.cta-card h3 {
  margin: 0 0 8px;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
}
.cta-card p {
  margin: 0 0 20px;
  font-size: 14px;
  color: var(--muted);
  line-height: 1.5;
}
#entrar-ml-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: 999px;
  padding: 12px 24px;
  font-size: 14px;
  font-weight: 800;
  font-family: var(--font);
  cursor: pointer;
  letter-spacing: 0.01em;
  transition: opacity 0.15s, transform 0.15s;
  box-shadow: 0 4px 16px rgba(1,243,179,0.35);
}
#entrar-ml-btn:hover {
  opacity: 0.88;
  transform: translateY(-1px);
}

/* Ocultar story en modo libre */
#story.hidden {
  display: none;
}

/* ── MODO LIBRE ── */
#ml-ui {
  position: fixed;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  display: flex;
  flex-direction: column;
}
#ml-ui.hidden { display: none; }

/* Header modo libre — misma apariencia que .story-header */
#ml-header {
  position: relative;
  flex: 0 0 auto;
  pointer-events: all;
}
.ui-inner {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding: 12px 20px;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
}
.ui-left  { display: flex; align-items: center; }
.ui-right { display: flex; align-items: center; justify-content: flex-end; }
.map-title-block {
  display: flex;
  align-items: center;
  gap: 12px;
}
.map-title-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px rgba(249,115,22,0.5);
  flex-shrink: 0;
}
.map-title {
  margin: 0;
  font-size: 17px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.02em;
  white-space: nowrap;
}

/* Botones de control */
.ctrl-btn {
  position: fixed;
  left: 16px;
  z-index: 20;
  pointer-events: all;
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--accent);
  color: #000;
  border: 1px solid #000;
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 700;
  font-family: var(--font);
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: opacity 0.15s, transform 0.15s;
  white-space: nowrap;
}
.ctrl-btn:hover {
  opacity: 0.85;
  transform: translateY(-1px);
}
.ctrl-btn.active {
  background: #000;
  color: var(--accent);
  border-color: #000;
}

#volver-btn      { top: 72px;  }
#reset-btn       { top: 120px; }
#filtro-btn      { top: 168px; }
#distancia-btn   { top: 216px; }

/* Panel de distancia */
.distancia-panel {
  position: fixed;
  top: 312px;
  left: 16px;
  z-index: 21;
  pointer-events: all;
  background: var(--bg2);
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  width: 240px;
  overflow: hidden;
}
.distancia-panel.hidden { display: none; }
.distancia-header {
  padding: 12px 14px 8px;
  border-bottom: 1px solid rgba(0,0,0,0.06);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.distancia-header button {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}
.distancia-header button:hover { color: var(--text); }
.distancia-body {
  padding: 14px 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.distancia-valor-row {
  display: flex;
  justify-content: center;
}
#distancia-valor {
  font-size: 24px;
  font-weight: 900;
  letter-spacing: -0.04em;
  color: #ff4444;
  line-height: 1;
}
#distancia-valor.distancia-off {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0;
}
#distancia-slider {
  width: 100%;
  accent-color: #ff4444;
  cursor: pointer;
  height: 4px;
}
.distancia-escala {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--muted);
  font-weight: 600;
  margin-top: -4px;
}
.distancia-leyenda {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding-top: 8px;
  border-top: 1px solid rgba(0,0,0,0.06);
}
.distancia-ley-item {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
}
.distancia-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Panel de filtro */
.filtro-panel {
  position: fixed;
  top: 264px;
  left: 16px;
  z-index: 21;
  pointer-events: all;
  background: var(--bg2);
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  width: 220px;
  overflow: hidden;
}
.filtro-panel.hidden { display: none; }
.filtro-header {
  padding: 12px 14px 8px;
  border-bottom: 1px solid rgba(0,0,0,0.06);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.filtro-titulo {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
}
.filtro-acciones {
  display: flex;
  gap: 6px;
}
.filtro-acciones button {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  font-family: var(--font);
  cursor: pointer;
  padding: 0;
}
.filtro-acciones button:hover { text-decoration: underline; }
.filtro-lista {
  padding: 8px 6px 10px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  max-height: 300px;
  overflow-y: auto;
}
.filtro-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
  transition: background 0.1s;
}
.filtro-item:hover { background: rgba(0,0,0,0.04); }
.filtro-item input[type="checkbox"] {
  accent-color: var(--accent);
  width: 14px;
  height: 14px;
  cursor: pointer;
  flex-shrink: 0;
}

/* ── Popup ── */
.maplibregl-popup {
  font: 13px/1.4 var(--font);
}
.maplibregl-popup-content {
  padding: 0;
  border-radius: 14px;
  overflow: hidden;
  background: var(--bg2);
  border: 1px solid rgba(0,0,0,0.1);
  box-shadow: var(--shadow-lg);
  min-width: 220px;
  max-width: 300px;
}
.maplibregl-popup-close-button {
  color: var(--muted);
  font-size: 16px;
  padding: 6px 10px;
}
.maplibregl-popup-close-button:hover { color: var(--accent); background: transparent; }

.pp-top-bar { height: 3px; background: var(--accent); }
.pp-inner {
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.pp-nombre {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
}
.pp-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.pp-cadena {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #fff;
  background: var(--accent);
  padding: 1px 7px;
  border-radius: 999px;
}
.pp-dir {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  font-style: italic;
  font-weight: 500;
}
.pp-rating-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-top: 6px;
  border-top: 1px solid rgba(0,0,0,0.07);
}
.pp-stars       { color: var(--accent); letter-spacing: 1px; }
.pp-rating-num  { font-weight: 800; color: var(--text); }
.pp-rating-n    { color: var(--muted); font-size: 11px; }

/* Distancia al colegio más cercano */
.pp-dist-row {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-top: 8px;
  padding: 10px 12px;
  background: rgba(0,0,0,0.03);
  border-radius: 8px;
  border: 1px solid rgba(0,0,0,0.07);
}
.pp-dist-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}
.pp-dist-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
}
.pp-dist-val {
  font-size: 18px;
  font-weight: 900;
  letter-spacing: -0.03em;
  line-height: 1;
}
.pp-dist-nombre {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}
.pp-dist-tipo {
  font-size: 11px;
  color: var(--muted);
  font-style: italic;
}

.pp-renta-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(0,0,0,0.07);
}
.pp-renta-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.pp-renta-val   { font-size: 15px; font-weight: 600; color: var(--accent); }
.pp-gmaps {
  display: inline-block;
  margin-top: 4px;
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  text-decoration: none;
  opacity: 0.75;
  transition: opacity 0.15s;
}
.pp-gmaps:hover { opacity: 1; text-decoration: underline; }

/* Tooltip hover */
.map-tooltip {
  position: fixed;
  z-index: 300;
  background: var(--bg2);
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  font-family: var(--font);
  padding: 5px 10px;
  border-radius: 6px;
  border: 1px solid rgba(0,0,0,0.1);
  pointer-events: none;
  white-space: nowrap;
  box-shadow: var(--shadow);
  opacity: 0;
  transition: opacity 0.12s;
}
.map-tooltip.visible { opacity: 1; }

/* Geocoder en modo libre */
.geocoder-ctrl {
  position: relative;
  width: 240px;
}
.geocoder-input {
  width: 100%;
  padding: 8px 12px;
  font-size: 13px;
  font-family: var(--font);
  border: 1px solid rgba(0,0,0,0.12);
  border-radius: 4px;
  background: #fff;
  color: #111;
  outline: none;
  box-shadow: var(--shadow);
}
.geocoder-input:focus { box-shadow: 0 0 0 2px rgba(249,115,22,0.4); }
.geocoder-input::placeholder { color: #9ca3af; }
.geocoder-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  background: #fff;
  border-radius: 4px;
  box-shadow: var(--shadow-lg);
  z-index: 10;
  max-height: 260px;
  overflow-y: auto;
}
.geocoder-item {
  padding: 9px 12px;
  font-size: 12px;
  line-height: 1.4;
  cursor: pointer;
  color: #111;
  border-bottom: 1px solid #f3f4f6;
}
.geocoder-item:last-child { border-bottom: none; }
.geocoder-item:hover { background: #fff7ed; }
.geocoder-empty { color: #9ca3af; cursor: default; }
.geocoder-empty:hover { background: none; }

/* ── Responsive ── */
@media (max-width: 680px) {
  :root { --card-w: calc(100vw - 32px); }
  #steps-container { padding: 0 16px; }
  #mapa-libre-cta  { padding: 0 16px; }
  .step { align-items: flex-end; padding: 0 0 40px; min-height: 120vh; }
  .map-title { font-size: 13px; }

  .story-header {
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 8px;
    padding: 12px 16px;
  }
  .story-header .header-leyenda {
    margin-left: 0;
    padding-left: 0;
    border-left: none;
    justify-content: center;
  }
  .story-header .header-ml-btn {
    margin-left: 0;
  }
}
