/* ------------------------------------------------------------------
   Tokens. Light by default; dark follows the device unless the
   applicant picked a theme (html[data-theme]).
   ------------------------------------------------------------------ */
:root {
    --bg: #f4f6fb;
    --surface: #ffffff;
    --surface-2: #eef2f9;
    --text: #0f172a;
    --text-muted: #475569;
    --border: rgba(15, 23, 42, 0.14);
    --primary: #2f5fe8;
    --primary-text: #ffffff;
    --focus: rgba(59, 130, 246, 0.35);
    --danger: #c62828;
    --danger-bg: #fdecec;
    --warning-bg: #fff7e0;
    --warning-text: #7a5300;
    --info-bg: #e8f1ff;
    --info-text: #16427a;
    --success-bg: #e7f6ec;
    --success-text: #1b5e20;
    --radius: 10px;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #050816;
        --surface: #0d1628;
        --surface-2: #13213b;
        --text: #f1f5f9;
        --text-muted: #94a3b8;
        --border: rgba(148, 163, 184, 0.25);
        --primary: #4f7cff;
        --danger: #ff8a80;
        --danger-bg: rgba(255, 82, 82, 0.12);
        --warning-bg: rgba(255, 193, 7, 0.12);
        --warning-text: #ffd166;
        --info-bg: rgba(79, 124, 255, 0.14);
        --info-text: #bcd0ff;
        --success-bg: rgba(76, 175, 80, 0.14);
        --success-text: #a5d6a7;
        color-scheme: dark;
    }
}

:root[data-theme="dark"] {
    --bg: #050816;
    --surface: #0d1628;
    --surface-2: #13213b;
    --text: #f1f5f9;
    --text-muted: #94a3b8;
    --border: rgba(148, 163, 184, 0.25);
    --primary: #4f7cff;
    --danger: #ff8a80;
    --danger-bg: rgba(255, 82, 82, 0.12);
    --warning-bg: rgba(255, 193, 7, 0.12);
    --warning-text: #ffd166;
    --info-bg: rgba(79, 124, 255, 0.14);
    --info-text: #bcd0ff;
    --success-bg: rgba(76, 175, 80, 0.14);
    --success-text: #a5d6a7;
    color-scheme: dark;
}

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

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.container { max-width: 70%; margin: 0 auto; padding: 0 16px; }
/* Phones and small tablets: 70% would squeeze the form, so use the full width. */
@media (max-width: 991.98px) { .container { max-width: none; } }
main.container { padding-bottom: 48px; }

h1 { font-size: 1.6rem; margin: 24px 0 4px; }
h2 { font-size: 1.3rem; margin: 8px 0 16px; }
h3 { font-size: 1.1rem; margin: 28px 0 12px; }
h4, h5 { margin: 0 0 8px; }
.muted { color: var(--text-muted); }
.prewrap { white-space: pre-wrap; margin: 0; }
[hidden] { display: none !important; }

/* Header */
.site-header { background: var(--surface); border-bottom: 1px solid var(--border); }
.site-header__inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 52px; }
.site-header__title { font-size: 0.95rem; }
/* The county logo (public/logo.png): transparent with dark lettering, so on a white tile to read in dark mode too. */
.site-header__brand { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 6px 0; }
.site-header__logo { flex: none; width: 44px; height: auto; padding: 2px 3px; background: #fff; border-radius: 6px; }
.theme-toggle { background: none; border: 1px solid var(--border); border-radius: 999px; width: 40px; height: 40px; font-size: 1.1rem; cursor: pointer; color: var(--text); }

.note { background: var(--danger-bg); border-left: 4px solid var(--danger); padding: 8px 12px; border-radius: 6px; font-size: 0.9rem; }
.req, label.required::after { color: var(--danger); font-weight: 700; }
label.required::after { content: " *"; }

/* Progress */
.progress { margin: 20px 0; }
.progress__steps { list-style: none; display: flex; flex-wrap: wrap; gap: 6px 14px; padding: 0; margin: 0 0 10px; font-size: 0.85rem; color: var(--text-muted); }
.progress__steps li { display: flex; align-items: center; gap: 6px; }
.progress__num { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--border); font-size: 0.75rem; }
.progress__steps .is-done .progress__num { background: var(--surface-2); }
.progress__steps .is-current { color: var(--primary); font-weight: 700; }
.progress__steps .is-current .progress__num { background: var(--primary); color: var(--primary-text); border-color: var(--primary); }
.progress__bar { height: 6px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.progress__bar > div { height: 100%; background: var(--primary); }
.progress__caption { font-size: 0.8rem; color: var(--text-muted); margin: 6px 0 0; }
@media (max-width: 640px) {
    .progress__steps li:not(.is-current) .progress__title { display: none; }
}

/* Cards and alerts */
.step-form, .card, .position-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.position-card { background: var(--surface-2); margin: 8px 0 16px; }
.position-card dl { margin: 0 0 12px; }
.position-card dt, .summary dt { font-size: 0.8rem; color: var(--text-muted); }
.position-card dd, .summary dd { margin: 0 0 8px; }
.alert { padding: 10px 14px; border-radius: 8px; margin: 0 0 16px; }
.alert--error { background: var(--danger-bg); color: var(--danger); }
.alert--warning { background: var(--warning-bg); color: var(--warning-text); }
.alert--info { background: var(--info-bg); color: var(--info-text); }
.card--success { border-color: var(--success-text); }
.card--success h1 { color: var(--success-text); margin-top: 0; }

/* Layout */
.grid-2 { display: grid; grid-template-columns: 1fr; gap: 0 24px; }
@media (min-width: 720px) { .grid-2 { grid-template-columns: 1fr 1fr; } }

/* Fields */
.field { margin-bottom: 16px; }
.field label { display: block; font-weight: 500; margin-bottom: 6px; }
.field input:not([type=checkbox]):not([type=radio]), .field select, .field textarea {
    width: 100%;
    padding: 10px 12px;
    font: inherit;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
}
.field input[type=file] { padding: 8px; background: var(--surface-2); border-style: dashed; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--focus); }
.field--error input, .field--error select, .field--error textarea { border-color: var(--danger); }
.field__errors { list-style: none; padding: 0; margin: 6px 0 0; color: var(--danger); font-size: 0.9rem; }
.field [id$="_help"] { font-size: 0.85rem; color: var(--text-muted); margin-top: 4px; }

.choices { display: flex; gap: 20px; flex-wrap: wrap; }
.choice, .checkbox { display: flex; align-items: flex-start; gap: 8px; font-weight: 400 !important; cursor: pointer; }
.choice input, .checkbox input { width: 18px; height: 18px; margin-top: 3px; accent-color: var(--primary); }

.age { font-size: 0.9rem; margin: -8px 0 16px; }
.age--ok { color: var(--success-text); }
.age--warning { color: var(--warning-text); }

/* Repeatable entries */
.collection { margin-top: 12px; }
.entry { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px 8px; margin: 0 0 14px; background: var(--surface-2); }
.entry legend { font-weight: 600; padding: 0 6px; }

/* Buttons */
.btn { display: inline-flex; justify-content: center; align-items: center; gap: 6px; font: inherit; font-weight: 600; padding: 12px 18px; border-radius: 8px; border: 1px solid transparent; cursor: pointer; }
.btn-primary { background: var(--primary); color: var(--primary-text); }
.btn-secondary { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.btn-outline { background: transparent; color: var(--primary); border-color: var(--primary); }
.btn-link { background: none; border: none; padding: 4px 0; font-weight: 500; }
.btn-danger { color: var(--danger); }
.btn:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.step-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--border); }
.step-nav .btn { width: 100%; }

/* Final-step upload in progress */
.upload-overlay { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: rgba(5, 8, 22, 0.6); }
.upload-overlay__box { max-width: 420px; background: var(--surface); color: var(--text); border-radius: var(--radius); padding: 24px; text-align: center; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3); }
.spinner { width: 40px; height: 40px; margin: 0 auto 12px; border: 4px solid var(--surface-2); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }

/* Round announcements (banners at the top of every page, pop-ups). */
.announcements { margin: 0 0 16px; }
.announcement { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: 8px; margin: 0 0 10px; border-left: 4px solid currentColor; }
.announcement[hidden] { display: none; }
.announcement--info { background: var(--info-bg); color: var(--info-text); }
.announcement--important { background: var(--warning-bg); color: var(--warning-text); }
.announcement__body { flex: 1; min-width: 0; }
.announcement__title { display: block; margin-bottom: 2px; }
.announcement__message { margin: 0; white-space: pre-line; overflow-wrap: anywhere; }
.announcement__link { display: inline-block; margin-top: 6px; color: inherit; font-weight: 600; }
.announcement__close { flex: none; border: 0; background: transparent; color: inherit; font-size: 1.1rem; line-height: 1; padding: 6px 8px; margin: -4px -6px 0 0; border-radius: 6px; cursor: pointer; min-width: 36px; min-height: 36px; }
.announcement__close:hover, .announcement__close:focus-visible { background: rgba(0, 0, 0, 0.08); outline: none; }
.announcement-dialog { max-width: min(520px, calc(100vw - 32px)); border: 0; border-radius: 12px; padding: 20px; background: var(--surface, #fff); color: var(--text, inherit); box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25); }
.announcement-dialog.announcement--important { border-top: 4px solid var(--warning-text); }
.announcement-dialog.announcement--info { border-top: 4px solid var(--primary); }
.announcement-dialog::backdrop { background: rgba(0, 0, 0, 0.45); }
.announcement-dialog__title { font-size: 1.15rem; margin: 0 0 8px; }
.announcement-dialog__actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: 16px; }
