/* =============================================================================
   Classroom Seating Plan Organiser
   Core stylesheet: tokens, layout, controls.

   The palette is built from four classroom pastels (mint, lilac, sky, butter)
   against near-white paper, with one deep teal that carries every primary
   action. Colour is never the only signal: every state also has a label, an
   outline or an icon, so the app works for colour-blind users and in the
   high-contrast theme.
   ========================================================================== */

:root {
    /* Surfaces and text */
    --paper:        #f7f9fb;
    --surface:      #ffffff;
    --surface-sunk: #f2f5f9;
    --ink:          #1d2433;
    --ink-soft:     #5b6478;
    --ink-faint:    #8b95a8;
    --line:         #e4e8ef;
    --line-strong:  #cfd6e2;

    /* Classroom pastels */
    --mint:       #d8ebe0;
    --mint-deep:  #3d6b58;
    --lilac:      #e4dff5;
    --lilac-deep: #55497f;
    --sky:        #d7e7f7;
    --sky-deep:   #2f5f85;
    --butter:     #f9e8c9;
    --butter-deep:#8a6524;
    --blush:      #f8dfe2;
    --blush-deep: #9c3a45;

    /* Action colour */
    --accent:        #2f6b60;
    --accent-hover:  #255449;
    --accent-soft:   #e4f0ec;
    --accent-ring:   rgba(47, 107, 96, 0.35);

    /* Shape and depth */
    --radius-sm: 7px;
    --radius:    11px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 2px rgba(29, 36, 51, 0.05);
    --shadow:    0 2px 10px rgba(29, 36, 51, 0.07);
    --shadow-lg: 0 12px 40px rgba(29, 36, 51, 0.16);

    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
            "PingFang SC", "Microsoft YaHei", Arial, sans-serif;

    --header-height: 60px;
}

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

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

body {
    margin: 0;
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.55;
    color: var(--ink);
    background: var(--paper);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0 0 0.5rem; line-height: 1.25; font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: 1.7rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.02rem; }
p  { margin: 0 0 0.85rem; }
p:last-child { margin-bottom: 0; }

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--accent-hover); }

img { max-width: 100%; }

:focus-visible {
    outline: 3px solid var(--accent-ring);
    outline-offset: 2px;
    border-radius: 4px;
}

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

.skip-link {
    position: absolute;
    left: 0.75rem;
    top: -3rem;
    z-index: 100;
    background: var(--surface);
    padding: 0.6rem 1rem;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    transition: top 0.15s ease;
}
.skip-link:focus { top: 0.75rem; }

/* -----------------------------------------------------------------------------
   Page frame
   -------------------------------------------------------------------------- */
.site-header {
    height: var(--header-height);
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    padding: 0 1.25rem;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 30;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    font-weight: 650;
    color: var(--ink);
    text-decoration: none;
    font-size: 0.97rem;
}

.brand__mark {
    width: 30px; height: 30px;
    border-radius: 8px;
    background: var(--mint);
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 2px;
    padding: 5px;
}
.brand__mark span {
    background: var(--mint-deep);
    border-radius: 1.5px;
    opacity: 0.85;
}
.brand__mark span:nth-child(3) { opacity: 0.35; }

.site-nav {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.site-nav a {
    color: var(--ink-soft);
    text-decoration: none;
    font-size: 0.9rem;
    padding: 0.4rem 0.7rem;
    border-radius: var(--radius-sm);
}
.site-nav a:hover { background: var(--surface-sunk); color: var(--ink); }
.site-nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.container {
    max-width: 1060px;
    margin: 0 auto;
    padding: 2rem 1.25rem 4rem;
}
.container--narrow { max-width: 460px; }
.container--wide   { max-width: 1320px; }

.page-head { margin-bottom: 1.75rem; }
.page-head p { color: var(--ink-soft); max-width: 62ch; }

.site-footer {
    border-top: 1px solid var(--line);
    padding: 1.25rem;
    text-align: center;
    color: var(--ink-faint);
    font-size: 0.82rem;
}
.site-footer a { color: var(--ink-soft); }

/* -----------------------------------------------------------------------------
   Cards and panels
   -------------------------------------------------------------------------- */
.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
}
.card--flush { padding: 0; overflow: hidden; }
.card__head {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}
.card__head h2 { margin: 0; font-size: 1.02rem; }
.card__head .spacer { margin-left: auto; }

.stack > * + * { margin-top: 1rem; }
.stack-sm > * + * { margin-top: 0.5rem; }
.row { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: center; }
.row--end { justify-content: flex-end; }
.spacer { margin-left: auto; }

/* Primary dashboard actions ------------------------------------------------- */
.action-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.9rem;
    margin-bottom: 2rem;
}

.action-tile {
    display: block;
    text-decoration: none;
    color: inherit;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1.15rem 1.2rem;
    box-shadow: var(--shadow-sm);
}
.action-tile:hover { border-color: var(--line-strong); box-shadow: var(--shadow); }
.action-tile strong { display: block; font-size: 1rem; margin-bottom: 0.2rem; }
.action-tile span { color: var(--ink-soft); font-size: 0.86rem; }

.action-tile--primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}
.action-tile--primary span { color: rgba(255, 255, 255, 0.85); }
.action-tile--primary:hover { background: var(--accent-hover); }

.tile-icon {
    width: 34px; height: 34px;
    border-radius: 9px;
    background: var(--accent-soft);
    display: flex; align-items: center; justify-content: center;
    margin-bottom: 0.7rem;
    font-size: 1.05rem;
}
.action-tile--primary .tile-icon { background: rgba(255, 255, 255, 0.18); }

/* -----------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    font: inherit;
    font-size: 0.9rem;
    font-weight: 560;
    line-height: 1.2;
    padding: 0.58rem 0.95rem;
    min-height: 40px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line-strong);
    background: var(--surface);
    color: var(--ink);
    cursor: pointer;
    text-decoration: none;
    transition: background 0.12s ease, border-color 0.12s ease;
}
.btn:hover { background: var(--surface-sunk); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; }

.btn--primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}
.btn--primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }

.btn--danger { color: var(--blush-deep); border-color: #e9c7cb; background: #fdf6f7; }
.btn--danger:hover { background: var(--blush); }

.btn--ghost { border-color: transparent; background: transparent; }
.btn--ghost:hover { background: var(--surface-sunk); }

.btn--sm { min-height: 32px; padding: 0.3rem 0.6rem; font-size: 0.82rem; }
.btn--lg { min-height: 46px; padding: 0.7rem 1.3rem; font-size: 0.97rem; }
.btn--block { width: 100%; }

/* -----------------------------------------------------------------------------
   Forms
   -------------------------------------------------------------------------- */
.field { margin-bottom: 1rem; }
.field label, .label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.3rem;
    color: var(--ink);
}
.field .hint {
    display: block;
    font-size: 0.8rem;
    color: var(--ink-soft);
    margin-top: 0.28rem;
}

input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="search"], select, textarea {
    width: 100%;
    font: inherit;
    font-size: 0.92rem;
    padding: 0.55rem 0.7rem;
    min-height: 40px;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
}
input:focus, select:focus, textarea:focus {
    border-color: var(--accent);
    outline: 3px solid var(--accent-ring);
    outline-offset: 0;
}
textarea { min-height: 84px; resize: vertical; }
input[aria-invalid="true"], select[aria-invalid="true"] { border-color: var(--blush-deep); }

.field-error { color: var(--blush-deep); font-size: 0.82rem; margin-top: 0.28rem; }

.checkline { display: inline-flex; align-items: center; gap: 0.45rem; font-size: 0.9rem; }
.checkline input { width: 17px; height: 17px; min-height: 0; accent-color: var(--accent); }

fieldset { border: 0; padding: 0; margin: 0 0 1rem; }
legend { font-size: 0.85rem; font-weight: 600; padding: 0; margin-bottom: 0.4rem; }

/* Segmented choices --------------------------------------------------------- */
.choice-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.6rem;
}

.choice {
    position: relative;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    padding: 0.7rem 0.8rem;
    cursor: pointer;
    background: var(--surface);
    display: block;
}
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice strong { display: block; font-size: 0.9rem; font-weight: 600; }
.choice span { font-size: 0.8rem; color: var(--ink-soft); }
.choice:hover { border-color: var(--accent); }
.choice:has(input:checked) {
    border-color: var(--accent);
    background: var(--accent-soft);
    box-shadow: inset 0 0 0 1px var(--accent);
}
.choice:has(input:focus-visible) { outline: 3px solid var(--accent-ring); outline-offset: 2px; }

/* -----------------------------------------------------------------------------
   Messages
   -------------------------------------------------------------------------- */
.alert {
    border-radius: var(--radius-sm);
    padding: 0.75rem 0.95rem;
    font-size: 0.89rem;
    border: 1px solid transparent;
    margin-bottom: 1rem;
}
.alert strong { font-weight: 650; }
.alert--info    { background: var(--sky);   border-color: #bcd6ee; color: var(--sky-deep); }
.alert--success { background: var(--mint);  border-color: #b9dbc8; color: var(--mint-deep); }
.alert--warning { background: var(--butter);border-color: #ecd6a7; color: var(--butter-deep); }
.alert--error   { background: var(--blush); border-color: #eec2c8; color: var(--blush-deep); }

.alert ul { margin: 0.5rem 0 0; padding-left: 1.1rem; }
.alert li { margin-bottom: 0.2rem; }

/* Toast --------------------------------------------------------------------- */
.toast-region {
    position: fixed;
    bottom: 1.25rem;
    right: 1.25rem;
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    width: min(440px, calc(100vw - 2rem));
    pointer-events: none;
}

.toast {
    background: var(--ink);
    color: #fff;
    border-radius: var(--radius-sm);
    padding: 0.7rem 0.95rem;
    font-size: 0.88rem;
    box-shadow: var(--shadow-lg);
    display: flex;
    gap: 0.6rem;
    align-items: flex-start;
    pointer-events: auto;
}
.toast--error { background: #7e2b35; }
.toast--success { background: #2c5a4b; }
.toast--warning { background: #6f5418; }
.toast button {
    margin-left: auto;
    background: none; border: 0; color: inherit;
    opacity: 0.7; cursor: pointer; font-size: 1rem; line-height: 1; padding: 0 0.15rem;
}

@media (prefers-reduced-motion: no-preference) {
    .toast { animation: toast-in 0.18s ease-out; }
    @keyframes toast-in { from { opacity: 0; transform: translateY(6px); } }
}

/* -----------------------------------------------------------------------------
   Tables
   -------------------------------------------------------------------------- */
.table-wrap { overflow-x: auto; }

table.data {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}
table.data th, table.data td {
    text-align: left;
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}
table.data th {
    font-size: 0.78rem;
    font-weight: 620;
    color: var(--ink-soft);
    background: var(--surface-sunk);
    white-space: nowrap;
}
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover { background: #fbfcfe; }
table.data td input[type="text"], table.data td select { min-height: 34px; padding: 0.3rem 0.5rem; font-size: 0.87rem; }

.tag {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.12rem 0.42rem;
    border-radius: 5px;
    background: var(--surface-sunk);
    color: var(--ink-soft);
    border: 1px solid var(--line);
}
.tag--sen { background: var(--lilac); color: var(--lilac-deep); border-color: #cdc4ea; }
.tag--eal { background: var(--sky);   color: var(--sky-deep);   border-color: #bcd6ee; }

/* Plan list ----------------------------------------------------------------- */
.plan-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.9rem 1.25rem;
    border-bottom: 1px solid var(--line);
    flex-wrap: wrap;
}
.plan-row:last-child { border-bottom: 0; }
.plan-row__main { min-width: 0; flex: 1 1 260px; }
.plan-row__main a { font-weight: 620; text-decoration: none; color: var(--ink); }
.plan-row__main a:hover { color: var(--accent); text-decoration: underline; }
.plan-row__meta { font-size: 0.82rem; color: var(--ink-soft); margin-top: 0.15rem; }
.plan-row__meta span + span::before { content: "  ·  "; color: var(--ink-faint); }
.plan-row__actions { display: flex; gap: 0.35rem; flex-wrap: wrap; }

.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--ink-soft);
}
.empty-state h3 { color: var(--ink); }

/* -----------------------------------------------------------------------------
   Dialogs
   -------------------------------------------------------------------------- */
dialog {
    border: 0;
    border-radius: var(--radius-lg);
    padding: 0;
    box-shadow: var(--shadow-lg);
    max-width: min(560px, calc(100vw - 2rem));
    width: 100%;
    color: var(--ink);
    background: var(--surface);
}
dialog::backdrop { background: rgba(23, 30, 44, 0.45); }
.dialog__body { padding: 1.35rem; }
.dialog__body h2 { margin-bottom: 0.4rem; }
.dialog__foot {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    padding: 0.9rem 1.35rem;
    border-top: 1px solid var(--line);
    background: var(--surface-sunk);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    flex-wrap: wrap;
}

/* -----------------------------------------------------------------------------
   Wizard steps
   -------------------------------------------------------------------------- */
.steps {
    display: flex;
    gap: 0.5rem;
    list-style: none;
    padding: 0;
    margin: 0 0 1.5rem;
    flex-wrap: wrap;
    font-size: 0.85rem;
}
.steps li {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    color: var(--ink-faint);
    padding: 0.35rem 0.7rem 0.35rem 0.4rem;
    border-radius: 100px;
    background: var(--surface);
    border: 1px solid var(--line);
}
.steps li b {
    width: 22px; height: 22px;
    border-radius: 50%;
    background: var(--surface-sunk);
    color: var(--ink-soft);
    display: grid; place-items: center;
    font-size: 0.75rem;
}
.steps li[aria-current="step"] { color: var(--ink); border-color: var(--accent); background: var(--accent-soft); }
.steps li[aria-current="step"] b { background: var(--accent); color: #fff; }
.steps li[data-done="1"] b { background: var(--mint); color: var(--mint-deep); }

/* -----------------------------------------------------------------------------
   Utilities
   -------------------------------------------------------------------------- */
.muted { color: var(--ink-soft); }
.small { font-size: 0.83rem; }
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 0.75rem; }
.mt-2 { margin-top: 1.5rem; }
.mb-0 { margin-bottom: 0; }
.nowrap { white-space: nowrap; }
.text-right { text-align: right; }
[hidden] { display: none !important; }

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.75rem;
}
.stat {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 0.9rem 1rem;
}
.stat b { display: block; font-size: 1.55rem; font-weight: 650; line-height: 1.1; }
.stat span { font-size: 0.8rem; color: var(--ink-soft); }

@media (max-width: 640px) {
    /* The header stops being sticky on a phone: screen height is the scarce
       resource, and the nav needs a row of its own. */
    .site-header {
        position: static;
        height: auto;
        flex-wrap: wrap;
        padding: 0.55rem 0.85rem;
        row-gap: 0.35rem;
    }
    .brand { font-size: 0.92rem; white-space: nowrap; }
    .brand__mark { width: 26px; height: 26px; padding: 4px; }
    .site-nav {
        width: 100%;
        margin-left: 0;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .site-nav a { padding: 0.35rem 0.5rem; white-space: nowrap; }

    .container { padding: 1.25rem 1rem 3rem; }
    h1 { font-size: 1.4rem; }
    .plan-row__actions { width: 100%; }
    .toast-region { right: 0.75rem; left: 0.75rem; width: auto; }
}

/* -----------------------------------------------------------------------------
   Wizard additions (October 2026): suggested plan name, CEFR column, seat
   shortfall panel.
   -------------------------------------------------------------------------- */
.link-button {
    background: none;
    border: 0;
    padding: 0;
    margin-left: 0.35rem;
    font: inherit;
    color: var(--accent);
    text-decoration: underline;
    text-underline-offset: 2px;
    cursor: pointer;
}
.link-button:hover { color: var(--accent-hover); }
.link-button:focus-visible { outline: 2px solid var(--accent-ring); outline-offset: 2px; border-radius: 3px; }

#student-table select.cefr-select,
#class-table select.cefr-select { min-width: 5.2rem; }

.shortfall {
    border-color: #ecd3a3;
    background: linear-gradient(0deg, var(--surface), var(--surface)) padding-box;
    box-shadow: inset 4px 0 0 var(--butter);
}
.shortfall h2 { font-size: 1.05rem; }

/* -----------------------------------------------------------------------------
   Email verification pages
   -------------------------------------------------------------------------- */
.verify-card { padding-top: 2rem; }
.verify-card h1 { font-size: 1.45rem; margin: 0; }
.verify-mark {
    display: inline-grid;
    place-items: center;
    width: 52px;
    height: 52px;
    border-radius: 16px;
    background: var(--mint);
    color: var(--mint-deep);
}
.verify-mark--warn { background: var(--butter); color: var(--butter-deep); }
.verify-card ul { padding-left: 1.1rem; }
.verify-card li + li { margin-top: 0.3rem; }

.badge {
    display: inline-block;
    font-size: 0.74rem;
    font-weight: 600;
    padding: 0.12rem 0.5rem;
    border-radius: 999px;
    white-space: nowrap;
}
.badge--ok   { background: var(--mint);   color: var(--mint-deep); }
.badge--wait { background: var(--butter); color: var(--butter-deep); }

/* Registration trap field: off screen for people, still in the form for scripts. */
.trap {
    position: absolute;
    left: -10000px;
    top: auto;
    width: 1px;
    height: 1px;
    overflow: hidden;
}
