/* ==========================================================================
   mapa.css — sección "Clientes en todo el Ecuador" (mapa SVG + contadores)
   ========================================================================== */

/* Colores de la sección: claro por defecto, oscuro con el botón de tema */
.mapa {
  --mapa-bg: #f6f6f7;
  --mapa-glow: rgba(215, 20, 26, 0.08);
  --mapa-text: #0d0d0d;
  --mapa-muted: #5f6368;
  --mapa-card: #ffffff;
  --mapa-card-border: #e6e6e6;
  --mapa-prov-fill: rgba(215, 20, 26, 0.06);
  --mapa-prov-stroke: rgba(13, 13, 13, 0.45);
  --mapa-tip-bg: #0d0d0d;
  --mapa-tip-text: #ffffff;

  position: relative;
  padding: 72px 0;
  background:
    radial-gradient(ellipse at 70% 40%, var(--mapa-glow), transparent 60%),
    var(--mapa-bg);
  color: var(--mapa-text);
  overflow: hidden;
}

:root[data-theme="dark"] .mapa {
  --mapa-bg: #0d0d0d;
  --mapa-glow: rgba(215, 20, 26, 0.18);
  --mapa-text: #ffffff;
  --mapa-muted: #b8b8bd;
  --mapa-card: rgba(255, 255, 255, 0.04);
  --mapa-card-border: rgba(255, 255, 255, 0.1);
  --mapa-prov-fill: rgba(215, 20, 26, 0.07);
  --mapa-prov-stroke: rgba(255, 255, 255, 0.5);
  --mapa-tip-bg: #ffffff;
  --mapa-tip-text: #0d0d0d;
}

.mapa__grid {
  display: grid;
  grid-template-columns: 1fr 1.3fr;
  gap: 40px;
  align-items: center;
}

.mapa__eyebrow {
  margin: 0;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--color-red);
}

.mapa__title {
  margin: 0.5rem 0 1rem;
  font-size: clamp(1.9rem, 3.6vw, 2.9rem);
  font-weight: 900;
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: var(--mapa-text);
}

.mapa__lead {
  margin: 0;
  max-width: 46ch;
  color: var(--mapa-muted);
}

/* ---------- Contadores ---------- */

.mapa__stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 28px;
}

.stat {
  padding: 16px 12px;
  text-align: center;
  background: var(--mapa-card);
  border: 1px solid var(--mapa-card-border);
  border-radius: var(--radius);
}

.stat__num {
  display: block;
  font-size: clamp(1.6rem, 3vw, 2.3rem);
  font-weight: 900;
  line-height: 1.1;
  color: var(--color-red);
  font-variant-numeric: tabular-nums;
}

.stat__label {
  display: block;
  margin-top: 4px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--mapa-muted);
}

/* ---------- Mapa ---------- */

.mapa__visual {
  position: relative;
}

.mapa__svg svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

/* Provincias: contorno real. Las que tienen clientes se pintan más fuertes */
.mapa__prov {
  fill: var(--mapa-prov-fill);
  stroke: var(--mapa-prov-stroke);
  stroke-width: 0.8;
  stroke-linejoin: round;
  transition: fill 0.3s ease;
}

.mapa__prov--activa {
  fill: rgba(215, 20, 26, 0.22);
}

.mapa__etiqueta {
  font-size: 9px;
  fill: var(--mapa-muted);
  letter-spacing: 0.02em;
}

/* Cada ciudad: entra con escala y opacidad, con retraso según su posición */
.mapa__dot-group {
  opacity: 0;
  cursor: pointer;
  outline: none;
  transform-box: fill-box;
  transform-origin: center;
}

/* Se activa desde mapa.js cuando le toca a la ciudad */
.mapa__dot-group.is-visible {
  animation: dot-in 0.33s ease forwards;
}

.mapa__dot {
  fill: #ff2d33;
  stroke: #ffffff;
  stroke-width: 1.2;
  filter: drop-shadow(0 0 4px rgba(255, 45, 51, 0.9));
}

.mapa__dot-halo {
  fill: rgba(255, 45, 51, 0.35);
  transform-box: fill-box;
  transform-origin: center;
  animation: pulse 2.4s ease-out infinite;
  pointer-events: none;
}

.mapa__dot-group:focus-visible .mapa__dot {
  stroke: #ffd400;
  stroke-width: 2;
}

@keyframes dot-in {
  from { opacity: 0; transform: scale(0.3); }
  to   { opacity: 1; transform: scale(1); }
}

@keyframes pulse {
  0%   { transform: scale(1);   opacity: 0.9; }
  100% { transform: scale(1.9); opacity: 0; }
}

/* ---------- Botones debajo de los contadores ---------- */

.mapa__acciones {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 24px;
}

/* ---------- Tooltip al pasar sobre una ciudad ---------- */

.mapa__tooltip {
  position: absolute;
  z-index: 2;
  transform: translate(-50%, calc(-100% - 14px));
  padding: 8px 12px;
  background: var(--mapa-tip-bg);
  color: var(--mapa-tip-text);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  font-size: 0.85rem;
  line-height: 1.35;
  white-space: nowrap;
  pointer-events: none;
}

.mapa__tooltip[hidden] {
  display: none;
}

.mapa__tooltip span {
  color: #5f6368;
}

/* ---------- Botones debajo de los contadores ---------- */

.mapa__acciones {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 28px;
}

/* ---------- Responsive ---------- */

@media (max-width: 900px) {
  .mapa__grid {
    grid-template-columns: 1fr;
    gap: 32px;
  }
}

@media (max-width: 600px) {
  .mapa {
    padding: 56px 0;
  }

  .mapa__stats {
    gap: 8px;
  }

  .stat {
    padding: 12px 6px;
  }

  .stat__label {
    font-size: 0.62rem;
    letter-spacing: 0.06em;
  }
}

@media (prefers-reduced-motion: reduce) {
  .mapa__dot-group {
    opacity: 1;
    animation: none;
  }

  .mapa__dot-halo {
    animation: none;
    opacity: 0;
  }
}
