/* =========================================================
   HELOC Veterans quiz (M-065) - Comparisons.org
   Design: 20700146 (flag background, navy / blue palette).
   Questions and logic from 20700173, veteran question first (Alex, 3/12). Mobile first.
   ========================================================= */
:root {
  --navy: #1d3557;
  --blue: #2670a8;
  --blue-dark: #155578;
  --blue-light: #e8f1f9;
  --blue-line: #d3e1ee;
  --red: #b22234;
  --ink: #0f1e2a;
  --muted: #475569;
  --soft: #64748b;
  --line: #e2e5e8;
  --bg: #f3f6fa; /* fallback under the flag background */
  --footer-bg: #f2f4f7;
  --green: #047857;
  --tp-green: #00b67a;
  /* Clear shadow on answer buttons (Alex) */
  --opt-shadow: 0 6px 18px rgba(15, 40, 70, 0.13), 0 1px 3px rgba(15, 40, 70, 0.10);
  --radius: 14px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
/* US flag background, same image and white fade as 20700146 (Alex, 3/12).
   Fixed layer on ::before (background-attachment: fixed is unreliable on iPhone). */
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    linear-gradient(rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0.85)),
    url("assets/flag-bg.jpg") center top / cover no-repeat;
}
img { display: block; max-width: 100%; height: auto; }
ul, ol { list-style: none; }
button { font: inherit; }
a { color: inherit; }

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

/* ---------- Closing image (placeholder until the real photo is ready) ---------- */
.closing-img {
  display: block; width: 100%; max-width: 560px; margin: 40px auto 24px;
  aspect-ratio: 3 / 2; border-radius: 16px; object-fit: cover;
}
.closing-img--placeholder {
  display: flex; align-items: center; justify-content: center; padding: 16px;
  background: #eef2f7; border: 2px dashed #c3ccd8; color: var(--muted);
  font-size: 14px; text-align: center;
}

/* ---------- Header (approved Comparisons.org component) ---------- */
.brand-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 16px; background: #fff; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.brand-row__brand { flex: 0 1 181px; min-width: 0; }
.brand-row__logo { width: 181px; height: auto; }
.disclosure-link {
  flex: none; font-size: 11px; line-height: 16px; color: var(--soft);
  text-decoration: underline; text-underline-offset: 2px; cursor: pointer;
}
.disclosure-link:hover { color: var(--blue); }
body.quiz-active .disclosure-link { visibility: hidden; }

/* ---------- Layout ---------- */
.main { padding: 0 16px; }
/* The quiz fills the screen so the footer never shows above the fold (AGENTS.md) */
.quiz-area {
  max-width: 560px;
  margin: 0 auto;
  padding: 12px 0 24px;
  min-height: calc(100svh - 62px);
}

/* ---------- Intro (Question 1 only) ---------- */
.intro { text-align: center; }
.hero-title {
  font-size: 30px; font-weight: 800; line-height: 1.2; letter-spacing: -0.02em;
  color: var(--navy); text-wrap: balance;
  margin-bottom: 24px;
}
body.quiz-active .intro { display: none; }

/* ---------- Quiz nav: Back row, then Step X of 10 + %, then bar (Alex) ---------- */
.quiz-nav { margin: 4px 0 24px; }
body:not(.quiz-active) .quiz-nav,
body.is-flow .quiz-nav { display: none; }
.quiz-back {
  display: inline-flex; align-items: center; gap: 2px;
  margin: 0 0 10px -4px; padding: 6px 4px;
  background: none; border: 0; cursor: pointer;
  font-size: 16px; font-weight: 600; color: var(--blue);
}
.quiz-back svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.quiz-nav__meta { display: flex; justify-content: space-between; font-size: 13px; font-weight: 600; color: var(--soft); margin-bottom: 8px; }
.quiz-nav__step { text-transform: uppercase; letter-spacing: 0.5px; }
.quiz-nav__pct { color: var(--blue); }
.quiz-nav__bar { height: 6px; background: var(--blue-light); border-radius: 999px; overflow: hidden; }
.quiz-nav__fill { display: block; height: 100%; width: 0; background: var(--blue); border-radius: 999px; transition: width 0.3s ease; }

/* ---------- Steps ---------- */
.form_step { display: none; text-align: center; }
.form_step.--active { display: block; }
/* Questions only fade in (no exit animation); Loading appears instantly (AGENTS.md) */
.form_step.--active:not([data-step="11"]) { animation: stepIn 0.25s ease; }
@keyframes stepIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* Question title: 30px mobile, sentence case (Alex) */
.q-title {
  font-size: 30px; font-weight: 700; line-height: 1.22; letter-spacing: -0.02em;
  color: var(--ink); text-wrap: balance;
  margin: 0 auto 24px; max-width: 520px;
}
/* Question 1 sits under the headline: one size down so the headline leads */
.q-title--first { font-size: 24px; margin-bottom: 8px; }
.q-sub { font-size: 16px; color: var(--soft); margin: -12px auto 24px; max-width: 420px; text-wrap: pretty; }
.q-title--first + .q-sub { margin-top: 0; }

/* ---------- Answer options ---------- */
.options { display: grid; gap: 14px; margin: 0 auto; max-width: 440px; }
.opt { display: block; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.opt-box {
  display: flex; align-items: center; justify-content: center; gap: 14px;
  min-height: 72px; padding: 18px 20px;
  background: #fff;
  border: 1.5px solid var(--blue-line);
  border-radius: var(--radius);
  box-shadow: var(--opt-shadow);
  color: var(--ink);
  transition: border-color 0.15s ease, background-color 0.15s ease, color 0.15s ease, transform 0.12s ease;
}
/* Answer text 20px on all steps (Alex) */
.opt-text { font-size: 20px; font-weight: 600; line-height: 1.25; letter-spacing: -0.01em; }
.opt-range { font-weight: 500; }
/* Hover only on devices with a mouse - on phones hover "sticks" to the next step's button (Alex) */
@media (hover: hover) {
  .opt:hover .opt-box { border-color: var(--blue); }
}
.opt:active .opt-box { transform: scale(0.98); }
.opt input:focus-visible + .opt-box { outline: 3px solid var(--blue); outline-offset: 2px; }
.opt input:checked + .opt-box { background: var(--blue); border-color: var(--blue); color: #fff; }

/* Yes / No: big check and X, No in yellow (Alex) */
.options--yn { grid-template-columns: 1fr 1fr; gap: 12px; }
.options--yn .opt-box { flex-direction: column; gap: 12px; min-height: 158px; padding: 20px 12px 16px; }
.yn-icon {
  width: 84px; height: 84px; display: flex; align-items: center; justify-content: center;
  border-radius: 50%; background: var(--blue-light); color: var(--blue);
}
.yn-icon svg { width: 48px; height: 48px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.opt--no .yn-icon { background: #fef3c7; color: #d97706; }
.opt input:checked + .opt-box .yn-icon { background: rgba(255, 255, 255, 0.2); color: #fff; }

/* Icon cards (property type / use / purpose) */
.options--cards .opt-box { justify-content: flex-start; text-align: left; min-height: 80px; }
.opt-icon { flex: none; width: 34px; height: 34px; color: var(--blue); }
.opt-icon svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.opt-icon svg text, .opt-icon svg .dot { fill: currentColor; }
.opt input:checked + .opt-box .opt-icon { color: #fff; }

/* Pills (income / credit / amount) */
.options--pills .opt-box { min-height: 68px; }

/* ---------- Trust tags (Question 1): 14px, one row (Alex) ---------- */
.trust-tags { display: flex; justify-content: center; flex-wrap: wrap; gap: 5px; margin-top: 22px; }
.trust-tags li {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 14px; font-weight: 700; white-space: nowrap;
  color: var(--blue-dark); background: var(--blue-light);
  padding: 5px 7px; border-radius: 6px;
}
.trust-tags svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- CTA (Next / closing): ~70px, 22px text (Alex) ---------- */
.cta {
  display: flex; align-items: center; justify-content: center;
  width: 100%; max-width: 440px; min-height: 70px; margin: 28px auto 0; padding: 14px 24px;
  font-size: 22px; font-weight: 700; color: #fff; text-decoration: none;
  background: var(--blue); border: 0; border-radius: var(--radius); cursor: pointer;
  transition: background-color 0.15s ease;
}
@media (hover: hover) { .cta:hover { background: var(--blue-dark); } }
.cta:focus-visible { outline: 3px solid var(--navy); outline-offset: 3px; }
.cta:disabled { background: #cbd5e1; color: #fff; cursor: not-allowed; }

/* ---------- Sliders ---------- */
.range-slider { max-width: 440px; margin: 8px auto 0; padding: 0 6px; }
.range-value {
  font-size: 44px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.1;
  color: var(--blue); font-variant-numeric: tabular-nums; margin-bottom: 18px;
}
/* Mortgage before it's moved shows "Slide to select" (20700173) - a bit smaller so it fits at 320 */
.range-slider:not(.is-touched) .range-value { font-size: 32px; line-height: 48px; }
.ineligible-message {
  max-width: 340px; margin: 8px auto 0; padding: 20px 24px;
  font-size: 17px; line-height: 1.5; text-align: center;
  color: #b45309; background: #fff7ed; border: 1px solid #fdba74; border-radius: 12px;
}
.range-slider input[type=range] {
  --fill: 0%;
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 8px; margin: 12px 0; border-radius: 999px; outline: none; cursor: pointer;
  background: linear-gradient(to right, var(--blue) 0 var(--fill), var(--blue-light) var(--fill) 100%);
}
.range-slider input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 32px; height: 32px; border-radius: 50%;
  background: #fff; border: 3px solid var(--blue);
  box-shadow: 0 2px 8px rgba(38, 112, 168, 0.35); cursor: pointer;
}
.range-slider input[type=range]::-moz-range-thumb {
  width: 32px; height: 32px; border-radius: 50%;
  background: #fff; border: 3px solid var(--blue);
  box-shadow: 0 2px 8px rgba(38, 112, 168, 0.35); cursor: pointer;
}
/* Until the slider is moved, the handle pulses - a hint that it needs to be dragged */
.range-slider:not(.is-touched) input[type=range]::-webkit-slider-thumb { animation: thumbPulse 1.6s ease-out infinite; }
.range-slider:not(.is-touched) input[type=range]::-moz-range-thumb { animation: thumbPulse 1.6s ease-out infinite; }
@keyframes thumbPulse {
  0% { box-shadow: 0 2px 8px rgba(38, 112, 168, 0.35), 0 0 0 0 rgba(38, 112, 168, 0.45); }
  70% { box-shadow: 0 2px 8px rgba(38, 112, 168, 0.35), 0 0 0 14px rgba(38, 112, 168, 0); }
  100% { box-shadow: 0 2px 8px rgba(38, 112, 168, 0.35), 0 0 0 0 rgba(38, 112, 168, 0); }
}
.range-bounds { display: flex; justify-content: space-between; font-size: 14px; font-weight: 500; color: var(--soft); }

/* ---------- ZIP: ~86px field, 22px text (Alex) ---------- */
.zip-field {
  display: flex; align-items: center; gap: 10px;
  max-width: 440px; min-height: 86px; margin: 0 auto; padding: 0 22px;
  background: #fff; border: 2px solid var(--blue); border-radius: var(--radius);
  box-shadow: var(--opt-shadow);
}
.zip-field input[type=text] {
  flex: 1; min-width: 0; border: 0; outline: none; background: transparent;
  font: 700 22px var(--font); letter-spacing: 0.15em; text-align: center; color: var(--ink);
}
.zip-field input[type=text]::placeholder { color: #a7b2bd; font-weight: 500; letter-spacing: 0.08em; }
.zip-field svg { flex: none; width: 24px; height: 24px; fill: var(--blue-dark); }
.zip-field:focus-within { box-shadow: 0 0 0 4px rgba(38, 112, 168, 0.18), var(--opt-shadow); }
.field-error { margin-top: 10px; font-size: 14px; color: #b42318; }
.zip-place {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  margin-top: 12px; font-size: 16px; font-weight: 600; color: var(--navy);
}
.zip-place::before {
  content: ""; width: 18px; height: 18px; border-radius: 50%; flex: none;
  background: #16a34a url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5' fill='none' stroke='%23fff' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 12px no-repeat;
}
.zip-place[hidden] { display: none; }

/* ---------- Eligibility banner (step 10) ---------- */
.eligibility-banner {
  max-width: 440px; margin: 0 auto 24px; padding: 14px 18px;
  font-size: 16px; line-height: 1.45; color: var(--navy);
  background: var(--blue-light); border: 1px solid var(--blue-line); border-radius: 12px;
}
.eligibility-banner strong { color: var(--blue); }

/* ---------- Loading ---------- */
.loading { display: flex; flex-direction: column; align-items: center; padding-top: 48px; }
.spinner { fill: var(--blue-dark); margin-top: 8px; }
.spinner__dots { transform-origin: center; animation: spinDots 0.75s steps(12) infinite; }
@keyframes spinDots { to { transform: rotate(360deg); } }

/* ---------- Result ---------- */
.result { padding-top: 8px; }
.result__title { font-size: 28px; font-weight: 800; line-height: 1.2; letter-spacing: -0.02em; color: var(--navy); text-wrap: balance; }
.result__sub { margin: 10px auto 0; max-width: 420px; font-size: 16px; color: var(--muted); text-wrap: pretty; }
.result__for {
  display: table; margin: 12px auto 0; padding: 5px 12px; border-radius: 999px;
  background: #eaf2fa; color: var(--navy); font-size: 14px; font-weight: 600;
}
.result__for:empty { display: none; }
.offer {
  position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 16px;
  margin: 22px auto 0; max-width: 440px; padding: 40px 20px 24px;
  background: #fff; border-radius: 12px;
  box-shadow: 0 0 15px rgba(0, 0, 0, 0.15);
}
.offer__logo, .offer__list { order: 1; }
.offer__list { order: 2; }
.offer__ribbon {
  position: absolute; top: 8px; left: -6px;
  padding: 0 14px; height: 26px; line-height: 26px;
  font-size: 13px; font-weight: 700; color: #fff; white-space: nowrap;
  background: #ffa41d; border-radius: 2px;
}
.offer__ribbon::after {
  content: ""; position: absolute; left: 0; bottom: -6px;
  border-style: solid; border-color: #c47800 transparent transparent; border-width: 6px 0 0 6px;
}
.offer__logo img { width: 180px; max-width: 100%; height: auto; margin: -8px 0; }
/* "Check Rates" right after the highlights, rating under it - keeps the button above the fold on small phones */
.offer__cta { order: 3; }
.offer__rating { order: 4; }
.offer__list { list-style: disc; text-align: left; padding-left: 20px; font-size: 16px; line-height: 1.45; color: var(--ink); }
.offer__list li + li { margin-top: 6px; }
.offer__rating { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 14px; color: var(--muted); }
.offer__rating-label { font-weight: 700; color: var(--navy); }
.offer__score { font-size: 18px; font-weight: 700; color: var(--tp-green); }
.offer__reviews { font-size: 14px; }
.offer__stars { width: 140px; height: auto; }
.offer__stars .s-green { fill: #00b67a; }
.offer__stars .s-lime { fill: #73cf11; }
.offer__stars .s-gray { fill: #dcdce6; }
.offer__note { font-size: 14px; }
.offer__cta {
  display: flex; align-items: center; justify-content: center;
  width: 100%; min-height: 60px; padding: 12px 22px;
  font-size: 20px; font-weight: 700; color: #fff; text-decoration: none;
  background: var(--tp-green); border-radius: 999px;
  transition: background-color 0.15s ease;
}
@media (hover: hover) { .offer__cta:hover { background: #009864; } }

/* ---------- Below the quiz (Question 1 only) ---------- */
/* ~72px between the quiz and the content under it on mobile, ~96px on desktop (Alex) */
.below { max-width: 1100px; margin: 72px auto 0; }
body.quiz-active .below { display: none; }
/* On Question 1 the quiz does not need to fill the screen - the content below follows it */
body:not(.quiz-active) .quiz-area { min-height: 0; padding-bottom: 0; }

.partners { text-align: center; }
.partners__title { font-size: 18px; font-weight: 600; color: var(--ink); }
.partners__grid { display: grid; grid-template-columns: 1fr 1fr; align-items: center; gap: 4px 12px; margin-top: 16px; }
.partners__grid img { width: 100%; height: auto; }

.adv { padding: 48px 0 8px; text-align: center; }
.adv__title { font-size: 26px; font-weight: 700; letter-spacing: -0.01em; color: var(--navy); margin-bottom: 32px; }
.adv__list { display: grid; gap: 32px; }
.adv__list li { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.adv__icon { display: flex; align-items: center; justify-content: center; height: 48px; }
.adv__icon svg { fill: none; stroke: #5b9bd5; stroke-width: 2; }
.adv__icon .fill-soft { fill: #d4e7f4; }
.adv__icon .fill-white { fill: #fff; }
.adv__icon .txt { fill: #5b9bd5; }
.adv__list h3 { font-size: 18px; font-weight: 700; line-height: 1.3; color: var(--ink); }
.adv__list p { max-width: 340px; font-size: 15px; line-height: 1.55; color: var(--muted); }
.cta--closing { margin-top: 40px; gap: 8px; }
.cta__arrow { flex: none; transition: transform .15s ease; }
@media (hover: hover) { .cta--closing:hover .cta__arrow { transform: translateX(3px); } }

/* ---------- Footer: 150px above it on every screen (Alex) ---------- */
.footer { margin-top: 150px; background: var(--footer-bg); border-top: 1px solid var(--line); }
.footer__inner { max-width: 820px; margin: 0 auto; padding: 32px 16px; text-align: center; }
.footer__copy { font-size: 12px; color: var(--muted); }
.footer__legal { margin-top: 4px; font-size: 12px; line-height: 1.6; color: var(--muted); }
.footer__links { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px 24px; margin-top: 24px; font-size: 14px; }
.footer__links a { color: var(--green); text-decoration: none; }
.footer__links a:hover { text-decoration: underline; }

/* ---------- Advertiser Disclosure dialog (approved component) ---------- */
#disclosure-toggle { position: fixed; top: 0; left: 0; }
.modal { display: none; position: fixed; inset: 0; z-index: 50; align-items: center; justify-content: center; padding: 16px; }
.page:has(#disclosure-toggle:checked) .modal { display: flex; }
.modal__backdrop { position: absolute; inset: 0; background: rgba(15, 23, 42, 0.55); cursor: pointer; }
.modal__box {
  position: relative; width: 100%; max-width: 520px; padding: 28px 28px 24px;
  border-radius: 16px; background: #fff; box-shadow: 0 24px 60px -20px rgba(15, 23, 42, 0.45);
}
.modal__title { font-size: 18px; font-weight: 700; line-height: 1.3; color: var(--ink); }
.modal__box p { margin-top: 12px; font-size: 14px; line-height: 1.6; color: var(--muted); }
.modal__close { position: absolute; top: 10px; right: 14px; font-size: 26px; line-height: 1; color: var(--soft); cursor: pointer; }
.modal__close:hover { color: var(--ink); }

/* ---------- Small phones (380 and down) ---------- */
@media (max-width: 380px) {
  .q-title { font-size: 28px; }
  .q-title--first { font-size: 22px; }
  .hero-title { font-size: 27px; }
  .yn-icon { width: 72px; height: 72px; }
  .yn-icon svg { width: 42px; height: 42px; }
  .options--yn .opt-box { min-height: 140px; }
  .opt-box { padding: 16px; }
  .trust-tags { gap: 4px; }
  .trust-tags li { font-size: 13px; padding: 5px 6px; }
}
/* 320px: tags stay in one row (smaller is allowed at 320 - Alex) */
@media (max-width: 350px) {
  .trust-tags svg { display: none; }
}

/* ---------- 640px+ ---------- */
@media (min-width: 640px) {
  .options--cards { grid-template-columns: 1fr 1fr; max-width: 560px; }
  .options--cards .opt-box { flex-direction: column; justify-content: center; text-align: center; min-height: 130px; gap: 10px; }
  .partners__grid { grid-template-columns: repeat(3, 1fr); }
  .adv__list { grid-template-columns: repeat(2, 1fr); gap: 36px 28px; }
}

/* ---------- 1024px+ ---------- */
@media (min-width: 1024px) {
  .brand-row { padding: 14px 30px; }
  .quiz-area { max-width: 640px; padding-top: 24px; }
  .hero-title { font-size: 42px; }
  .q-title { font-size: 32px; }
  .q-title--first { font-size: 26px; }
  .below { margin-top: 96px; }
  .partners__grid { grid-template-columns: repeat(6, 1fr); }
  .adv__list { grid-template-columns: repeat(5, 1fr); gap: 32px; }
  .adv__list p { font-size: 14px; }
}
