/* =========================================================================
   Mr. Auto Finance - apply form (loads after styles.css and brand.css)
   One calm question at a time for an anxious, mostly mobile audience:
   brand headings with the terracotta full stop, visible field labels and
   messages, readable disabled state, 44px+ tap targets, a quiet frame on desktop.
   Brand tokens come from brand.css (--maf-*). The template's rules in
   styles.css are overridden here, never edited.
   ========================================================================= */

body.apply-shell {
  --apply-w: 640px;
  --apply-bg: var(--maf-paper);
  --apply-edge: #CFC3B2;      /* input and tile borders: findable against paper and white */
  --apply-error: #A3201A;
}
/* The template reserves 76px at the bottom of every phone page for a sticky call bar the
   apply page does not have; that space belongs to the form (styles.css, section 19). */
body.apply-shell { padding-bottom: env(safe-area-inset-bottom, 0px); }
/* Phones with the keyboard open: the page shrinks to the visible area (set by script.js) */
body.apply-shell.kb-open { height: var(--maf-vvh, 100dvh); }

/* ---- Header: solid paper with a hairline, like the marketing pages ----- */
body.apply-shell .apply-header {
  flex: none;
  background: var(--maf-paper);
  border-bottom: 1px solid var(--maf-line);
  padding: 12px 16px;
}
body.apply-shell .apply-header__logo { width: auto; }
body.apply-shell.on-thanks .apply-header__logo { width: auto; }

/* ---- Progress area: time-left label, brand-colour bar, reassurance ------- */
/* "Step X of 5" is in the markup for screen readers only (.sr-only); the bar carries role=progressbar. */
.apply-prog {
  flex: none;
  width: 100%;
  max-width: var(--apply-w);
  margin: 0 auto;
  padding: 16px 16px 0;
  word-spacing: 0.1em; /* the face sets digits tight against the next word */
}
.apply-prog[hidden] { display: none; }
.apply-prog__meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  font-size: 0.875rem;
  line-height: 1.3;
}
.apply-prog__time { font-weight: 700; color: var(--maf-ox); letter-spacing: -0.005em; }
.apply-prog__bar {
  position: relative;
  height: 8px;
  border-radius: 999px;
  background: #E6DCCB;
}
.apply-prog__fill {
  position: relative;
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--maf-ox);
  transition: width 0.45s cubic-bezier(0.16, 1, 0.3, 1);
}
/* the brand's accent full stop closes the bar */
.apply-prog__fill::after {
  content: '';
  position: absolute;
  inset-inline-end: -2px;
  top: 50%;
  width: 12px;
  height: 12px;
  margin-top: -6px;
  border-radius: 50%;
  background: var(--maf-tc);
  box-shadow: 0 0 0 3px var(--apply-bg);
}
.apply-prog__reassure {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 14px 0 0;
  font-size: 0.8125rem;
  line-height: 1.45;
  font-weight: 500;
  color: var(--maf-muted);
  text-align: left;
}
.apply-prog__reassure svg { flex: none; margin-top: 1px; color: var(--maf-tc-text); }

/* "The form is in English" note, shown only for ?lang=ko|zh|fa. Its text, lang and dir are set in the HTML. */
.apply-langnote {
  margin: 0 0 14px;
  padding: 10px 14px;
  background: var(--maf-iv);
  border: 1px solid var(--maf-line);
  border-radius: 12px;
  font-size: 0.9375rem;
  line-height: 1.55;
  font-weight: 500;
  color: var(--maf-ink);
  word-spacing: normal;
}
.apply-langnote[hidden] { display: none; }
.apply-langnote[lang="ko"] { font-family: 'Plus Jakarta Sans', 'Apple SD Gothic Neo', 'Malgun Gothic', 'Noto Sans KR', sans-serif; word-break: keep-all; }
.apply-langnote[lang="zh"] { font-family: 'Plus Jakarta Sans', 'PingFang SC', 'Microsoft YaHei', 'Noto Sans SC', sans-serif; line-break: strict; }
.apply-langnote[lang="fa"] { font-family: 'Vazirmatn', 'Plus Jakarta Sans', Tahoma, sans-serif; }

@media (prefers-reduced-motion: reduce) {
  .apply-prog__fill { transition: none; }
}

/* ---- Main column: steps start at the top, left aligned ---------------- */
body.apply-shell .apply-main.apply-main--centered {
  align-items: flex-start;
  padding: 24px 16px 28px;
}
.apply-form { width: 100%; max-width: var(--apply-w); margin: 0 auto; }
body.apply-shell .apply-form .qstep {
  max-width: none;
  margin: 0;
  text-align: left;
  align-items: stretch;
  gap: 16px;
}

/* Quiet frame on desktop: a white card on ivory, one hairline, no shadow */
@media (min-width: 768px) {
  body.apply-shell { --apply-bg: var(--maf-iv); background: var(--maf-iv); }
  .apply-prog { padding: 28px 0 0; }
  body.apply-shell .apply-main.apply-main--centered { padding: 24px 40px 56px; }
  body.apply-shell .apply-form .qstep {
    background: #fff;
    border: 1px solid var(--maf-line);
    border-radius: 24px;
    padding: 40px 44px 44px;
    gap: 18px;
  }
  .apply-prog__meta { font-size: 0.9375rem; }
  .apply-prog__reassure { font-size: 0.875rem; }
}

/* Short phones (about 667px and under): trim the chrome so the tallest steps still fit */
@media (max-width: 767px) and (max-height: 720px) {
  body.apply-shell .apply-header { padding-top: 8px; padding-bottom: 8px; }
  .apply-prog { padding-top: 10px; }
  .apply-prog__meta { margin-bottom: 8px; }
  .apply-prog__reassure { margin-top: 8px; }
  body.apply-shell .apply-main.apply-main--centered { padding-top: 20px; }
  body.apply-shell .apply-form .qstep { gap: 12px; }
  body.apply-shell .name-row { gap: 12px; }
  body.apply-shell .afield input,
  body.apply-shell .afield select { min-height: 48px; padding-block: 10px; }
}
/* Keyboard open: give the fields the room */
body.apply-shell.kb-open .apply-header { padding-block: 6px; }
body.apply-shell.kb-open .apply-prog { padding-top: 8px; }
body.apply-shell.kb-open .apply-prog__reassure,
body.apply-shell.kb-open .apply-prog__time,
body.apply-shell.kb-open .apply-langnote { display: none; }
body.apply-shell.kb-open .apply-main.apply-main--centered { padding-top: 16px; }

/* ---- Step titles: left aligned, deep teal, terracotta full stop --------- */
body.apply-shell .qstep__h,
body.apply-shell .thanks-card h1 {
  font-size: clamp(1.625rem, 1.25rem + 1.6vw, 1.875rem);
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.15;
  color: var(--maf-ox);
  text-align: left;
  text-wrap: balance;
  margin: 0;
}
body.apply-shell .qstep__h:focus,
body.apply-shell .thanks-card h1:focus { outline: none; }
body.apply-shell .qstep__sub,
body.apply-shell .qstep__reason {
  margin: -4px 0 0;
  font-size: 1rem;
  line-height: 1.5;
  font-weight: 500;
  color: var(--maf-body);
  letter-spacing: 0;
  text-align: left;
  max-width: 46ch;
}
body.apply-shell .qstep__subq {
  margin: 4px 0 0;
  font-size: 1.0625rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--maf-ink);
  text-align: left;
}

/* ---- Fields: visible labels above, plain-words messages below --------- */
body.apply-shell .afield { display: flex; flex-direction: column; gap: 0; text-align: left; }
body.apply-shell .afield label {
  margin: 0 0 6px;
  font-size: 0.9375rem;
  font-weight: 700;
  letter-spacing: -0.005em;
  text-transform: none;
  color: var(--maf-ink);
}
body.apply-shell .afield input,
body.apply-shell .afield select,
body.apply-shell .afield textarea {
  width: 100%;
  min-height: 52px;
  padding: 13px 16px;
  background: #fff;
  border: 1.5px solid var(--apply-edge);
  border-radius: 14px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 500;
  line-height: 1.3;
  color: var(--maf-ink);
  text-align: left;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
body.apply-shell .afield textarea { min-height: 104px; resize: vertical; line-height: 1.45; }
body.apply-shell .afield input:focus,
body.apply-shell .afield select:focus,
body.apply-shell .afield textarea:focus {
  outline: 2px solid transparent;
  border-color: var(--maf-ox);
  box-shadow: 0 0 0 3px rgba(23, 84, 90, 0.18);
}
body.apply-shell .afield input::placeholder,
body.apply-shell .afield textarea::placeholder {
  color: #7A716A;
  opacity: 1;
  font-weight: 400;
}
body.apply-shell .afield .field-note {
  margin-top: 6px;
  font-size: 0.875rem;
  line-height: 1.4;
  color: var(--maf-muted);
  text-align: left;
}
.field-error, .qstep__error {
  margin: 0;
  font-size: 0.875rem;
  line-height: 1.4;
  font-weight: 600;
  color: var(--apply-error);
}
.field-error:not(:empty) { margin-top: 6px; }
.field-error, .apply-hint { text-wrap: balance; } /* two-line messages split evenly, no stranded last word */
body.apply-shell .afield [aria-invalid="true"] { border-color: var(--apply-error); }
body.apply-shell .afield [aria-invalid="true"]:focus { box-shadow: 0 0 0 3px rgba(163, 32, 26, 0.16); }
/* Submit failure: a calm notice above the button */
.qstep__error { font-size: 0.9375rem; line-height: 1.5; }
.qstep__error:not(:empty) {
  padding: 12px 14px;
  background: #FBEEEB;
  border-radius: 12px;
}

/* Contact: first and last name stack on phones and sit side by side from 600px */
body.apply-shell .name-row { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; align-items: start; }
@media (min-width: 600px) {
  body.apply-shell .name-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}

/* ---- Choices: vehicle photos, option rows, income tiles ---------------- */
body.apply-shell .vehicle-tiles {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 4px 0 0;
}
body.apply-shell .vehicle-tile {
  min-height: 44px;
  padding: 8px 8px 12px;
  background: #fff;
  border: 1.5px solid var(--apply-edge);
  border-radius: 18px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
body.apply-shell .vehicle-tile__photo { border-radius: 12px; box-shadow: none; }
body.apply-shell .vehicle-tile__label { color: var(--maf-ink); font-weight: 700; }
body.apply-shell .vehicle-tile.is-selected,
body.apply-shell .vehicle-tile[aria-checked="true"] {
  border-color: var(--maf-ox);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(23, 84, 90, 0.16);
}
body.apply-shell .vehicle-tile.is-selected .vehicle-tile__label,
body.apply-shell .vehicle-tile[aria-checked="true"] .vehicle-tile__label { color: var(--maf-ox); }

body.apply-shell .option-list,
body.apply-shell .income-tiles { gap: 10px; margin: 4px 0 0; text-align: left; }
body.apply-shell .option-row,
body.apply-shell .income-tile {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 52px;
  padding: 12px 18px;
  background: #fff;
  border: 1.5px solid var(--apply-edge);
  border-radius: 14px;
  box-shadow: none;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--maf-ink);
  text-align: left;
  transition: border-color 0.2s ease, background-color 0.2s ease, color 0.2s ease;
}
/* radio mark at the end of each row so it reads as a choice */
body.apply-shell .option-row::after,
body.apply-shell .income-tile::after {
  content: '';
  flex: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid var(--apply-edge);
  background: #fff;
}
@media (hover: hover) {
  body.apply-shell .option-row:hover,
  body.apply-shell .income-tile:hover { border-color: var(--maf-ox); }
}
body.apply-shell .option-row.is-selected,
body.apply-shell .income-tile.is-selected,
body.apply-shell .option-row[aria-checked="true"],
body.apply-shell .income-tile[aria-checked="true"] {
  background: var(--maf-ox);
  border-color: var(--maf-ox);
  color: var(--maf-iv);
}
body.apply-shell .option-row.is-selected::after,
body.apply-shell .income-tile.is-selected::after,
body.apply-shell .option-row[aria-checked="true"]::after,
body.apply-shell .income-tile[aria-checked="true"]::after {
  border-color: var(--maf-ap);
  background: var(--maf-ap);
  box-shadow: inset 0 0 0 3px var(--maf-ox);
}
/* Rent | Own, with "With family / other" on its own row */
body.apply-shell .option-list--compact { grid-template-columns: 1fr 1fr; }
body.apply-shell .option-list--compact .option-row { min-height: 56px; }
body.apply-shell .option-list--compact .option-row:nth-child(3) { grid-column: 1 / -1; }
/* Work collapses to the chosen row while the length field is open
   (the screen was called "employment" before 2026-10-26; styles.css still carries the old selectors). */
.qstep[data-step="work"].employment-picked .option-list { gap: 0; margin-top: 0; }
.qstep[data-step="work"].employment-picked .option-row:not(.is-selected) { display: none; }
.qstep[data-step="work"].employment-picked .qstep__subq { margin-top: var(--s-12); }
.qstep[data-step="work"].employment-picked .emp-duration-wrap { margin-top: 10px; }
.qstep[data-step="work"].employment-picked #empDuration .qstep__nav { margin-top: var(--s-20); }
body.apply-shell .qstep[data-step="work"].employment-picked .option-row.is-selected { cursor: default; box-shadow: none; }

/* Progressive blocks: keep input focus rings from being clipped, space the pieces */
body.apply-shell .progressive-field { display: flex; flex-direction: column; gap: 12px; }
body.apply-shell .progressive-field.is-revealed { padding: 4px; margin: 0 -4px; }
body.apply-shell .emp-duration-wrap { margin: 0; }
/* The housing screen's lower half (payment, note, consent, Submit) is taller than the 600px reveal cap */
body.apply-shell #housingRest.is-revealed { max-height: 1600px; }
body.apply-shell #housingRest .qstep__subq { margin-top: 0; }

/* Optional note: a quiet text button that opens the textarea */
body.apply-shell .note-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  margin: 0 0 0 -4px;
  padding: 0 4px;
  background: none;
  border: 0;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.9375rem;
  font-weight: 700;
  line-height: 1.3;
  color: var(--maf-ox);
  text-align: left;
  cursor: pointer;
  touch-action: manipulation;
}
body.apply-shell .note-toggle span {
  text-wrap: balance;
  text-decoration: underline;
  text-decoration-color: var(--maf-ap);
  text-underline-offset: 4px;
}
body.apply-shell .note-toggle:hover { color: var(--maf-ox-900); }
body.apply-shell .note-toggle:focus-visible { outline: 2px solid var(--maf-ox); outline-offset: 2px; }
body.apply-shell .note-toggle__icon { flex: none; color: var(--maf-tc-text); transition: transform 0.2s ease; }
body.apply-shell .note-toggle.is-open .note-toggle__icon { transform: rotate(45deg); }
body.apply-shell .afield.note-panel { margin-top: 4px; }
body.apply-shell .afield.note-panel[hidden] { display: none; }
@media (prefers-reduced-motion: reduce) {
  body.apply-shell .note-toggle__icon { transition: none; }
}

/* ---- Notice, consent, legal -------------------------------------------- */
body.apply-shell .qstep__notice {
  margin: 0;
  font-size: 0.875rem;
  line-height: 1.5;
  font-weight: 500;
  color: var(--maf-body);
  text-align: left;
}
body.apply-shell .qstep__consent {
  margin: 0;
  font-size: 0.9375rem;
  line-height: 1.55;
  font-weight: 500;
  color: var(--maf-ink);
  text-align: left;
}
body.apply-shell .qstep__consent strong { font-weight: 700; }
body.apply-shell .qstep__legal {
  margin: 0;
  font-size: 0.8125rem;
  line-height: 1.55;
  color: var(--maf-muted);
  text-align: left;
}
body.apply-shell .qstep__legal a,
body.apply-shell .qstep__notice a,
body.apply-shell .thanks-card__email a {
  color: var(--maf-ox);
  font-weight: 600;
  text-decoration: underline;
  text-decoration-color: var(--maf-ap);
  text-underline-offset: 3px;
  /* vertical padding on an inline box enlarges the tap area without changing line spacing */
  padding: 15px 3px;
  margin-inline: -3px;
}

/* ---- Continue: deep teal when ready, warm and readable when not ---------- */
body.apply-shell .qstep__nav { justify-content: flex-start; margin-top: 4px; }
body.apply-shell .qstep__nav .btn--primary {
  flex: 1 1 auto;
  width: 100%;
  min-height: 56px;
  border: 1px solid transparent;
  font-family: inherit;
}
body.apply-shell .qstep__nav .btn--primary[aria-disabled="true"],
body.apply-shell .qstep__nav .btn--primary[aria-disabled="true"]:hover {
  opacity: 1;
  background: var(--maf-iv);
  color: var(--maf-muted);
  border: 1px solid #D3C7B5;
  box-shadow: none;
  transform: none;
  cursor: not-allowed;
}
body.apply-shell .qstep__nav .btn--primary[disabled] {
  opacity: 0.7;
  cursor: progress;
  pointer-events: none;
}
@media (min-width: 768px) {
  body.apply-shell .qstep__nav .btn--primary { flex: 0 0 auto; width: auto; min-width: 260px; }
}
.apply-hint {
  margin: -6px 0 0;
  text-align: left;
  font-size: 0.875rem;
  line-height: 1.4;
  font-weight: 500;
  color: var(--maf-muted);
  word-spacing: 0.08em;
}
.apply-hint[hidden] { display: none; }
/* ---- Back button -------------------------------------------------------- */
body.apply-shell .apply-back {
  width: 48px;
  height: 48px;
  left: 4px;
  color: var(--maf-ox);
  border-radius: 999px;
}
body.apply-shell .apply-back:hover { color: var(--maf-ox-900); background: rgba(23, 84, 90, 0.06); }

/* ---- Thank you ----------------------------------------------------------- */
body.apply-shell .qstep--thanks { max-width: none; }
body.apply-shell .thanks-card { align-items: stretch; text-align: left; gap: 14px; }
body.apply-shell .thanks-card__image img { aspect-ratio: 16 / 10; border-radius: 18px; }
body.apply-shell .thanks-card p {
  max-width: 48ch;
  margin: 0;
  font-size: 1rem;
  line-height: 1.55;
  color: var(--maf-body);
  text-align: left;
}
body.apply-shell .thanks-card .thanks-card__ready { color: var(--maf-ink); font-weight: 600; }
body.apply-shell .thanks-card .thanks-card__email { font-size: 0.9375rem; color: var(--maf-muted); }
