/* ==========================================================================
   Student exam interface
   Distraction-free: no navigation, no links away from the paper.
   ========================================================================== */

.exam-body {
    background: var(--bg);
    min-height: 100vh;
}

/* --------------------------------------------------------------------------
   Header
   -------------------------------------------------------------------------- */

.exam-header {
    position: sticky;
    top: 0;
    z-index: 20;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 1px 3px rgba(15, 32, 65, .07);
}

.exam-header-inner {
    max-width: 1280px;
    margin: 0 auto;
    padding: .6rem 1.1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.exam-identity { min-width: 0; }

.exam-title {
    font-size: .98rem;
    font-weight: 700;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.exam-student {
    font-size: .8rem;
    color: var(--muted);
}

.exam-meters {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 1.1rem;
    flex-wrap: wrap;
}

.meter-label {
    font-size: .68rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--muted);
    font-weight: 700;
}

.meter-value {
    font-size: 1.05rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    line-height: 1.1;
}

#exam-timer.is-warning { color: var(--warning); }

#exam-timer.is-critical {
    color: var(--danger);
    animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
    50% { opacity: .45; }
}

.progress-track {
    width: 130px;
    height: 6px;
    border-radius: 999px;
    background: var(--border);
    overflow: hidden;
    margin-top: .3rem;
}

.progress-fill {
    height: 100%;
    background: var(--success);
    width: 0;
    transition: width .2s ease;
}

/* --------------------------------------------------------------------------
   Main grid
   -------------------------------------------------------------------------- */

.exam-main {
    max-width: 1280px;
    margin: 0 auto;
    padding: 1.1rem;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 280px;
    gap: 1.1rem;
    align-items: start;
}

@media (max-width: 960px) {
    .exam-main { grid-template-columns: minmax(0, 1fr); }
    .exam-navigator { order: -1; }
}

/* --------------------------------------------------------------------------
   Question card
   -------------------------------------------------------------------------- */

.question {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.15rem 1.3rem 1.3rem;
}

.question[hidden] { display: none; }

.question-meta {
    display: flex;
    align-items: center;
    gap: .7rem;
    flex-wrap: wrap;
    padding-bottom: .7rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: .95rem;
}

.question-number {
    font-weight: 700;
    font-size: .95rem;
}

/* The visible, searchable question id the student can quote to the
   instructor: "I have a question about PY-OOP-008-B". */
.question-id {
    font-family: var(--mono);
    font-size: .8rem;
    font-weight: 700;
    letter-spacing: .02em;
    background: var(--primary-soft);
    color: #1b3f9c;
    border: 1px solid #c3d3f7;
    border-radius: var(--radius-sm);
    padding: .12rem .5rem;
}

.flag-btn {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .3rem .65rem;
    border: 1px solid var(--border-strong);
    border-radius: 999px;
    background: var(--surface);
    color: var(--muted);
    font: inherit;
    font-size: .8rem;
    font-weight: 600;
    cursor: pointer;
}

.flag-btn:hover { background: var(--surface-alt); }

.flag-btn.is-flagged {
    background: var(--flag-soft);
    border-color: #ddcefc;
    color: #5b21b6;
}

.question-text {
    font-size: 1rem;
    margin-bottom: .3rem;
}

/* --------------------------------------------------------------------------
   Choices
   -------------------------------------------------------------------------- */

.choices {
    display: flex;
    flex-direction: column;
    gap: .5rem;
    margin-top: 1rem;
}

.choice {
    display: flex;
    align-items: flex-start;
    gap: .7rem;
    padding: .65rem .8rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    cursor: pointer;
    transition: border-color .1s ease, background .1s ease;
}

.choice:hover {
    border-color: var(--primary);
    background: var(--surface-alt);
}

.choice input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.choice-letter {
    flex: 0 0 auto;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 1px solid var(--border-strong);
    display: grid;
    place-items: center;
    font-size: .8rem;
    font-weight: 700;
    color: var(--muted);
    background: var(--surface-alt);
}

.choice-text {
    font-family: var(--mono);
    font-size: .89rem;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
    padding-top: .12rem;
}

.choice.is-selected {
    border-color: var(--primary);
    background: var(--primary-soft);
    box-shadow: inset 0 0 0 1px var(--primary);
}

.choice.is-selected .choice-letter {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

/* --------------------------------------------------------------------------
   Question footer
   -------------------------------------------------------------------------- */

.question-nav {
    display: flex;
    align-items: center;
    gap: .6rem;
    margin-top: 1.2rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.question-nav .grow { text-align: center; }

.question-nav-bar {
    background: var(--surface);
    border: 1px solid var(--border);
    border-top: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: .7rem .9rem;
    margin-top: .9rem;
}

.save-state {
    font-size: .78rem;
    color: var(--muted);
    min-height: 1.1rem;
}

.save-state.is-saving { color: var(--warning); }
.save-state.is-saved { color: var(--success); }
.save-state.is-error { color: var(--danger); font-weight: 600; }

/* --------------------------------------------------------------------------
   Navigator
   -------------------------------------------------------------------------- */

.exam-navigator {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: .95rem 1rem 1.1rem;
    position: sticky;
    top: 78px;
}

.navigator-title {
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--muted);
    font-weight: 700;
    margin-bottom: .6rem;
}

.navigator-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(34px, 1fr));
    gap: .3rem;
    max-height: 46vh;
    overflow-y: auto;
    padding-right: .15rem;
}

@media (max-width: 960px) {
    .navigator-grid { max-height: 150px; }
    .exam-navigator { position: static; }
}

.nav-cell {
    aspect-ratio: 1;
    min-height: 32px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--muted);
    font: inherit;
    font-size: .76rem;
    font-weight: 650;
    font-variant-numeric: tabular-nums;
    cursor: pointer;
    display: grid;
    place-items: center;
    position: relative;
    padding: 0;
}

.nav-cell:hover { border-color: var(--primary); }

.nav-cell.is-answered {
    background: var(--success-soft);
    border-color: #a9dcc0;
    color: #0d5c36;
}

.nav-cell.is-flagged::after {
    content: "";
    position: absolute;
    top: 2px;
    right: 2px;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--flag);
}

.nav-cell.is-current {
    outline: 2px solid var(--primary);
    outline-offset: 1px;
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.navigator-legend {
    margin-top: .85rem;
    padding-top: .75rem;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: .35rem;
    font-size: .78rem;
    color: var(--muted);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: .45rem;
}

.legend-swatch {
    width: 15px;
    height: 15px;
    border-radius: 4px;
    border: 1px solid var(--border-strong);
    background: var(--surface);
    flex: 0 0 auto;
}

.legend-swatch.answered { background: var(--success-soft); border-color: #a9dcc0; }
.legend-swatch.current { background: var(--primary); border-color: var(--primary); }
.legend-swatch.flagged { background: var(--flag); border-color: var(--flag); }

.navigator-actions {
    margin-top: .9rem;
    display: flex;
    flex-direction: column;
    gap: .45rem;
}

/* --------------------------------------------------------------------------
   Copy deterrence
   These make casual copying awkward. They are NOT security: the server never
   sends the answer key, and every rule is enforced again server side.
   -------------------------------------------------------------------------- */

.no-copy {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

.no-copy .code code { -webkit-user-select: none; user-select: none; }

/* --------------------------------------------------------------------------
   Confirmation and result screens
   -------------------------------------------------------------------------- */

.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: .8rem;
    margin: 1rem 0 1.2rem;
}

.summary-tile {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: .85rem;
    text-align: center;
    background: var(--surface-alt);
}

.summary-tile .value {
    font-size: 1.8rem;
    font-weight: 700;
    line-height: 1.1;
}

.summary-tile .label {
    font-size: .76rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--muted);
    font-weight: 700;
}

.summary-tile.answered .value { color: var(--success); }
.summary-tile.unanswered .value { color: var(--danger); }
.summary-tile.flagged .value { color: var(--flag); }

.unanswered-list {
    display: flex;
    flex-wrap: wrap;
    gap: .3rem;
    margin-top: .5rem;
}

.unanswered-list a {
    display: inline-grid;
    place-items: center;
    min-width: 32px;
    padding: .2rem .35rem;
    border: 1px solid var(--danger);
    border-radius: var(--radius-sm);
    background: var(--danger-soft);
    color: #8e1f1f;
    font-size: .78rem;
    font-weight: 650;
    text-decoration: none;
}

.result-score {
    font-size: 3rem;
    font-weight: 750;
    line-height: 1;
    margin: .3rem 0;
}

.result-outcome {
    display: inline-block;
    padding: .3rem .95rem;
    border-radius: 999px;
    font-weight: 700;
    font-size: .95rem;
}

.result-outcome.pass { background: var(--success-soft); color: #0d5c36; }
.result-outcome.fail { background: var(--danger-soft); color: #8e1f1f; }

/* --------------------------------------------------------------------------
   Answer review (only when the instructor enables it)
   -------------------------------------------------------------------------- */

.review-item {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.1rem;
    margin-bottom: .8rem;
    background: var(--surface);
}

.review-item.is-correct { border-left: 4px solid var(--success); }
.review-item.is-wrong { border-left: 4px solid var(--danger); }

.review-choice {
    display: flex;
    gap: .6rem;
    align-items: flex-start;
    padding: .4rem .6rem;
    border-radius: var(--radius-sm);
    font-family: var(--mono);
    font-size: .86rem;
    white-space: pre-wrap;
}

.review-choice.correct { background: var(--success-soft); }
.review-choice.chosen-wrong { background: var(--danger-soft); }

.review-tag {
    font-family: var(--sans);
    font-size: .72rem;
    font-weight: 700;
    margin-left: auto;
    white-space: nowrap;
    align-self: center;
}

.explanation {
    margin-top: .6rem;
    padding: .6rem .75rem;
    background: var(--surface-alt);
    border-radius: var(--radius-sm);
    font-size: .86rem;
}

/* --------------------------------------------------------------------------
   Instructions screen
   The .screen / .screen-card / .screen-brand shells live in app.css, because
   the administrator sign-in page uses them too.
   -------------------------------------------------------------------------- */

.rules {
    margin: 0 0 1.2rem;
    padding-left: 1.15rem;
    font-size: .9rem;
}

.rules li { margin-bottom: .4rem; }

.exam-facts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: .7rem;
    margin: 1rem 0 1.3rem;
}

.exam-fact {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: .6rem .7rem;
    background: var(--surface-alt);
}

.exam-fact .value {
    font-size: 1.25rem;
    font-weight: 700;
    line-height: 1.15;
}

.exam-fact .label {
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--muted);
    font-weight: 700;
}
