/* =============================================================================
   IDC Client Intake Form — STYLES
   Mobile-first. Tested layout breakpoints: 320 / 375 / 390 / 430 / 768 / 1024+.
   No horizontal scrolling at any width; all controls are >= 44px tall.
============================================================================= */

/* -----------------------------------------------------------------------------
   1. DESIGN TOKENS
   [IDC BRAND COLOR] — replace --brand and --brand-dark with IDC's official
   colors. Keep contrast against white at 4.5:1 or better (WCAG 2.1 AA). The
   placeholder blue below measures ~8.6:1 on white.
----------------------------------------------------------------------------- */
:root {
  /* IDC brand, sampled from the official logo (assets/idc-logo.png).
     The logo's own red (#E43030) measures 4.41:1 on white, just under the WCAG
     AA threshold for normal text, so it is used only for large decorative areas
     (the header rule, gradients). Text and controls use the darkened --brand. */
  --logo-red:     #E43030;   /* logo wordmark red — decorative only */
  --logo-orange:  #F08430;   /* logo globe orange — decorative only */

  --brand:        #C4281A;   /* 5.73:1 on white — headings, buttons, controls  */
  --brand-dark:   #9E2115;   /* 7.83:1 — hover, active                         */
  --brand-tint:   #FDF0ED;   /* warm 6% tint — selected rows, info panels      */
  --brand-tint-2: #FAE3DC;   /* slightly deeper tint — rules and dividers      */
  --accent:       #A85000;   /* 5.51:1 — orange-family text where it is needed */

  --ink:          #201A18;
  --ink-soft:     #55504E;
  --line:         #E2D8D4;
  --line-strong:  #9B908C;
  --bg:           #FAF7F5;
  --surface:      #FFFFFF;

  /* Errors sit far darker than --brand so the two reds never read as the same
     state. Every error also carries a warning glyph and bold text, so meaning
     is never conveyed by color alone (WCAG 1.4.1). */
  --danger:       #7A1912;   /* 10.63:1 on white */
  --danger-bg:    #FDECEA;
  --success:      #1B7A45;
  --info-bg:      #FFF6F3;

  --radius:       10px;
  --radius-lg:    14px;
  --shadow:       0 1px 2px rgba(60,20,10,.06), 0 4px 12px rgba(60,20,10,.07);
  --focus:        0 0 0 3px #FFFFFF, 0 0 0 6px var(--brand);

  --space-1: .25rem;  --space-2: .5rem;   --space-3: .75rem;
  --space-4: 1rem;    --space-5: 1.5rem;  --space-6: 2rem;   --space-7: 3rem;

  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial,
          "Noto Sans", "Noto Sans Arabic", sans-serif;

  --tap: 48px;               /* minimum touch target */
  --measure: 640px;          /* comfortable reading width */
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 1.0625rem;          /* 17px — readable on small phones */
  line-height: 1.55;
  overflow-wrap: break-word;     /* long names / emails never overflow */
}

h1, h2, h3 { line-height: 1.25; margin: 0 0 var(--space-3); }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.0625rem; }
p  { margin: 0 0 var(--space-3); }

.wrap {
  width: 100%;
  max-width: var(--measure);
  margin-inline: auto;
  padding-inline: var(--space-4);
}

.skip-link {
  position: absolute; left: -9999px;
  background: var(--brand); color: #fff;
  padding: var(--space-3) var(--space-4);
  border-radius: 0 0 var(--radius) 0; z-index: 100;
}
.skip-link:focus { left: 0; top: 0; }

/* Visible focus everywhere, for keyboard and switch-control users. */
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 6px; }

/* -----------------------------------------------------------------------------
   3. HEADER / FOOTER
----------------------------------------------------------------------------- */
.site-header {
  background: var(--surface);
  border-bottom: 4px solid transparent;
  border-image: linear-gradient(90deg, var(--logo-orange), var(--logo-red)) 1;
  padding-block: var(--space-4);
  padding-top: max(var(--space-4), env(safe-area-inset-top));
}
.site-header__inner {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-3); flex-wrap: wrap;
}

/* The logo is a horizontal lockup (roughly 2.77:1) that already contains the
   organization name, so it is sized by height with width left automatic. The
   name is repeated in visually-hidden text for screen readers, and becomes
   visible only if the image fails to load. */
.brand { display: flex; align-items: center; gap: var(--space-3); min-width: 0; }
.brand__logo {
  height: 58px; width: auto; max-width: min(80vw, 340px);
  object-fit: contain; display: block;
}
.brand__logo[hidden] { display: none; }
.brand__name {
  position: absolute; width: 1px; height: 1px;
  margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}
.brand__name.is-fallback {
  position: static; width: auto; height: auto; margin: 0;
  overflow: visible; clip: auto; clip-path: none; white-space: normal;
  font-weight: 700; color: var(--brand); font-size: 1.0625rem;
}

.langpick { display: flex; align-items: center; gap: var(--space-2); }
.langpick[hidden] { display: none; }
.langpick__label { font-size: .875rem; color: var(--ink-soft); }
.langpick__select {
  min-height: 44px; padding: var(--space-2) var(--space-3);
  border: 1px solid var(--line-strong); border-radius: var(--radius);
  background: var(--surface); font: inherit; font-size: 1rem;
}

.site-footer {
  margin-top: var(--space-7);
  padding-block: var(--space-5);
  padding-bottom: max(var(--space-5), env(safe-area-inset-bottom));
  background: var(--surface); border-top: 1px solid var(--line);
  color: var(--ink-soft); font-size: .875rem;
}
.site-footer__org { font-weight: 600; color: var(--ink); margin-bottom: var(--space-1); }
.site-footer a { color: var(--brand); }
.site-footer__contact { display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-3); }
.site-footer__contact a, .site-footer__contact span { min-height: 24px; }
.site-footer p:last-child { margin-bottom: 0; }

/* -----------------------------------------------------------------------------
   4. CARDS / SECTIONS
----------------------------------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: var(--space-5) var(--space-4);
  margin-block: var(--space-4);
}
.card[hidden] { display: none; }

.intro { border-top: 4px solid transparent;
         border-image: linear-gradient(90deg, var(--logo-orange), var(--logo-red)) 1; }
.intro__title { color: var(--brand); }
.intro__lead { font-size: 1.0625rem; }
.intro__time,
.intro__note { color: var(--ink-soft); font-size: .9375rem; }
.intro__privacy {
  background: var(--brand-tint); border-radius: var(--radius);
  padding: var(--space-3); font-size: .9375rem; margin-bottom: 0;
}

.step__title { color: var(--brand); }
.step__help  { color: var(--ink-soft); font-size: .9375rem; margin-bottom: var(--space-5); }

/* -----------------------------------------------------------------------------
   5. PROGRESS
----------------------------------------------------------------------------- */
.progress { margin-top: var(--space-5); }
.progress[hidden] { display: none; }
.progress__text {
  font-size: .875rem; font-weight: 600; color: var(--ink-soft);
  margin-bottom: var(--space-2);
}
.progress__track {
  height: 10px; background: var(--brand-tint-2); border-radius: 999px; overflow: hidden;
}
.progress__fill {
  height: 100%; width: 0;
  background: linear-gradient(90deg, var(--logo-orange), var(--brand));
  border-radius: 999px; transition: width .25s ease;
}

/* -----------------------------------------------------------------------------
   6. FIELDS
----------------------------------------------------------------------------- */
.field { margin-bottom: var(--space-5); }
.field[hidden] { display: none; }

.label {
  display: inline-block; font-weight: 600; color: var(--ink);
  margin-bottom: var(--space-2);
}
.req {
  display: inline-block; margin-inline-start: var(--space-2);
  color: var(--danger); font-size: .8125rem; font-weight: 600;
  text-transform: lowercase; vertical-align: middle;
}
.req::before { content: "\2731\00a0"; }         /* red star + space */

.help { color: var(--ink-soft); font-size: .875rem; margin: var(--space-2) 0 0; }
.help--lead { margin: 0 0 var(--space-4); }
.counter { color: var(--ink-soft); font-size: .8125rem; margin: var(--space-1) 0 0; }

.input {
  display: block; width: 100%;
  min-height: var(--tap);
  padding: var(--space-3);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface); color: var(--ink);
  font: inherit; font-size: 1.0625rem;   /* >=16px stops iOS zoom-on-focus */
  transition: border-color .15s ease, box-shadow .15s ease;
}
.input:hover { border-color: var(--brand); }
.input:focus-visible { border-color: var(--brand); box-shadow: var(--focus); }
.input::placeholder { color: #98A2B3; }

.select {
  appearance: none;
  padding-inline-end: 2.75rem;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%234B5563'%3E%3Cpath d='M5.5 7.5l4.5 5 4.5-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-3) center;
  background-size: 20px;
}
[dir="rtl"] .select { background-position: left var(--space-3) center; }

.textarea { min-height: 7rem; resize: vertical; line-height: 1.5; }

.currency { position: relative; }
.fieldset[hidden], .row[hidden] { display: none; }
.currency__symbol {
  position: absolute; inset-inline-start: var(--space-3); top: 50%;
  transform: translateY(-50%); color: var(--ink-soft); font-weight: 600;
}
.input--currency { padding-inline-start: 1.85rem; }

/* Two-up rows collapse to one column on narrow phones. */
.row { display: flex; flex-wrap: wrap; gap: var(--space-4); }
.row > .field { flex: 1 1 100%; margin-bottom: var(--space-5); }
@media (min-width: 400px) {
  .row > .field--grow  { flex: 1 1 55%; }
  .row > .field--state { flex: 1 1 35%; }
  .row > .field--zip   { flex: 0 1 9rem; }
  .row > .field--num   { flex: 1 1 8rem; }
}

/* -----------------------------------------------------------------------------
   7. FIELDSETS, RADIOS, CHECKBOXES
----------------------------------------------------------------------------- */
.fieldset { border: 0; padding: 0; margin: 0 0 var(--space-5); min-width: 0; }
.fieldset--block {
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: var(--space-4); margin-bottom: var(--space-5);
}
.fieldset__legend {
  font-weight: 700; color: var(--brand); padding-inline: var(--space-2);
}

.choices { display: flex; flex-direction: column; gap: var(--space-2); }
.choices [hidden] { display: none; }

.choice {
  display: flex; align-items: flex-start; gap: var(--space-3);
  min-height: var(--tap);
  padding: var(--space-3);
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); cursor: pointer;
  transition: background .12s ease, border-color .12s ease;
}
.choice:hover { border-color: var(--brand); background: var(--brand-tint); }

/* The native control stays in the accessibility tree but is visually replaced
   by .choice__box, which mirrors its state. */
.choice input { position: absolute; opacity: 0; width: 1px; height: 1px; }

.choice__box {
  flex: none; width: 26px; height: 26px; margin-top: 1px;
  border: 2px solid var(--line-strong); background: var(--surface);
  border-radius: 6px; position: relative;
}
.choice input[type="radio"] ~ .choice__box { border-radius: 50%; }

.choice input:checked ~ .choice__box {
  border-color: var(--brand); background: var(--brand);
}
.choice input[type="checkbox"]:checked ~ .choice__box::after {
  content: ""; position: absolute; left: 7px; top: 2px;
  width: 6px; height: 12px; border: solid #fff;
  border-width: 0 3px 3px 0; transform: rotate(45deg);
}
.choice input[type="radio"]:checked ~ .choice__box::after {
  content: ""; position: absolute; inset: 5px;
  background: #fff; border-radius: 50%;
}
.choice input:focus-visible ~ .choice__box { box-shadow: var(--focus); }
.choice:has(input:checked) { border-color: var(--brand); background: var(--brand-tint); }

.choice__text { flex: 1; }
.choice--consent { margin-bottom: var(--space-3); align-items: flex-start; }

@media (min-width: 560px) {
  .choices--grid { display: grid; grid-template-columns: 1fr 1fr; }
}

/* -----------------------------------------------------------------------------
   8. VALIDATION STATES
----------------------------------------------------------------------------- */
.error {
  display: flex; gap: var(--space-2);
  color: var(--danger); font-size: .9375rem; font-weight: 500;
  margin: var(--space-2) 0 0;
}
.error[hidden] { display: none; }
.error::before { content: "\26A0"; flex: none; }   /* warning sign */

.input--invalid { border-color: var(--danger); border-width: 2px; background: #FFFBFB; }
.fieldset--invalid .choice { border-color: var(--danger); }

/* -----------------------------------------------------------------------------
   9. NOTICES
----------------------------------------------------------------------------- */
.notice {
  border-radius: var(--radius); padding: var(--space-4);
  margin-block: var(--space-4); border-inline-start: 5px solid;
}
.notice[hidden] { display: none; }
.notice p:last-child { margin-bottom: 0; }
.notice--info  { background: var(--info-bg);  border-color: var(--brand); }
.notice--error { background: var(--danger-bg); border-color: var(--danger); color: #7A1912; }
.notice__title { font-size: 1rem; margin-bottom: var(--space-2); }
.notice__list { margin: 0; padding-inline-start: 1.25rem; }
.notice__list li { margin-bottom: var(--space-1); }
.notice__list a { color: inherit; font-weight: 600; }
.notice__sub { font-size: .9375rem; margin-top: var(--space-2); }

/* -----------------------------------------------------------------------------
   10. REVIEW SUMMARY
----------------------------------------------------------------------------- */
.review__heading { color: var(--brand); }
.review { margin-bottom: var(--space-5); }
.review__group {
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: var(--space-3) var(--space-4); margin-bottom: var(--space-3);
}
.review__groupTitle {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: var(--space-3); font-size: 1rem; font-weight: 700;
  color: var(--brand); margin-bottom: var(--space-2);
}
.review__list { margin: 0; }
.review__row { display: flex; flex-wrap: wrap; gap: var(--space-2); padding-block: var(--space-1); }
.review__key { color: var(--ink-soft); font-size: .9375rem; flex: 1 1 45%; }
.review__val { font-weight: 600; flex: 1 1 45%; }
.review__val--empty { font-weight: 400; color: var(--ink-soft); font-style: italic; }

.signdate { color: var(--ink-soft); font-size: .9375rem; }
.field--save { margin-top: var(--space-5); }

/* -----------------------------------------------------------------------------
   11. BUTTONS AND NAVIGATION
----------------------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: var(--tap); padding: var(--space-3) var(--space-5);
  border: 2px solid transparent; border-radius: var(--radius);
  font: inherit; font-size: 1.0625rem; font-weight: 600;
  text-decoration: none; cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.btn--primary { background: var(--brand); color: #fff; }
.btn--primary:hover { background: var(--brand-dark); }
.btn--ghost { background: var(--surface); color: var(--brand); border-color: var(--brand); }
.btn--ghost:hover { background: var(--brand-tint); }
.btn--link {
  background: none; border: 0; padding: var(--space-2) 0; min-height: 44px;
  color: var(--brand); text-decoration: underline; font-weight: 600;
}
.btn[disabled] { opacity: .6; cursor: progress; }
.btn[hidden] { display: none; }

.navbar {
  position: sticky; bottom: 0; z-index: 10;
  display: flex; gap: var(--space-3);
  padding: var(--space-3) 0;
  padding-bottom: max(var(--space-3), env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 70%, rgba(250,247,245,0));
}
.navbar[hidden] { display: none; }
.navbar .btn { flex: 1; }
.navbar .btn--ghost { flex: 0 1 9rem; }

/* -----------------------------------------------------------------------------
   12. CONFIRMATION
----------------------------------------------------------------------------- */
.confirm { text-align: center; border-top: 4px solid var(--success); }
.confirm__mark { color: var(--success); margin-bottom: var(--space-3); }
.confirm__title { color: var(--success); }
.confirm__body { font-size: 1.0625rem; }
.confirm__ref { color: var(--ink-soft); font-size: .875rem; }
.confirm__ref code {
  background: var(--bg); padding: 2px 6px; border-radius: 4px;
  font-size: .875rem; word-break: break-all;
}
.confirm__actions {
  display: flex; flex-direction: column; gap: var(--space-3);
  margin-top: var(--space-5);
}
@media (min-width: 480px) {
  .confirm__actions { flex-direction: row; justify-content: center; }
}

/* -----------------------------------------------------------------------------
   13. QR PANEL (shared with qr.html)
----------------------------------------------------------------------------- */
.qr { text-align: center; }
.qr__heading { color: var(--brand); }
.qr__canvas {
  display: block; margin: var(--space-4) auto;
  width: 260px; height: 260px; max-width: 100%;
  background: #fff; padding: var(--space-3);
  border: 1px solid var(--line); border-radius: var(--radius);
}
.qr__url { font-size: .875rem; color: var(--ink-soft); word-break: break-all; }
.qr__actions { display: flex; flex-wrap: wrap; gap: var(--space-3); justify-content: center; }

/* -----------------------------------------------------------------------------
   14. HONEYPOT (never shown to a human; not display:none so bots still fill it)
----------------------------------------------------------------------------- */
.hp {
  position: absolute; left: -10000px; top: auto;
  width: 1px; height: 1px; overflow: hidden;
}

/* -----------------------------------------------------------------------------
   15. LARGER SCREENS
----------------------------------------------------------------------------- */
@media (min-width: 768px) {
  body { font-size: 1.125rem; }
  h1 { font-size: 1.875rem; }
  h2 { font-size: 1.5rem; }
  .card { padding: var(--space-6); }
  .brand__logo { height: 76px; max-width: 460px; }
}

/* -----------------------------------------------------------------------------
   16. USER PREFERENCES
----------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

@media (prefers-contrast: more) {
  :root { --line: #000; --line-strong: #000; --ink-soft: #333; }
  .input { border-width: 2px; }
}

@media print {
  .navbar, .langpick, .progress, .skip-link, .site-footer { display: none !important; }
  .card { box-shadow: none; border: 1px solid #000; break-inside: avoid; }
  body { background: #fff; }
}

/* -----------------------------------------------------------------------------
   17. PROGRAM ROUTING FEEDBACK
   Shown on the first step so the client can see why the form is changing.
----------------------------------------------------------------------------- */
.progress__modules {
  margin: var(--space-2) 0 0;
  font-size: .8125rem; color: var(--ink-soft);
}
.progress__modules[hidden] { display: none; }

.routed {
  background: var(--brand-tint);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--space-4);
  margin-top: var(--space-5);
}
.routed[hidden] { display: none; }
.routed__title { font-weight: 700; color: var(--brand); margin-bottom: var(--space-2); }
.routed__list { margin: 0; padding-inline-start: 1.25rem; }
.routed__list li { margin-bottom: var(--space-1); }

/* Context box explaining why a sensitive question is being asked. */
.whybox {
  background: var(--info-bg);
  border-inline-start: 4px solid var(--brand);
  border-radius: var(--radius);
  padding: var(--space-3);
  font-size: .9375rem;
  margin-bottom: var(--space-5);
}

/* A block of follow-up questions revealed by an earlier answer. */
.subgroup {
  border-inline-start: 3px solid var(--brand-tint-2);
  padding-inline-start: var(--space-4);
  margin-bottom: var(--space-5);
}
.subgroup[hidden] { display: none; }
.subgroup__title {
  color: var(--brand); font-size: 1rem;
  margin-bottom: var(--space-4);
}

/* -----------------------------------------------------------------------------
   18. CALCULATED VALUES
   Read-only figures derived from what the client typed. Styled as output, not
   as an input, so nobody tries to edit them.
----------------------------------------------------------------------------- */
.calc {
  display: flex; flex-wrap: wrap; align-items: baseline;
  gap: var(--space-2) var(--space-3);
  background: var(--brand-tint);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  padding: var(--space-3);
  margin-bottom: var(--space-4);
}
.calc[hidden] { display: none; }
.calc .label { margin-bottom: 0; font-weight: 500; color: var(--ink-soft); flex: 1 1 55%; }
.calc .help  { flex: 1 1 100%; margin-top: 0; }

.calc__value {
  font-size: 1.25rem; font-weight: 700; color: var(--brand);
  font-variant-numeric: tabular-nums;
}
/* The poverty band is a sentence, not a figure, so it reads at body size and
   takes a full line of its own. */
.calc--category { flex-direction: column; align-items: flex-start; }
.calc__value--wrap { font-size: 1.0625rem; line-height: 1.4; }

.calcgroup { margin-bottom: var(--space-5); }
.calcgroup__note {
  font-size: .8125rem; color: var(--ink-soft);
  margin: 0 0 var(--space-4);
}
.calcgroup:not(:has(.calc:not([hidden]))) { display: none; }
