/*
 * Survey styling.
 *
 * Written for a Grade 8 to 11 learner holding a tablet in a school hall, so:
 * large type, generous tap targets (nothing under 48px), high contrast, and no
 * animation that could be read as the app doing something with their answers.
 *
 * No build step. This file is served as written and precached by the service
 * worker, so a tablet that has been enrolled once needs nothing further.
 */

:root {
    --ink: #12324a;
    --ink-soft: #4a6076;
    --paper: #f7f9fb;
    --card: #ffffff;
    --line: #d3dde6;
    --accent: #12324a;
    --accent-ink: #ffffff;
    --focus: #0b6bcb;
    --danger: #a4252b;
    --radius: 10px;
    --tap: 48px;
}

* {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 18px;
    line-height: 1.55;
    /* A learner should never lose their place by accidentally selecting text
       while scrolling with a thumb. Inputs re-enable it below. */
    -webkit-user-select: none;
    user-select: none;
}

.app {
    max-width: 46rem;
    margin: 0 auto;
    padding: 1.25rem 1rem 4rem;
}

/* ------------------------------------------------------------- screens --- */

.screen__title {
    font-size: 1.7rem;
    line-height: 1.25;
    margin: 0 0 0.75rem;
}

.screen__lead {
    font-size: 1.15rem;
    margin: 0 0 1.25rem;
}

.screen__note,
.screen__meta {
    color: var(--ink-soft);
    font-size: 0.95rem;
}

.screen--welcome,
.screen--thanks {
    text-align: center;
    padding-top: 2rem;
}

.consent__salutation {
    font-weight: 600;
}

.consent__para {
    margin: 0 0 0.9rem;
}

/* ------------------------------------------------------------ progress --- */

.progress {
    height: 10px;
    background: var(--line);
    border-radius: 999px;
    overflow: hidden;
    margin-bottom: 0.4rem;
}

.progress__fill {
    height: 100%;
    background: var(--accent);
    transition: width 160ms linear;
}

.progress__label {
    margin: 0 0 1.5rem;
    color: var(--ink-soft);
    font-size: 0.9rem;
}

/* -------------------------------------------------------------- themes --- */

.theme__title {
    font-size: 1.3rem;
    margin: 0 0 0.35rem;
}

.theme__subtitle {
    font-weight: 600;
    margin: 0 0 0.35rem;
}

.theme__intro {
    color: var(--ink-soft);
    margin: 0 0 1.5rem;
}

/* ----------------------------------------------------------- questions --- */

.q {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    margin: 0 0 1.1rem;
    padding: 1rem;
}

.q__legend {
    display: block;
    padding: 0;
    font-weight: 600;
}

.q__num {
    display: inline-block;
    min-width: 2.2rem;
    color: var(--ink-soft);
}

.q__help {
    margin: 0.4rem 0 0.8rem;
    color: var(--ink-soft);
    font-size: 0.92rem;
    font-style: italic;
}

.q__options {
    margin-top: 0.75rem;
}

.opt {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    min-height: var(--tap);
    padding: 0.55rem 0.6rem;
    border: 1px solid transparent;
    border-radius: var(--radius);
    cursor: pointer;
}

.opt:hover {
    background: var(--paper);
}

.opt input {
    width: 1.5rem;
    height: 1.5rem;
    margin-top: 0.15rem;
    flex: 0 0 auto;
    accent-color: var(--accent);
}

/* Checked options need to be obvious from a metre away when an invigilator is
   helping a learner who cannot see the screen well. */
.opt:has(input:checked) {
    background: #eef4f9;
    border-color: var(--accent);
}

.opt__text {
    flex: 1 1 auto;
}

.q__input {
    -webkit-user-select: text;
    user-select: text;
    display: block;
    width: 100%;
    min-height: var(--tap);
    margin-top: 0.75rem;
    padding: 0.6rem 0.75rem;
    font: inherit;
    color: var(--ink);
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.q__input--text {
    min-height: 6rem;
    resize: vertical;
}

.q__clear {
    margin-top: 0.5rem;
    padding: 0.35rem 0;
    background: none;
    border: 0;
    color: var(--ink-soft);
    font: inherit;
    font-size: 0.9rem;
    text-decoration: underline;
    cursor: pointer;
}

/* ------------------------------------------------------------- buttons --- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: var(--tap);
    padding: 0.7rem 1.4rem;
    font: inherit;
    font-weight: 600;
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    cursor: pointer;
}

.btn--primary {
    background: var(--accent);
    color: var(--accent-ink);
}

.btn--quiet {
    background: var(--card);
    color: var(--ink);
}

.btn--large {
    font-size: 1.2rem;
    padding: 1rem 2.2rem;
}

.btn--stop {
    display: block;
    width: 100%;
    margin-top: 1.5rem;
    background: var(--card);
    border-color: var(--danger);
    color: var(--danger);
}

.btn[disabled] {
    opacity: 0.6;
    cursor: default;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

.actions--nav {
    justify-content: space-between;
}

/* --------------------------------------------------------------- alerts --- */

.alert {
    padding: 0.85rem 1rem;
    border-radius: var(--radius);
    margin: 1rem 0;
}

.alert--error {
    background: #fdecec;
    border: 1px solid var(--danger);
    color: var(--danger);
}

.field__label {
    display: block;
    margin-top: 1.25rem;
    font-weight: 600;
}

/* ----------------------------------------------------------- idle lock --- */

/* Covers the whole screen. An abandoned tablet showing a half-answered form
   about discipline at home is the worst thing that can happen in the hall. */
.idle {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 2rem;
    text-align: center;
    background: var(--paper);
}

.idle__text {
    font-size: 1.6rem;
    font-weight: 600;
    margin: 0;
}

.idle__note {
    max-width: 28rem;
    margin: 0;
    color: var(--ink-soft);
}

/* --------------------------------------------------------- help footer --- */

.help-footer {
    margin-top: 2.5rem;
    padding: 1rem;
    background: #eef4f9;
    border-radius: var(--radius);
}

.help-footer__title {
    margin: 0 0 0.35rem;
    font-weight: 600;
}

.help-footer__text {
    margin: 0;
    font-size: 0.95rem;
    color: var(--ink-soft);
}

/* ---------------------------------------------------------------- a11y --- */

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

@media (prefers-reduced-motion: reduce) {
    .progress__fill {
        transition: none;
    }
}

@media (min-width: 48rem) {
    body {
        font-size: 19px;
    }

    .app {
        padding: 2rem 1.5rem 5rem;
    }
}
