/* ============================================================================
   Asambleas v2 · base.css
   Hoja única de accesibilidad. La cargan TODAS las páginas.

   Por qué estos valores (ver docs/01-vision-y-principios.md, regla 3):
   - Texto base 20 px en móvil / 18 px en escritorio: la persona que define el
     diseño tiene 70-80 años y ve regular de cerca.
   - Botones de 64 px de alto mínimo y ancho completo en móvil: se tocan con el
     pulgar sin apuntar.
   - Contraste AA como mínimo (AAA en lo que se lee al votar).
   - Foco visible y grueso: también se usa con teclado/lector.
   ============================================================================ */

:root {
  /* Tipografía heredada de la marca (Houzapp · Módulo de Asambleas) */
  --fuente: 'DM Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --fuente-titulo: 'DM Serif Display', Georgia, serif;

  /* Tamaños. Móvil primero; en escritorio se bajan un poco (ver @media). */
  --texto: 20px;
  --texto-chico: 17px;        /* nunca menos de 17 px para texto que se lee */
  --h1: 30px;
  --h2: 24px;
  --boton-alto: 64px;
  --boton-texto: 22px;
  --radio: 16px;
  --radio-chico: 10px;
  --gutter: 16px;
  --toque-min: 56px;           /* tamaño de toque mínimo para cualquier control */

  /* Paleta heredada (navy / dorado) */
  --navy: #1a237e;
  --navy2: #283593;
  --navy3: #3949ab;
  --indigo: #5c6bc0;
  --pale: #e8eaf6;
  --pale2: #f5f6ff;
  --gold: #ffd54f;
  --gold-oscuro: #c9a227;      /* dorado legible sobre blanco */
  --borde: #c5cae9;

  /* Colores de voto: contraste ≥ 4.5:1 con texto blanco encima */
  --si: #1e7b34;               /* verde */
  --si-fondo: #e6f4ea;
  --no: #c62828;               /* rojo */
  --no-fondo: #fdecea;
  --blanco-voto: #5f6368;      /* gris */
  --blanco-voto-fondo: #eeeeee;

  /* Estados */
  --ok: #1e7b34;
  --alerta: #b45309;
  --alerta-fondo: #fff4e5;
  --error: #c62828;
  --error-fondo: #fdecea;

  /* Superficies (tema claro) */
  --fondo: #ffffff;
  --fondo-suave: #f5f6ff;
  --tinta: #1e2a3a;
  --tinta-suave: #4a5568;
  --tarjeta: #ffffff;
  --sombra: 0 2px 12px rgba(26, 35, 126, .10);
  --escenario-fondo: #0d1117;

  --foco: 0 0 0 4px #ffffff, 0 0 0 8px var(--gold-oscuro);
}

/* Tema oscuro: automático según el sistema, o forzado con data-tema="oscuro"
   (pantalla.html lo fuerza porque un televisor con fondo blanco encandila). */
@media (prefers-color-scheme: dark) {
  :root:not([data-tema="claro"]) {
    --fondo: #0d1117;
    --fondo-suave: #161b22;
    --tinta: #f1f5f9;
    --tinta-suave: #c3cbd6;
    --tarjeta: #161b22;
    --borde: #30363d;
    --pale: #1f2a44;
    --pale2: #161b22;
    --sombra: 0 2px 12px rgba(0, 0, 0, .45);
    --si: #2e9e49;
    --si-fondo: #12301b;
    --no: #e53935;
    --no-fondo: #3a1414;
    --blanco-voto: #8a9099;
    --blanco-voto-fondo: #2a2f36;
    --alerta-fondo: #3a2a10;
    --error-fondo: #3a1414;
    --gold-oscuro: #ffd54f;
    --foco: 0 0 0 4px #0d1117, 0 0 0 8px var(--gold);
  }
}
:root[data-tema="oscuro"] {
  --fondo: #0d1117;
  --fondo-suave: #161b22;
  --tinta: #f1f5f9;
  --tinta-suave: #c3cbd6;
  --tarjeta: #161b22;
  --borde: #30363d;
  --pale: #1f2a44;
  --pale2: #161b22;
  --sombra: 0 2px 12px rgba(0, 0, 0, .45);
  --si: #2e9e49;
  --si-fondo: #12301b;
  --no: #e53935;
  --no-fondo: #3a1414;
  --blanco-voto: #8a9099;
  --blanco-voto-fondo: #2a2f36;
  --alerta-fondo: #3a2a10;
  --error-fondo: #3a1414;
  --gold-oscuro: #ffd54f;
  --foco: 0 0 0 4px #0d1117, 0 0 0 8px var(--gold);
}

/* Escritorio: un poco más chico porque la pantalla está más lejos de la cara
   que un celular pero el puntero es preciso. */
@media (min-width: 900px) {
  :root {
    --texto: 18px;
    --texto-chico: 16px;
    --h1: 32px;
    --boton-texto: 20px;
  }
}

/* ── Reset mínimo ──────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--fuente);
  font-size: var(--texto);
  line-height: 1.45;
  color: var(--tinta);
  background: var(--fondo);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;            /* nunca scroll horizontal */
}
img, video, svg { max-width: 100%; display: block; }
h1, h2, h3 { margin: 0 0 .5em; line-height: 1.2; }
h1 { font-family: var(--fuente-titulo); font-size: var(--h1); font-weight: 400; }
h2 { font-size: var(--h2); font-weight: 700; }
h3 { font-size: var(--texto); font-weight: 700; }
p { margin: 0 0 1em; }
a { color: var(--navy3); }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
.oculto, [hidden] { display: none !important; }
.visualmente-oculto {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* Foco visible y grueso en todo lo que se puede tocar */
:focus-visible { outline: none; box-shadow: var(--foco); border-radius: var(--radio-chico); }
/* Los títulos reciben foco por programa (para lectores de pantalla); sin anillo visual. */
h1:focus, h2:focus, h1:focus-visible, h2:focus-visible { box-shadow: none; outline: none; }

/* Movimiento: respetar la preferencia del sistema */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ── Marco de página del asistente ─────────────────────────────────────────── */
.pagina {
  max-width: 560px;
  margin: 0 auto;
  padding: 0 var(--gutter) calc(var(--gutter) * 2);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}
.pagina > main { flex: 1; display: flex; flex-direction: column; gap: 20px; }
/* Páginas de pasos (index, prueba): cada sección llena la altura para que la
   botonera quede abajo, al alcance del pulgar. */
.pagina-pasos > main > section:not([hidden]) { display: flex; flex-direction: column; flex: 1; }
.pagina-pasos > main > section > h1 { margin-bottom: 12px; }
/* Botonera que queda al alcance del pulgar (abajo) */
.botonera-abajo {
  margin-top: auto;
  display: flex; flex-direction: column; gap: 14px;
  padding-top: 20px;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

/* Marca */
.marca {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 0;
  color: var(--tinta-suave);
  font-size: var(--texto-chico);
}
.marca strong { font-family: var(--fuente-titulo); font-weight: 400; font-size: 20px; color: var(--tinta); }
.marca .punto { width: 10px; height: 10px; border-radius: 50%; background: var(--gold); }

/* ── Botones ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: var(--boton-alto);
  width: 100%;
  padding: 12px 20px;
  border: 2px solid transparent;
  border-radius: var(--radio);
  background: var(--navy);
  color: #fff;
  font-size: var(--boton-texto);
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  transition: transform .08s ease, filter .15s ease;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: scale(.985); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; filter: none; }
.btn-enorme { min-height: 84px; font-size: 26px; border-radius: 20px; }
.btn-secundario { background: var(--tarjeta); color: var(--navy); border-color: var(--navy3); }
:root[data-tema="oscuro"] .btn-secundario,
.btn-secundario.oscuro { color: #fff; border-color: #fff; background: transparent; }
@media (prefers-color-scheme: dark) {
  :root:not([data-tema="claro"]) .btn-secundario { color: #fff; border-color: #c3cbd6; }
}
.btn-ayuda { background: var(--gold); color: #1e2a3a; }
.btn-peligro { background: var(--no); }
.btn-chico { min-height: var(--toque-min); width: auto; font-size: var(--texto-chico); padding: 8px 18px; font-weight: 600; }
.btn-enlace {
  background: none; border: none; color: var(--navy3); text-decoration: underline;
  min-height: var(--toque-min); width: auto; padding: 8px; font-weight: 600; font-size: var(--texto-chico);
}
.btn-si { background: var(--si); color: #fff; }
.btn-no { background: var(--no); color: #fff; }
.btn-blanco { background: var(--blanco-voto); color: #fff; }
.btn-opcion {
  background: var(--tarjeta); color: var(--tinta); border: 3px solid var(--borde);
  justify-content: flex-start; text-align: left; font-weight: 600;
}
.btn-opcion[aria-pressed="true"], .btn-opcion.elegida {
  border-color: var(--navy3); background: var(--pale); color: var(--navy);
}
:root[data-tema="oscuro"] .btn-opcion[aria-pressed="true"] { color: #fff; }
.btn .icono { font-size: 1.25em; line-height: 1; }
.btn-fila { display: flex; gap: 12px; }
.btn-fila > .btn { flex: 1; }

/* ── Tarjetas y bandas ─────────────────────────────────────────────────────── */
.tarjeta {
  background: var(--tarjeta);
  border: 1.5px solid var(--borde);
  border-radius: var(--radio);
  box-shadow: var(--sombra);
  padding: 20px;
}
.tarjeta-error { border-color: var(--error); background: var(--error-fondo); }
.tarjeta-alerta { border-color: var(--alerta); background: var(--alerta-fondo); }
.tarjeta-ok { border-color: var(--si); background: var(--si-fondo); }
.tarjeta h2 { margin-top: 0; }
.tarjeta .grande { font-size: var(--h1); font-weight: 700; line-height: 1.15; }

.banda {
  position: fixed; left: 0; right: 0; top: 0; z-index: 60;
  padding: 12px var(--gutter);
  background: var(--alerta); color: #fff;
  font-weight: 700; text-align: center;
  display: flex; align-items: center; justify-content: center; gap: 10px;
}
.banda-info { background: var(--navy3); }
.banda .girando { width: 18px; height: 18px; border: 3px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: girar 1s linear infinite; }
@keyframes girar { to { transform: rotate(360deg); } }

/* ── Overlays (una sola cosa por pantalla) ─────────────────────────────────── */
.overlay {
  position: fixed; inset: 0; z-index: 50;
  background: var(--fondo);
  color: var(--tinta);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex; flex-direction: column;
}
.overlay-contenido {
  flex: 1; display: flex; flex-direction: column; gap: 18px;
  width: 100%; max-width: 560px; margin: 0 auto;
  padding: 24px var(--gutter) calc(var(--gutter) + env(safe-area-inset-bottom, 0));
}
.overlay-contenido .botonera-abajo { margin-top: auto; }
.overlay-titulo { font-size: var(--h1); font-weight: 700; line-height: 1.2; margin: 0; }
.overlay-texto { font-size: var(--texto); color: var(--tinta-suave); margin: 0; }
.overlay-destacado { font-size: 34px; font-weight: 800; line-height: 1.15; }

/* Hoja inferior (ayuda) */
.hoja {
  position: fixed; inset: 0; z-index: 70;
  background: rgba(0,0,0,.55);
  display: flex; align-items: flex-end; justify-content: center;
}
.hoja-panel {
  width: 100%; max-width: 560px;
  background: var(--tarjeta); color: var(--tinta);
  border-radius: 24px 24px 0 0;
  padding: 20px var(--gutter) calc(20px + env(safe-area-inset-bottom, 0));
  display: flex; flex-direction: column; gap: 12px;
  max-height: 92vh; overflow-y: auto;
}

/* ── Quórum ────────────────────────────────────────────────────────────────── */
.quorum {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  font-weight: 700;
}
.quorum .pct { font-size: 26px; }
.quorum .marca-ok { color: var(--si); font-size: 26px; }
.quorum .barra { flex-basis: 100%; height: 14px; background: var(--pale); border-radius: 7px; overflow: hidden; }
.quorum .barra > span { display: block; height: 100%; background: var(--si); border-radius: 7px; transition: width .6s ease; }
.quorum .barra > span.falta { background: var(--alerta); }

/* ── Medidor de volumen ────────────────────────────────────────────────────── */
.medidor {
  height: 28px; background: var(--pale); border-radius: 14px; overflow: hidden;
  border: 2px solid var(--borde);
}
.medidor > span { display: block; height: 100%; width: 0; background: var(--si); border-radius: 14px; transition: width .08s linear; }

/* ── Teclado numérico grande (3 × 4) ──────────────────────────────────────── */
.teclado {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px;
}
.teclado button {
  min-height: 72px; font-size: 30px; font-weight: 700;
  border: 2px solid var(--borde); border-radius: var(--radio);
  background: var(--tarjeta); color: var(--tinta);
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.teclado button:active { background: var(--pale); }
.teclado button.tecla-accion { font-size: 20px; background: var(--pale2); }
.digitos {
  display: flex; gap: 10px; justify-content: center; margin: 8px 0 16px;
}
.digitos span {
  flex: 1; max-width: 64px; height: 72px;
  display: flex; align-items: center; justify-content: center;
  font-size: 34px; font-weight: 700;
  border: 2px solid var(--borde); border-radius: var(--radio-chico);
  background: var(--tarjeta);
}
.digitos span.lleno { border-color: var(--navy3); }
.digitos.largo span { font-size: 26px; height: 64px; max-width: 48px; }
.campo-visible {
  width: 100%; min-height: 64px; font-size: 28px; font-weight: 700; letter-spacing: 2px;
  text-align: center; border: 2px solid var(--borde); border-radius: var(--radio);
  padding: 8px 14px; background: var(--tarjeta); color: var(--tinta);
}

/* ── Escenario (video único) ───────────────────────────────────────────────── */
.escenario {
  position: relative; width: 100%; aspect-ratio: 16 / 9;
  background: var(--escenario-fondo); border-radius: var(--radio); overflow: hidden;
}
.escenario video { width: 100%; height: 100%; object-fit: contain; background: var(--escenario-fondo); }
.escenario .sin-video {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: #c3cbd6; font-size: var(--texto); text-align: center; padding: 16px;
}
.hablante { font-size: 24px; font-weight: 700; margin-top: 10px; min-height: 1.2em; }
.hablante small { display: block; font-size: var(--texto-chico); font-weight: 500; color: var(--tinta-suave); }

/* ── Campos de formulario sencillos ────────────────────────────────────────── */
.campo { display: flex; flex-direction: column; gap: 6px; }
.campo label { font-weight: 700; }
.campo input, .campo textarea, .campo select {
  min-height: var(--toque-min); padding: 10px 14px;
  border: 2px solid var(--borde); border-radius: var(--radio-chico);
  background: var(--tarjeta); color: var(--tinta); width: 100%;
}
.campo textarea { min-height: 140px; resize: vertical; }
.textarea-grande { min-height: 180px; font-size: var(--texto); }

/* ── Listas de etiquetas (inmuebles) ───────────────────────────────────────── */
.etiquetas { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.etiquetas span {
  background: var(--pale); color: var(--navy); border-radius: 999px; padding: 8px 16px;
  font-weight: 700; font-size: var(--texto-chico);
}
:root[data-tema="oscuro"] .etiquetas span { color: #fff; }
@media (prefers-color-scheme: dark) { :root:not([data-tema="claro"]) .etiquetas span { color: #fff; } }

/* ── Resultado de votación ─────────────────────────────────────────────────── */
.resultado-barras { display: flex; flex-direction: column; gap: 10px; }
.resultado-fila { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; align-items: center; }
.resultado-fila .nombre { font-weight: 700; }
.resultado-fila .valor { font-weight: 800; font-variant-numeric: tabular-nums; }
.resultado-fila .barra { grid-column: 1 / -1; height: 18px; background: var(--pale); border-radius: 9px; overflow: hidden; }
.resultado-fila .barra > span { display: block; height: 100%; background: var(--navy3); border-radius: 9px; transition: width .5s ease; }
.resultado-fila.si .barra > span { background: var(--si); }
.resultado-fila.no .barra > span { background: var(--no); }
.resultado-fila.blanco .barra > span { background: var(--blanco-voto); }
.veredicto { font-size: 30px; font-weight: 800; text-align: center; padding: 10px 0; }
.veredicto.aprobada { color: var(--si); }
.veredicto.no-aprobada { color: var(--no); }

/* Cuenta regresiva */
.cuenta { font-size: 72px; font-weight: 800; text-align: center; font-variant-numeric: tabular-nums; line-height: 1; }

/* Toast / mensaje breve */
.aviso {
  position: fixed; left: var(--gutter); right: var(--gutter); bottom: calc(20px + env(safe-area-inset-bottom, 0));
  z-index: 80; background: var(--tinta); color: var(--fondo);
  padding: 16px 20px; border-radius: var(--radio); font-weight: 700; text-align: center;
  box-shadow: 0 6px 24px rgba(0,0,0,.3);
}
.texto-suave { color: var(--tinta-suave); }
.centrado { text-align: center; }
.sep { height: 1px; background: var(--borde); margin: 8px 0; }
