/*
    Public exam page. Mobile first: most students open it on a phone by scanning the QR code. System fonts only.
    Teachquizly colours: cream page and cards, navy for text, buttons and what the student picked. The brand red is only a
    small accent (the logo, the label above a title); answers and errors never use it, so nothing chosen looks wrong.
*/

:root {
    color-scheme: light dark;
    --brand: #211c32;
    --brand-strong: #3a3350;
    --on-brand: #f6f2e9;
    --brand-soft: #e9e5ec;
    --accent: #ae4030;
    --bg: #f6f2e9;
    --surface: #fffbf3;
    --text: #211c32;
    --muted: #5e5869;
    --border: #d3c9b5;
    --field-border: #928771; /* text boxes: at least 3:1 on both the card and the page, so the box itself can be seen */
    --line: #e5ded0;
    --danger: #b3261e;
    --danger-soft: #fdecea;
    --success: #1e7a46;
    --success-soft: #dcf1e5;
    --focus: #2f6fde;
    --radius: 16px;
    --radius-sm: 12px;
    --shadow: 0 1px 2px rgba(33, 28, 50, 0.07), 0 2px 10px rgba(33, 28, 50, 0.06);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 106.25%; /* 17px: easier on phones, and inputs at 16px+ stop iOS from zooming in */
    line-height: 1.5;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

/* The brand's dark counterparts: the navy becomes the page, cream becomes the ink and the buttons. */
@media (prefers-color-scheme: dark) {
    :root {
        --brand: #f6f2e9;
        --brand-strong: #ffffff;
        --on-brand: #211c32;
        --brand-soft: #332c4b;
        --accent: #e2735e;
        --bg: #15121d;
        --surface: #211c32;
        --text: #f6f2e9;
        --muted: #b9b3c6;
        --border: #4b4363;
        --field-border: #736a8c;
        --line: #3a3350;
        --danger: #ffb4ab;
        --danger-soft: #3d1f1d;
        --success: #7fd6a2;
        --success-soft: #183326;
        --focus: #8ab4ff;
        --shadow: none;
    }
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    overflow-wrap: break-word;
}

h1,
h2 {
    line-height: 1.25;
    margin: 0 0 0.5rem;
}

h1 {
    font-size: 1.45rem;
}

h2 {
    font-size: 1.2rem;
}

p {
    margin: 0 0 0.75rem;
}

h1:focus {
    outline: none;
}

a {
    color: var(--brand);
}

:focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 2px;
}

.visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* ---------- Logo (BrandLogo.razor; the exam pages' header is in MainLayout.razor.css) ---------- */

.brand-logo,
.brand-logo img {
    display: block;
}

.brand-logo img {
    width: auto;
    height: 1.7rem;
}

/* ---------- Cards and texts ---------- */

.card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-top: 0.5rem;
    box-shadow: var(--shadow);
}

.eyebrow {
    margin: 0 0 0.25rem;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--accent);
}

.facts {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    list-style: none;
    padding: 0;
    margin: 0.25rem 0 1rem;
}

.facts li {
    background: var(--brand-soft);
    color: var(--text);
    border-radius: 999px;
    padding: 0.2rem 0.75rem;
    font-size: 0.9rem;
}

.hint {
    color: var(--muted);
    font-size: 0.9rem;
    margin: 0.5rem 0 0;
}

.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    background: var(--danger-soft);
    color: var(--danger);
    margin: 0.75rem 0;
}

.message .actions,
.actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 1rem;
}

/* ---------- Form controls ---------- */

fieldset {
    border: 0;
    margin: 0;
    padding: 0;
    min-width: 0;
}

.field-label {
    display: block;
    font-weight: 600;
    margin: 1rem 0 0.4rem;
    padding: 0;
}

input[type=text],
input[type=search],
textarea {
    display: block;
    width: 100%;
    padding: 0.8rem 0.9rem;
    border: 1.5px solid var(--field-border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: 1rem;
}

textarea {
    resize: vertical;
    min-height: 3.2em;
}

input[type=text]:focus,
input[type=search]:focus,
textarea:focus {
    border-color: var(--brand);
    outline: 2px solid var(--brand);
    outline-offset: 0;
}

.code-input {
    font-size: 1.3rem !important;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    text-align: center;
}

.button {
    display: block;
    width: 100%;
    min-height: 3rem;
    padding: 0.8rem 1rem;
    border: 1.5px solid transparent;
    border-radius: var(--radius-sm);
    font: inherit;
    font-weight: 600;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    touch-action: manipulation;
}

.button.primary {
    background: var(--brand);
    color: var(--on-brand);
}

.button.primary:hover {
    background: var(--brand-strong);
}

.button.secondary {
    background: transparent;
    border-color: var(--border);
    color: var(--text);
}

.button:disabled {
    opacity: 0.6;
    cursor: progress;
}

form > .button.primary {
    margin-top: 1.25rem;
}

.link {
    background: none;
    border: 0;
    padding: 0.5rem 0.25rem;
    margin: -0.5rem 0;
    color: var(--brand);
    font: inherit;
    font-size: 0.9rem;
    text-decoration: underline;
    cursor: pointer;
}

/* Radio options shown as large tappable rows (answer options and the class list). */
.options {
    display: grid;
    gap: 0.5rem;
}

.option {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-height: 3.25rem;
    padding: 0.7rem 0.9rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.option input {
    flex: none;
    width: 1.3rem;
    height: 1.3rem;
    margin: 0;
    accent-color: var(--brand);
}

.option:has(input:checked) {
    border-color: var(--brand);
    background: var(--brand-soft);
    box-shadow: inset 0 0 0 1px var(--brand);
}

/* Move the focus ring from the small radio to the whole row, only where :has() exists (else the radio keeps its own). */
@supports selector(:has(*)) {
    .option:has(input:focus-visible) {
        outline: 3px solid var(--focus);
        outline-offset: 2px;
    }

    .option input:focus-visible {
        outline: none;
    }
}

/* ---------- Name screen ---------- */

.students .filter {
    margin-bottom: 0.75rem;
}


/* ---------- Exam ---------- */

.exam-header {
    padding: 0.5rem 0.25rem 0.25rem;
}

.exam-header h1 {
    margin-bottom: 0.25rem;
}

.who {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.25rem 0.75rem;
    color: var(--muted);
}

.who-name {
    font-weight: 600;
    color: var(--text);
}

.inline-form {
    display: inline;
}

.progress-bar {
    position: sticky;
    top: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 0.5rem -1rem 0;
    padding: 0.6rem 1rem;
    background: var(--bg);
    border-bottom: 1px solid var(--line);
    font-size: 0.9rem;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

.progress-bar progress {
    flex: 1;
    height: 0.5rem;
    border: 0;
    border-radius: 999px;
    background: var(--brand-soft);
    overflow: hidden;
    -webkit-appearance: none;
    appearance: none;
}

.progress-bar progress::-webkit-progress-bar {
    background: var(--brand-soft);
    border-radius: 999px;
}

.progress-bar progress::-webkit-progress-value {
    background: var(--brand);
    border-radius: 999px;
}

.progress-bar progress::-moz-progress-bar {
    background: var(--brand);
    border-radius: 999px;
}

.question {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1.1rem 1rem 1.15rem;
    margin-top: 0.75rem;
    box-shadow: var(--shadow);
    border-left: 4px solid transparent;
    scroll-margin-top: 3.5rem;
}

.question.answered {
    border-left-color: var(--brand);
}

.question.attention {
    border-left-color: var(--danger);
}

.question legend {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.25rem 0.6rem;
    padding: 0;
    margin-bottom: 0.4rem;
    float: left; /* lets the legend sit inside the card's padding like normal text */
    width: 100%;
}

.question legend + * {
    clear: both;
}

.q-number {
    font-weight: 700;
    color: var(--brand);
}

.q-hint {
    font-size: 0.85rem;
    color: var(--muted);
}

.prompt {
    clear: both;
    font-size: 1.15rem;
    font-weight: 500;
    margin: 0 0 0.9rem;
    white-space: pre-line;
}

.blank {
    display: inline-block;
    width: 3.5em;
    height: 1em;
    margin: 0 0.2em;
    border-bottom: 2px solid currentColor;
    vertical-align: -0.1em;
}

.question .field-label {
    margin-top: 0;
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--muted);
}

.submit-area {
    margin-top: 1.25rem;
}

.submit-area .hint {
    text-align: center;
}

/* ---------- Dialog ---------- */

/* Browsers without <dialog> would otherwise show closed dialogs inline. */
dialog:not([open]) {
    display: none;
}

.dialog {
    width: min(92vw, 26rem);
    border: 0;
    border-radius: var(--radius);
    padding: 1.25rem;
    background: var(--surface);
    color: var(--text);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.dialog::backdrop {
    background: rgba(21, 18, 29, 0.5);
}

.dialog-actions {
    display: flex;
    flex-direction: column-reverse;
    gap: 0.5rem;
    margin-top: 1rem;
}

@media (min-width: 420px) {
    .dialog-actions {
        flex-direction: row;
        justify-content: flex-end;
    }

    .dialog-actions .button {
        width: auto;
        flex: 1;
    }
}

/* ---------- Thank you ---------- */

.thanks {
    text-align: center;
    padding: 2rem 1.25rem;
}

.thanks-icon {
    width: 4.5rem;
    height: 4.5rem;
    margin: 0 auto 1rem;
    display: block;
}

.thanks-icon circle {
    fill: var(--success-soft);
    stroke: var(--success);
    stroke-width: 2;
}

.thanks-icon path {
    fill: none;
    stroke: var(--success);
    stroke-width: 3.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}

@media (min-width: 640px) {
    .card {
        padding: 1.75rem;
        margin-top: 1.5rem;
    }

    .question {
        padding: 1.25rem 1.5rem;
    }

    .progress-bar {
        margin-left: 0;
        margin-right: 0;
        border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    }
}

@media (prefers-reduced-motion: no-preference) {
    .option,
    .question {
        transition: border-color 0.15s ease, background-color 0.15s ease;
    }
}

/* The short privacy notice under the name forms (exam and word game). */
.privacy-note {
    margin-top: 1rem;
    font-size: 0.85rem;
}

.privacy-note a {
    color: inherit;
}
