/* ==========================================================================
   Pantalla de marcacion: un solo objetivo por pantalla, lenguaje llano,
   instrucciones grandes y contraste accesible (WCAG AA).
   ========================================================================== */

/* --- accesibilidad ------------------------------------------------------ */

.salto-contenido {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--acento); color: #fff; padding: .8rem 1.2rem;
  border-radius: 0 0 var(--radio-s) 0; font-weight: 600;
}
.salto-contenido:focus { left: 0; }

/* Anillo de foco visible en todo el sitio: sin esto, quien navega con
   teclado no sabe donde esta. */
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 3px solid var(--acento-2);
  outline-offset: 2px;
  border-radius: 4px;
}

/* --- estructura --------------------------------------------------------- */

.envoltorio { max-width: 720px; margin: 0 auto; padding: 0 1rem 2.5rem; }

.cabecera-simple {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding: 1.1rem 0 1.3rem;
}
.cabecera-simple .marca { gap: .65rem; min-width: 0; }
.cabecera-simple .marca .logo {
  width: 38px; height: 38px; flex: 0 0 38px; border-radius: 10px;
  background: linear-gradient(140deg, var(--acento), #1d4ed8);
  display: grid; place-items: center; font-size: 19px;
}
.cabecera-simple h1 {
  font-size: 1rem; font-weight: 650; letter-spacing: -.2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.reloj { text-align: right; white-space: nowrap; line-height: 1.2; }
.reloj strong { display: block; font-size: 1.5rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.reloj span { font-size: .78rem; }

.pantalla { animation: aparecer .25s ease-out; }
@keyframes aparecer { from { opacity: 0; transform: translateY(6px); } }

/* --- pantalla 1: inicio ------------------------------------------------- */

.cargando-pantalla {
  display: grid; place-items: center; gap: .9rem; padding: 4rem 1rem;
  text-align: center; color: var(--texto-2);
}
.cargando-pantalla p { font-size: .95rem; }

.estado-tarjeta {
  border-radius: var(--radio); padding: 1.6rem 1.25rem; text-align: center;
  border: 1px solid; margin-bottom: 1.2rem;
}
.estado-ok { background: rgba(34, 197, 94, .09); border-color: rgba(34, 197, 94, .35); }
.estado-warn { background: rgba(245, 158, 11, .09); border-color: rgba(245, 158, 11, .35); }
.estado-err { background: rgba(239, 68, 68, .09); border-color: rgba(239, 68, 68, .35); }
.estado-emoji { font-size: 2.6rem; line-height: 1; margin-bottom: .6rem; }
.estado-titulo { font-size: 1.35rem; font-weight: 650; margin-bottom: .3rem; }
.estado-texto { font-size: 1rem; color: var(--texto); }

/* Boton principal: grande, de un solo color, imposible de no ver. */
.boton.gigante {
  width: 100%; padding: 1.4rem 1.5rem; font-size: 1.3rem; font-weight: 700;
  border-radius: var(--radio); display: flex; align-items: center;
  justify-content: center; gap: .7rem; min-height: 72px;
  box-shadow: 0 8px 24px rgba(59, 130, 246, .3);
}
.boton.gigante .boton-ico { font-size: .9rem; }
.boton.gigante:active { transform: translateY(2px); }
.ayuda-texto { text-align: center; margin-top: .9rem; font-size: .95rem; color: var(--texto-2); }

/* Turnos cuando no hay ninguno abierto: informativo, no seleccionable. */
.lista-turnos { display: grid; gap: .6rem; margin-top: .4rem; }
.turno-info {
  display: flex; align-items: center; gap: .9rem; padding: .9rem 1rem;
  background: var(--panel); border: 1px solid var(--borde); border-radius: var(--radio-s);
}
.turno-info .t-hora {
  font-size: 1.35rem; font-weight: 300; font-variant-numeric: tabular-nums;
  min-width: 68px;
}
.turno-info .t-nombre { flex: 1; min-width: 0; }
.turno-info .t-nombre strong { display: block; font-size: .98rem; }
.turno-info .t-nombre span { font-size: .8rem; }
.turno-info .t-estado { font-size: .74rem; }

/* Turnos que se pueden tocar para elegir. Un <button> de verdad, para que
   tambien funcione con el teclado y lo anuncie el lector de pantalla. */
.turno-info.elegible {
  width: 100%; text-align: left; cursor: pointer; font-family: inherit;
  color: inherit; padding: 1.05rem 1rem; min-height: 68px;
  transition: background .15s, border-color .15s, transform .1s;
}
.turno-info.elegible:hover { background: var(--panel-2); border-color: var(--acento); }
.turno-info.elegible:active { transform: scale(.985); }
.turno-info.elegible .t-hora { font-size: 1.5rem; font-weight: 600; min-width: 76px; }
.turno-info.elegible .t-nombre strong { font-size: 1.05rem; }
.turno-info.elegible .t-nombre span { font-size: .85rem; }

/* Sede de la marcacion: fecha con la red o selector si hay que elegir.
   Nunca es obligatoria: si no se sabe, se marca sin sede. */
.sede-marcacion {
  margin-top: 1rem; padding: .85rem 1rem; border-radius: var(--radio-s);
  background: var(--panel); border: 1px dashed var(--borde-fuerte, var(--borde));
}
.sede-fija {
  display: flex; align-items: center; gap: .55rem; font-size: .95rem;
  color: var(--texto);
}
.sede-fija .ico { font-size: 1.05rem; }
.sede-fija .sede-nota { color: var(--texto-2); font-size: .8rem; margin-left: auto; }
.sede-elegir { display: flex; flex-direction: column; gap: .4rem; }
.sede-elegir label { font-size: .78rem; font-weight: 600; color: var(--texto-2); }
.sede-elegir select {
  background: var(--fondo-2); color: var(--texto); border: 1px solid var(--borde);
  border-radius: var(--radio-s); padding: .55rem .65rem; font-size: .95rem;
}
.sede-elegir select:focus { outline: 2px solid var(--acento); outline-offset: 2px; }

/* Avisos explicitos de las senales de riesgo, bajo los datos del resultado. */
.res-avisos { display: grid; gap: .5rem; margin-top: .7rem; }
.res-avisos .aviso { text-align: left; }

/* Aviso cuando las ventanas se solapan y hay que elegir. */
.aviso-solape {
  margin: 0 0 1rem; padding: .85rem 1rem; font-size: .88rem; line-height: 1.55;
  background: rgba(59, 130, 246, .09); border: 1px solid rgba(59, 130, 246, .35);
  border-radius: var(--radio-s); color: var(--texto-2);
}
.aviso-solape strong { color: var(--texto); }

/* Privacidad: la reassure, pero legible. */
.privacidad {
  margin-top: 1.4rem; padding: .95rem 1.05rem; font-size: .88rem; line-height: 1.6;
  background: var(--panel); border: 1px solid var(--borde);
  border-left: 3px solid var(--acento); border-radius: var(--radio-s);
  color: var(--texto-2);
}
.privacidad strong { color: var(--texto); }

/* Ayuda desplegable */
.ayuda { margin-top: 1rem; }
.ayuda > summary {
  cursor: pointer; padding: .9rem 1.05rem; background: var(--panel);
  border: 1px solid var(--borde); border-radius: var(--radio-s);
  font-size: .95rem; font-weight: 600; list-style: none;
}
.ayuda > summary::-webkit-details-marker { display: none; }
.ayuda > summary::after { content: " \25BE"; color: var(--texto-2); }
.ayuda[open] > summary { border-radius: var(--radio-s) var(--radio-s) 0 0; border-bottom: none; }
.ayuda-cuerpo {
  border: 1px solid var(--borde); border-top: none;
  border-radius: 0 0 var(--radio-s) var(--radio-s); padding: .4rem .9rem .9rem;
  background: var(--panel);
}
.ayuda-cuerpo details { border-bottom: 1px solid var(--borde); }
.ayuda-cuerpo details:last-of-type { border-bottom: none; }
.ayuda-cuerpo summary {
  cursor: pointer; padding: .8rem 0; font-weight: 600; font-size: .92rem; list-style: none;
}
.ayuda-cuerpo summary::-webkit-details-marker { display: none; }
.ayuda-cuerpo summary::before { content: "\25B8 "; color: var(--texto-2); }
.ayuda-cuerpo details[open] summary::before { content: "\25BE "; }
.ayuda-cuerpo p { font-size: .9rem; color: var(--texto-2); line-height: 1.6; padding-bottom: .8rem; }
.ayuda-pie { font-size: .85rem; color: var(--texto-2); padding-top: .8rem; font-weight: 600; }

/* --- pantalla 2: captura ------------------------------------------------ */

.captura-cabecera {
  display: flex; align-items: center; gap: .8rem; margin-bottom: .8rem;
}
.espacio-cabecera { width: 40px; flex: 0 0 40px; }
.captura-paso { flex: 1; text-align: center; font-size: .98rem; font-weight: 600; color: var(--texto); }

.boton-icono {
  width: 40px; height: 40px; flex: 0 0 40px; border-radius: 50%;
  background: var(--panel); border: 1px solid var(--borde); color: var(--texto);
  font-size: 1rem; cursor: pointer; display: grid; place-items: center;
  font-family: inherit;
}
.boton-icono:hover { background: var(--panel-2); }

.camara-marco {
  position: relative; background: #000; border-radius: var(--radio);
  overflow: hidden; aspect-ratio: 3 / 4; max-height: 68vh;
  margin: 0 auto; width: 100%; border: 1px solid var(--borde);
}
.camara-marco video, .camara-marco canvas {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
}
.camara-marco video { transform: scaleX(-1); }

.guia-rostro { position: absolute; inset: 0; pointer-events: none; display: grid; place-items: center; }
.guia-rostro .ovalo {
  width: 54%; aspect-ratio: 3 / 4; border-radius: 50% / 44%;
  border: 3px dashed rgba(255, 255, 255, .45);
  transition: border-color .25s, transform .25s;
}
.camara-marco.con-rostro .ovalo { border-color: var(--ok); }
.camara-marco.sin-rostro .ovalo { border-color: var(--alerta); }
.camara-marco.terminado .ovalo { border-color: var(--acento-2); }

/* La instruccion es lo mas importante de la pantalla: grande y centrada. */
.instruccion {
  position: absolute; inset: 0; display: grid; place-content: center;
  justify-items: center; gap: .5rem; padding: 1.5rem; text-align: center;
  background: rgba(6, 11, 22, .62); backdrop-filter: blur(3px);
  pointer-events: none;
}
.instruccion.oculta { background: none; backdrop-filter: none; }
.instruccion-flecha { font-size: 4.5rem; line-height: 1; font-weight: 700; }
.instruccion-flecha.pulsa { animation: pulsar 1s ease-in-out infinite; }
@keyframes pulsar { 0%, 100% { opacity: .5; } 50% { opacity: 1; } }
.instruccion-texto {
  font-size: 1.5rem; font-weight: 700; line-height: 1.25;
  text-shadow: 0 2px 12px rgba(0, 0, 0, .8); max-width: 14ch;
}
.instruccion.ok .instruccion-flecha { color: #4ade80; }
.instruccion.mal .instruccion-flecha { color: #f87171; }

/* Anillo de progreso */
.anillo {
  position: absolute; left: 50%; bottom: 4.6rem; transform: translateX(-50%);
  width: 74px; height: 74px; display: grid; place-items: center; pointer-events: none;
}
.anillo svg { position: absolute; inset: 0; transform: rotate(-90deg); }
.anillo circle { fill: none; stroke-width: 7; }
.anillo-base { stroke: rgba(255, 255, 255, .22); }
.anillo-valor {
  stroke: var(--acento-2); stroke-linecap: round;
  stroke-dasharray: 276.5; stroke-dashoffset: 276.5;
  transition: stroke-dashoffset .12s linear;
}
.anillo span {
  font-size: .85rem; font-weight: 700; font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 6px rgba(0, 0, 0, .8);
}
.anillo.completo .anillo-valor { stroke: #4ade80; }

.captura-pie {
  position: absolute; left: 0; right: 0; bottom: 0; padding: .8rem 1rem;
  text-align: center; font-size: .95rem; font-weight: 600;
  background: linear-gradient(transparent, rgba(6, 11, 22, .92) 45%);
  min-height: 3.4rem; padding-top: 1.6rem;
}

.captura-vacia {
  position: absolute; inset: 0; display: grid; place-items: center; gap: .6rem;
  align-content: center; color: var(--texto-2); font-size: .95rem; text-align: center;
  background: var(--fondo-2); padding: 1.5rem;
}
.captura-vacia .emoji { font-size: 2.4rem; }

.opciones-captura { margin-top: 1rem; text-align: center; }
.interruptor {
  display: inline-flex; align-items: center; gap: .55rem; cursor: pointer;
  font-size: .9rem; color: var(--texto-2);
}
.interruptor input { width: 1.15rem; height: 1.15rem; accent-color: var(--acento); cursor: pointer; }

/* --- pantalla 3: resultado ---------------------------------------------- */

.resultado-grande { text-align: center; padding: 1.5rem .5rem; }
.resultado-emoji { font-size: 4rem; line-height: 1; margin-bottom: .8rem; }
.resultado-titulo { font-size: 1.6rem; font-weight: 700; margin-bottom: .5rem; outline: none; }
.resultado-texto { font-size: 1.05rem; color: var(--texto-2); line-height: 1.6; }
.resultado-titulo.ok { color: #4ade80; }
.resultado-titulo.mal { color: #f87171; }
.resultado-texto strong { color: var(--texto); }

.resultado-datos {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: .7rem; margin-top: 1.5rem; text-align: left;
}
.resultado-datos > div {
  background: var(--panel); border: 1px solid var(--borde);
  border-radius: var(--radio-s); padding: .7rem .8rem;
}
.resultado-datos dt {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--texto-2);
}
.resultado-datos dd { font-size: 1.05rem; font-weight: 650; margin-top: .1rem; }

.acciones-resultado { display: grid; gap: .7rem; margin-top: 1.5rem; }
.acciones-resultado .boton { width: 100%; padding: 1.05rem; font-size: 1.05rem; min-height: 56px; }

.detalle-tecnico { margin-top: 1.5rem; }
.detalle-tecnico summary {
  cursor: pointer; font-size: .85rem; color: var(--texto-2);
  text-align: center; padding: .7rem; list-style: none;
}
.detalle-tecnico summary::-webkit-details-marker { display: none; }
.detalle-tecnico summary::after { content: " \25BE"; }
.detalle-tecnico pre {
  background: var(--fondo-2); border: 1px solid var(--borde); border-radius: var(--radio-s);
  padding: .9rem; font-size: .78rem; line-height: 1.55; overflow-x: auto;
  color: var(--texto-2); white-space: pre-wrap; word-break: break-word;
}

/* --- pie ---------------------------------------------------------------- */

.pie { text-align: center; margin-top: 2rem; font-size: .8rem; }
.pie a { color: var(--texto-2); }

/* --- responsive --------------------------------------------------------- */

@media (max-width: 480px) {
  .envoltorio { padding: 0 .8rem 2rem; }
  .boton.gigante { font-size: 1.15rem; padding: 1.2rem; min-height: 64px; }
  .instruccion-texto { font-size: 1.25rem; }
  .instruccion-flecha { font-size: 3.5rem; }
  .resultado-titulo { font-size: 1.35rem; }
  .resultado-emoji { font-size: 3.2rem; }
  .resultado-datos { grid-template-columns: repeat(2, 1fr); }
  .reloj strong { font-size: 1.3rem; }
}

/* Pantallas muy altas (kioscos verticales) */
@media (min-height: 900px) {
  .camara-marco { max-height: 72vh; }
}

/* Modo de alto contraste del sistema */
@media (prefers-contrast: more) {
  :root { --texto-3: #a9bcd8; --borde: #4a5c85; --texto-2: #cdd9ec; }
  .estado-tarjeta, .privacidad, .ayuda-cuerpo { border-width: 2px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
