/* ==========================================================================
   WSNF forms: shared styles (application and referral pages)

   COLOURS: change them here, in one place. Everything else uses these.
     --header-bg     header background (white logo and title sit on it)
     --header-line   thin line under the header
     --deadline-bar  coloured bar on the left of the Deadline box
     --brand         buttons, links, focus rings, selected options
     --brand-dark    button hover
     --brand-tint    light backgrounds (selected option, hover)
     --warn-bg / --warn-border   the yellow "cannot save your progress" note
   The values below are PLACEHOLDERS. Keep text contrast in mind: white text
   on --header-bg and on --brand needs at least 4.5:1 (this blue gives about 6.9:1).
   ========================================================================== */
:root {
  --header-bg: #850f21;
  --header-line: #540b0b;
  --deadline-bar: #b3122b;

  --brand: #0057b8;
  --brand-dark: #00438f;
  --brand-tint: #eaf2fc;

  --warn-bg: #fffbeb;
  --warn-border: #f59e0b;

  --ink: #172033;
  --muted: #4a5568;
  --line: #dde2ea;
  --control-border: #7b8698;
  --page-bg: #f4f6f9;
  --surface: #ffffff;

  --error: #b42318;
  --error-bg: #fef3f2;
  --warn: #92400e;

  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 8px 24px rgba(16, 24, 40, 0.06);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  color-scheme: light;
  accent-color: var(--brand);
}

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

[hidden] { display: none !important; }

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

body {
  margin: 0;
  background: var(--page-bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.6;
  overflow-wrap: break-word; /* long words and emails wrap instead of pushing the page wider */
}

img { max-width: 100%; height: auto; }
a { color: var(--brand); overflow-wrap: anywhere; }

:focus-visible {
  outline: 3px solid var(--brand);
  outline-offset: 2px;
}

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

.skip-link {
  position: absolute;
  left: 16px; top: -100px;
  z-index: 10;
  padding: 10px 16px;
  background: var(--surface);
  border-radius: 8px;
}
.skip-link:focus { top: 12px; }

/* ---------- Header ---------- */
.site-header {
  background: var(--header-bg);
  border-bottom: 4px solid var(--header-line);
  color: #fff;
}
.site-header__inner {
  max-width: 760px;
  margin: 0 auto;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.site-header__logo { display: block; height: 44px; width: auto; flex: none; }
.site-header__home { display: block; flex: none; border-radius: 6px; }
.site-header__home:focus-visible { outline: 3px solid #fff; outline-offset: 4px; }
.site-header__title {
  flex: 1;
  min-width: 0;
  margin: 0;
  text-align: right;
  font-size: clamp(1.0625rem, 4.6vw, 1.75rem);
  line-height: 1.2;
  font-weight: 700;
}
@media (min-width: 600px) {
  .site-header__inner { padding: 18px 16px; }
  .site-header__logo { height: 52px; }
}

/* ---------- Page: one centered column ---------- */
.page {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 24px 16px 56px;
}
.page > main { min-width: 0; }

.loading, .fatal {
  max-width: 720px;
  margin: 40px auto;
  padding: 0 16px;
  text-align: center;
  color: var(--muted);
}
.fatal {
  color: var(--ink);
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  margin: 24px 16px;
}
@media (min-width: 792px) { .fatal { margin: 40px auto; } }
.fatal h2 { margin-top: 0; }

/* ---------- Top of page: deadline, intro, eligibility ---------- */
.deadline {
  margin: 0 0 20px;
  padding: 14px 18px;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 6px solid var(--deadline-bar);
  border-radius: var(--radius);
  font-size: 1.25rem;
  line-height: 1.3;
}
.deadline__label { font-weight: 600; color: var(--muted); }
.deadline__value { font-weight: 700; }

.intro p { margin: 0 0 20px; font-size: 1.0625rem; }

.eligibility {
  margin: 0 0 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.eligibility summary {
  list-style: none;
  cursor: pointer;
  padding: 14px 20px;
  font-weight: 600;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.eligibility summary::-webkit-details-marker { display: none; }
.eligibility summary::after {
  content: "";
  flex: none;
  width: 9px; height: 9px;
  border-right: 2px solid var(--ink);
  border-bottom: 2px solid var(--ink);
  transform: rotate(45deg);
  margin: -4px 4px 0 0;
  transition: transform 0.15s;
}
.eligibility[open] summary::after { transform: rotate(-135deg); margin-top: 4px; }
.eligibility__body { padding: 0 20px 18px; font-size: 0.9375rem; }
.eligibility__body h3 { margin: 16px 0 6px; font-size: 1rem; }
.eligibility__body h3:first-child { margin-top: 0; }
.eligibility__body ul { margin: 0; padding-left: 1.2rem; }
.eligibility__body li + li { margin-top: 4px; }
.eligibility__body p { margin: 16px 0 0; color: var(--muted); }

.notice {
  margin: 0 0 20px;
  padding: 12px 16px;
  border-left: 6px solid var(--brand);
  background: var(--brand-tint);
  border-radius: var(--radius);
  font-size: 0.9375rem;
}
.notice p { margin: 0; }
.notice--warning { background: var(--warn-bg); border-left-color: var(--warn-border); }
.notice--error { background: var(--error-bg); border-left-color: var(--error); margin: 16px 0; }
.notice--page { max-width: 720px; margin: 24px auto; }

/* ---------- Form card and sections ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 22px 18px;
}
@media (min-width: 600px) { .card { padding: 36px 40px; } }

.required-note { margin: 0 0 4px; color: var(--muted); font-size: 0.9375rem; }

.section { margin-top: 36px; padding-top: 32px; border-top: 1px solid var(--line); }
.required-note + .section { margin-top: 12px; padding-top: 0; border-top: 0; }
.section h2 { margin: 0 0 20px; font-size: 1.25rem; line-height: 1.3; }
.section-intro { margin: -12px 0 20px; color: var(--muted); }

/* ---------- Fields ---------- */
.field { margin: 0 0 24px; padding: 0; border: 0; min-width: 0; }
.field:last-child { margin-bottom: 0; }

.field label, .field legend { display: block; padding: 0; font-weight: 600; }
.tag { font-weight: 400; color: var(--muted); font-size: 0.875rem; margin-left: 4px; }
.tag::before { content: "("; }
.tag::after { content: ")"; }

.hint { margin: 2px 0 8px; color: var(--muted); font-size: 0.9375rem; }
.field > label + input, .field > label + select, .field > label + textarea { margin-top: 6px; }

input[type="text"], input[type="email"], input[type="date"], select, textarea {
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 48px;
  padding: 11px 14px;
  font: inherit;
  font-size: 1rem; /* 16px minimum stops iOS zooming on focus */
  color: var(--ink);
  background-color: #fff;
  border: 1px solid var(--control-border);
  border-radius: 10px;
}
textarea { resize: vertical; min-height: 9rem; line-height: 1.5; }
textarea#address { min-height: 5.5rem; }

input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid var(--brand);
  outline-offset: 1px;
  border-color: var(--brand);
}

.field.has-error input[type="text"],
.field.has-error input[type="email"],
.field.has-error input[type="date"],
.field.has-error select,
.field.has-error textarea { border-color: var(--error); box-shadow: inset 0 0 0 1px var(--error); }

/* Date: same look as the other fields on every browser; the calendar popup itself is drawn by the browser. */
input[type="date"] { -webkit-appearance: none; appearance: none; text-align: left; }
input[type="date"]::-webkit-date-and-time-value { text-align: left; }
input[type="date"]::-webkit-calendar-picker-indicator {
  cursor: pointer;
  opacity: 0.8;
  padding: 6px;
  margin-right: -6px;
  border-radius: 8px;
}
input[type="date"]::-webkit-calendar-picker-indicator:hover { opacity: 1; background: var(--brand-tint); }

/* Dropdown: custom arrow so it matches the other fields everywhere. */
select {
  -webkit-appearance: none;
  appearance: none;
  padding-right: 44px;
  cursor: pointer;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--ink) 50%),
    linear-gradient(135deg, var(--ink) 50%, transparent 50%);
  background-position: calc(100% - 22px) calc(50% + 1px), calc(100% - 16px) calc(50% + 1px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
}

/* Browsers that support customizable selects (recent Chrome and Edge) also get a styled list.
   Others keep the arrow above and the system list. */
@supports (appearance: base-select) {
  select, select::picker(select) { appearance: base-select; }
  select {
    background-image: none;
    padding-right: 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
  select::picker-icon {
    content: "";
    width: 9px; height: 9px;
    border-right: 2px solid var(--ink);
    border-bottom: 2px solid var(--ink);
    transform: rotate(45deg) translateY(-2px);
    transition: transform 0.15s;
  }
  select:open::picker-icon { transform: rotate(-135deg) translateY(-2px); }
  select::picker(select) {
    margin-top: 6px;
    padding: 6px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: 0 12px 32px rgba(16, 24, 40, 0.18);
  }
  select option {
    min-height: 44px;
    padding: 10px 12px;
    border-radius: 8px;
    font: inherit;
    cursor: pointer;
  }
  select option:hover, select option:focus-visible { background: var(--brand-tint); outline: none; }
  select option:checked { font-weight: 600; }
  select option::checkmark { color: var(--brand); }
}

.error { margin: 6px 0 0; color: var(--error); font-size: 0.9375rem; font-weight: 600; }
.error::before { content: "Error: "; }
.field-foot { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.field-foot .error { flex: 1; min-width: 0; }

.counter {
  margin: 6px 0 0 auto;
  flex: none;
  font-size: 0.875rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.counter.is-warn { color: var(--warn); font-weight: 600; }
.counter.is-over { color: var(--error); font-weight: 700; }

/* Radios and checkbox */
.choices { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }
.field .choice {
  display: inline-flex !important;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  min-width: 96px;
  padding: 8px 18px;
  border: 1px solid var(--control-border);
  border-radius: 10px;
  font-weight: 400 !important;
  cursor: pointer;
  background: #fff;
}
.choice input { width: 20px; height: 20px; margin: 0; accent-color: var(--brand); }
.choice:has(input:checked) { border-color: var(--brand); background: var(--brand-tint); box-shadow: inset 0 0 0 1px var(--brand); }
.choice:has(input:focus-visible) { outline: 3px solid var(--brand); outline-offset: 2px; }
.field.has-error .choice { border-color: var(--error); }

.check { display: flex !important; gap: 12px; align-items: flex-start; font-weight: 400 !important; cursor: pointer; }
.check input { flex: none; width: 22px; height: 22px; margin: 2px 0 0; accent-color: var(--brand); }
.check span { min-width: 0; }

/* ---------- Transcript upload ---------- */
.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 24px 16px;
  border: 2px dashed var(--control-border);
  border-radius: var(--radius);
  background: #fafbfc;
  text-align: center;
}
.dropzone.is-dragover { border-color: var(--brand); background: var(--brand-tint); }
.dropzone__text { margin: 0; color: var(--muted); }
.field.has-error .dropzone { border-color: var(--error); }

.file-list { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 8px; }
.file-list li {
  display: flex;
  align-items: center;
  gap: 8px 12px;
  flex-wrap: wrap;
  padding: 8px 8px 8px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}
.file-list__name { flex: 1 1 140px; min-width: 0; overflow-wrap: anywhere; font-weight: 600; }
.file-list__size { flex: none; color: var(--muted); font-size: 0.875rem; font-variant-numeric: tabular-nums; }
.file-total { margin: 8px 0 0; color: var(--muted); font-size: 0.875rem; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 22px;
  font: inherit;
  font-weight: 600;
  border-radius: 10px;
  border: 2px solid var(--brand);
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s;
}
.btn--primary { background: var(--brand); color: #fff; min-height: 52px; padding: 0 36px; font-size: 1.0625rem; }
.btn--primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn--primary:disabled { opacity: 0.7; cursor: progress; }
.btn--secondary { background: #fff; color: var(--brand); }
.btn--secondary:hover { background: var(--brand-tint); }
.btn--small { min-height: 40px; padding: 0 14px; font-size: 0.9375rem; }
@media (max-width: 599px) { .btn--primary { width: 100%; } }

#turnstile-widget { margin: 4px 0 16px; max-width: 100%; overflow: hidden; }

/* ---------- Error summary ---------- */
.error-summary {
  border: 2px solid var(--error);
  border-left-width: 8px;
  background: var(--error-bg);
  border-radius: 10px;
  padding: 14px 18px;
  margin-bottom: 24px;
}
.error-summary h2 { margin: 0 0 8px; font-size: 1.125rem; color: var(--error); }
.error-summary ul { margin: 0; padding-left: 1.2rem; }
.error-summary a { color: var(--error); font-weight: 600; }

/* ---------- Spam trap: off-screen, not display:none ---------- */
.trap { position: absolute; left: -10000px; top: auto; width: 1px; height: 1px; overflow: hidden; }

/* ---------- Success and message panels ---------- */
.success h2 { margin-top: 0; font-size: 1.5rem; }
.success p { font-size: 1.0625rem; }
.success:focus { outline: none; }

/* ---------- Footer ---------- */
.site-footer {
  padding: 24px 16px 32px;
  border-top: 1px solid var(--line);
  background: var(--surface);
  text-align: center;
  color: var(--muted);
}
.site-footer p { margin: 0; }
.site-footer__links { margin-top: 6px !important; }

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