/* ===========================================================================
   MECHANIST enrol portal — student / employer facing design system
   ---------------------------------------------------------------------------
   Shared by every page an applicant, employer, parent or school rep sees:
   index, student_form, id_upload, success, capture_signature,
   capture_tp_signature, menu.

   MOBILE FIRST. These pages are mostly opened on a phone from an SMS link, so
   the base rules target a small screen and widen at breakpoints. Two details do
   the heavy lifting there:
     - every form control is >=16px, because iOS Safari auto-zooms the page when
       you focus an input smaller than that
     - interactive targets are >=44px tall (Apple's minimum touch target)

   Class names deliberately match what the pages already used, so switching a
   page over is mostly deleting its <style> block.
   =========================================================================== */

:root {
    --brand: #F04664;
    --brand-light: #FF7070;
    --brand-ink: #C22F49;
    --brand-wash: #FEF2F4;

    --bg: #F7F5F6;
    --surface: #FFFFFF;
    --surface-2: #FAF8F9;
    --border: #E9E3E5;
    --border-strong: #D6CDD0;
    --text: #1E1A1C;
    --muted: #6B5F64;
    --faint: #92868B;

    --ok: #1B8A54;      --ok-bg: #E7F5EE;      --ok-border: #BFE3D0;
    --warn: #A2660A;    --warn-bg: #FDF4E3;    --warn-border: #EDD6A8;
    --danger: #C6283C;  --danger-bg: #FDECEE;  --danger-border: #F3C6CC;

    --radius: 10px;
    --radius-lg: 16px;
    --shadow: 0 1px 3px rgba(30, 26, 28, .05), 0 12px 30px rgba(30, 26, 28, .07);

    --font: "Archivo", system-ui, -apple-system, "Segoe UI", sans-serif;
    --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

    /* legacy aliases — pages still reference these inline */
    --primary: var(--brand);
    --primary-light: var(--brand-light);
    --bg-color: var(--bg);
    --text-dark: var(--text);
}

* { box-sizing: border-box; }

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

body {
    margin: 0;
    padding: 16px;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* Pages that show a single short card (index, success) centre it vertically. */
body.center {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

/* ------------------------------------------------------------- The card ---
   One column, full width on a phone, capped and centred on a larger screen. */

.container {
    background: var(--surface);
    border: 1px solid var(--border);
    border-top: 5px solid var(--brand);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 24px 20px;
    margin: 0 auto;
    max-width: 700px;
    width: 100%;
}
.container.narrow { max-width: 520px; }
.container > :first-child { margin-top: 0; }
.container > :last-child { margin-bottom: 0; }

h1, h2, h3 { letter-spacing: -.015em; text-wrap: balance; line-height: 1.25; }
h1 { font-size: 1.5rem; font-weight: 700; margin: 0 0 12px; color: var(--text); }
h2 { font-size: 1.25rem; font-weight: 700; margin: 0 0 12px; color: var(--text); }
h3 { font-size: 1.05rem; font-weight: 700; margin: 0 0 8px; color: var(--text); }
p  { margin: 0 0 14px; color: var(--muted); }
p.intro { margin-bottom: 22px; }
a { color: var(--brand-ink); }

.icon, .check-icon { font-size: 3rem; line-height: 1; margin-bottom: 12px; }
.check-icon { color: var(--ok); }

/* --------------------------------------------------------------- Progress */

.progress-bar {
    background: var(--border);
    height: 8px;
    border-radius: 99px;
    margin-bottom: 22px;
    overflow: hidden;
}
.progress-fill {
    background: var(--brand);
    height: 100%;
    border-radius: 99px;
    transition: width .3s ease;
}

/* ------------------------------------------------------------------ Forms */

.form-group { margin-bottom: 18px; }

label {
    display: block;
    font-weight: 600;
    font-size: .95rem;
    margin-bottom: 7px;
    color: var(--text);
}
.required { color: var(--danger); }

input[type="text"], input[type="date"], input[type="search"], input[type="tel"],
input[type="email"], input[type="number"], input[type="file"], select, textarea {
    width: 100%;
    /* 16px minimum: anything smaller makes iOS Safari zoom in on focus. */
    font-size: 16px;
    font-family: var(--font);
    color: var(--text);
    background: var(--surface);
    padding: 12px 14px;
    min-height: 48px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    transition: border-color .13s, box-shadow .13s;
}
textarea { line-height: 1.6; resize: vertical; }
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(240, 70, 100, .16);
}
input::placeholder, textarea::placeholder { color: var(--faint); }

/* Radios / checkboxes as comfortable tap targets rather than tiny dots. */
.radio-group { display: flex; flex-direction: column; gap: 10px; margin-bottom: 18px; }
.radio-group label,
.checkbox-group label {
    font-weight: 500;
    display: flex;
    align-items: flex-start;
    gap: 11px;
    cursor: pointer;
    margin-bottom: 0;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 13px 15px;
    min-height: 48px;
    transition: border-color .13s, background .13s;
}
.radio-group label:has(input:checked),
.checkbox-group label:has(input:checked) {
    border-color: var(--brand);
    background: var(--brand-wash);
}
.checkbox-group label { margin-bottom: 10px; }
input[type="radio"], input[type="checkbox"] {
    width: 20px; height: 20px;
    min-height: 0;
    margin: 1px 0 0;
    flex-shrink: 0;
    accent-color: var(--brand);
}

/* Inline radio row (e.g. Yes / No) may sit side by side once there's room. */
@media (min-width: 480px) {
    .radio-group.inline { flex-direction: row; flex-wrap: wrap; }
    .radio-group.inline label { flex: 1 1 auto; }
}

/* Two-option segmented switch (student_form address entry mode). */
.radio-slider-fifty {
    display: flex;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 16px;
}
.radio-slider-fifty input[type="radio"] { display: none; }
.radio-slider-fifty label {
    flex: 1;
    text-align: center;
    padding: 13px 10px;
    margin: 0;
    cursor: pointer;
    font-weight: 600;
    color: var(--muted);
    background: transparent;
    border: none;
    border-radius: 0;
    min-height: 48px;
    display: flex; align-items: center; justify-content: center;
}
.radio-slider-fifty input[type="radio"]:checked + label { background: var(--brand); color: #fff; }

/* ---------------------------------------------------------------- Buttons */

.btn, button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--brand);
    color: #fff;
    border: 1px solid transparent;
    border-radius: var(--radius);
    padding: 14px 22px;
    min-height: 48px;
    font-family: var(--font);
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.3;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    transition: background .13s, box-shadow .13s, transform .06s;
}
.btn:hover, button:hover { background: var(--brand-light); }
.btn:active, button:active { transform: translateY(1px); }
.btn:focus-visible, button:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(240, 70, 100, .3);
}
button.submit-btn { width: 100%; }
.btn-back, .btn-clear, button.secondary-btn {
    background: var(--surface);
    color: var(--text);
    border-color: var(--border-strong);
}
.btn-back:hover, .btn-clear:hover, button.secondary-btn:hover { background: var(--surface-2); }

/* Signature pages stack Clear + Submit full width under the pad, as before. */
[data-sig-form] .btn { width: 100%; margin-top: 10px; }

/* Back / Next pair: full width and stacked on a phone, apart on a wider screen. */
.btn-container { display: flex; gap: 10px; margin-top: 26px; }
.btn-container .btn { flex: 1; }
@media (min-width: 560px) {
    .btn-container { justify-content: space-between; }
    .btn-container .btn { flex: 0 0 auto; min-width: 140px; }
}

/* ----------------------------------------------------- Panels and notices */

.alert, .advice, .summary-box, .doc-body, .declaration-box, .card-block, .hint, .upload-section {
    border-radius: var(--radius);
    padding: 15px 16px;
    margin-bottom: 18px;
}
.alert { font-weight: 600; border: 1px solid; }
.alert-info    { background: var(--ok-bg);     color: var(--ok);     border-color: var(--ok-border); }
.alert-success { background: var(--ok-bg);     color: var(--ok);     border-color: var(--ok-border); }
.alert-error   { background: var(--danger-bg); color: var(--danger); border-color: var(--danger-border); }

.advice {
    background: var(--warn-bg);
    border: 1px solid var(--warn-border);
    color: var(--warn);
    font-size: .93rem;
}
.hint, .summary-box {
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--muted);
    font-size: .93rem;
}
.card-block { border: 1px solid var(--border); background: var(--surface); }
.upload-section { border: 1px solid var(--border); background: var(--surface-2); display: none; }
.file-input-group { margin-bottom: 14px; }
.file-input-group label { font-weight: 600; }

/* Long legal text — scrolls inside itself so it can't swamp a phone screen. */
.doc-body, .declaration-box {
    background: var(--surface);
    border: 1px solid var(--border);
    font-size: .93rem;
    line-height: 1.65;
    max-height: 300px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* The "switch to your phone" prompt is pointless when already on a phone. */
.mobile-switch {
    background: var(--surface-2);
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
    margin-bottom: 22px;
}
@media (max-width: 768px) { .mobile-switch { display: none !important; } }

/* ----------------------------------------------------------------- Tables */

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin-bottom: 16px; }
.unit-table { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: .88rem; }
.unit-table th, .unit-table td {
    text-align: left;
    padding: 9px 10px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.unit-table th {
    background: var(--surface-2);
    color: var(--muted);
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    white-space: nowrap;
}
.unit-table td:first-child { font-family: var(--mono); font-size: .85rem; white-space: nowrap; }

.badge-ct {
    background: var(--brand-wash);
    color: var(--brand-ink);
    border: 1px solid var(--brand);
    padding: 2px 8px;
    border-radius: 99px;
    font-size: .72rem;
    font-weight: 700;
    white-space: nowrap;
}

/* --------------------------------------------------------- Signature pad */

.signature-pad {
    border: 2px dashed var(--border-strong);
    border-radius: var(--radius);
    background: var(--surface);
    width: 100%;
    height: 220px;
    /* Stops the browser panning/zooming the page while a finger is drawing. */
    touch-action: none;
    display: block;
}
@media (min-width: 560px) { .signature-pad { height: 250px; } }

.done { text-align: center; padding: 40px 16px; }
.done h2 { color: var(--ok); border: none; }

/* ------------------------------------------------------ Wider than phone */

@media (min-width: 560px) {
    body { padding: 28px 20px; }
    .container { padding: 34px 34px; }
    h1 { font-size: 1.75rem; }
}

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

/* ------------------------------------------- AddressFinder autocomplete --
   Third-party widget: it injects its own inline styles, so these need to stay
   !important to win. Kept visually consistent with our inputs. */
.af_list {
    background: #fff !important;
    border: 1px solid var(--border-strong) !important;
    border-radius: var(--radius) !important;
    box-shadow: var(--shadow) !important;
    padding: 0 !important;
    margin-top: 5px !important;
    list-style-type: none !important;
    z-index: 999 !important;
}
.af_item {
    padding: 12px 15px !important;
    cursor: pointer !important;
    border-bottom: 1px solid var(--border) !important;
    color: var(--text) !important;
    font-family: var(--font) !important;
    font-size: 15px !important;
    margin: 0 !important;
}
.af_item:last-child { border-bottom: none !important; }
.af_item:hover, .af_item.af_hover {
    background: var(--brand-wash) !important;
    color: var(--brand-ink) !important;
    font-weight: 600 !important;
}
