/* HUD de transporte para Realidad Aumentada: paneles de vidrio sobre la escena (o la cámara en modo RA). */
:root {
  --fondo: #0b1020;
  --vidrio: rgba(18, 26, 46, 0.58);
  --vidrio-fuerte: rgba(14, 20, 38, 0.74);
  --linea: rgba(255, 255, 255, 0.14);
  --linea-suave: rgba(255, 255, 255, 0.08);
  --texto: #ffffff;
  --suave: rgba(235, 240, 250, 0.72);
  --tenue: rgba(235, 240, 250, 0.5);
  --amarillo: #ffc81e;       /* acento CITA */
  --amarillo-texto: #1a1400;
  --verde: #33d17a;
  --radio: 22px;
  --radio-chico: 12px;
  --blur: blur(18px) saturate(140%);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; min-height: 100svh;
  background: var(--fondo); color: var(--texto);
  font: 500 17px/1.3 system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  overflow-x: hidden;
}
p, h1, h2 { margin: 0; }
button { font: inherit; color: inherit; }
svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Escena de fondo (sin cámara) ---------- */
.escena {
  position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none;
  background:
    radial-gradient(120% 70% at 50% 0%, #22325a 0%, rgba(34, 50, 90, 0) 60%),
    radial-gradient(80% 50% at 85% 100%, rgba(255, 200, 30, 0.12) 0%, rgba(255, 200, 30, 0) 70%),
    linear-gradient(180deg, #111a33 0%, #0b1020 55%, #070a14 100%);
}
body.modo-ra .escena { background: transparent; } /* en RA se ve la cámara detrás */
/* Piso en perspectiva: da la sensación de estar parado en la calle */
.escena-piso {
  position: absolute; left: -50%; right: -50%; bottom: -10%; height: 55%;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.07) 1px, transparent 1px);
  background-size: 56px 56px;
  transform: perspective(420px) rotateX(62deg);
  transform-origin: 50% 100%;
  -webkit-mask-image: linear-gradient(180deg, transparent 0%, #000 45%);
          mask-image: linear-gradient(180deg, transparent 0%, #000 45%);
  animation: avanzar 6s linear infinite;
}
@keyframes avanzar { to { background-position: 0 56px, 0 0; } }
/* Mira de RA, muy tenue, abajo al centro */
.mira {
  position: absolute; left: 50%; bottom: 13%; width: 64px; height: 64px; margin-left: -32px;
  border: 1.5px solid rgba(255, 255, 255, 0.22); border-radius: 50%;
  animation: respirar 4s ease-in-out infinite;
}
.mira span { position: absolute; inset: 22px; border-radius: 50%; border: 1.5px solid rgba(255, 200, 30, 0.55); }
.mira::before, .mira::after {
  content: ''; position: absolute; left: 50%; width: 1.5px; height: 12px; margin-left: -0.75px; background: rgba(255, 255, 255, 0.28);
}
.mira::before { top: -14px; } .mira::after { bottom: -14px; }
@keyframes respirar { 50% { transform: scale(1.06); opacity: 0.75; } }

/* ---------- Estructura ---------- */
.hud {
  position: relative; z-index: 1;
  width: 100%; max-width: 560px; margin: 0 auto;
  padding: max(14px, env(safe-area-inset-top)) 14px 18px;
  display: flex; flex-direction: column; gap: 12px;
}
.hud-cuerpo { display: flex; flex-direction: column; gap: 12px; }
.tablero { display: flex; flex-direction: column; gap: 12px; }
.tablero[hidden], .selector[hidden] { display: none; }
.panel {
  background: var(--vidrio);
  -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
  border: 1px solid var(--linea); border-radius: var(--radio);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  animation: aparecer 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
@keyframes aparecer { from { opacity: 0; transform: translateY(10px) scale(0.99); } }
.tablero > :nth-child(2) { animation-delay: 0.06s; }
.tablero > :nth-child(3) { animation-delay: 0.12s; }

/* ---------- Cabecera: ubicación, hora y clima ---------- */
.hud-cabecera { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: stretch; }
.ubicacion {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; text-align: left; cursor: pointer; min-width: 0;
}
.ubicacion-icono {
  flex: none; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid var(--linea); background: rgba(255, 255, 255, 0.06);
}
.ubicacion-icono svg { width: 20px; height: 20px; }
.ubicacion-textos { display: flex; flex-direction: column; min-width: 0; }
.ubicacion-nombre { font-size: 17px; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ubicacion-detalle { font-size: 14px; color: var(--suave); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.tiempo { padding: 10px 14px; text-align: right; display: flex; flex-direction: column; justify-content: center; }
.reloj { font-size: 30px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; letter-spacing: -0.5px; }
.clima { display: flex; align-items: center; justify-content: flex-end; gap: 6px; margin-top: 6px; font-size: 18px; font-weight: 650; }
.clima[hidden], .clima-texto[hidden] { display: none; }
.clima-icono svg { width: 22px; height: 22px; display: block; }
.clima-icono .sol { color: var(--amarillo); }
.clima-texto { font-size: 12px; color: var(--suave); margin-top: 2px; }

/* ---------- Empresas y sentido ---------- */
.ruta {
  display: flex; align-items: center; gap: 14px; padding: 14px 16px; text-align: left; cursor: pointer; width: 100%;
}
.ruta-icono {
  flex: none; display: grid; place-items: center; width: 50px; height: 50px; border-radius: 14px;
  background: var(--amarillo); color: var(--amarillo-texto); box-shadow: 0 0 22px rgba(255, 200, 30, 0.35);
}
.ruta-icono svg { width: 28px; height: 28px; stroke-width: 2; }
.ruta-textos { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.ruta-empresas { font-size: 22px; font-weight: 600; }
.ruta-empresas b { color: var(--amarillo); font-weight: 800; }
.ruta-empresas i { font-style: normal; color: var(--tenue); margin: 0 2px; }
.ruta-sentido { font-size: 17px; color: var(--suave); }
.flecha { color: var(--amarillo); margin: 0 6px; }
.ruta-sentido { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ruta-cambiar {
  flex: none; display: grid; place-items: center; width: 40px; height: 40px; color: var(--suave);
  border-radius: 50%; border: 1px solid var(--linea); background: rgba(255, 255, 255, 0.05);
}
.ruta-cambiar svg { width: 20px; height: 20px; }

/* ---------- Próximo ómnibus (elemento dominante) ---------- */
.proximo {
  position: relative; display: block; padding: 16px 18px 18px; color: var(--texto); text-decoration: none;
  background: var(--vidrio-fuerte);
  border: 1.5px solid rgba(255, 200, 30, 0.75);
  box-shadow: 0 0 0 1px rgba(255, 200, 30, 0.15), 0 0 32px rgba(255, 200, 30, 0.22), 0 12px 34px rgba(0, 0, 0, 0.45);
}
.proximo[hidden] { display: none; }
/* Esquinas tipo visor de RA */
.esquina { position: absolute; width: 22px; height: 22px; border: 3px solid var(--amarillo); }
.e1 { top: -2px; left: -2px; border-right: 0; border-bottom: 0; border-top-left-radius: var(--radio); }
.e2 { top: -2px; right: -2px; border-left: 0; border-bottom: 0; border-top-right-radius: var(--radio); }
.e3 { bottom: -2px; left: -2px; border-right: 0; border-top: 0; border-bottom-left-radius: var(--radio); }
.e4 { bottom: -2px; right: -2px; border-left: 0; border-top: 0; border-bottom-right-radius: var(--radio); }
.proximo-etiqueta {
  display: inline-flex; align-items: center; gap: 7px; padding: 4px 10px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.1); font-size: 13px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
}
.punto { width: 7px; height: 7px; border-radius: 50%; background: var(--amarillo); box-shadow: 0 0 8px var(--amarillo); }
.proximo-fila { display: flex; align-items: center; gap: 16px; margin-top: 8px; flex-wrap: wrap; }
.proximo-hora {
  font-size: clamp(64px, 20vw, 92px); font-weight: 750; line-height: 0.95; letter-spacing: -2px; font-variant-numeric: tabular-nums;
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.35);
}
.proximo-faltan { display: flex; align-items: center; gap: 10px; padding-left: 16px; border-left: 1px solid var(--linea); }
.cronometro { width: 28px; height: 28px; color: var(--suave); flex: none; }
.faltan-rotulo { display: block; font-size: 15px; color: var(--suave); }
.faltan-valor { display: block; font-size: 24px; font-weight: 750; color: var(--amarillo); font-variant-numeric: tabular-nums; white-space: nowrap; }
.proximo-detalle { display: flex; align-items: center; gap: 12px; margin-top: 14px; flex-wrap: wrap; }
.proximo-servicio { font-size: 19px; font-weight: 550; }
/* Cuando falta poco: el borde late suave */
.proximo.pronto { animation: aparecer 0.5s both, latido 2s ease-in-out infinite; }
.proximo.pronto .faltan-valor { color: #fff; }
@keyframes latido { 50% { box-shadow: 0 0 0 1px rgba(255, 200, 30, 0.35), 0 0 46px rgba(255, 200, 30, 0.45), 0 12px 34px rgba(0, 0, 0, 0.45); } }
/* Cambio de próximo ómnibus */
.proximo.cambio .proximo-hora { animation: entrarHora 0.6s cubic-bezier(0.2, 0.8, 0.2, 1); }
@keyframes entrarHora { from { opacity: 0; transform: translateY(12px); filter: blur(4px); } }

/* Etiqueta de empresa */
.chip {
  display: inline-flex; align-items: center; justify-content: center; min-width: 52px; padding: 4px 10px;
  border-radius: 8px; font-size: 14px; font-weight: 800; letter-spacing: 0.02em;
  background: var(--color, var(--amarillo)); color: var(--color-texto, var(--amarillo-texto));
}

/* ---------- Próximas salidas (timeline) ---------- */
.salidas { padding: 14px 14px 12px; }
.salidas-titulo { font-size: 14px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--suave); margin: 2px 4px 8px; }
.lista { list-style: none; margin: 0; padding: 0 0 0 18px; position: relative; }
.lista::before {
  content: ''; position: absolute; left: 5px; top: 18px; bottom: 18px; width: 2px; border-radius: 2px;
  background: linear-gradient(180deg, var(--amarillo), rgba(255, 200, 30, 0.1));
}
.lista:empty::before { display: none; }
.lista li { position: relative; animation: aparecer 0.4s both; }
.lista li::before {
  content: ''; position: absolute; left: -17px; top: 50%; width: 8px; height: 8px; margin-top: -4px; border-radius: 50%;
  background: #1b2440; border: 2px solid rgba(255, 200, 30, 0.6);
}
.lista li:first-child::before { background: var(--amarillo); box-shadow: 0 0 10px var(--amarillo); }
.salida {
  display: grid; grid-template-columns: auto auto minmax(0, 1fr) auto; align-items: center; gap: 4px 12px;
  padding: 11px 8px; color: var(--texto); text-decoration: none; border-bottom: 1px solid var(--linea-suave); border-radius: 10px;
}
.lista li:last-child .salida { border-bottom: 0; }
.salida:hover, .salida:focus-visible { background: rgba(255, 255, 255, 0.05); }
.salida-hora { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.salida-textos { display: flex; flex-direction: column; min-width: 0; }
.salida-servicio {
  font-size: 16px; color: var(--suave); line-height: 1.2; overflow: hidden;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.salida-extra { font-size: 12px; color: var(--tenue); }
.salida-faltan { font-size: 14px; color: var(--suave); text-align: right; white-space: nowrap; display: flex; align-items: center; gap: 6px; }
.salida-faltan::after { content: '›'; font-size: 22px; line-height: 1; color: var(--tenue); }
.salida.pronto .salida-hora, .salida.pronto .salida-faltan { color: var(--amarillo); }
.etiqueta-dia { font-size: 12px; font-weight: 600; color: var(--tenue); margin-left: 6px; }

.ver-mas {
  display: block; width: 100%; margin-top: 8px; padding: 12px; border-radius: 14px; cursor: pointer;
  background: rgba(255, 255, 255, 0.06); border: 1px solid var(--linea); font-weight: 650;
}
.ver-mas[hidden], .sin-salidas[hidden], .aviso-prueba[hidden] { display: none; }
.sin-salidas { padding: 10px 6px; color: var(--suave); }

/* ---------- Estado del servicio ---------- */
.estado { display: flex; align-items: center; gap: 12px; padding: 12px 14px; animation-delay: 0.18s; }
.estado-punto {
  flex: none; width: 11px; height: 11px; border-radius: 50%; background: var(--verde);
  box-shadow: 0 0 0 0 rgba(51, 209, 122, 0.6); animation: pulso 2.4s ease-out infinite;
}
@keyframes pulso { 70% { box-shadow: 0 0 0 9px rgba(51, 209, 122, 0); } 100% { box-shadow: 0 0 0 0 rgba(51, 209, 122, 0); } }
.estado-textos { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.estado-texto { font-size: 15px; font-weight: 600; }
.estado-sub { font-size: 13px; color: var(--tenue); }
.estado-parada {
  flex: none; padding: 8px 12px; border-radius: 999px; cursor: pointer;
  background: rgba(255, 255, 255, 0.06); border: 1px solid var(--linea); font-size: 13px; font-weight: 650;
}
.aviso-prueba { text-align: center; font-size: 12px; color: var(--tenue); }

/* ---------- Botón y pantalla del modo RA ---------- */
.boton-ra { display: flex; align-items: center; gap: 14px; width: 100%; padding: 12px 16px; text-align: left; cursor: pointer; animation-delay: 0.15s; }
.boton-ra[hidden] { display: none; }
.boton-ra-icono {
  flex: none; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%;
  border: 1.5px solid rgba(255, 200, 30, 0.8); color: var(--amarillo); box-shadow: 0 0 16px rgba(255, 200, 30, 0.25);
}
.boton-ra-icono svg { width: 24px; height: 24px; }
.boton-ra-textos { display: flex; flex-direction: column; }
.boton-ra-titulo { font-size: 17px; font-weight: 700; }
.boton-ra-sub { font-size: 13px; color: var(--suave); }

/* Cámara de fondo (reemplaza la escena) */
.ra-fondo { position: fixed; inset: 0; z-index: 0; background: #000; }
.ra-fondo[hidden] { display: none; }
.ra-camara { position: absolute; inset: 0; overflow: hidden; }
body.modo-ra .escena { display: none; }
/* Con la cámara detrás, el vidrio es un poco más transparente para que se vea la calle */
body.modo-ra { --vidrio: rgba(12, 18, 34, 0.5); --vidrio-fuerte: rgba(10, 14, 28, 0.62); background: #000; }
body.modo-ra .boton-ra-icono { background: var(--amarillo); color: var(--amarillo-texto); }
body.modo-ra.encontrado .boton-ra-sub { color: var(--verde); }
/* Cámara primero: en RA el HUD se esconde; al ver el símbolo aparece la tarjeta grande. "Ver horarios" trae el HUD */
.ver-horarios, .pista-ra { display: none; }
body.modo-ra:not(.con-horarios) .hud { display: none; }
body.modo-ra.con-horarios .hud { padding-bottom: 90px; } /* que "Volver a la cámara" no tape el final del HUD */
body.modo-ra:not(.con-horarios) .pista-ra:not([hidden]) {
  display: block; position: fixed; left: 50%; top: 42%; z-index: 20; transform: translateX(-50%); margin: 0;
  width: min(86vw, 360px); padding: 12px 18px; border-radius: 16px; text-align: center; font-size: 17px; font-weight: 700;
  background: rgba(10, 14, 28, 0.7); border: 1px dashed rgba(255, 200, 30, 0.7);
}
.tarjeta-ra { display: none; }
body.modo-ra:not(.con-horarios) .tarjeta-ra:not([hidden]) {
  display: block; position: fixed; left: 50%; z-index: 20; transform: translateX(-50%);
  width: min(92vw, 520px); text-align: left; cursor: pointer;
  animation: aparecerTarjeta 0.35s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
body.modo-ra .tarjeta-ra.pronto:not([hidden]) { animation: aparecerTarjeta 0.35s both, latido 2s ease-in-out infinite; }
@keyframes aparecerTarjeta { from { opacity: 0; transform: translateX(-50%) scale(0.85); } }
body.modo-ra .tarjeta-ra.saliendo:not([hidden]) { animation: salirTarjeta 0.25s ease-in both; }
@keyframes salirTarjeta { to { opacity: 0; transform: translateX(-50%) scale(0.9); } }
.tarjeta-despues { display: block; margin-top: 12px; font-size: 15px; color: var(--suave); }
.tarjeta-tocar { display: block; margin-top: 8px; font-size: 13px; font-weight: 700; color: var(--amarillo); }
body.modo-ra .ver-horarios {
  display: block; position: fixed; left: 50%; z-index: 20; transform: translateX(-50%);
  bottom: calc(96px + env(safe-area-inset-bottom)); padding: 12px 26px; border-radius: 999px;
  font-size: 16px; font-weight: 700; cursor: pointer; animation: none;
}
body.modo-ra:not(.con-horarios) .publicidad { position: fixed; left: 0; right: 0; bottom: 0; }

/* Capa del marco pegado al cartel: arriba de todo, sin bloquear toques */
.ra-capa { position: fixed; inset: 0; z-index: 15; pointer-events: none; overflow: hidden; }
.ra-capa * { pointer-events: none !important; }

.aviso-ra {
  position: fixed; left: 50%; bottom: 120px; z-index: 40; transform: translateX(-50%); width: min(92vw, 420px);
  padding: 12px 16px; border-radius: 14px; text-align: center; font-size: 15px;
  background: rgba(14, 20, 38, 0.92); border: 1px solid rgba(255, 200, 30, 0.6);
}
.aviso-ra[hidden] { display: none; }

/* Marco sobre el símbolo (espacio CSS de MindAR: 1000 px = ancho del marcador; es cuadrado) */
.marco-ra { position: relative; width: 1000px; height: 1000px; font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; }
.marco-ra .esq { position: absolute; width: 130px; height: 130px; border: 9px solid var(--amarillo); opacity: 0.85; filter: drop-shadow(0 0 14px rgba(255, 200, 30, 0.6)); }
.marco-ra .q1 { top: -20px; left: -20px; border-right: 0; border-bottom: 0; border-top-left-radius: 40px; }
.marco-ra .q2 { top: -20px; right: -20px; border-left: 0; border-bottom: 0; border-top-right-radius: 40px; }
.marco-ra .q3 { bottom: -20px; left: -20px; border-right: 0; border-top: 0; border-bottom-left-radius: 40px; }
.marco-ra .q4 { bottom: -20px; right: -20px; border-left: 0; border-top: 0; border-bottom-right-radius: 40px; }

/* ---------- Selector de parada y sentido ---------- */
.selector { padding: 16px; }
.selector-titulo { font-size: 24px; font-weight: 700; margin: 2px 2px 10px; }
.selector-opciones { display: grid; gap: 8px; }
.opcion {
  display: block; width: 100%; padding: 14px 16px; border-radius: 16px; cursor: pointer; text-align: left;
  background: rgba(255, 255, 255, 0.06); border: 1px solid var(--linea); font-size: 18px; font-weight: 650;
}
.opcion:hover, .opcion:focus-visible { border-color: rgba(255, 200, 30, 0.7); }
.opcion small { display: block; margin-top: 2px; font-size: 14px; font-weight: 500; color: var(--suave); }

/* ---------- Publicidad ---------- */
.publicidad {
  position: sticky; bottom: 0; z-index: 2; padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
  background: rgba(7, 10, 20, 0.7); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
  border-top: 1px solid var(--linea);
}
.publicidad[hidden] { display: none; }
.publicidad-enlace { display: block; max-width: 728px; margin: 0 auto; border-radius: 12px; overflow: hidden; }
.publicidad-imagen { display: block; width: 100%; height: auto; aspect-ratio: 728 / 90; object-fit: cover; }

:focus-visible { outline: 2px solid var(--amarillo); outline-offset: 3px; }

/* ---------- Celular angosto ---------- */
@media (max-width: 440px) {
  /* Fila de la lista en dos renglones: empresa arriba, servicio abajo */
  .salida {
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-areas: 'hora chip faltan' 'hora textos faltan';
    row-gap: 3px;
  }
  .salida-hora { grid-area: hora; font-size: 21px; }
  .salida .chip { grid-area: chip; justify-self: start; min-width: 0; padding: 2px 8px; font-size: 12px; }
  .salida-textos { grid-area: textos; }
  .salida-servicio { font-size: 15px; }
  .salida-faltan { grid-area: faltan; font-size: 13px; }
  .proximo-hora { font-size: clamp(52px, 16.5vw, 72px); letter-spacing: -1.5px; }
  .proximo-fila { gap: 12px; flex-wrap: nowrap; }
  .proximo-faltan { padding-left: 12px; }
  .cronometro { display: none; }
  .faltan-valor { font-size: 21px; }
}
@media (max-width: 340px) {
  .reloj { font-size: 26px; }
  .proximo-fila { flex-wrap: wrap; }
  .proximo-faltan { padding-left: 0; border-left: 0; }
}

/* ---------- Celular horizontal y PC: próximo a la izquierda, lista a la derecha ---------- */
@media (min-width: 760px) and (orientation: landscape), (min-width: 980px) {
  .hud { max-width: 1100px; }
  .tablero:not([hidden]) { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); grid-template-rows: auto 1fr; gap: 12px; align-items: start; }
  .tablero .ruta { grid-column: 1; }
  .tablero .proximo { grid-column: 1; }
  .tablero .salidas { grid-column: 2; grid-row: 1 / span 2; }
}
@media (max-height: 500px) and (orientation: landscape) {
  .proximo-hora { font-size: 64px; }
  .escena-piso, .mira { display: none; }
  .ubicacion, .tiempo, .ruta { padding-top: 8px; padding-bottom: 8px; }
  .publicidad-enlace { max-width: 420px; }
}
@media (min-width: 980px) { .mira { display: none; } }

/* Movimiento reducido: sin animaciones continuas */
@media (prefers-reduced-motion: reduce) {
  .escena-piso, .mira, .estado-punto, .proximo.pronto { animation: none; }
}
