/* =========================================================================
   REPORT A QUESTION

   The button rides inside six different action rows — the practice pill, the
   test-mode question head, the test-review pill, the result page's button row,
   and both full-length review surfaces — each with its own background and its
   own token set (test mode paints from --tm-*, everything else from
   premium-ui.css). So the button carries no background of its own and states
   its colours literally: a neutral grey that reads on both themes, and the
   product's red on hover and once reported.

   The dialog is a body child, so it draws from :root tokens and follows the
   light/dark switch with everything else.
   ========================================================================= */

/* Scoped reset. The two pages that load this file do not agree on box-sizing —
   fulltest.html leaves a bare <textarea> at content-box, so `width: 100%` on
   the note field overflowed the sheet and put a horizontal scrollbar under the
   dialog. Declared here rather than relying on either page's reset. */
.qr-btn,
.qr-modal,
.qr-modal *,
.qr-modal *::before,
.qr-modal *::after {
    box-sizing: border-box;
}

.qr-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: none;
    color: #7d8798;
    font-size: 0.95rem;
    line-height: 1;
    cursor: pointer;
    transition: color 0.18s ease, background 0.18s ease, transform 0.18s ease;
}

.qr-btn:hover,
.qr-btn:focus-visible {
    color: var(--danger, #f2776b);
    background: color-mix(in srgb, var(--danger, #f2776b) 14%, transparent);
    transform: translateY(-1px);
}

.qr-btn:focus-visible {
    outline: 2px solid var(--danger, #f2776b);
    outline-offset: 2px;
}

/* Already sent from this browser. Still clickable — a second report is
   sometimes the right thing — but it should not look like an unread task. */
.qr-btn.is-reported {
    color: var(--warning, #f0b429);
    opacity: 0.75;
}

/* The result page's row is a line of labelled buttons, not icons, so the
   report control gets a label there too. */
.qr-btn.qr-btn-wide {
    width: auto;
    height: auto;
    gap: 6px;
    padding: 6px 12px;
    border: 1px solid var(--line, #444);
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
}

.qr-btn.qr-btn-wide::after {
    content: 'Report';
}

.qr-btn.qr-btn-wide.is-reported::after {
    content: 'Reported';
}

/* ── dialog ─────────────────────────────────────────────────────────────── */

.qr-modal {
    position: fixed;
    inset: 0;
    z-index: 2147483000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px;
}

.qr-modal[hidden] {
    display: none;
}

.qr-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(6, 9, 14, 0.62);
    backdrop-filter: blur(3px);
}

.qr-sheet {
    position: relative;
    width: min(460px, 100%);
    max-height: min(88vh, 720px);
    display: flex;
    flex-direction: column;
    border-radius: var(--radius, 20px);
    border: 1px solid var(--line, #262e3a);
    background: var(--surface-solid, #151a22);
    color: var(--text-main, #eef2f8);
    box-shadow: var(--shadow-md, 0 18px 50px rgba(0, 0, 0, 0.45));
    animation: qrRise 0.22s cubic-bezier(0.16, 1, 0.3, 1) both;
    overflow: hidden;
}

@keyframes qrRise {
    from { opacity: 0; transform: translateY(14px) scale(0.985); }
    to   { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
    .qr-sheet { animation: none; }
    .qr-btn { transition: none; }
}

.qr-head {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 18px 18px 14px;
    border-bottom: 1px solid var(--line, #262e3a);
}

.qr-head h3 {
    margin: 0;
    font-size: 1.02rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.qr-head small {
    display: block;
    margin-top: 3px;
    font-size: 0.79rem;
    color: var(--text-muted, #939eaf);
}

.qr-x {
    margin-left: auto;
    width: 30px;
    height: 30px;
    flex: none;
    border: none;
    border-radius: 50%;
    background: none;
    color: var(--text-muted, #939eaf);
    font-size: 0.95rem;
    cursor: pointer;
}

.qr-x:hover {
    background: color-mix(in srgb, var(--text-muted, #939eaf) 16%, transparent);
    color: var(--text-main, #eef2f8);
}

.qr-body {
    padding: 16px 18px;
    overflow-y: auto;
}

/* The question the student is reporting, so there is no doubt which one this
   dialog is about after a mis-tap. Set as textContent, never as markup. */
.qr-quote {
    margin: 0 0 14px;
    padding: 10px 12px;
    border-left: 3px solid var(--brand, #7ba6ff);
    border-radius: 0 8px 8px 0;
    background: color-mix(in srgb, var(--brand, #7ba6ff) 9%, transparent);
    font-size: 0.83rem;
    line-height: 1.5;
    color: var(--text-muted, #939eaf);
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.qr-reasons {
    display: grid;
    gap: 8px;
    margin-bottom: 16px;
}

.qr-reason {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--line, #262e3a);
    border-radius: 12px;
    background: var(--surface-raised, #1c222c);
    color: var(--text-main, #eef2f8);
    font-size: 0.86rem;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    transition: border-color 0.16s ease, background 0.16s ease;
}

.qr-reason i {
    width: 18px;
    flex: none;
    text-align: center;
    font-size: 0.9rem;
    color: var(--text-muted, #939eaf);
}

.qr-reason:hover {
    border-color: color-mix(in srgb, var(--brand, #7ba6ff) 48%, transparent);
}

.qr-reason.is-on {
    border-color: var(--brand, #7ba6ff);
    background: color-mix(in srgb, var(--brand, #7ba6ff) 13%, transparent);
}

.qr-reason.is-on i {
    color: var(--brand, #7ba6ff);
}

.qr-label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.76rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-muted, #939eaf);
}

.qr-label span {
    text-transform: none;
    letter-spacing: 0;
    font-weight: 500;
    color: var(--danger, #f2776b);
}

.qr-note {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--line, #262e3a);
    border-radius: 12px;
    background: var(--surface-raised, #1c222c);
    color: var(--text-main, #eef2f8);
    font-size: 0.87rem;
    line-height: 1.5;
    resize: vertical;
}

.qr-note:focus {
    outline: none;
    border-color: var(--brand, #7ba6ff);
}

.qr-hint {
    margin: 10px 0 0;
    font-size: 0.76rem;
    color: var(--text-muted, #939eaf);
}

.qr-foot {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 14px 18px;
    border-top: 1px solid var(--line, #262e3a);
    background: color-mix(in srgb, var(--surface-raised, #1c222c) 60%, transparent);
}

.qr-cancel,
.qr-send {
    padding: 9px 18px;
    border-radius: 100px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
}

.qr-cancel {
    border: 1px solid var(--line, #262e3a);
    background: none;
    color: var(--text-muted, #939eaf);
}

.qr-cancel:hover {
    color: var(--text-main, #eef2f8);
}

.qr-send {
    border: none;
    background: var(--danger, #f2776b);
    color: #fff;
}

.qr-send:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.qr-send:not(:disabled):hover {
    filter: brightness(1.08);
}

/* The dialog opens over practice, over a running test and over the full-length
   console — all three scroll their own containers, and one of them locks the
   body already. Locking here too is safe: close() always removes it. */
body.qr-open {
    overflow: hidden;
}

@media (max-width: 520px) {
    .qr-modal {
        align-items: flex-end;
        padding: 0;
    }

    .qr-sheet {
        width: 100%;
        max-height: 90vh;
        border-radius: 20px 20px 0 0;
        border-bottom: none;
    }
}
