/* ########################## Student answer views ########################## */
@keyframes qa-pop-in {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: none; }
}

@keyframes qa-bump {
    0% { transform: scale(.55); }
    60% { transform: scale(1.18); }
    100% { transform: scale(1); }
}

.qa-panel {
    display: grid;
    justify-items: center;
    gap: 1.35rem;
    width: min(92vw, 640px);
    padding: 2rem;
    border: 3px solid var(--dark);
    border-radius: var(--border-radius);
    background: var(--beige);
    box-shadow: 8px 8px 0 var(--dark);
    animation: qa-pop-in .25s ease;
}

.qa-timer {
    font-family: var(--ekwarg);
    font-size: 1.5rem;
    padding: .1rem 1rem;
    border: 3px solid var(--dark);
    border-radius: 999px;
    background: var(--teal);
    color: var(--beige);
    font-variant-numeric: tabular-nums;
    box-shadow: 3px 3px 0 var(--dark);
}

.qa-head {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    width: 100%;
}

.qa-head .qa-timer { grid-column: 2; }

.qa-dismiss {
    grid-column: 3;
    justify-self: end;
    display: grid; place-items: center;
    width: 1.9rem; height: 1.9rem;
    border: 3px solid var(--dark);
    border-radius: 6px;
    background: var(--beige);
    color: var(--dark);
    cursor: pointer;
    transition: background .12s ease, transform .08s ease;
}
.qa-dismiss:hover { background: var(--red); color: var(--beige); transform: translateY(-1px); }
.qa-dismiss:active { transform: translateY(1px); }

.qa-timer.warn { background: var(--orange); }
.qa-timer.danger { background: var(--red); animation: qa-bump .4s ease infinite; }

.qa-prompt {
    width: 100%;
    text-align: center;
    margin: 0;
    overflow-wrap: break-word;
}

.qa-body {
    display: grid;
    justify-items: center;
    gap: 1.25rem;
    width: 100%;
}

.qa-hint {
    margin: 0;
    font-size: .95rem;
    font-weight: 600;
    opacity: .7;
    text-align: center;
}

.qa-status {
    margin: 0;
    font-weight: bold;
    text-align: center;
    min-height: 1.2rem;
}

.qa-status.qa-recorded { color: var(--teal); animation: qa-bump .3s ease; }
.qa-status.qa-error { color: var(--red); }

/* The global .submitBtn already draws its own offset border via ::after; lean on that instead of
   stacking a second box-shadow (which produced a ghosted border on hover). Just lift/press it,
   and override the slow 1s gradient transition so the hover feels snappy. */
.qa-submit {
    width: auto;
    min-width: 13rem;
    text-align: center;
    /* Keep the lift snappy but let the fill/colour sweep at the app-standard 1s (matches every
       other .submitBtn) instead of the faster override used while iterating. */
    transition: transform .12s ease, background-position 1s ease-in-out, color 1s ease-in-out;
}

/* Response buttons only (not global .submitBtn): the button lifts up-left on hover while its
   ::after backdrop is counter-translated to hold its screen position, so the offset shadow
   deepens into a clean raise instead of the whole unit sliding. Pressing settles it back down. */
.qa-submit::after { transition: transform .12s ease; }
.qa-submit:hover:not(:disabled) { transform: translate(-2px, -2px); }
.qa-submit:hover:not(:disabled)::after { transform: translate(2px, 2px); }
.qa-submit:active:not(:disabled) { transform: translate(0, 0); }
.qa-submit:active:not(:disabled)::after { transform: translate(0, 0); }
.qa-submit:disabled { opacity: .5; cursor: not-allowed; }

/* ########## YesNo ########## */
.qa-yesno {
    display: flex;
    flex-wrap: wrap;
    gap: 1.75rem;
    justify-content: center;
}

.qa-yesno-btn {
    height: 11rem;
    width: 11rem;
    padding: .9rem;
    border-radius: var(--border-radius);
    border: 4px solid var(--dark);
    background: var(--beige);
    color: var(--dark);
    font-family: var(--ekwarg);
    font-size: 1.9rem;
    line-height: 1.15;
    overflow-wrap: break-word;
    text-wrap: balance;
    cursor: pointer;
    box-shadow: 7px 7px 0 var(--dark);
    transition: transform .08s ease, box-shadow .08s ease, background .15s ease, color .15s ease;
}

/* The display size suits a word; a full clause has to come down to stay readable. */
.qa-yesno-btn.qa-yesno-md { width: 13rem; font-size: 1.2rem; }
.qa-yesno-btn.qa-yesno-sm { width: 14rem; font-size: 1rem; }

.qa-yesno-btn:hover:not(:disabled) { transform: translate(-3px, -3px); box-shadow: 10px 10px 0 var(--qa-accent, var(--dark)); }
.qa-yesno-btn:active:not(:disabled) { transform: translate(4px, 4px); box-shadow: 3px 3px 0 var(--dark); }
.qa-yesno-btn.selected { background: var(--qa-accent, var(--teal)); color: var(--beige); }
.qa-yesno-btn:disabled { opacity: .5; cursor: not-allowed; box-shadow: 3px 3px 0 var(--dark); }

/* ########## Single / Multiple choice ########## */
.qa-options {
    display: grid;
    gap: .8rem;
    width: 100%;
    max-width: 30rem;
}

.qa-option {
    display: flex;
    align-items: center;
    gap: .9rem;
    padding: .75rem 1rem;
    border: 3px solid var(--dark);
    border-radius: var(--border-radius);
    background: var(--beige);
    cursor: pointer;
    font-size: 1.1rem;
    font-weight: 600;
    box-shadow: 4px 4px 0 var(--dark);
    transition: transform .08s ease, box-shadow .08s ease, background .15s ease, color .15s ease;
}

.qa-option:hover { transform: translate(-2px, -2px); box-shadow: 6px 6px 0 var(--dark); }
.qa-option:active { transform: translate(2px, 2px); box-shadow: 2px 2px 0 var(--dark); }
.qa-option input { display: none; }

.qa-badge {
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    width: 2.1rem;
    height: 2.1rem;
    border-radius: 8px;
    border: 2px solid var(--dark);
    background: var(--qa-accent, var(--teal));
    color: var(--beige);
    font-family: var(--ekwarg);
    font-size: 1.15rem;
}

.qa-option-text { flex: 1; }

.qa-option.selected {
    background: var(--qa-accent, var(--teal));
    color: var(--beige);
}

.qa-option.selected .qa-badge { background: var(--beige); color: var(--dark); }
.qa-option:has(input:disabled) { opacity: .45; box-shadow: 2px 2px 0 var(--dark); pointer-events: none; }

/* ########## Free text ########## */
.qa-textarea {
    width: 100%;
    max-width: 34rem;
    min-height: 8rem;
    resize: vertical;
    border: 3px solid var(--dark);
    border-radius: var(--border-radius);
    background: var(--beige);
    color: var(--dark);
    font-family: var(--ekwarg);
    font-size: 1.05rem;
    padding: var(--padding-box);
    outline: none;
    box-shadow: 4px 4px 0 var(--dark);
    transition: box-shadow .1s ease, border-color .15s ease;
}

.qa-textarea:focus { border-color: var(--teal); box-shadow: 4px 4px 0 var(--teal); }
.qa-textarea:disabled { opacity: .6; }

.qa-textrow {
    display: flex;
    align-items: center;
    gap: 1rem;
    width: 100%;
    max-width: 34rem;
    justify-content: space-between;
}

/* Never shrinks: squeezed narrow it breaks "0 / 200" over two lines. */
.qa-counter {
    flex: 0 0 auto;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
    font-size: .9rem;
    font-weight: 600;
    opacity: .7;
}

/* ########## Scale ########## */
.qa-scale {
    display: grid;
    gap: 1rem;
    justify-items: center;
    width: 100%;
    max-width: 30rem;
}

.qa-scale-value {
    display: grid;
    place-items: center;
    min-width: 3.25rem;
    min-height: 3.25rem;
    padding: 0 .5rem;
    border: 3px solid var(--dark);
    border-radius: 50%;
    background: var(--teal);
    color: var(--beige);
    font-family: var(--ekwarg);
    font-size: 1.9rem;
    box-shadow: 3px 3px 0 var(--dark);
    animation: qa-bump .18s ease;
}

/* ########## Numeric ########## */
.qa-numeric {
    display: flex;
    align-items: center;
    gap: .6rem;
}

.qa-number-input {
    width: 11rem;
    border: 3px solid var(--dark);
    border-radius: var(--border-radius);
    background: var(--beige);
    color: var(--dark);
    font-family: var(--ekwarg);
    font-size: 1.5rem;
    text-align: center;
    padding: .45rem .6rem;
    outline: none;
    box-shadow: 4px 4px 0 var(--dark);
    transition: box-shadow .1s ease, border-color .15s ease;
}

.qa-number-input:focus { border-color: var(--teal); box-shadow: 4px 4px 0 var(--teal); }
.qa-number-input.invalid { border-color: var(--red); box-shadow: 4px 4px 0 var(--red); }
.qa-number-input:disabled { opacity: .6; }
.qa-unit { font-size: 1.3rem; font-weight: bold; }

.answerUnsupported {
    padding: 1rem;
    font-style: italic;
    opacity: .7;
}

/* ########## Word cloud ########## */
.qa-cloud {
    display: grid;
    gap: .75rem;
    width: 100%;
    max-width: 34rem;
}

.qa-chips {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    min-height: 2.4rem;
    align-content: flex-start;
}

.qa-chip {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .3rem .7rem;
    border: 3px solid var(--dark);
    border-radius: 999px;
    background: var(--beige);
    color: var(--dark);
    font-family: var(--ekwarg);
    font-size: 1rem;
    box-shadow: 3px 3px 0 var(--dark);
}

.qa-word-input {
    flex: 1 1 auto;
    min-width: 0;
    border: 3px solid var(--dark);
    border-radius: var(--border-radius);
    background: var(--beige);
    color: var(--dark);
    font-family: var(--ekwarg);
    font-size: 1.05rem;
    padding: .55rem .8rem;
    outline: none;
    box-shadow: 4px 4px 0 var(--dark);
}

/* Separated from the controls: this is the class's picture, not part of answering. */
.qa-cloud-live {
    border-top: 2px dashed var(--dark);
    padding-top: .75rem;
    margin-top: .25rem;
}

/* The right answer, once the question is shut. */
.qa-answer {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: center;
    gap: .35rem .6rem;
    /* Closer to the answers it is about than to the status line under it. */
    margin: .75rem 0 1.25rem;
    padding: .6rem .9rem;
    border: 3px solid var(--dark);
    border-radius: var(--border-radius);
    background: var(--beige);
    box-shadow: 4px 4px 0 var(--dark);
}

.qa-answer-label {
    font-family: var(--inter);
    font-size: .8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.qa-answer-text {
    font-family: var(--ekwarg);
    font-size: 1.15rem;
    overflow-wrap: anywhere;
}

.qa-answer-verdict {
    font-family: var(--inter);
    font-size: .85rem;
    font-weight: 700;
}

.qa-answer-verdict.right { color: var(--teal); }

/* Ink, not red: red reads at 3.5:1 at this size, and bad news does not need shouting anyway. */
.qa-answer-verdict.wrong { color: var(--dark); }

/* The colour lives on the frame, where 3:1 is the bar and red clears it, rather than on small text. */
.qa-answer-right {
    border-color: var(--teal);
    box-shadow: 4px 4px 0 var(--teal);
}

.qa-answer-wrong {
    border-color: var(--red);
    box-shadow: 4px 4px 0 var(--red);
}

/* Standing on its own at a reveal: no controls above it to be separated from. The margin replaces
   the padding the rule took with it, so the heading does not run into the line above. */
.qa-cloud-plain {
    border-top: none;
    padding-top: 0;
    margin-top: 1.25rem;
}

/* Read on a phone, unlike the teacher-only labels this was first copied from: sentence case, and
   no opacity, which at this size would drop it under the contrast it owes. */
.qa-cloud-title {
    margin: 0 0 .5rem;
    font-family: var(--inter);
    font-size: .9rem;
    font-weight: 600;
    text-align: center;
}

.qa-word-input:focus { border-color: var(--teal); box-shadow: 4px 4px 0 var(--teal); }
.qa-word-input:disabled { opacity: .6; }


/* ===== Mobile (<=640px) ===== */
@media (max-width: 640px) {
    /* Panel takes nearly the full width with lighter padding; keep the pop-in card. */
    .qa-panel {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
        padding: 1.1rem;
        gap: 1rem;
        box-shadow: 5px 5px 0 var(--dark);
    }

    .qa-timer { font-size: 1.25rem; }
    .qa-prompt { font-size: 1.35rem; }
    .qa-body { gap: 1rem; }

    /* YesNo: two buttons fit side by side, gap and size scaled down. */
    .qa-yesno {
        width: 100%;
        gap: 1rem;
    }

    .qa-yesno-btn {
        height: 8rem;
        width: 8rem;
        max-width: calc(50% - .5rem);
        font-size: 1.5rem;
        box-shadow: 5px 5px 0 var(--dark);
    }

    .qa-yesno-btn.qa-yesno-md { width: 8rem; font-size: 1.05rem; }
    .qa-yesno-btn.qa-yesno-sm { width: 8rem; font-size: .95rem; }

    /* Options, text, scale and numeric all stay within the panel. */
    .qa-options { max-width: 100%; }

    .qa-option {
        font-size: 1rem;
        padding: .7rem .85rem;
        min-height: 44px;
    }

    .qa-textarea {
        max-width: 100%;
        font-size: 1rem;
    }

    .qa-textrow { max-width: 100%; }

    .qa-cloud { max-width: 100%; }

    .qa-word-input { min-height: 44px; }

    /* The free-text row's full-width Send would leave a word box too narrow to read what you typed. */
    .qa-cloud .qa-submit {
        width: auto;
        flex: 0 0 auto;
    }


    .qa-scale { max-width: 100%; }

    .qa-numeric {
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
    }

    .qa-number-input {
        width: 100%;
        max-width: 12rem;
        box-sizing: border-box;
    }

    /* Cap the submit so it never forces horizontal scroll on a 320px screen. */
    .qa-submit {
        min-width: 0;
        width: 100%;
        min-height: 44px;
    }
}

@media (max-width: 380px) {
    .qa-panel { padding: 1rem; }
    .qa-prompt { font-size: 1.2rem; }

    .qa-yesno-btn {
        height: 6.5rem;
        font-size: 1.3rem;
    }
}

/* Beside the countdown on the teacher card, small enough not to compete with Stop. */
.et-group {
    display: inline-flex;
    align-items: center;
    gap: .25rem;
}

.et-btn {
    font-family: var(--inter);
    font-size: .8rem;
    padding: .15rem .45rem;
    border: 2px solid var(--dark);
    border-radius: 999px;
    background: none;
    color: var(--dark);
    cursor: pointer;
    white-space: nowrap;
}

.et-btn:hover:not(:disabled) { background: var(--beige); }
.et-btn:disabled { opacity: .4; cursor: default; }

/* Keyboard hint inside a submit button. Global rather than scoped: rendered by the answer leaves
   and by the student feedback overlay, which are separate components. */
.qa-kbd {
    margin-left: .45rem;
    padding: .05rem .3rem;
    border: 1px solid currentColor;
    border-radius: var(--border-radius);
    font-family: var(--inter);
    font-size: .7em;
    font-weight: normal;
    opacity: .65;
    white-space: nowrap;
}

/* No physical keyboard, so the hint would only take space. */
@media (hover: none) and (pointer: coarse) {
    .qa-kbd { display: none; }
}
