/* Cáscara compartida por ExamTakingPage y SimulacroTakingPage: el CSS scoped de Blazor solo
   alcanza al dueño del archivo, así que vive aquí bajo :where(.exam-taking-content) (especificidad
   cero) para que cualquier regla scoped de cada página gane sin pelear. */

/* Altura relativa, no 100dvh: `article.content` ya mide 100dvh dentro de un marco que vale
   100dvh MENOS los safe-area insets, así que fijar 100dvh aquí desbordaba y salían dos scrolls. */
.exam-taking-content {
    position: relative;
    height: 100%;
    display: flex;
    align-items: center;
    flex-direction: column;
    flex-wrap: nowrap;
    justify-content: center;
}

:where(.exam-taking-content) .loading-exam-container {
    display: flex;
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: center;
    text-align: center;
}

:where(.exam-taking-content) .exam-title-text {
    margin-bottom: 10px;
    font-weight: bold;
    text-align: center;
    font-size: 1.5rem;
}

/* Titulo + boton de ayuda en la misma fila. */
:where(.exam-taking-content) .exam-title-text:has(.how-to-play-wrapper) {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

/* Es el contenedor quien scrollea; antes el tope de 400px vivía en la tarjeta, así que
   el contenido más largo (el del simulacro) se salía de su propia caja. */
:where(.exam-taking-content) .exam-intro-cards-container {
    display: flex;
    flex-direction: column;
    flex-wrap: nowrap;
    gap: 10px;
    align-items: center;
    max-height: 100%;
    overflow-y: auto;
    padding: 2rem 0;
}

:where(.exam-taking-content) .exam-intro-card {
    border-radius: var(--app-border-radius-lg);
    padding: 20px;
    max-width: 560px;
    width: calc(100% - 20px);
    display: flex;
    flex-direction: column;
    align-items: stretch;
    flex-wrap: nowrap;
    background: var(--mud-palette-surface);
    border: var(--app-border);
    box-shadow: var(--app-box-shadow-sm);
    animation: scaleIn 0.4s ease-out;
}

:where(.exam-taking-content) .exam-intro-header {
    border-bottom: 1px dashed var(--mud-palette-divider);
}

:where(.exam-taking-content) .exam-metadata-container {
    display: flex;
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: center;
    font-style: italic;
    padding-bottom: 5px;
}

:where(.exam-taking-content) .exam-intro-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 10px;
    margin: 20px 0px;
}

:where(.exam-taking-content) .exam-question-page {
    width: 100%;
    height: 100%;
    padding: 10px;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    scrollbar-gutter: stable both-edges;
}

/* ── Pantalla de resultados ──────────────────────────────────── */
/* Deliberadamente NO usa .exam-intro-card (max-width: 560px, padding
   ajustado): la pantalla de resultados necesita respirar, no vivir
   metida en la misma cajita angosta que la bienvenida. Compartida por
   SimulacroTecTakingPage y ExamenEspecialPage. */

:where(.exam-taking-content) .resultados-container {
    display: flex;
    flex-direction: column;
    gap: 28px;
    width: 100%;
    max-width: 780px;
    margin: 0 auto;
    padding: 32px 16px;
    max-height: 100%;
    overflow-y: auto;
}

/* ExamenEspecialPage incrusta ExamResultsPage (cuyo .results-container pide
   height:100% + scroll propio) junto a acciones hermanas: sin esto el 100%
   no se reparte y salen dos scrolls anidados. La cáscara absorbe el alto y
   deja UN solo scroll en el wrapper. */
:where(.exam-taking-content) .resultados-especiales {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: safe center;
}
:where(.exam-taking-content) .resultados-especiales > .results-container {
    height: auto;
    min-height: 0;
    max-height: none;
    overflow: visible;
    flex-shrink: 0;
    width: 100%;
}
:where(.exam-taking-content) .resultados-especiales > .resultados-acciones {
    flex-shrink: 0;
    width: 100%;
    max-width: 500px;
    justify-content: center;
    padding-bottom: 16px;
}

:where(.exam-taking-content) .resultados-hero {
    display: flex;
    align-items: center;
    gap: 28px;
    flex-wrap: wrap;
    justify-content: center;
    text-align: left;
}

:where(.exam-taking-content) .resultados-anillo {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 128px;
    height: 128px;
    border-radius: 50%;
    background: conic-gradient(var(--mud-palette-success) calc(var(--pct, 0) * 1%),
                               var(--mud-palette-lines-default) 0);
}

:where(.exam-taking-content) .resultados-anillo::before {
    content: "";
    position: absolute;
    inset: 10px;
    border-radius: 50%;
    background-color: var(--mud-palette-surface);
}

:where(.exam-taking-content) .resultados-anillo-valor {
    position: relative;
    font-size: 2.2rem;
    font-weight: 800;
    line-height: 1;
    color: var(--mud-palette-text-primary);
}

:where(.exam-taking-content) .resultados-anillo-valor small {
    font-size: 1rem;
    font-weight: 600;
}

:where(.exam-taking-content) .resultados-hero-texto {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 220px;
}

:where(.exam-taking-content) .resultados-titulo {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--mud-palette-text-primary);
}

:where(.exam-taking-content) .resultados-subtitulo {
    font-size: 0.95rem;
    color: var(--mud-palette-text-secondary);
}

:where(.exam-taking-content) .resultados-datos-clave {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 10px;
}

:where(.exam-taking-content) .resultados-dato {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95rem;
    color: var(--mud-palette-text-primary);
}

:where(.exam-taking-content) .resultados-seccion {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

:where(.exam-taking-content) .resultados-seccion-titulo {
    font-size: 1rem;
    font-weight: 700;
    color: var(--mud-palette-text-primary);
}

:where(.exam-taking-content) .resultados-desglose {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

:where(.exam-taking-content) .resultados-materia {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

:where(.exam-taking-content) .resultados-materia-encabezado {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
}

:where(.exam-taking-content) .resultados-materia-nombre {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--mud-palette-text-primary);
}

:where(.exam-taking-content) .resultados-materia-fraccion {
    font-size: 0.85rem;
    color: var(--mud-palette-text-secondary);
}

:where(.exam-taking-content) .resultados-materia-barra {
    height: 8px;
    width: 100%;
    border-radius: 4px;
    background: var(--mud-palette-divider);
    overflow: hidden;
}

:where(.exam-taking-content) .resultados-materia-barra-fill {
    height: 100%;
    width: 100%;
    transform: scaleX(calc(var(--pct, 0) / 100));
    transform-origin: left center;
    background: var(--mud-palette-primary);
    transition: transform 0.6s ease-out;
}

:where(.exam-taking-content) .resultados-acciones {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    padding-top: 8px;
    border-top: var(--app-border);
}

@media (max-width: 480px) {
    :where(.exam-taking-content) .resultados-hero {
        justify-content: center;
        text-align: center;
    }

    :where(.exam-taking-content) .resultados-hero-texto {
        align-items: center;
    }

    :where(.exam-taking-content) .resultados-datos-clave {
        align-items: center;
    }

    :where(.exam-taking-content) .resultados-acciones {
        flex-direction: column;
    }

    :where(.exam-taking-content) .resultados-acciones .mud-button-root {
        width: 100%;
    }
}

:where(.exam-taking-content) .exam-taking-page-header {
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;

    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    background: color-mix(in srgb, var(--mud-palette-background) 85%, transparent);
    border-radius: var(--app-border-radius-lg);

    z-index: 3;
}

:where(.exam-taking-content) .progress-bar-container {
    height: 20px;
    width: 100%;
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: flex-end;
}

/* Los estados van por token: en claro, el `white` y el `grey` de antes
   dejaban la barra invisible sobre el fondo de la página. */
:where(.exam-taking-content) .progress-bar-item {
    flex-grow: 1;
    background-color: color-mix(in srgb, var(--mud-palette-text-primary) 20%, transparent);
    height: 3px;
    margin: 0px 5px;
    border-radius: var(--app-border-radius);
    transition: all 0.3s ease;
}

:where(.exam-taking-content) .progress-bar-item.progress {
    background-color: var(--mud-palette-primary);
    height: 6px;
    animation: pulse 1.5s ease-in-out infinite;
}

:where(.exam-taking-content) .progress-bar-item.completed {
    background-color: var(--mud-palette-text-secondary);
}

:where(.exam-taking-content) .progress-bar-item.correct {
    background-color: var(--mud-palette-success);
}

:where(.exam-taking-content) .progress-bar-item.incorrect {
    background-color: var(--mud-palette-error);
}

:where(.exam-taking-content) .exam-page-navigation-container {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: space-evenly;
}

:where(.exam-taking-content) .exam-question-content {
    margin: auto 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 5px;
}

/* El encabezado (materia + metadatos) es una banda propia: se separa del
   bloque pregunta/hoja con un filete y aire, no queda pegado a la tarjeta. */
:where(.exam-taking-content) .exam-question-heading {
    width: 100%;
    max-width: 900px;
    margin-bottom: 28px;
    padding-bottom: 14px;
    border-bottom: 1px dashed var(--mud-palette-divider);
}

/* El margen del título sobra aquí: el aire lo pone la banda. */
:where(.exam-taking-content) .exam-question-heading .exam-title-text {
    margin-bottom: 0;
}

:where(.exam-taking-content) .question-container {
    max-width: 500px;
    width: calc(100% - 20px);
    border-radius: var(--app-border-radius-lg);
    display: flex;
    flex-direction: column;
    flex-wrap: nowrap;
    padding: 10px;
    animation: slideUp 0.25s ease-out;
    background-color: var(--mud-palette-background);
    position: relative;
    z-index: 2;
}

:where(.exam-taking-content) .question {
    text-align: center;
    font-size: 1.1rem;
    margin-top: auto;
    margin-bottom: 30px;
}

:where(.exam-taking-content) .pts-display {
    text-align: right;
    padding: 10px 10px 0px 0px;
    animation: fadeIn 0.5s ease-in;
}

:where(.exam-taking-content) .question-figure {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
    padding: 0 1rem;
}

/* .question-figure-trigger es el botón nativo que envuelve la figura; se resetea
   a look transparente pa no verse como botón, solo cambia el cursor. */
:where(.exam-taking-content) .question-figure-trigger {
    background: none;
    border: none;
    padding: 0 1rem;
    margin: 0;
    cursor: zoom-in;
    font: inherit;
    color: inherit;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
}

/* Pista de zoom: sin ella la única señal de que la figura se amplía es el
   cursor, que en táctil no existe. */
:where(.exam-taking-content) .question-figure-hint {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.15rem 0.6rem;
    border-radius: 999px;
    border: 1px solid var(--mud-palette-divider);
    background: var(--mud-palette-background-grey);
    color: var(--mud-palette-text-secondary);
    font-size: 0.75rem;
    line-height: 1.6;
    transition: color 0.15s ease, border-color 0.15s ease;
}

:where(.exam-taking-content) .question-figure-hint .mud-icon-root {
    font-size: 0.95rem;
}

:where(.exam-taking-content) .question-figure-trigger:hover .question-figure-hint,
:where(.exam-taking-content) .question-figure-trigger:focus-visible .question-figure-hint {
    color: var(--mud-palette-primary);
    border-color: var(--mud-palette-primary);
}

:where(.exam-taking-content) .question-figure-trigger:focus-visible {
    outline: 2px solid var(--mud-palette-primary);
    outline-offset: 4px;
    border-radius: var(--app-border-radius-sm);
}

:where(.exam-taking-content) .question-figure-img {
    max-width: 100%;
    max-height: 320px;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: var(--app-border-radius-sm);
    border: 1px solid var(--mud-palette-divider);
    background: var(--mud-palette-surface);
    padding: 0.5rem;
}

/* SVG inyectado (figura_svg): el SVG trae fondo blanco propio, así que
   el contenedor lo acompaña en vez de pelearse con él. */
:where(.exam-taking-content) .question-figure-svg {
    width: 100%;
    max-width: 360px;
    border-radius: var(--app-border-radius-sm);
    border: 1px solid var(--mud-palette-divider);
    background: #fff;
    padding: 0.5rem;
}

:where(.exam-taking-content) .question-figure-svg svg {
    display: block;
    max-width: 100%;
    height: auto;
    margin: 0 auto;
}

:where(.exam-taking-content) .item-container {
    display: flex;
    flex-wrap: wrap;
    flex-direction: row;
    justify-content: center;
    align-content: center;
    align-items: center;
    padding: 0 10px;
    margin-bottom: auto;
    gap: 10px;
}

:where(.exam-taking-content) .item-option {
    min-height: 44px;
    flex-basis: 40%;
    text-align: left;
    cursor: pointer;
    transition: background-color 0.2s ease-out, color 0.2s ease-out, transform 0.2s ease-out;
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: center;
    gap: 5px;
    position: relative;
    overflow-wrap: anywhere;
}

/* El texto de la opción ya no es un nodo suelto sino un elemento flex: sin min-width
   se niega a encogerse y las opciones largas desbordan la tarjeta. */
:where(.exam-taking-content) .option-text {
    min-width: 0;
}

@media (hover: hover) {
    :where(.exam-taking-content) .item-option:hover .option-letter {
        transform: translateY(-2px);
        background-color: var(--mud-palette-action-default-hover);
    }
}

:where(.exam-taking-content) .item-option.selected .option-selected {
    opacity: 1;
}

:where(.exam-taking-content) .option-selected {
    position: absolute;
    color: var(--mud-palette-text-primary);
    transform: translate(-5px, -35px);
    font-size: 2rem;
    font-style: italic;
    font-weight: 900;
    opacity: 0;
    transition: opacity 0.3s ease;
}

:where(.exam-taking-content) .item-option.correct {
    color: var(--mud-palette-success-lighten);
}

:where(.exam-taking-content) .item-option.correct .option-letter {
    background-color: var(--mud-palette-success);
    color: var(--mud-palette-black);
}

:where(.exam-taking-content) .item-option.correct .option-check {
    opacity: 1;
}

:where(.exam-taking-content) .item-option.incorrect {
    color: var(--mud-palette-error-darken);
}

:where(.exam-taking-content) .item-option.incorrect .option-letter {
    background-color: var(--mud-palette-error-darken);
    color: var(--mud-palette-black);
}

:where(.exam-taking-content) .item-option.incorrect .option-cross {
    opacity: 1;
}

:where(.exam-taking-content) .option-letter {
    border: 1px solid color-mix(in srgb, var(--mud-palette-text-primary) 45%, transparent);
    padding: 3px;
    border-radius: 100px;
    min-width: 30px;
    min-height: 30px;
    position: relative;
    transition: background-color 0.2s ease-out, transform 0.2s ease-out, border-color 0.2s ease-out;
    max-height: 30px;
    max-width: 30px;
    align-content: center;
    text-align: center;
}

/* Hueco fijo al final de la opción donde se cruzan ✓ y ✗ al corregir; antes era absoluto
   en `top: -40px` y el glifo caía encima de la fila de arriba. */
:where(.exam-taking-content) .option-check-area {
    position: relative;
    width: 1.5rem;
    height: 1.5rem;
    flex-shrink: 0;
}

:where(.exam-taking-content) .option-check-area * {
    position: absolute;
    inset: 0;
    font-size: 1.5rem;
    line-height: 1;
    opacity: 0;
    transition: opacity 0.3s ease;
}

/* Caja propia bajo .question-container: sin margen negativo para no tapar
   la última fila de opciones en revisión (flex-basis 40% + iconos ✓/✗). */
:where(.exam-taking-content) .exam-explanation-container {
    max-width: 500px;
    width: calc(100% - 20px);
    border-radius: var(--app-border-radius-lg);
    border: 1px solid var(--mud-palette-divider);
    background-color: var(--mud-palette-background);
    display: flex;
    flex-direction: column;
    flex-wrap: nowrap;
    padding: 12px 10px;
    animation: slideUp 0.25s ease-out;
}

:where(.exam-taking-content) .exam-explanation-container p {
    margin: 0 !important;
}

:where(.exam-taking-content) .exam-explanation-text {
    text-align: center;
    font-style: italic;
    width: calc(100% - 40px);
    margin: 0px auto;
}

/* La píldora "Inicio" sigue `fixed` por encima del contenido; sin esta holgura tapaba el
   final de la pregunta y las opciones bajas. Solo por debajo de 951px, que es donde existe. */
@media (max-width: 950px) {

    :where(.exam-taking-content) .exam-intro-cards-container {
        padding-bottom: calc(2rem + var(--bottom-nav-compact-clearance));
    }

    :where(.exam-taking-content) .exam-question-page {
        padding-bottom: calc(10px + var(--bottom-nav-compact-clearance));
    }
}

/* Debajo de 1100px la hoja lateral no existe; en móvil se llega a ella por el botón del
   header (overlay). */

:where(.exam-taking-content) .exam-question-content-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    gap: 12px;
}

:where(.exam-taking-content) .exam-question-column {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    gap: 12px;
}

:where(.exam-taking-content) .exam-answer-sheet-desktop {
    display: none;
}

:where(.exam-taking-content) .answer-sheet-toggle {
    min-width: 0;
}

:where(.exam-taking-content) .answer-sheet-overlay {
    position: fixed;
    inset: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: color-mix(in srgb, var(--mud-palette-background) 70%, transparent);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

:where(.exam-taking-content) .answer-sheet-overlay-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    max-height: 100%;
    animation: scaleIn 0.3s ease-out;
}

/* El papel no puede crecer más que la pantalla: si lo hiciera, empujaría el botón "Cerrar"
   fuera del overlay. Los 200px descontados son el resto del overlay (padding, título, etc). */
:where(.exam-taking-content) .answer-sheet-overlay-inner .answer-sheet {
    --sheet-max-h: calc(100dvh - 200px);
}

/* z-index 30: por encima del answer-sheet-overlay (10) y del delivery overlay (20),
   ya que el lightbox puede abrirse mientras cualquiera de esos está visible. */
:where(.exam-taking-content) .figure-lightbox-overlay {
    position: fixed;
    inset: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: color-mix(in srgb, #000 80%, transparent);
    cursor: zoom-out;
}

:where(.exam-taking-content) .figure-lightbox-overlay:focus-visible {
    outline: none;
}

:where(.exam-taking-content) .figure-lightbox-inner {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    max-width: min(94vw, 900px);
    max-height: 94dvh;
    cursor: default;
    animation: scaleIn 0.2s ease-out;
}

:where(.exam-taking-content) .figure-lightbox-toolbar {
    display: flex;
    align-items: center;
    gap: 4px;
    background: color-mix(in srgb, #000 55%, transparent);
    border-radius: var(--app-border-radius-sm);
    padding: 4px 8px;
}

:where(.exam-taking-content) .figure-lightbox-zoom-btn,
:where(.exam-taking-content) .figure-lightbox-close {
    min-width: 0;
    color: #fff;
}

:where(.exam-taking-content) .figure-lightbox-close {
    margin-left: 8px;
}

:where(.exam-taking-content) .figure-lightbox-zoom-label {
    min-width: 3.5em;
    text-align: center;
    color: #fff;
    font-variant-numeric: tabular-nums;
    font-size: 0.9rem;
}

/* touch-action: none evita que el navegador interprete el pinch/scroll nativo
   y pelee con nuestro cálculo de zoom/pan basado en pointer events. */
:where(.exam-taking-content) .figure-lightbox-viewport {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: min(90vw, 900px);
    max-height: 80dvh;
    overflow: hidden;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}

:where(.exam-taking-content) .figure-lightbox-content {
    transform-origin: center center;
    transition: transform 0.08s linear;
    will-change: transform;
}

:where(.exam-taking-content) .figure-lightbox-img {
    display: block;
    max-width: min(90vw, 900px);
    max-height: 80dvh;
    object-fit: contain;
    border-radius: var(--app-border-radius-sm);
    background: var(--mud-palette-surface);
    padding: 0.5rem;
    pointer-events: none;
}

:where(.exam-taking-content) .figure-lightbox-svg {
    max-width: min(90vw, 900px);
    max-height: 80dvh;
    border-radius: var(--app-border-radius-sm);
    background: #fff;
    padding: 1rem;
    pointer-events: none;
}

:where(.exam-taking-content) .figure-lightbox-svg svg {
    display: block;
    max-width: 100%;
    height: auto;
    margin: 0 auto;
}

@media (min-width: 1100px) {
    /* En escritorio la hoja ya está a la vista; el botón sobra. */
    :where(.exam-taking-content) .answer-sheet-toggle {
        display: none;
    }

    :where(.exam-taking-content) .exam-question-content-container {
        flex-direction: row;
        align-items: flex-start;
        justify-content: center;
        gap: 24px;
    }

    /* El scroller pasa a ser esta columna, así la cabecera y la hoja quedan fijas.
       `position: sticky` no bastaba: su recorrido depende del bloque contenedor, y con pregunta corta es cero. */
    :where(.exam-taking-content) .exam-question-page {
        overflow-y: hidden;
    }

    /* El `margin: auto 0` centraba el bloque cuando la página scrolleaba; ahora scrollea
       la columna, así que el bloque llena la altura y el centrado lo hace cada columna por dentro. */
    :where(.exam-taking-content) .exam-question-content {
        margin: 0;
        flex: 1;
        min-height: 0;
        width: 100%;
    }

    /* Los `min-height: 0` son obligatorios en toda la cadena flex: sin
       ellos el mínimo automático de un ítem flex es su contenido, la
       columna nunca se considera desbordada y el scroll no aparece. */
    :where(.exam-taking-content) .exam-question-content-container {
        flex: 1;
        min-height: 0;
    }

    /* `safe center` y no `center` a secas: con centrado normal, el contenido que desborda
       se sale por arriba de la caja, fuera del alcance del scroll; `safe` degrada a flex-start. */
    :where(.exam-taking-content) .exam-question-column {
        flex: 0 1 520px;
        align-self: stretch;
        justify-content: safe center;
        min-height: 0;
        overflow-y: auto;
        scrollbar-gutter: stable;
    }

    /* Ya no necesita sticky: nada se mueve a su alrededor. El `order` la manda a la
       izquierda sin tocar el DOM, así la pregunta sigue siendo lo primero en móvil y lectores de pantalla. */
    :where(.exam-taking-content) .exam-answer-sheet-desktop {
        display: block;
        order: -1;
        align-self: stretch;
        flex: 0 0 auto;
        animation: slideUp 0.4s ease-out;
    }

    /* El papel ocupa todo el alto de la columna: si se quedara corto, la
       pregunta centrada de al lado arrancaría más abajo que la hoja. */
    :where(.exam-taking-content) .exam-answer-sheet-desktop .answer-sheet {
        height: 100%;
        display: flex;
        flex-direction: column;
    }

    :where(.exam-taking-content) .exam-answer-sheet-desktop .sheet-viewport {
        height: auto;
        flex: 1;
        min-height: 0;
        container-type: size;
    }

    /* La fila se estira para que quepan exactamente --visible-rows sin romper el translateY
       (en unidades de fila). Va en .sheet-rows y no .sheet-viewport: un elemento no es su propio contenedor de consulta. */
    :where(.exam-taking-content) .exam-answer-sheet-desktop .sheet-rows {
        --row-h: calc(100cqh / var(--visible-rows));
    }

    /* El hueco se conserva (`visibility`, no `display`): quitarla del flujo recolocaría la
       pregunta a mitad de la animación. La transición es más corta que la entrada del clon. */
    :where(.exam-taking-content) .exam-question-page.delivering .exam-answer-sheet-desktop {
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.2s ease-out, visibility 0s linear 0.2s;
    }
}

/* La red global de prefers-reduced-motion de app.css las detiene. */

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
        transform: scaleY(1);
    }

    50% {
        opacity: 0.7;
        transform: scaleY(1.5);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Overlay propio, no el de `.answer-sheet-overlay`: aquel es interactivo y se cierra al
   tocarlo; este es decorativo y se lo lleva el desmontaje del componente al pasar a resultados. */

:where(.exam-taking-content) .exam-delivery-overlay {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    pointer-events: none;
    background: color-mix(in srgb, var(--mud-palette-background) 70%, transparent);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    animation: fadeIn 0.25s ease-out both;
}

/* Una sola animación con paradas en porcentaje en vez de tres encadenadas con delay:
   encadenarlas hace que dos reglas peleen por `transform` y animationend dispare varias veces. */
:where(.exam-taking-content) .exam-delivery-sheet {
    animation: sheetDelivery 1.15s both;
}

:where(.exam-taking-content) .exam-delivery-sheet .answer-sheet {
    --sheet-max-h: calc(100dvh - 120px);
}

@keyframes sheetDelivery {
    /* Entra: llega descuadrada y se asienta. */
    0% {
        opacity: 0;
        transform: translateY(0) scale(0.92) rotate(-2deg);
        filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.25));
        animation-timing-function: cubic-bezier(0.16, 1, 0.3, 1);
    }

    /* Quieta y centrada: el momento de "aquí está mi examen". */
    30% {
        opacity: 1;
        transform: translateY(0) scale(1) rotate(0deg);
        filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.3));
        animation-timing-function: ease-out;
    }

    /* Se levanta: la sombra crece porque el papel se separa de la mesa. */
    61% {
        opacity: 1;
        transform: translateY(-14px) scale(1.02) rotate(0deg);
        filter: drop-shadow(0 26px 40px rgba(0, 0, 0, 0.45));
        animation-timing-function: cubic-bezier(0.55, 0, 1, 0.45);
    }

    /* Se va por arriba, acelerando. */
    100% {
        opacity: 0;
        transform: translateY(-125vh) scale(0.85) rotate(3deg);
        filter: drop-shadow(0 40px 60px rgba(0, 0, 0, 0));
    }
}
.exam-timer {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-left: 10px;
    font-variant-numeric: tabular-nums;
}

.exam-timer.expired {
    color: var(--mud-palette-error);
    font-weight: 600;
}
