/* ============================================================
   Qualification wizard styles (global)

   Global, not scoped, for the same reason as course-picker.css:
   the wizard markup spans several child components (TypePickerStep,
   GcseSubjectGrid, SubjectEntry, GradePicker, ManualEntryForm,
   QualificationCard), each with a different Blazor scope id.
   Uses Fluent design tokens throughout. The qw-seg segmented
   control mirrors Settings.razor.css .seg (scoped there, so
   duplicated here with a qw- prefix).
   ============================================================ */

/* ── Sheet / panel ──────────────────────────────────────── */

.qw-overlay {
    position: fixed;
    inset: 0;
    z-index: 1150;
    background: rgba(0, 0, 0, 0.35);
}

/* Desktop: centred panel. */
.qw-sheet {
    position: fixed;
    z-index: 1151;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: min(720px, calc(100vw - 32px));
    max-height: min(85vh, 720px);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 16px 20px calc(20px + env(safe-area-inset-bottom, 0px));
    background: var(--colorNeutralBackground1);
    border-radius: 12px;
    box-shadow: var(--shadow16, 0 8px 32px rgba(0, 0, 0, 0.24));
}

/* Mobile: full-screen sheet. */
@media (max-width: 768px) {
    .qw-sheet {
        left: 0;
        top: 0;
        transform: none;
        width: 100%;
        height: 100dvh;
        max-height: none;
        border-radius: 0;
    }
}

.qw-head {
    display: flex;
    align-items: center;
    gap: 8px;
}

.qw-title {
    flex: 1 1 auto;
    margin: 0;
    font-size: var(--fontSizeBase500);
    font-weight: var(--fontWeightSemibold);
    color: var(--colorNeutralForeground1);
    outline: none;
}

.qw-back,
.qw-close {
    flex-shrink: 0;
    min-width: 44px;
    min-height: 44px;
    border: 0;
    border-radius: var(--borderRadiusMedium);
    background: transparent;
    color: var(--colorNeutralForeground2);
    font-size: 18px;
    cursor: pointer;
    transition: background-color .12s ease, color .12s ease;
}

.qw-back:hover,
.qw-close:hover {
    background: var(--colorNeutralBackground3);
    color: var(--colorNeutralForeground1);
}

/* ── Step 1: type cards ─────────────────────────────────── */

.qw-type-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.qw-type-card {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    min-height: 64px;
    padding: 16px;
    border: 1px solid var(--colorNeutralStroke1);
    border-radius: var(--borderRadiusMedium);
    background: var(--colorNeutralBackground1);
    color: var(--colorNeutralForeground1);
    font-family: inherit;
    text-align: left;
    cursor: pointer;
    transition: border-color .12s ease, box-shadow .12s ease;
}

.qw-type-card:hover {
    border-color: var(--colorBrandStroke1);
    box-shadow: var(--shadow4);
}

.qw-type-name {
    font-size: var(--fontSizeBase400);
    font-weight: var(--fontWeightSemibold);
}

.qw-type-sub {
    font-size: var(--fontSizeBase200);
    color: var(--colorNeutralForeground2);
}

/* ── Step 2: subject grid ───────────────────────────────── */

.qw-subject-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
}

.qw-gcse-sections {
    display: flex;
    flex-direction: column;
    gap: 22px;
}

.qw-gcse-section h3 {
    margin: 0 0 9px;
    color: var(--colorBrandForeground1);
    font-size: var(--fontSizeBase300);
    font-weight: var(--fontWeightSemibold);
}

@media (max-width: 600px) {
    .qw-subject-grid {
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    }
}

.qw-subject-card {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    min-height: 56px;
    padding: 12px;
    border: 1px solid var(--colorNeutralStroke1);
    border-radius: var(--borderRadiusMedium);
    background: var(--colorNeutralBackground1);
    color: var(--colorNeutralForeground1);
    font-family: inherit;
    font-size: var(--fontSizeBase300);
    text-align: left;
    cursor: pointer;
    transition: border-color .12s ease, box-shadow .12s ease;
}

.qw-subject-card:hover {
    border-color: var(--colorBrandStroke1);
    box-shadow: var(--shadow4);
}

.qw-subject-other {
    grid-column: 1 / -1;
    color: var(--colorBrandForeground1);
    font-weight: var(--fontWeightSemibold);
}

.qw-grade-chip {
    font-size: 11px;
    font-weight: var(--fontWeightSemibold);
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--colorBrandBackground2);
    color: var(--colorBrandForeground1);
    white-space: nowrap;
}

/* Subjects that already have a grade — sorted to the top of the grid and
   tinted green so "done" reads at a glance. */
.qw-subject-done {
    background: var(--colorStatusSuccessBackground1, #f1faf1);
    border-color: var(--colorStatusSuccessBorder1, #9fd89f);
}

.qw-subject-done:hover {
    border-color: var(--colorStatusSuccessForeground1, #0e700e);
}

.qw-subject-done .qw-grade-chip {
    background: var(--colorStatusSuccessBackground2, #9fd89f);
    color: var(--colorStatusSuccessForeground2, #0e700e);
}

/* ── Free-text fields (subject entry, other grade) ──────── */

.qw-field {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.qw-label {
    font-size: var(--fontSizeBase300);
    font-weight: var(--fontWeightSemibold);
    color: var(--colorNeutralForeground1);
}

.qw-input {
    width: 100%;
    min-height: 44px;
    padding: 0 12px;
    border: 1px solid var(--colorNeutralStroke1);
    border-radius: var(--borderRadiusMedium);
    /* 16px so iOS Safari doesn't zoom the viewport on focus. */
    font-size: var(--fontSizeBase400);
    background: var(--colorNeutralBackground1);
    color: var(--colorNeutralForeground1);
    transition: border-color .12s ease, box-shadow .12s ease;
}

.qw-input:focus {
    outline: none;
    border-color: var(--colorBrandStroke1);
    box-shadow: 0 0 0 2px var(--colorBrandBackground2);
}

.qw-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.qw-suggestion {
    min-height: 36px;
    padding: 4px 12px;
    border: 1px solid var(--colorNeutralStroke1);
    border-radius: 999px;
    background: var(--colorNeutralBackground2);
    color: var(--colorNeutralForeground1);
    font-family: inherit;
    font-size: var(--fontSizeBase200);
    cursor: pointer;
    transition: border-color .12s ease, background-color .12s ease;
}

.qw-suggestion:hover {
    border-color: var(--colorBrandStroke1);
    background: var(--colorBrandBackground2);
}

@media (pointer: coarse) {
    .qw-suggestion {
        min-height: 44px;
    }
}

.qw-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* ── Step 3: segmented toggle + grade cards ─────────────── */

/* Mirrors Settings.razor.css .seg (scoped there, so duplicated). */
.qw-seg {
    display: inline-flex;
    align-items: center;
    align-self: flex-start;
    gap: 2px;
    padding: 3px;
    border: 1px solid var(--colorNeutralStroke2);
    border-radius: 9px;
    background: var(--colorNeutralBackground2);
}

.qw-seg-option {
    appearance: none;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--colorNeutralForeground2);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 34px;
    padding: 0 14px;
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    transition: background-color .15s ease, color .15s ease, box-shadow .15s ease;
}

@media (pointer: coarse) {
    .qw-seg-option {
        min-height: 44px;
    }
}

.qw-seg-option:hover {
    color: var(--colorBrandForeground1);
    background: var(--colorBrandBackground2);
}

.qw-seg-option.active {
    background: var(--colorBrandBackground);
    color: var(--colorNeutralForegroundOnBrand);
    box-shadow: var(--shadow2);
}

.qw-seg-option.active:hover {
    color: var(--colorNeutralForegroundOnBrand);
}

.qw-grade-step {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.qw-grade-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(52px, 1fr));
    gap: 8px;
}

/* 9-1 (and letter) GCSE scales sit on a single row, low → high; small
   minimum so all ten cards fit the sheet, wrapping only on narrow phones. */
.qw-grade-grid--row {
    grid-template-columns: repeat(auto-fit, minmax(44px, 1fr));
}

.qw-grade-card {
    width: 100%;
    min-width: 0;
    min-height: 48px;
    padding: 0 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--colorNeutralStroke1);
    border-radius: var(--borderRadiusMedium);
    background: var(--colorNeutralBackground1);
    color: var(--colorNeutralForeground1);
    font-family: inherit;
    font-size: var(--fontSizeBase400);
    font-weight: var(--fontWeightSemibold);
    cursor: pointer;
    transition: border-color .12s ease, background-color .12s ease;
}

.qw-grade-card:hover {
    border-color: var(--colorBrandStroke1);
    background: var(--colorBrandBackground2);
}

.qw-grade-card[aria-checked="true"] {
    background: var(--colorBrandBackground);
    border-color: var(--colorBrandBackground);
    color: var(--colorNeutralForegroundOnBrand);
}

.qw-link {
    align-self: flex-start;
    min-height: 44px;
    border: 0;
    background: transparent;
    color: var(--colorBrandForegroundLink);
    cursor: pointer;
    font-family: inherit;
    font-size: var(--fontSizeBase300);
    padding: 0;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.qw-link:hover {
    color: var(--colorBrandForegroundLinkHover, var(--colorBrandForeground1));
}

/* ── Manual form ────────────────────────────────────────── */

.qw-manual {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* ── Review list — grouped by type, one table per group ──
   Each type (GCSE, A Level, BTEC …) is its own section with a plain table:
   Subject | Grade (the headline — large, brand-coloured) | Predicted/Actual
   | Edit/Remove. No save-state pill — the page's summary handles feedback. */

.qw-review {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.qw-group-heading {
    margin: 0 0 10px;
    font-size: var(--fontSizeBase200);
    font-weight: var(--fontWeightSemibold);
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--colorNeutralForeground3, var(--colorNeutralForeground2));
}

.qw-table {
    width: 100%;
    border-collapse: collapse;
}

.qw-table th {
    padding: 6px 16px 6px 0;
    text-align: left;
    font-size: var(--fontSizeBase200);
    font-weight: var(--fontWeightSemibold);
    color: var(--colorNeutralForeground3, var(--colorNeutralForeground2));
    border-bottom: 1px solid var(--colorNeutralStroke2);
}

.qw-table td {
    padding: 10px 16px 10px 0;
    vertical-align: middle;
    border-bottom: 1px solid var(--colorNeutralStroke2);
}

.qw-table-subject {
    font-size: var(--fontSizeBase300);
    font-weight: var(--fontWeightSemibold);
    color: var(--colorNeutralForeground1);
}

/* Grade — the headline of the row: large, plain, brand-coloured */
.qw-table-grade {
    font-size: 26px;
    font-weight: 700;
    line-height: 1;
    color: var(--colorBrandForeground1);
    white-space: nowrap;
}

th.qw-table-actions,
td.qw-table-actions {
    width: 1%;
    padding-right: 0;
    text-align: right;
    white-space: nowrap;
}

.qw-status {
    font-size: 11px;
    font-weight: 600;
    color: var(--colorNeutralForeground3, var(--colorNeutralForeground2));
}

.qw-status.actual {
    color: var(--colorStatusSuccessForeground1, #0e700e);
}

.qw-card-action {
    border: 0;
    background: transparent;
    cursor: pointer;
    color: var(--colorBrandForegroundLink);
    font-family: inherit;
    font-size: var(--fontSizeBase200);
    padding: 6px 6px;
    border-radius: var(--borderRadiusMedium);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.qw-card-remove,
.qw-card-remove:hover {
    color: var(--colorStatusDangerForeground1, #b10e1c);
}

@media (pointer: coarse) {
    .qw-card-action {
        min-width: 44px;
        min-height: 44px;
    }
}

/* Mobile: tighten the table so four columns still fit. */
@media (max-width: 600px) {
    .qw-table th,
    .qw-table td {
        padding-right: 10px;
    }

    .qw-table-grade {
        font-size: 22px;
    }
}

/* ── "Where are you with your grades?" gate ──────────────
   One-off question shown before the qualifications list; the answer
   replaces the wizard's per-add Predicted/Actual toggle. */

.qual-gate-title {
    margin: 0 0 10px;
    font-size: var(--fontSizeBase500);
    font-weight: var(--fontWeightSemibold);
    color: var(--colorNeutralForeground1);
}

.qual-gate-question {
    margin: 14px 0 10px;
}

.qual-gate-options {
    display: grid;
    gap: 10px;
}

.qual-gate-option {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    padding: 14px 16px;
    border: 1px solid var(--colorNeutralStroke1);
    border-radius: var(--borderRadiusMedium);
    background: var(--colorNeutralBackground1);
    color: var(--colorNeutralForeground1);
    font-family: inherit;
    text-align: left;
    cursor: pointer;
    transition: border-color .12s ease, box-shadow .12s ease;
}

.qual-gate-option:hover {
    border-color: var(--colorBrandStroke1);
    box-shadow: var(--shadow4);
}

.qual-gate-option-title {
    font-size: var(--fontSizeBase400);
    font-weight: var(--fontWeightSemibold);
}

.qual-gate-option-sub {
    font-size: var(--fontSizeBase200);
    color: var(--colorNeutralForeground2);
}

.qual-gate-hint {
    margin: 12px 0 0;
    font-size: var(--fontSizeBase200);
    color: var(--colorNeutralForeground3, var(--colorNeutralForeground2));
}

/* Answer recap + "Change answer" link above the qualifications list. */
.qual-mode-note {
    display: flex;
    align-items: baseline;
    gap: 10px;
    flex-wrap: wrap;
    margin: 0 0 12px;
    color: var(--colorNeutralForeground2);
    font-size: var(--fontSizeBase300);
}

/* ── Reduced motion ─────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
    .qw-type-card,
    .qw-subject-card,
    .qw-grade-card,
    .qw-suggestion,
    .qw-seg-option,
    .qw-input,
    .qw-back,
    .qw-close,
    .qual-gate-option {
        transition: none;
    }
}
