/* ==========================================================
   RUTAS · Mapa interactivo de Belén de Umbría
   Paleta: verdes de Risaralda + un acento cálido.
   ========================================================== */
:root {
  --verde-oscuro: #1f4d3a;
  --verde-medio: #3f8a5c;
  --verde-claro: #8cc5a0;
  --verde-suave: #e8f3ec;
  --acento: #f2a900;
  --fondo: #f5f8f5;
  --texto: #1d2b24;
  --texto-suave: #5b6b62;
  --borde: #d6e2d9;
  --blanco: #fff;
  --fuente: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--fuente);
  color: var(--texto);
  background: var(--fondo);
  line-height: 1.5;
}
body.sin-scroll { overflow: hidden; }

/* El desenfoque se aplica a la capa de la página, nunca al modal */
.app { min-height: 100dvh; display: flex; flex-direction: column; transition: filter 0.3s ease; }
.app--desenfocada { filter: blur(6px) saturate(0.9); pointer-events: none; user-select: none; }

/* ---------- Encabezado ---------- */
.encabezado {
  display: flex; align-items: baseline; flex-wrap: wrap; gap: 0.2rem 1rem;
  padding: 0.8rem clamp(1rem, 3vw, 2.5rem) 0.6rem;
}
.encabezado h1 {
  margin: 0; font-size: clamp(1.7rem, 1.2rem + 2vw, 2.6rem);
  letter-spacing: 0.12em; text-transform: uppercase; color: var(--verde-oscuro); line-height: 1.1;
}
.etiqueta {
  align-self: center; padding: 0.15rem 0.7rem; border-radius: 999px;
  background: var(--verde-oscuro); color: #fff; font-size: 0.75rem; letter-spacing: 0.08em; text-transform: uppercase;
}
.subtitulo { margin: 0; color: var(--texto-suave); }

/* ---------- Distribución ---------- */
.mapa-layout {
  flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) 290px; gap: 1rem;
  padding: 0 clamp(1rem, 3vw, 2.5rem) 1.4rem;
}
.mapa-stage {
  position: relative; height: calc(100dvh - 7.2rem); min-height: 460px;
  border: 1px solid var(--borde); border-radius: 20px; overflow: hidden;
  background:
    radial-gradient(circle at 1px 1px, rgba(31, 77, 58, 0.09) 1px, transparent 1.5px) 0 0 / 22px 22px,
    linear-gradient(180deg, #fbfdfb, #eef5ef);
}
.mapa { display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; user-select: none; }
.mapa--arrastrando { cursor: grabbing; }

/* ---------- Territorio ---------- */
.territorio {
  fill: #e2f0e6; stroke: var(--verde-oscuro); stroke-width: 4; stroke-linejoin: round;
  filter: url(#sombra-territorio);
}
.sector {
  font-size: 24px; font-weight: 600; fill: var(--verde-oscuro); opacity: 0.85; pointer-events: none;
  paint-order: stroke; stroke: #fff; stroke-width: 6px; stroke-linejoin: round;
}
.sector--principal { font-size: 32px; font-weight: 800; opacity: 1; }

.brujula circle { fill: #fff; stroke: var(--verde-oscuro); stroke-width: 3; opacity: 0.9; }
.brujula .fino { fill: none; stroke-width: 1.5; }
.brujula .aguja { fill: var(--verde-oscuro); }
.brujula .aguja.suave { fill: var(--verde-claro); }
.brujula text { font-size: 24px; font-weight: 800; fill: var(--verde-oscuro); }

/* ---------- Rutas ---------- */
.ruta { cursor: pointer; transition: opacity 0.3s ease; outline: none; }
.ruta-borde { fill: none; stroke: #fff; stroke-width: calc(var(--w) + 5px); stroke-linecap: round; stroke-linejoin: round; opacity: 0.85; }
.ruta-linea {
  fill: none; stroke: var(--c); stroke-width: var(--w); stroke-linecap: round; stroke-linejoin: round;
  transition: stroke-width 0.2s ease, filter 0.2s ease;
}
.ruta-zona { fill: none; stroke: transparent; stroke-width: 34px; stroke-linecap: round; stroke-linejoin: round; }

.ruta[data-tipo="principal"]   { --c: var(--verde-oscuro); --w: 9px; }
.ruta[data-tipo="secundaria"]  { --c: var(--verde-medio);  --w: 6px; }
.ruta[data-tipo="alternativa"] { --c: #e2a21c;             --w: 5px; }
.ruta[data-tipo="conexion"]    { --c: #6fae86;             --w: 3.5px; }
.ruta[data-tipo="conexion"] .ruta-linea { stroke-dasharray: 8 11; animation: flujo 1.8s linear infinite; }
@keyframes flujo { to { stroke-dashoffset: -38; } }

.ruta:hover .ruta-linea, .ruta:focus-visible .ruta-linea,
.ruta.is-activa .ruta-linea, .ruta.is-relacionada .ruta-linea {
  stroke-width: calc(var(--w) + 3px); filter: brightness(1.12);
}
.ruta:focus-visible .ruta-borde { stroke: var(--acento); }
.ruta--oculta { display: none; }
.mapa--foco .ruta:not(.is-relacionada) { opacity: 0.22; }

/* ---------- Puntos ---------- */
.punto { cursor: pointer; outline: none; }
.punto-cuerpo { transform-box: fill-box; transform-origin: center; transition: transform 0.2s ease; }
.punto:hover .punto-cuerpo, .punto:focus-visible .punto-cuerpo { transform: scale(1.18); }
.punto-hit { fill: transparent; }
.punto-halo { transform-box: fill-box; transform-origin: center; fill: var(--c); opacity: 0.28; transition: opacity 0.2s ease, transform 0.25s ease; }
.punto-base { fill: var(--c); stroke: #fff; stroke-width: 4; transition: fill 0.2s ease; }
.punto-centro { fill: #fff; }
.punto-bandera { fill: var(--acento); stroke: var(--verde-oscuro); stroke-width: 3; stroke-linejoin: round; }

.punto--principal  { --c: var(--acento); }
.punto--principal .punto-centro { fill: var(--verde-oscuro); }
.punto--principal .punto-halo { animation: pulso 2.6s ease-in-out infinite; }
.punto--secundario { --c: var(--verde-oscuro); }
.punto--adicional  { --c: var(--verde-medio); }
@keyframes pulso { 0%, 100% { transform: scale(1); opacity: 0.32; } 50% { transform: scale(1.22); opacity: 0.12; } }

.punto:hover .punto-halo, .punto:focus-visible .punto-halo { opacity: 0.5; }
.punto:focus-visible .punto-base { stroke: var(--acento); stroke-width: 7; }
.punto.is-selected .punto-halo { opacity: 0.55; animation: none; transform: scale(1.3); }
.punto.is-selected .punto-base { fill: var(--acento); stroke: var(--verde-oscuro); }
.punto.is-selected .punto-centro { fill: var(--verde-oscuro); }

/* Etiqueta con el nombre (aparece al pasar el cursor o enfocar) */
.punto-etiqueta { opacity: 0; pointer-events: none; transition: opacity 0.2s ease; }
.punto:hover .punto-etiqueta, .punto:focus-visible .punto-etiqueta, .punto.is-selected .punto-etiqueta { opacity: 1; }
.punto-etiqueta-fondo { fill: var(--verde-oscuro); }
.punto-etiqueta-texto { fill: #fff; font-size: 24px; font-weight: 600; }

/* ---------- Controles y avisos sobre el mapa ---------- */
.controles { position: absolute; right: 14px; bottom: 14px; display: flex; flex-direction: column; gap: 8px; }
.control, .icono {
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--borde); background: #fff; color: var(--verde-oscuro);
  font: inherit; cursor: pointer; transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}
.control { width: 44px; height: 44px; border-radius: 12px; font-size: 1.5rem; line-height: 1; box-shadow: 0 2px 8px rgba(31, 77, 58, 0.15); }
.control:hover:not(:disabled), .icono:hover { background: var(--verde-oscuro); color: #fff; }
.control:disabled { opacity: 0.4; cursor: not-allowed; }
.control:focus-visible, .icono:focus-visible, .leyenda-ruta:focus-visible { outline: 3px solid var(--acento); outline-offset: 2px; }

.pista {
  position: absolute; top: 14px; left: 14px; margin: 0; padding: 0.3rem 0.8rem; border-radius: 999px;
  background: rgba(255, 255, 255, 0.9); border: 1px solid var(--borde); font-size: 0.8rem; color: var(--texto-suave);
}
.ruta-info {
  position: absolute; left: 14px; right: 76px; bottom: 14px; display: flex; gap: 0.8rem; align-items: flex-start; justify-content: space-between;
  padding: 0.7rem 0.9rem; border-radius: 14px; background: #fff; border: 1px solid var(--borde); box-shadow: 0 4px 16px rgba(31, 77, 58, 0.18);
  font-size: 0.9rem;
}
.ruta-info strong { display: block; color: var(--verde-oscuro); }
.ruta-info span { color: var(--texto-suave); }
.icono { width: 32px; height: 32px; border-radius: 50%; font-size: 1.3rem; line-height: 1; flex: none; }

/* ---------- Leyenda ---------- */
.leyenda { padding: 1rem 1.1rem; border: 1px solid var(--borde); border-radius: 20px; background: #fff; align-self: start; }
.leyenda h2 { margin: 0 0 0.3rem; font-size: 0.8rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--verde-oscuro); }
.leyenda h2:not(:first-child) { margin-top: 1.2rem; }
.leyenda-ayuda { margin: 0 0 0.5rem; font-size: 0.8rem; color: var(--texto-suave); }
.leyenda-ruta {
  display: flex; align-items: center; gap: 0.7rem; width: 100%; padding: 0.45rem 0.5rem; border: 0; border-radius: 10px;
  background: transparent; font: inherit; color: var(--texto); text-align: left; cursor: pointer; transition: background 0.2s ease, opacity 0.2s ease;
}
.leyenda-ruta:hover { background: var(--verde-suave); }
.leyenda-ruta[aria-pressed="false"] { opacity: 0.45; text-decoration: line-through; }
.muestra { flex: none; width: 36px; border-top: var(--g) solid var(--c); border-radius: 3px; }
.muestra--principal   { --g: 6px; --c: var(--verde-oscuro); }
.muestra--secundaria  { --g: 4px; --c: var(--verde-medio); }
.muestra--alternativa { --g: 4px; --c: #e2a21c; }
.muestra--conexion    { --g: 3px; --c: #6fae86; border-top-style: dashed; }
.leyenda-punto { display: flex; align-items: center; gap: 0.7rem; margin: 0.35rem 0.5rem; }
.punto-m { flex: none; display: inline-block; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 2px var(--c); background: var(--c); }
.punto-m--principal  { --c: var(--acento);       width: 22px; height: 22px; margin: 0 7px; }
.punto-m--secundario { --c: var(--verde-oscuro); width: 17px; height: 17px; margin: 0 9px; }
.punto-m--adicional  { --c: var(--verde-medio);  width: 13px; height: 13px; margin: 0 11px; }
.aviso { margin: 1.2rem 0 0; padding-top: 0.9rem; border-top: 1px solid var(--borde); font-size: 0.78rem; color: var(--texto-suave); }

/* ---------- Modal ---------- */
.modal-capa {
  position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; padding: 1rem;
  background: rgba(18, 38, 28, 0); transition: background 0.3s ease;
}
.modal-capa.is-open { background: rgba(18, 38, 28, 0.42); }
.modal {
  position: relative; width: min(100%, 520px); max-height: calc(100dvh - 2rem); overflow: auto;
  padding: clamp(1.4rem, 4vw, 2.2rem); border-radius: 20px; background: #fff; box-shadow: 0 24px 60px rgba(10, 30, 20, 0.35);
  opacity: 0; transform: translateY(16px) scale(0.98); transition: opacity 0.3s ease, transform 0.3s ease; outline: none;
}
.modal-capa.is-open .modal { opacity: 1; transform: none; }
.modal-cerrar { position: absolute; top: 14px; right: 14px; }
.modal h2 { margin: 0 2.4rem 0.9rem 0; font-size: clamp(1.4rem, 1.1rem + 1.2vw, 1.9rem); line-height: 1.2; color: var(--verde-oscuro); }
.modal-linea { height: 1px; margin: 0 0 1.1rem; border: 0; background: var(--borde); }
.modal p { margin: 0; color: var(--texto); }

/* ---------- Adaptación ---------- */
@media (max-width: 960px) {
  .mapa-layout { grid-template-columns: 1fr; }
  .mapa-stage { height: 68dvh; min-height: 420px; }
  .leyenda { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 0.2rem 1rem; }
  .leyenda h2, .leyenda-ayuda, .aviso { grid-column: 1 / -1; }
  .leyenda h2:not(:first-child) { margin-top: 0.8rem; }
}
@media (max-width: 560px) {
  .encabezado { padding-top: 0.6rem; }
  .pista { font-size: 0.72rem; }
  .control { width: 48px; height: 48px; }
  .ruta-info { right: 14px; bottom: 76px; }   /* sube el panel para no chocar con los controles */
}
@media (min-width: 1800px) {
  .mapa-layout { grid-template-columns: minmax(0, 1fr) 340px; }
  body { font-size: 1.15rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}