/* ============================================================================
   MCQ EXAM PAPER — shared by the student exam (student/student_mcq.php) and the
   free public MCQ (mcq.php), so both look exactly alike. Colours come from the
   host page's variables; the exam cyan has fallbacks so a page that does not
   define it still gets the same paper.
   ============================================================================ */

.paper-wrapper {
    --xa: var(--exam-accent, #10B4D3);
    --xa-dark: var(--exam-accent-dark, #0C97B2);
    --xa-soft: var(--exam-accent-soft, #E4F7FB);
    background-color: var(--bg-card); border-radius: 16px; overflow: hidden;
    border: 1px solid var(--border); box-shadow: var(--shadow);
}

/* One cyan bar across the top of the paper: what is left, who is sitting it,
   which paper, and the clock. It stays put in every view. */
.exam-bar {
    background-color: var(--xa); color: #FFFFFF; padding: 14px 26px;
    display: flex; justify-content: space-between; align-items: center; gap: 14px;
    font-weight: 700; font-size: 15px; flex-wrap: wrap;
}
.exam-bar .eb-mid { flex: 1 1 auto; text-align: center; letter-spacing: .2px; }
.exam-bar .eb-end { text-align: right; display: inline-flex; align-items: center; gap: 12px; }
.exam-bar b { font-weight: 800; }
.exam-bar b.low { color: #FFE27A; }
.eb-full {
    background: rgba(255,255,255,.18); border: 1px solid rgba(255,255,255,.45); color: #fff;
    height: 34px; padding: 0 12px; border-radius: 999px; cursor: pointer;
    display: inline-flex; align-items: center; gap: 6px; font-weight: 700; font-size: 13px;
    font-family: inherit;
}
.eb-full:hover { background: rgba(255,255,255,.3); }
.eb-full i { font-size: 18px; }

.paper-header-sub {
    background-color: var(--bg-app); color: var(--text-primary); padding: 12px 25px;
    display: flex; justify-content: space-between; align-items: center;
    font-size: 14px; font-weight: 600; border-bottom: 1px solid var(--border); flex-wrap: wrap; gap: 10px;
}
.text-green { color: var(--success); font-weight: 700; }
.text-orange { color: var(--warning, #FF9500); font-weight: 700; }

/* Overview Grid Area */
.paper-overview-body { padding: 30px; background: var(--bg-card); min-height: 500px; display: flex; flex-direction: column; gap: 25px; }
.grid-container { display: flex; flex-direction: column; gap: 20px; }
.grid-panel { background: var(--bg-app); border: 1px solid var(--border); border-radius: 12px; padding: 20px; }
.grid-panel-title {
    font-size: 16px; font-weight: 700; color: var(--text-primary); margin-bottom: 15px;
    border-bottom: 2px solid var(--border); padding-bottom: 8px;
    display: inline-flex; align-items: center; gap: 8px;
}
.grid-panel-title i { font-size: 20px; color: var(--xa); }

.q-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(45px, 1fr)); gap: 10px; }
.q-num-btn {
    background: var(--bg-card); border: 1.5px solid var(--border); color: var(--text-primary); height: 45px;
    display: flex; align-items: center; justify-content: center; border-radius: 8px;
    font-weight: 600; font-size: 15px; cursor: pointer; transition: all 0.2s ease; position: relative;
}
.q-num-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); transform: translateY(-2px); }
.q-num-btn.answered { background: var(--accent); color: #FFFFFF; border-color: var(--accent); }
/* listening numbers carry a small headphone in the corner */
.q-num-btn .lis {
    position: absolute; top: -7px; right: -7px; width: 19px; height: 19px; border-radius: 50%;
    background: var(--xa); color: #fff; font-size: 12px;
    display: flex; align-items: center; justify-content: center; border: 2px solid var(--bg-app);
}

.submit-wrap { display: flex; justify-content: flex-end; padding-top: 10px; }
.btn-primary {
    background-color: var(--accent); color: #FFFFFF; border: none; padding: 14px 30px;
    border-radius: 12px; font-size: 16px; font-weight: 700; cursor: pointer; transition: all 0.3s ease;
}
.btn-primary:hover { filter: brightness(1.1); transform: translateY(-2px); }

/* ---- The question page: prompt on the left, answers on the right ----
   One question fills the card at a time, with a hairline between the two
   halves. On a phone they stack, answers under the prompt. */
.paper-question-body { display: none; background: var(--bg-card); min-height: 500px; }
.q-container {
    display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
    align-items: start; min-height: 480px;
}
.q-side  { padding: 30px 34px; }
.opt-side{ padding: 30px 34px; border-left: 1px solid var(--border); background: var(--bg-app); align-self: stretch; }

/* Section tag above a listening question */
.q-section {
    display: inline-flex; align-items: center; gap: 6px; margin-bottom: 12px;
    background: var(--xa-soft); color: var(--xa-dark); border: 1px solid var(--xa);
    padding: 5px 12px; border-radius: 999px; font-size: 12.5px; font-weight: 700; letter-spacing: .2px;
}
.q-section i { font-size: 16px; }

/* Order 1: Text — the number sits inline with the prompt, as on paper */
.q-text { font-size: 18px; font-weight: 700; color: var(--text-primary); line-height: 1.6; }
.q-text .q-no { margin-right: 6px; }

/* Order 2 & 3: Image then Audio, inside their own framed box */
.q-media-box { display: flex; flex-direction: column; gap: 15px; margin-top: 22px; }
.q-img-wrap {
    border: 1px solid var(--border); border-radius: 14px; background: var(--bg-card);
    padding: 22px; display: flex; align-items: center; justify-content: center; min-height: 240px;
}
.q-img-wrap img { max-width: 100%; max-height: 320px; object-fit: contain; }

/* Order 4: Options */
.options-list { display: flex; flex-direction: column; gap: 14px; }
.opt-label { display: block; cursor: pointer; }
.opt-input { position: absolute; opacity: 0; width: 0; height: 0; }
.opt-card {
    display: flex; align-items: center; gap: 16px; border: 1.5px solid var(--border);
    border-radius: 14px; padding: 18px 20px; background: var(--bg-card); transition: all 0.2s ease;
}
.opt-circle {
    width: 38px; height: 38px; border: 1.5px solid var(--xa); border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 15px; color: var(--xa); flex-shrink: 0;
    background: transparent; transition: all 0.2s ease;
}
.opt-content { font-size: 16.5px; font-weight: 600; color: var(--text-primary); line-height: 1.45; flex: 1; min-width: 0; }
.opt-content img { max-height: 110px; max-width: 100%; border-radius: 8px; border: 1px solid var(--border); }

.opt-label:hover .opt-card { border-color: var(--xa); }
/* :focus-visible keeps the hidden radio reachable by keyboard */
.opt-input:focus-visible + .opt-card { outline: 2px solid var(--xa); outline-offset: 2px; }
.opt-input:checked + .opt-card { border-color: var(--xa); background: var(--xa-soft); }
.opt-input:checked + .opt-card .opt-circle { background: var(--xa); color: #FFFFFF; border-color: var(--xa); }

/* ---- Whole Page: every question stacked in one scroll ---- */
.paper-question-body.mode-whole { background: var(--bg-app); padding: 6px 0; }
.mode-whole .ubt-q-page { background: var(--bg-card); margin: 18px; border-radius: 14px;
    border: 1px solid var(--border); overflow: hidden; }
.mode-whole .q-container { min-height: 0; }
.mode-whole .q-side, .mode-whole .opt-side { padding: 22px 24px; }
.mode-whole .q-img-wrap { min-height: 0; }

/* ---- Footer action bar ---- */
.action-bar {
    display: flex; justify-content: space-between; align-items: center; gap: 12px;
    padding: 18px 26px; border-top: 1px solid var(--border); background: var(--bg-card); flex-wrap: wrap;
}
.ab-left { display: flex; gap: 14px; flex-wrap: wrap; }
.btn-pill {
    background-color: var(--xa); color: #FFFFFF; border: none;
    padding: 14px 26px; border-radius: 999px; font-size: 15px; font-weight: 700; cursor: pointer;
    display: inline-flex; align-items: center; gap: 9px; transition: all 0.2s; font-family: inherit;
}
.btn-pill:hover { background-color: var(--xa-dark); }
.btn-pill i { font-size: 18px; }
.btn-pill.ghost { background: transparent; color: var(--xa); border: 1.5px solid var(--xa); }
.btn-pill.ghost:hover { background: var(--xa-soft); }

/* ---- One-play audio ----
   No pause, no seek, no replay: a single button starts the clip and the bar
   just shows how far it has got. */
.once-audio {
    display: flex; align-items: center; gap: 14px; width: 100%; max-width: 460px;
    border: 1.5px solid var(--xa); background: var(--xa-soft);
    border-radius: 14px; padding: 12px 16px; user-select: none; -webkit-user-select: none;
}
.opt-content .once-audio { max-width: none; padding: 9px 12px; gap: 11px; }
.oa-btn {
    width: 46px; height: 46px; border-radius: 50%; border: none; flex-shrink: 0;
    background: var(--xa); color: #fff; font-size: 26px; cursor: pointer;
    display: flex; align-items: center; justify-content: center; transition: transform .15s, background .2s;
}
.opt-content .oa-btn { width: 38px; height: 38px; font-size: 22px; }
.oa-btn:hover:not(:disabled) { transform: scale(1.06); background: var(--xa-dark); }
.oa-btn:disabled { cursor: default; }
.oa-body { flex: 1; min-width: 0; }
.oa-top { display: flex; justify-content: space-between; align-items: center; gap: 2px 8px; margin-bottom: 7px; flex-wrap: wrap; }
.oa-label { font-size: 13.5px; font-weight: 700; color: var(--text-primary); display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.oa-label i { color: var(--xa); font-size: 16px; }
.oa-hint { font-size: 11.5px; font-weight: 700; color: var(--xa-dark); white-space: nowrap; }
.oa-bar { height: 6px; border-radius: 99px; background: rgba(0,0,0,.08); overflow: hidden; }
.oa-bar span { display: block; height: 100%; width: 0; background: var(--xa); border-radius: 99px; transition: width .25s linear; }
.oa-time { font-size: 12.5px; font-weight: 700; color: var(--text-secondary); font-variant-numeric: tabular-nums; min-width: 34px; text-align: right; }

.once-audio[data-state="loading"] .oa-btn i { animation: oaSpin 1s linear infinite; }
@keyframes oaSpin { to { transform: rotate(360deg); } }
.once-audio[data-state="playing"] .oa-btn { animation: oaPulse 1.6s ease-in-out infinite; }
@keyframes oaPulse { 0%,100% { box-shadow: 0 0 0 0 rgba(16,180,211,.45); } 50% { box-shadow: 0 0 0 8px rgba(16,180,211,0); } }
.once-audio[data-state="done"] { border-color: var(--border); background: var(--bg-app); }
.once-audio[data-state="done"] .oa-btn { background: var(--text-secondary); opacity: .55; }
.once-audio[data-state="done"] .oa-bar span { background: var(--text-secondary); opacity: .5; }
.once-audio[data-state="done"] .oa-hint { color: var(--text-secondary); }
.once-audio[data-state="error"] { border-color: var(--danger, #FF3B30); }
.once-audio[data-state="error"] .oa-hint { color: var(--danger, #FF3B30); }
.once-audio.oa-shake { animation: oaShake .4s; }
@keyframes oaShake { 20%,60% { transform: translateX(-5px); } 40%,80% { transform: translateX(5px); } }

/* ---- Full screen: the paper takes the whole window ----
   Real fullscreen where the browser allows it; the class alone already fills
   the viewport, which is all an iPhone gets. */
.paper-wrapper.is-full {
    position: fixed; inset: 0; z-index: 5000; border-radius: 0; border: none;
    overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
    display: flex; flex-direction: column;
}
.paper-wrapper.is-full .exam-bar { position: sticky; top: 0; z-index: 2; }
.paper-wrapper.is-full .paper-overview-body,
.paper-wrapper.is-full .paper-question-body { flex: 1 0 auto; }
/* the question fills the screen; Next / Submit stay pinned to the bottom edge */
.paper-wrapper.is-full .paper-question-body { padding-bottom: 82px; }
.paper-wrapper.is-full .q-container { min-height: calc(100vh - 136px); min-height: calc(100dvh - 136px); }
.paper-wrapper.is-full .mode-whole .q-container { min-height: 0; }
.paper-wrapper.is-full .paper-question-body .action-bar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 3; box-shadow: 0 -8px 24px rgba(0,0,0,.06);
}
html.exam-full-lock, html.exam-full-lock body { overflow: hidden; }

@media (max-width: 860px) {
    .q-container { grid-template-columns: 1fr; }
    .opt-side { border-left: none; border-top: 1px solid var(--border); }
    .q-side, .opt-side { padding: 22px 20px; }
    .exam-bar { font-size: 13.5px; padding: 12px 16px; }
    .exam-bar .eb-mid { flex-basis: 100%; order: 3; text-align: left; }
    .eb-full span { display: none; }
    .action-bar { padding: 14px 16px; }
    .ab-left { flex: 1 1 100%; }
    .btn-pill { flex: 1 1 auto; justify-content: center; padding: 13px 18px; font-size: 14px; }
    .paper-wrapper.is-full .paper-question-body { padding-bottom: 150px; }
    .paper-wrapper.is-full .q-container { min-height: 0; }
    .paper-overview-body { padding: 20px; }
    .paper-overview-body > .paper-header-sub { margin: -20px -20px 0 !important; }
    .paper-header-sub { font-size: 13px; justify-content: center; text-align: center; }
}
