/* ──────────────────────────────────────────────────────────────────────
   OWC Knowledge Quest — mobile-first stylesheet.
   Design language borrowed from QualifyIQ's public assessment:
   slate-50 canvas, white cards, 16px radii, sticky progress header,
   sticky thumb-reach footer, >=48px tap targets.
   ────────────────────────────────────────────────────────────────────── */

:root {
    --bg:            #f8fafc;
    --surface:       #ffffff;
    --surface-soft:  #f1f5f9;
    --border:        #e2e8f0;
    --border-strong: #cbd5e1;
    --text:          #0f172a;
    --muted:         #475569;
    --faint:         #94a3b8;

    --primary:       #0b4f6c;
    --primary-dark:  #083a50;
    --primary-soft:  #e6f1f6;
    --accent:        #2563eb;
    --success:       #16a34a;
    --success-soft:  #f0fdf4;
    --danger:        #dc2626;
    --danger-soft:   #fef2f2;

    --radius:        16px;
    --radius-lg:     24px;
    --radius-sm:     10px;
    --shadow:        0 1px 2px rgba(15, 23, 42, .04);
    --shadow-lg:     0 10px 30px rgba(15, 23, 42, .07);

    --tap:           52px;
}

* { box-sizing: border-box; }

html {
    background: var(--bg);
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    min-height: 100dvh;
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--text);
    background: var(--bg);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--accent); }

.shell {
    display: flex;
    flex-direction: column;
    min-height: 100dvh;
}

.wrap {
    width: 100%;
    max-width: 44rem;
    margin: 0 auto;
    padding: 0 16px;
}

/* ── Sticky progress header ─────────────────────────────────────────── */

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    background: rgba(255, 255, 255, .95);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border);
    padding: 10px 0 12px;
}

.topbar-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    font-size: 13px;
    color: var(--muted);
}

.topbar-chapter { font-weight: 600; color: var(--text); }

.topbar-count {
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    color: var(--faint);
    font-size: 12px;
}

.topbar-sub {
    font-size: 11px;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--faint);
    margin: 1px 0 0;
}

.bar {
    margin-top: 9px;
    height: 6px;
    border-radius: 999px;
    background: var(--surface-soft);
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    border-radius: 999px;
    background: var(--primary);
    transition: width .35s ease;
}

/* Chapter pips */
.pips { display: flex; gap: 6px; margin-top: 10px; }

.pip {
    flex: 1;
    height: 4px;
    border-radius: 999px;
    background: var(--border);
    text-decoration: none;
}

.pip.is-done    { background: var(--success); }
.pip.is-current { background: var(--primary); }

/* Chapters ahead of the current one are not reachable yet. */
.pip.is-locked {
    background: var(--border);
    opacity: .5;
    cursor: not-allowed;
}

/* ── Main ───────────────────────────────────────────────────────────── */

.main { flex: 1 1 auto; padding: 22px 0 28px; }

.page-head { margin-bottom: 22px; }

.eyebrow {
    font-size: 11px;
    letter-spacing: .2em;
    text-transform: uppercase;
    color: var(--faint);
    margin: 0 0 6px;
    font-weight: 600;
}

h1 { font-size: 26px; line-height: 1.25; margin: 0 0 8px; letter-spacing: -.02em; }
h2 { font-size: 19px; line-height: 1.3;  margin: 0 0 6px; letter-spacing: -.01em; }

.lede { color: var(--muted); margin: 0; font-size: 15px; }

/* ── Cards ──────────────────────────────────────────────────────────── */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px;
    margin-bottom: 14px;
}

.card-lg { border-radius: var(--radius-lg); padding: 24px 20px; box-shadow: var(--shadow-lg); }

/* ── Question blocks ────────────────────────────────────────────────── */

.q {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px;
    margin-bottom: 12px;
    scroll-margin-top: 110px;
    transition: border-color .2s ease;
}

.q.is-answered { border-color: #bbf7d0; }

/* The question the student was sent back to answer. */
.q.is-missing {
    border-color: #fbbf24;
    box-shadow: 0 0 0 3px rgba(251, 191, 36, .18);
    animation: nudge .5s ease;
}

.q.is-missing .q-num { background: #fef3c7; color: #92400e; }

@keyframes nudge {
    0%, 100% { transform: translateX(0); }
    25%      { transform: translateX(-4px); }
    75%      { transform: translateX(4px); }
}

.q-head { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 12px; }

.q-num {
    flex: 0 0 auto;
    min-width: 26px;
    height: 26px;
    border-radius: 8px;
    background: var(--primary-soft);
    color: var(--primary);
    font-size: 12px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    font-variant-numeric: tabular-nums;
    margin-top: 2px;
    padding: 0 6px;
    transition: background .2s ease, color .2s ease;
}

.q.is-answered .q-num { background: var(--success); color: #fff; }

.q-prompt {
    font-size: 15.5px;
    font-weight: 600;
    line-height: 1.45;
    color: var(--text);
}

.q-body { display: flex; flex-direction: column; gap: 10px; }

/* Labelled / numbered sub-answers */
.sub { display: flex; align-items: center; gap: 10px; }

.sub-label {
    flex: 0 0 auto;
    min-width: 26px;
    font-weight: 700;
    color: var(--primary);
    font-size: 14px;
}

.sub-label.is-wide {
    min-width: 0;
    flex: 0 0 100%;
    font-weight: 600;
    color: var(--muted);
    font-size: 13px;
    margin-bottom: -4px;
}

.sub.is-stacked { flex-wrap: wrap; }

/* ── Inputs ─────────────────────────────────────────────────────────── */

.input, .textarea {
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    font-size: 16px; /* 16px stops iOS Safari zooming on focus */
    line-height: 1.5;
    color: var(--text);
    transition: border-color .15s ease, box-shadow .15s ease;
    -webkit-appearance: none;
}

.input { min-height: 48px; }

.textarea {
    min-height: 92px;
    resize: vertical;
    overflow: hidden; /* JS auto-grows it */
}

.input:focus, .textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(11, 79, 108, .13);
}

.input::placeholder, .textarea::placeholder { color: #b6c2cf; }

/* ── Multiple-choice options ────────────────────────────────────────── */

.choices { display: flex; flex-direction: column; gap: 8px; }

.choice { display: block; position: relative; }

.choice input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.choice-box {
    display: flex;
    align-items: flex-start;
    gap: 11px;
    min-height: 52px;            /* comfortably above the 44px touch minimum */
    padding: 13px 14px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background: var(--surface);
    cursor: pointer;
    transition: border-color .15s ease, background .15s ease, box-shadow .15s ease;
    -webkit-tap-highlight-color: transparent;
}

.choice-letter {
    flex: 0 0 auto;
    width: 26px;
    height: 26px;
    border-radius: 999px;
    border: 1.5px solid var(--border-strong);
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all .15s ease;
}

.choice-text {
    flex: 1 1 auto;
    font-size: 15.5px;
    line-height: 1.45;
    color: var(--text);
    padding-top: 2px;
}

.choice input:checked + .choice-box {
    border-color: var(--primary);
    background: var(--primary-soft);
    box-shadow: 0 1px 6px rgba(11, 79, 108, .13);
}

.choice input:checked + .choice-box .choice-letter {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.choice input:focus-visible + .choice-box {
    box-shadow: 0 0 0 3px rgba(11, 79, 108, .25);
}

@media (hover: hover) {
    .choice-box:hover { border-color: var(--primary); }
}

/* True/False sits side by side where there is room. */
@media (min-width: 400px) {
    .choices.is-tf { flex-direction: row; }
    .choices.is-tf .choice { flex: 1 1 0; }
    .choices.is-tf .choice-box { justify-content: center; }
    .choices.is-tf .choice-text { flex: 0 0 auto; padding-top: 0; }
}

/* ── Sticky footer ──────────────────────────────────────────────────── */

.footbar {
    position: sticky;
    bottom: 0;
    z-index: 20;
    background: rgba(255, 255, 255, .96);
    backdrop-filter: blur(8px);
    border-top: 1px solid var(--border);
    padding: 10px 0 calc(10px + env(safe-area-inset-bottom));
}

.footbar-row { display: flex; align-items: center; gap: 10px; }

.savestate {
    text-align: center;
    font-size: 12px;
    color: var(--faint);
    margin: 7px 0 0;
    min-height: 16px;
    transition: color .2s ease;
}

.savestate.is-saving { color: var(--muted); }
.savestate.is-saved  { color: var(--success); }
.savestate.is-error  { color: var(--danger); }

/* ── Buttons ────────────────────────────────────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: var(--tap);
    padding: 0 20px;
    border-radius: var(--radius);
    border: 1px solid transparent;
    background: var(--primary);
    color: #fff;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background .15s ease, transform .08s ease, opacity .15s ease;
    -webkit-tap-highlight-color: transparent;
}

.btn:hover  { background: var(--primary-dark); }
.btn:active { transform: translateY(1px); }

.btn:focus-visible { outline: 3px solid rgba(11, 79, 108, .35); outline-offset: 2px; }

.btn-block { width: 100%; }
.btn-grow  { flex: 1 1 auto; }

.btn-ghost {
    background: transparent;
    color: var(--muted);
    border-color: var(--border-strong);
    padding: 0 16px;
    flex: 0 0 auto;
}

.btn-ghost:hover { background: var(--surface-soft); color: var(--text); }

.btn-success { background: var(--success); }
.btn-success:hover { background: #15803d; }

.btn[disabled], .btn[aria-disabled="true"] {
    opacity: .5;
    cursor: not-allowed;
    pointer-events: none;
}

.btn-sm { min-height: 40px; font-size: 14px; padding: 0 14px; border-radius: 12px; }

/* Chapter not finished yet. Still tappable on purpose — tapping it is how the
   student gets taken to the question they missed. */
.btn.is-gated {
    background: var(--surface);
    color: var(--muted);
    border-color: var(--border-strong);
}

.btn.is-gated:hover { background: var(--surface-soft); color: var(--text); }

/* ── Notices ────────────────────────────────────────────────────────── */

.notice {
    border-radius: var(--radius);
    padding: 13px 15px;
    font-size: 14.5px;
    margin-bottom: 16px;
    border: 1px solid transparent;
    line-height: 1.55;
}

.notice-info    { background: var(--primary-soft); border-color: #cfe3ec; color: #0a4257; }
.notice-success { background: var(--success-soft); border-color: #bbf7d0; color: #14532d; }
.notice-error   { background: var(--danger-soft);  border-color: #fecaca; color: #991b1b; }
.notice-warn    { background: #fffbeb;             border-color: #fde68a; color: #854d0e; }

.notice strong { font-weight: 700; }

/* ── Login ──────────────────────────────────────────────────────────── */

.centered {
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 28px 0;
}

.brandmark {
    text-align: center;
    margin-bottom: 22px;
}

.brandmark .eyebrow { margin-bottom: 8px; }

.field { margin-bottom: 16px; }

.label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
}

.hint { font-size: 12.5px; color: var(--faint); margin: 6px 0 0; line-height: 1.5; }

/* ── Review list ────────────────────────────────────────────────────── */

.chapter-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    margin-bottom: 10px;
    text-decoration: none;
    color: inherit;
    box-shadow: var(--shadow);
    transition: border-color .15s ease, transform .08s ease;
}

.chapter-row:hover { border-color: var(--border-strong); }
.chapter-row:active { transform: translateY(1px); }

.chapter-row-main { flex: 1 1 auto; min-width: 0; }

/* Both must be block: as inline spans they sat on one line for short
   subtitles and wrapped for long ones, so no two rows lined up. */
.chapter-row-title {
    display: block;
    font-weight: 600;
    font-size: 15px;
    line-height: 1.35;
}

.chapter-row-sub {
    display: block;
    font-size: 12.5px;
    color: var(--faint);
    margin-top: 1px;
    line-height: 1.45;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tally {
    flex: 0 0 auto;
    font-size: 12.5px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    padding: 5px 11px;
    border-radius: 999px;
    background: var(--surface-soft);
    color: var(--muted);
    white-space: nowrap;
}

.tally.is-complete { background: var(--success-soft); color: #15803d; }

.chev { flex: 0 0 auto; color: var(--faint); font-size: 18px; line-height: 1; }

/* ── Misc ───────────────────────────────────────────────────────────── */

.stack-gap { height: 10px; }

.center { text-align: center; }

.muted { color: var(--muted); }

.sr-only {
    position: absolute; width: 1px; height: 1px;
    padding: 0; margin: -1px; overflow: hidden;
    clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

.big-tick {
    width: 64px; height: 64px;
    border-radius: 999px;
    background: var(--success-soft);
    color: var(--success);
    display: flex; align-items: center; justify-content: center;
    font-size: 32px; font-weight: 700;
    margin: 0 auto 18px;
    border: 2px solid #bbf7d0;
}

@media (min-width: 640px) {
    h1 { font-size: 30px; }
    .main { padding: 30px 0 36px; }
    .q { padding: 20px; }
    .card-lg { padding: 30px 28px; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; }
}

/* ── Result panel (done page) ───────────────────────────────────────── */

.scorepanel {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 18px;
    border-radius: var(--radius);
    border: 1.5px solid;
    margin: 20px 0 18px;
}

.scorepanel.is-pass { background: var(--success-soft); border-color: #bbf7d0; }
.scorepanel.is-fail { background: var(--danger-soft);  border-color: #fecaca; }

.score-verdict {
    flex: 0 0 auto;
    font-size: 19px;
    font-weight: 800;
    letter-spacing: 2px;
    padding: 12px 14px;
    border-radius: 12px;
    background: #fff;
}

.is-pass .score-verdict { color: #15803d; }
.is-fail .score-verdict { color: #b91c1c; }

.score-figures { flex: 1 1 auto; min-width: 0; }

.score-big {
    font-size: 34px;
    font-weight: 800;
    line-height: 1;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}

.score-big span { font-size: 18px; color: var(--faint); font-weight: 600; }

.score-sub { font-size: 13px; color: var(--muted); margin-top: 5px; }
