/* =========================================================================
   Encuesta accesible · Aprendizaje de matemáticas
   Dirección de diseño: institucional moderno. Blanco + azul profundo +
   celeste como acento. Prioridad absoluta: legibilidad, contraste y foco
   visible. Regla de la paleta: el texto solo usa azul oscuro (#203d76) y
   gris azulado (#44546b); el celeste (#54c6cc) y el azul claro (#5a9ad5)
   son decorativos (bordes, fondos, barras) porque no contrastan para texto.
   ========================================================================= */

/* --- Fuentes -----------------------------------------------------------
   Fraunces (display, con carácter) para títulos; Atkinson Hyperlegible
   para el cuerpo: una tipografía diseñada por el Braille Institute para
   máxima legibilidad. Elección deliberada por accesibilidad. */
@import url('https://fonts.googleapis.com/css2?family=Atkinson+Hyperlegible:ital,wght@0,400;0,700;1,400&family=Fraunces:opsz,wght@9..144,500;9..144,600&display=swap');

:root {
  --paper:      #ffffff;
  --paper-2:    #eef4fb;   /* azul muy pálido para superficies secundarias */
  --ink:        #1d2433;   /* texto principal: contraste ~15:1 sobre blanco */
  --ink-soft:   #44546b;   /* gris azulado: ~7.9:1, apto para texto */
  --line:       #c9d8ec;
  --accent:     #203d76;   /* azul oscuro: acción principal, ~10.9:1 */
  --accent-ink: #16294f;
  --sky:        #5a9ad5;   /* azul claro: bordes, hovers, decoración */
  --gold:       #203d76;   /* realce de texto (núm. de pregunta, requerido) */
  --gold-soft:  #e3f6f7;   /* celeste pálido para selección */
  --cyan:       #54c6cc;   /* celeste: solo decorativo, nunca texto */
  --ok:         #2f6f4f;
  --focus:      #0a66c2;   /* anillo de foco muy visible */
  --radius:     14px;
  --maxw:       720px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: 'Atkinson Hyperlegible', system-ui, sans-serif;
  font-size: 19px;           /* base grande (> 18px) */
  line-height: 1.65;
  color: var(--ink);
  background-color: var(--paper);
  /* Textura sutil de papel, sin distraer */
  background-image:
    radial-gradient(circle at 15% 20%, rgba(84,198,204,0.06) 0, transparent 45%),
    radial-gradient(circle at 85% 80%, rgba(32,61,118,0.05) 0, transparent 45%);
  -webkit-font-smoothing: antialiased;
}

/* --- Saltar al contenido (para teclado / lectores) --- */
.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--ink);
  color: #fff;
  padding: 12px 18px;
  border-radius: 0 0 var(--radius) 0;
  z-index: 100;
  font-weight: 700;
}
.skip-link:focus { left: 0; }

/* --- Layout ------------------------------------------------------------ */
.wrap {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 32px 22px 96px;
}

.topbar {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 22px 22px 0;
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--ink-soft);
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.topbar .mark {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  background: var(--accent);
  color: #fff;
  border-radius: 9px;
  font-family: 'Fraunces', serif;
  font-weight: 600;
  font-size: 1.1rem;
}

/* --- Tipografía -------------------------------------------------------- */
h1, h2, h3 {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 600;
  line-height: 1.18;
  color: var(--ink);
  letter-spacing: -0.01em;
}
h1 { font-size: clamp(2rem, 6vw, 2.9rem); margin: 0.2em 0 0.3em; }
h2 { font-size: clamp(1.5rem, 4.5vw, 2rem); margin: 0 0 0.2em; }

.lead {
  font-size: 1.15rem;
  color: var(--ink-soft);
}

/* --- Barra de progreso ------------------------------------------------- */
.progress {
  margin: 8px 0 30px;
}
.progress__label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.95rem;
  color: var(--ink-soft);
  margin-bottom: 8px;
  font-weight: 700;
}
.progress__bar {
  height: 14px;
  background: var(--paper-2);
  border: 1.5px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
}
.progress__fill {
  height: 100%;
  background: linear-gradient(90deg, var(--cyan), var(--accent));
  border-radius: 999px;
  transition: width 0.35s ease;
}

/* --- Tarjeta de sección ------------------------------------------------ */
.eyebrow {
  display: inline-block;
  font-family: 'Atkinson Hyperlegible', sans-serif;
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 6px;
}
.section-intro {
  color: var(--ink-soft);
  font-size: 1.1rem;
  margin: 0 0 28px;
  padding-bottom: 24px;
  border-bottom: 2px solid var(--line);
}

/* --- Preguntas --------------------------------------------------------- */
.question {
  margin: 0 0 38px;
}
.question__title {
  font-size: 1.2rem;
  font-weight: 700;
  margin: 0 0 4px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.question__title .num {
  flex: 0 0 auto;
  color: var(--gold);
  font-family: 'Fraunces', serif;
}
.question__help {
  color: var(--ink-soft);
  font-size: 1rem;
  margin: 0 0 14px;
}
.req {
  color: var(--gold);
  font-weight: 700;
}

/* Botón "escuchar la pregunta" */
.speak-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 4px 0 14px;
  padding: 8px 14px;
  font-size: 0.95rem;
  font-weight: 700;
  font-family: inherit;
  color: var(--accent-ink);
  background: var(--paper-2);
  border: 2px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
}
.speak-btn:hover { background: #fff; border-color: var(--accent); }
.speak-btn[aria-pressed="true"] {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* Espacio reservado para futuro video en Lengua de Señas (oculto si no hay) */
.lsc-video {
  margin: 0 0 16px;
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  padding: 14px;
  color: var(--ink-soft);
  font-size: 0.95rem;
  display: none;            /* visible solo cuando exista una URL */
}

/* --- Campos de texto --------------------------------------------------- */
input[type="text"],
textarea {
  width: 100%;
  font-family: inherit;
  font-size: 1.05rem;
  color: var(--ink);
  background: #fff;
  border: 2px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
}
textarea { min-height: 130px; resize: vertical; }

input[type="text"]:hover,
textarea:hover { border-color: var(--sky); }

/* --- Tarjetas seleccionables (single / multiple) ----------------------- */
.options {
  display: grid;
  gap: 12px;
  margin: 4px 0 0;
  list-style: none;
  padding: 0;
}
.option {
  position: relative;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 18px;
  background: #fff;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.option:hover { border-color: var(--accent); }

/* Toda la tarjeta es clicable; la casilla real va oculta visualmente
   pero accesible para teclado y lectores. */
.option input {
  position: absolute;
  opacity: 0;
  width: 1px; height: 1px;
  margin: 0;
}
.option__box {
  flex: 0 0 auto;
  width: 28px; height: 28px;
  border: 2.5px solid var(--accent);
  background: #fff;
  display: grid;
  place-items: center;
  color: #fff;
}
/* Casilla cuadrada para múltiple, redonda para única */
.option--multiple .option__box { border-radius: 8px; }
.option--single   .option__box { border-radius: 50%; }

.option__box svg { width: 18px; height: 18px; opacity: 0; }

.option__text { font-size: 1.08rem; }

/* Estado seleccionado */
.option input:checked ~ .option__box {
  background: var(--accent);
}
.option input:checked ~ .option__box svg { opacity: 1; }
.option:has(input:checked) {
  border-color: var(--accent);
  background: var(--gold-soft);
  box-shadow: inset 0 0 0 1px var(--accent);
}

/* Foco visible MUY claro (teclado) */
.option input:focus-visible ~ .option__box {
  outline: 4px solid var(--focus);
  outline-offset: 3px;
}

/* Campo "Otra:" */
.other-field {
  margin-top: 12px;
}
.other-field label {
  display: block;
  font-weight: 700;
  margin-bottom: 6px;
  font-size: 1rem;
}

/* --- Foco global ------------------------------------------------------- */
a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
.speak-btn:focus-visible {
  outline: 4px solid var(--focus);
  outline-offset: 2px;
}

/* --- Botones de navegación -------------------------------------------- */
.nav {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-top: 40px;
  padding-top: 26px;
  border-top: 2px solid var(--line);
}
.btn {
  font-family: inherit;
  font-size: 1.1rem;
  font-weight: 700;
  border-radius: 999px;
  padding: 15px 30px;
  cursor: pointer;
  border: 2px solid transparent;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.btn--primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn--primary:hover { background: var(--accent-ink); border-color: var(--accent-ink); }
.btn--ghost {
  background: transparent;
  color: var(--accent-ink);
  border-color: var(--line);
}
.btn--ghost:hover { border-color: var(--accent); background: #fff; }
.btn--lg { font-size: 1.2rem; padding: 18px 38px; }
.nav .spacer { flex: 1; }

.saved-hint {
  font-size: 0.95rem;
  color: var(--ok);
  font-weight: 700;
  margin-left: auto;
}

/* --- Portada ----------------------------------------------------------- */
.hero {
  text-align: left;
}
.hero__card {
  background: #fff;
  border: 2px solid var(--line);
  border-radius: 20px;
  padding: 30px;
  margin: 30px 0;
}
.facts {
  display: grid;
  gap: 14px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.facts li {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}
.facts .dot {
  flex: 0 0 auto;
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--gold-soft);
  color: var(--gold);
  display: grid; place-items: center;
  font-weight: 700;
}

/* --- Gracias ----------------------------------------------------------- */
.thanks { text-align: center; padding-top: 30px; }
.thanks .big-check {
  width: 92px; height: 92px;
  margin: 0 auto 18px;
  border-radius: 50%;
  background: var(--ok);
  color: #fff;
  display: grid; place-items: center;
}

/* --- Accesibilidad: respeta "menos movimiento" ------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* --- Solo para lectores de pantalla ------------------------------------ */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* --- Móvil ------------------------------------------------------------- */
@media (max-width: 540px) {
  body { font-size: 18px; }
  .wrap { padding: 24px 16px 80px; }
  .nav { flex-wrap: wrap; }
  .btn { width: 100%; justify-content: center; }
  .nav .spacer { display: none; }
  .saved-hint { margin: 0 auto; }
}

/* --- Login / formularios en tarjeta ------------------------------------ */
.card-form {
  background: #fff;
  border: 2px solid var(--line);
  border-radius: 20px;
  padding: 28px;
  margin: 26px 0;
}
.field { margin-bottom: 22px; }
.field label {
  display: block;
  font-weight: 700;
  font-size: 1.1rem;
  margin-bottom: 8px;
}
.field input {
  width: 100%;
  font-family: inherit;
  font-size: 1.15rem;
  color: var(--ink);
  background: #fff;
  border: 2px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
}
.field input:hover { border-color: var(--sky); }
.field-help {
  margin: 8px 0 0;
  font-size: 0.98rem;
  color: var(--ink-soft);
}

/* --- Alertas ----------------------------------------------------------- */
.alert {
  background: #fdecec;
  border: 2px solid #e3a3a3;
  color: #8a1f1f;
  font-weight: 700;
  padding: 14px 18px;
  border-radius: 12px;
  margin: 4px 0 20px;
}

/* --- Panel de administración ------------------------------------------ */
.admin-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
}
.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin: 22px 0 26px;
}
.stat {
  background: #fff;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  text-align: center;
}
.stat--ok { border-color: #9cc7b0; background: #eef8f1; }
.stat--pending { border-color: var(--sky); background: var(--paper-2); }
.stat__num {
  display: block;
  font-family: 'Fraunces', serif;
  font-size: 2.4rem;
  font-weight: 600;
  line-height: 1;
}
.stat__label {
  display: block;
  margin-top: 6px;
  font-size: 0.95rem;
  color: var(--ink-soft);
  font-weight: 700;
}

.table-wrap { overflow-x: auto; margin-top: 22px; }
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 1rem;
  background: #fff;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.data-table th,
.data-table td {
  text-align: left;
  padding: 13px 16px;
  border-bottom: 1.5px solid var(--line);
}
.data-table th {
  background: var(--paper-2);
  font-size: 0.92rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.data-table tbody tr:last-child td { border-bottom: none; }

.badge {
  display: inline-block;
  font-weight: 700;
  font-size: 0.9rem;
  padding: 5px 12px;
  border-radius: 999px;
}
.badge--ok { background: #d7efdf; color: #1f6b41; }
.badge--pending { background: var(--gold-soft); color: var(--accent); }

@media (max-width: 540px) {
  .stats { grid-template-columns: 1fr; }
}
