/* ================================================================
   stylesQuiz.css  —  Módulo del Quiz Braille
   Complementa styles.css · Solo afecta a quiz.html
   ================================================================ */


/* ── Gestión de pantallas ────────────────────────────────────────
   Solo una pantalla visible a la vez                             */

.quiz-pantalla {
    display: none;   /* oculta por defecto — JS añade .activa a la correcta */
}

.quiz-pantalla.activa {
    display: block;
    animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}


/* ═══════════════════════════════════════════════════════════════
   PANTALLA DE INICIO
═══════════════════════════════════════════════════════════════ */

/* Sección de selección (modo / dificultad) */
.quiz-seccion {
    margin-bottom: 1.5rem;
}

.quiz-seccion-titulo {
    font-family: 'Courier New', monospace;
    font-size: 20px;
    font-weight: bold;
    color: #ffffff;
    letter-spacing: 1px;
    text-transform: uppercase;
    margin-bottom: 10px;
    display: block;
}

.quiz-seccion-btns {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

/* Botones de selección de modo y dificultad */
.btn-modo,
.btn-dif {
    padding: 9px 20px;
    font-family: 'Courier New', monospace;
    font-size: 16px;
    font-weight: bold;
    color: aliceblue;
    background: #2f2c2b;
    border: 2px solid #4a3728;
    border-radius: 6px;
    cursor: pointer;
    transition: border-color 0.2s, background-color 0.2s, color 0.2s;
}

.btn-modo:hover,
.btn-dif:hover {
    border-color: #fd8d32;
    color: #fd8d32;
}

.btn-modo.seleccionado,
.btn-dif.seleccionado {
    background: #fd8d32;
    border-color: #fd8d32;
    color: #ffffff;
}

/* Descripción dinámica de la dificultad elegida */
.quiz-dif-descripcion {
    font-family: 'Courier New', monospace;
    font-size: 18px;
    font-style: italic;
    color: #ffffff;
    line-height: 1.5;
    margin-top: 10px;
    margin-bottom: 0;
}

/* Botón de iniciar */
.btn-iniciar-juego {
    display: block;
    width: 100%;
    max-width: 280px;
    padding: 14px;
    margin: 2rem auto 0;
    font-family: 'Courier New', monospace;
    font-size: 20px;
    font-weight: bold;
    color: #ffffff;
    background: #2f2c2b;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
    letter-spacing: 1px;
}

.btn-iniciar-juego:hover  { background: #2f2c2b; border-color: #fd8d32; color: #fd8d32; }
.btn-iniciar-juego:active { transform: scale(0.97); }


/* ═══════════════════════════════════════════════════════════════
   PANTALLA DE JUEGO
═══════════════════════════════════════════════════════════════ */

/* ── HUD superior ────────────────────────────────────────────── */

.q-hud {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
    padding: 10px 14px;
    background: #2f2c2b;
    border-radius: 8px;
    margin-bottom: 12px;
}

.q-hud-item {
    font-family: 'Courier New', monospace;
    font-size: 18px;
    font-weight: bold;
    color: aliceblue;
    white-space: nowrap;
}

#q-puntaje { color: #fd8d32; }
#q-vidas   { font-size: 18px; letter-spacing: 1px; }

#q-racha {
    color: #fd8d32;
    font-size: 16px;
    opacity: 0;
    min-width: 5ch; 
    transition: opacity 0.3s, transform 0.3s;
}

/* Barra de progreso */
.q-progreso-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
}

.q-progreso-barra {
    flex: 1;
    height: 6px;
    background: #4a3728;
    border-radius: 99px;
    overflow: hidden;
}

.q-progreso-fill {
    height: 100%;
    width: 0%;
    background: #fd8d32;
    border-radius: 99px;
    transition: width 0.4s ease;
}

/* Modo "Infinito": no hay total que mostrar, así que la barra se
   muestra siempre llena con un degradado en movimiento — comunica
   "continúa sin fin" en vez de "vas por la mitad". */
.q-progreso-infinita .q-progreso-fill {
    background: linear-gradient(90deg, #fd8d32, #ffc98a, #fd8d32);
    background-size: 200% 100%;
    animation: flujo-infinito 1.8s linear infinite;
}

@keyframes flujo-infinito {
    0%   { background-position: 0% 0%; }
    100% { background-position: -200% 0%; }
}

#q-progreso-num {
    font-family: 'Courier New', monospace;
    font-size: 17px;
    color: #ffffff;
    white-space: nowrap;
    margin: 0;
}

/* ── Celda Braille ───────────────────────────────────────────── */

.q-celda-wrap {
    display: flex;
    justify-content: center;
    margin: 16px 0 10px;
}

/* Cuando la pregunta es un número, aquí caben dos celdas juntas:
   el signo generador (prefijo) + el dígito en sí, una al lado de
   la otra — sin etiquetas, solo para que el patrón se vuelva
   visualmente familiar con el uso repetido. */
#q-celda {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
}

#q-celda svg {
    filter: drop-shadow(0 4px 16px rgba(253, 141, 50, 0.25));
}

/* ── Feedback / instrucción ──────────────────────────────────── */

.q-feedback {
    font-family: 'Courier New', monospace;
    font-size: 20px;
    color: #ffffff;
    text-align: center;
    min-height: 28px;
    margin: 6px 0 24px;
    transition: color 0.2s;
}

.feedback-ok  { color: #ffffff; font-weight: bold; }
.feedback-err { color: #ffffff; font-weight: bold; }

/* ── Opciones de respuesta (grilla 2×2) ──────────────────────── */

.q-opciones {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 16px;

    overflow: hidden;
    contain: layout;
}

.q-opcion {
    padding: 18px 10px;
    font-family: 'Courier New', monospace;
    font-size: 22px;
    font-weight: bold;
    color: #ffffff;
    background: transparent;
    border: 2px solid #fd8d32;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.15s, color 0.15s, transform 0.1s;
    letter-spacing: 2px;

}

.q-opcion:hover:not([aria-disabled="true"]) {
    background: #fd8d32;
}

.q-opcion:active:not([aria-disabled="true"]) {
    transform: scale(0.97);
}

.q-opcion[aria-disabled="true"] {
    cursor: default;
    /* pointer-events: none bloquea los clics sin necesidad del atributo
       nativo "disabled". Esto evita que Chromium (Chrome, Edge, Opera,
       Vivaldi) quite el foco a la fuerza del botón recién presionado,
       que es lo que disparaba el "encogimiento" del layout en modo
       responsivo en esos navegadores. */
    pointer-events: none;
}

/* Estado: opción correcta */
.q-opcion.opcion-correcta {
    background: #fd8d32;
    border-color: #fd8d32;
    color: #2f2c2b;
    animation: pulso 0.35s ease;
}

/* Estado: opción incorrecta seleccionada */
.q-opcion.opcion-incorrecta {
    background: #c0392b;
    border-color: #c0392b;
    color: white;
    animation: temblor 0.4s ease;
}

/* Animaciones de feedback */
@keyframes pulso {
    0%   { transform: scale(1); }
    40%  { transform: scale(1.07); }
    100% { transform: scale(1); }
}

@keyframes temblor {
    0%, 100% { transform: translateX(0); }
    20%       { transform: translateX(-8px); }
    40%       { transform: translateX(8px); }
    60%       { transform: translateX(-5px); }
    80%       { transform: translateX(5px); }
}


/* ═══════════════════════════════════════════════════════════════
   PANTALLA DE RESULTADO
═══════════════════════════════════════════════════════════════ */

.res-header {
    text-align: center;
    margin-bottom: 2rem;
}

.res-emoji {
    font-size: 56px;
    display: block;
    margin-bottom: 8px;
    animation: rebote 0.6s ease;
}

@keyframes rebote {
    0%   { transform: scale(0); }
    60%  { transform: scale(1.15); }
    100% { transform: scale(1); }
}

.res-titulo {
    font-family: 'Courier New', monospace;
    font-size: 26px;
    font-weight: bold;
    color: #fd8d32;
    display: block;
    margin-bottom: 4px;
}

.res-mensaje {
    font-family: 'Courier New', monospace;
    font-size: 20px;
    color: #ffffff;
    display: block;
    font-weight: bold;
}

/* Tarjetas de estadísticas */
.res-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 1.5rem;
}

.res-stat {
    background: #2f2c2b;
    border-radius: 8px;
    padding: 10px 16px;
    text-align: center;
    border: .5px solid #4a3728;
}

.res-stat-valor {
    font-family: 'Courier New', monospace;
    font-size: 20px;
    font-weight: bold;
    color: #fd8d32;
    display: block;
    margin-bottom: 4px;
}

.res-stat-label {
    font-family: 'Courier New', monospace;
    font-size: 18px;
    color: #ffffff;
    display: block;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Barra de precisión */
.res-precision-wrap {
    margin-bottom: 2rem;
}

.res-precision-label {
    font-family: 'Courier New', monospace;
    font-size: 18px;
    color: #ffffff;
    display: flex;
    justify-content: space-between;
    margin-bottom: 6px;
}

.res-precision-barra {
    height: 8px;
    background: #4a3728;
    border-radius: 99px;
    overflow: hidden;
}

.res-precision-fill {
    height: 100%;
    width: 0%;
    background: #fd8d32;
    border-radius: 99px;
    transition: width 0.8s ease;
}

/* Botones de resultado */
.res-botones {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.btn-res-primario {
    flex: 1;
    padding: 12px;
    font-family: 'Courier New', monospace;
    font-size: 18px;
    font-weight: bold;
    color: #ffffff;
    background: transparent;
    border: 2px solid #fd8d32;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s;
    text-align: center;
}

.btn-res-primario:hover { background: #fd8d32; color: #ffffff;}

.btn-res-secundario {
    flex: 1;
    padding: 12px;
    font-family: 'Courier New', monospace;
    font-size: 18px;
    font-weight: bold;
    color: #ffffff;
    background: transparent;
    border: 2px solid #fd8d32;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s;
    text-align: center;
    text-decoration: none;
}

.btn-res-secundario:hover {background: #fd8d32;color: #ffffff;}

/* Estado mientras se genera la imagen para compartir (btn-compartir) */
.btn-res-primario:disabled,
.btn-res-secundario:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}
.btn-res-primario:disabled:hover,
.btn-res-secundario:disabled:hover {
    background: transparent;
    color: #ffffff;
}


/* Respeta la preferencia del sistema operativo de reducir movimiento.
   Desactiva todas las animaciones y transiciones del quiz para usuarios
   con epilepsia, vértigo, o cualquier condición sensible al movimiento.
   Es un requisito WCAG 2.1 criterio 2.3.3 (nivel AAA). */
@media (prefers-reduced-motion: reduce) {

    /* Elimina la animación de entrada de cada pantalla */
    .quiz-pantalla.activa {
        animation: none;
    }

    /* Elimina el feedback visual animado de los botones de respuesta */
    .q-opcion.opcion-correcta  { animation: none; }
    .q-opcion.opcion-incorrecta { animation: none; }

    /* Elimina el rebote del emoji de resultado */
    .res-emoji { animation: none; }

    /* Barra de progreso en modo infinito: quita el degradado en
       movimiento, deja un color sólido */
    .q-progreso-infinita .q-progreso-fill { animation: none; }

    /* Convierte las transiciones suaves en cambios instantáneos */
    .q-opcion,
    .btn-modo,
    .btn-dif,
    .btn-iniciar-juego,
    .btn-res-primario,
    .btn-res-secundario,
    .q-progreso-fill,
    .res-precision-fill { transition: none; }

    /* El scale en :active sigue funcionando (es feedback de pulsación,
       no una animación decorativa), pero se hace instantáneo */
    .btn-iniciar-juego:active { transition: none; }
}

@media (max-width: 768px) {

    .quiz-pantalla {
        flex-direction: column;
    }

    /* Centra los botones de modo y dificultad en pantallas pequeñas */

    .quiz-seccion-btns {
        justify-content: center;
    }

    .q-hud {
        gap: 6px;
        padding: 8px 10px;
    }

    .q-hud-item { font-size: 13px; }
    #q-vidas    { font-size: 16px; }

    .q-opcion {
        font-size: 20px;
        padding: 14px 8px;
    }

    .res-stats {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .res-stat-valor { font-size: 22px; }

    .btn-res-primario,
    .btn-res-secundario {
        font-size: 14px;
        padding: 10px;
    }
    .quiz-dif-descripcion{
        font-size: 16px;
    }
}