/* ==========================================================================
   match.myloanmatch.ca — My Loan Match bridge funnel
   Warm paper + deep ink. Indigo is reserved for action. The reveal card
   hands off into Wealth IQ's dark + gold identity.
   ========================================================================== */

:root {
  --paper: #f5f2ec;
  --paper-2: #ebe6dc;
  --card: #ffffff;
  --ink: #0e1726;
  --ink-2: #3b4555;
  --ink-3: #5f6878;
  --line: #e2dccf;
  --line-2: #d3ccbd;

  --brand: #3d32d4;
  --brand-ink: #2b22a6;
  --brand-tint: #efeefe;
  --brand-ring: rgba(61, 50, 212, 0.22);

  --mint: #149a62;
  --mint-tint: #e3f5ec;
  --danger: #c2372b;

  --wiq-bg: #0c1220;
  --wiq-bg-2: #172036;
  --gold: #e9b949;
  --gold-2: #f6d27a;

  --font-display: 'Bricolage Grotesque', 'Figtree', ui-sans-serif, system-ui, sans-serif;
  --font-ui: 'Figtree', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;

  --r-lg: 22px;
  --r-md: 14px;
  --r-sm: 10px;
  --shadow-card: 0 1px 0 rgba(14, 23, 38, 0.04), 0 10px 30px -12px rgba(14, 23, 38, 0.16);
  --shadow-press: 0 1px 2px rgba(14, 23, 38, 0.08);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

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

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

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background-color: var(--paper);
  background-image:
    radial-gradient(circle at 1px 1px, rgba(14, 23, 38, 0.07) 1px, transparent 0),
    radial-gradient(120% 60% at 50% -10%, #fffdf8 0%, rgba(255, 253, 248, 0) 60%);
  background-size: 22px 22px, 100% 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: geometricPrecision; /* stops glyph-advance rounding gaps at small sizes */
  -webkit-tap-highlight-color: transparent;
}

button,
input {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

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

/* ---------- Shell ---------- */

.shell {
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  padding: 0 16px calc(24px + env(safe-area-inset-bottom));
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(14px + env(safe-area-inset-top)) 2px 10px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
  color: var(--ink);
}

.brand__mark {
  width: 30px;
  height: 30px;
  flex: none;
}

.brand__word {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.02em;
}

.lang {
  display: inline-flex;
  padding: 3px;
  border-radius: 999px;
  background: var(--paper-2);
  border: 1px solid var(--line);
}

.lang__btn {
  border: 0;
  background: transparent;
  min-width: 46px;
  min-height: 40px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--ink-3);
  transition: background 0.2s var(--ease), color 0.2s var(--ease);
}

.lang__btn.is-active {
  background: var(--card);
  color: var(--ink);
  box-shadow: var(--shadow-press);
}

/* ---------- Step bar ---------- */

.stepbar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  margin: 2px 0 10px;
}

.back {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  min-height: 44px;
  padding: 0 10px 0 4px;
  margin-left: -4px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--ink-2);
  font-size: 15px;
  font-weight: 600;
  visibility: hidden;
}

.back:hover {
  background: var(--paper-2);
}

body[data-view='q1'] .back {
  display: none;
}

body[data-view='q1'] .stepbar {
  grid-template-columns: 1fr auto;
}

body[data-view='q2'] .back,
body[data-view='q3'] .back,
body[data-view='contact'] .back {
  visibility: visible;
}

.track {
  position: relative;
  height: 6px;
  border-radius: 999px;
  background: var(--paper-2);
  overflow: hidden;
  /* four segments */
  -webkit-mask: repeating-linear-gradient(90deg, #000 0 calc(25% - 3px), transparent calc(25% - 3px) 25%);
  mask: repeating-linear-gradient(90deg, #000 0 calc(25% - 3px), transparent calc(25% - 3px) 25%);
}

.track__fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 25%;
  background: var(--brand);
  border-radius: inherit;
  transition: width 0.45s var(--ease);
}

.step {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-3);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.step.is-hidden {
  visibility: hidden;
}

body[data-view='matching'] .stepbar,
body[data-view='reveal'] .stepbar,
body[data-view='stop18'] .stepbar {
  display: none;
}

/* ---------- Screens ---------- */

.stage {
  position: relative;
  overflow-x: clip;
  margin: 0 -8px;
  padding: 0 8px 4px; /* room for card shadows inside the clip */
  flex: 1 0 auto;
}

.screen {
  display: none;
}

.screen.is-active {
  display: block;
}

.screen.is-entering {
  animation: enter 0.34s var(--ease) both;
}

@keyframes enter {
  from {
    opacity: 0;
    transform: translateX(18px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.card {
  position: relative;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-card);
  padding: 24px 20px 22px;
}

.card--center {
  text-align: center;
  padding: 36px 22px 32px;
}

/* ---------- Type ---------- */

.kicker {
  display: inline-block;
  margin: 0 0 10px;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--mint-tint);
  color: #0d7a4c;
  font-size: 13.5px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.hero {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(30px, 8.4vw, 40px);
  line-height: 1.04;
  letter-spacing: -0.035em;
  font-variation-settings: 'opsz' 96;
  text-wrap: balance;
}

.chips {
  list-style: none;
  margin: 14px 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
}

.chips li {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-2);
}

.chips li::before {
  content: '';
  width: 16px;
  height: 16px;
  flex: none;
  border-radius: 50%;
  background: var(--mint)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4.6 8.3l2.2 2.2 4.6-5' fill='none' stroke='%23fff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E")
    center / 16px no-repeat;
}

.q {
  margin: 0 0 18px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(25px, 6.6vw, 30px);
  line-height: 1.12;
  letter-spacing: -0.025em;
  text-wrap: balance;
}

.q--small {
  margin: 24px 0 12px;
  padding-top: 20px;
  border-top: 1px dashed var(--line-2);
  font-size: 19px;
  letter-spacing: -0.015em;
}

.q--big {
  font-size: clamp(25px, 6.6vw, 30px);
}

.helper,
.muted {
  margin: -8px 0 18px;
  color: var(--ink-3);
  font-size: 15.5px;
  line-height: 1.45;
}

.card--center .muted {
  margin: 0;
}

/* ---------- Answer tiles ---------- */

.tiles {
  display: grid;
  gap: 10px;
}

.tiles--amount {
  grid-template-columns: 1fr 1fr;
}

.tile {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 62px;
  padding: 10px 14px;
  border: 1.5px solid var(--line-2);
  border-radius: var(--r-md);
  background: var(--card);
  color: var(--ink);
  font-weight: 700;
  text-align: center;
  box-shadow: var(--shadow-press);
  transition: border-color 0.18s var(--ease), background 0.18s var(--ease), transform 0.12s var(--ease),
    box-shadow 0.18s var(--ease);
  touch-action: manipulation;
  user-select: none;
}

.tiles--amount .tile {
  font-family: var(--font-display);
  font-size: 22px;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.tiles--amount .tile[data-value='more'] {
  font-family: var(--font-ui);
  font-size: 15.5px;
  letter-spacing: 0;
  line-height: 1.2;
}

@media (hover: hover) {
  .tile:hover {
    border-color: var(--brand);
    box-shadow: 0 0 0 4px var(--brand-tint);
  }
}

.tile:active {
  transform: scale(0.98);
}

.tile.is-selected {
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
  box-shadow: 0 8px 20px -10px var(--brand);
}

/* Row tiles (yes / no) */

.tiles--rows .tile {
  justify-content: flex-start;
  min-height: 64px;
  padding: 12px 18px;
  font-size: 18px;
  text-align: left;
}

.radio {
  width: 24px;
  height: 24px;
  flex: none;
  border-radius: 50%;
  border: 2px solid var(--line-2);
  background: var(--card);
  transition: border-color 0.18s var(--ease), box-shadow 0.18s var(--ease);
}

.tile.is-selected .radio {
  border-color: #fff;
  box-shadow: inset 0 0 0 5px var(--brand), inset 0 0 0 12px #fff;
}

/* ---------- Trust row ---------- */

.trust {
  list-style: none;
  margin: 16px 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 18px;
}

.trust li {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink-3);
}

.trust svg {
  color: var(--mint);
  flex: none;
}

/* ---------- Form ---------- */

.form {
  display: grid;
  gap: 14px;
}

.field {
  display: grid;
  gap: 6px;
}

.field__label {
  font-size: 14.5px;
  font-weight: 700;
  color: var(--ink-2);
}

.field input {
  width: 100%;
  min-height: 56px;
  padding: 0 16px;
  border: 1.5px solid var(--line-2);
  border-radius: var(--r-md);
  background: #fff;
  font-size: 17px; /* ≥16px stops iOS zoom-on-focus */
  font-weight: 500;
  color: var(--ink);
  transition: border-color 0.18s var(--ease), box-shadow 0.18s var(--ease);
  -webkit-appearance: none;
  appearance: none;
}

.field input::placeholder {
  color: #9aa1ad;
  font-weight: 400;
}

.field input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 4px var(--brand-tint);
}

.field.has-error input {
  border-color: var(--danger);
  box-shadow: 0 0 0 4px rgba(194, 55, 43, 0.1);
}

.field__err {
  min-height: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--danger);
}

.field__err:empty {
  display: none;
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 58px;
  padding: 0 20px;
  border: 0;
  border-radius: var(--r-md);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.005em;
  transition: transform 0.12s var(--ease), background 0.18s var(--ease), box-shadow 0.18s var(--ease);
  touch-action: manipulation;
}

.btn:active {
  transform: scale(0.985);
}

.btn--primary {
  margin-top: 4px;
  background: var(--brand);
  color: #fff;
  box-shadow: 0 10px 24px -12px var(--brand), inset 0 1px 0 rgba(255, 255, 255, 0.16);
}

@media (hover: hover) {
  .btn--primary:hover {
    background: var(--brand-ink);
  }
}

.btn[disabled] {
  opacity: 0.7;
  cursor: progress;
}

.micro {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.45;
  color: var(--ink-3);
  text-align: center;
}

.micro--lock {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: -6px;
}

.micro--lock svg {
  color: var(--mint);
}

/* ---------- Stop screen ---------- */

.stopicon {
  display: block;
  margin: 0 auto 14px;
  color: var(--ink-3);
}

/* ---------- Matching ---------- */

.scan {
  position: relative;
  width: 132px;
  height: 132px;
  margin: 4px auto 24px;
}

.scan__ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid transparent;
}

.scan__ring--1 {
  border-top-color: var(--brand);
  border-right-color: var(--brand);
  animation: spin 1.4s linear infinite;
}

.scan__ring--2 {
  inset: 16px;
  border-bottom-color: var(--mint);
  border-left-color: var(--mint);
  animation: spin 1.9s linear infinite reverse;
}

.scan__ring--3 {
  inset: -8px;
  border-color: var(--line);
  border-style: dashed;
  animation: spin 9s linear infinite;
}

.scan__core {
  position: absolute;
  inset: 38px;
  border-radius: 50%;
  background: var(--brand-tint);
  animation: pulse 1.4s var(--ease) infinite;
}

.scan__core::after {
  content: '';
  position: absolute;
  inset: 14px;
  border-radius: 50%;
  background: var(--brand);
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes pulse {
  0%,
  100% {
    transform: scale(0.92);
  }
  50% {
    transform: scale(1.05);
  }
}

.checklist {
  list-style: none;
  margin: 6px auto 0;
  padding: 0;
  display: grid;
  gap: 12px;
  max-width: 300px;
  text-align: left;
}

.checklist__item {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 16px;
  font-weight: 600;
  color: var(--ink-3);
  opacity: 0.55;
  transition: opacity 0.3s var(--ease), color 0.3s var(--ease);
}

.checklist__item .dot {
  position: relative;
  width: 24px;
  height: 24px;
  flex: none;
  border-radius: 50%;
  border: 2px solid var(--line-2);
  transition: background 0.3s var(--ease), border-color 0.3s var(--ease);
}

.checklist__item.is-done {
  opacity: 1;
  color: var(--ink);
}

.checklist__item.is-done .dot {
  border-color: var(--mint);
  background: var(--mint)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M7 12.4l3.2 3.2L17 8.8' fill='none' stroke='%23fff' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E")
    center / 20px no-repeat;
  animation: pop 0.35s var(--ease);
}

@keyframes pop {
  0% {
    transform: scale(0.6);
  }
  70% {
    transform: scale(1.12);
  }
  100% {
    transform: scale(1);
  }
}

/* ---------- Reveal (Wealth IQ hand-off) ---------- */

.card--reveal {
  overflow: hidden;
  text-align: center;
  padding: 28px 22px 22px;
  color: #fff;
  border-color: #1d2740;
  background:
    radial-gradient(90% 55% at 50% 0%, rgba(233, 185, 73, 0.2) 0%, rgba(233, 185, 73, 0) 70%),
    linear-gradient(180deg, var(--wiq-bg-2) 0%, var(--wiq-bg) 100%);
  box-shadow: 0 24px 50px -24px rgba(12, 18, 32, 0.7);
}

.card--reveal::before {
  /* fine gold hairline at the top edge */
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
}

.eyebrow {
  margin: 0 0 14px;
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold-2);
}

.wiq {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px 8px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.wiq__mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(145deg, var(--gold-2), var(--gold));
  color: var(--wiq-bg);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 19px;
  letter-spacing: -0.04em;
}

.wiq__name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 21px;
  letter-spacing: -0.02em;
}

.wiq__name b {
  margin-left: 3px;
  color: var(--gold);
  font-weight: 800;
}

.reveal__headline {
  margin: 18px 0 20px;
  display: grid;
  gap: 2px;
  font-weight: 400;
}

.reveal__pre,
.reveal__post {
  font-size: 17px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.78);
}

.reveal__amt {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(60px, 18vw, 76px);
  line-height: 1;
  letter-spacing: -0.045em;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
  text-shadow: 0 6px 30px rgba(233, 185, 73, 0.25);
}

.screen[data-screen='reveal'].is-entering .reveal__amt {
  animation: rise 0.6s var(--ease) 0.08s both;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.benefits {
  list-style: none;
  margin: 18px 0 0;
  padding: 16px;
  display: grid;
  gap: 12px;
  text-align: left;
  border-radius: var(--r-md);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.benefits li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 15.5px;
  font-weight: 600;
  line-height: 1.35;
  color: rgba(255, 255, 255, 0.92);
}

.benefits svg {
  flex: none;
  margin-top: 1px;
  color: var(--gold);
}

.btn--cta {
  margin-top: 0;
  background: linear-gradient(180deg, var(--gold-2), var(--gold));
  color: var(--wiq-bg);
  font-size: 18px;
  box-shadow: 0 12px 28px -12px rgba(233, 185, 73, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

@media (hover: hover) {
  .btn--cta:hover {
    background: linear-gradient(180deg, #fadf96, var(--gold-2));
  }
}

.btn--cta .arrow {
  transition: transform 0.2s var(--ease);
}

.btn--cta:hover .arrow {
  transform: translateX(3px);
}

.timer {
  height: 4px;
  margin: 14px 0 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}

.timer__fill {
  display: block;
  height: 100%;
  background: var(--gold);
  transform-origin: left center;
}

.countdown {
  margin: 0;
  min-height: 21px;
  font-size: 14px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.7);
  font-variant-numeric: tabular-nums;
}

.disclosure {
  margin: 16px 0 0;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 13px;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.66);
  text-align: left;
}

/* ---------- Footer ---------- */

.footer {
  margin-top: 28px;
  text-align: center;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--ink-3);
}

.footer p {
  margin: 0 0 8px;
}

.footer__links {
  display: flex;
  justify-content: center;
  gap: 12px;
}

.footer__links a {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  color: var(--ink-2);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--line-2);
}

/* ---------- Larger screens ---------- */

@media (min-width: 640px) {
  .shell {
    max-width: 560px;
    padding-left: 24px;
    padding-right: 24px;
  }

  .topbar {
    padding-top: 28px;
    padding-bottom: 18px;
  }

  .card {
    padding: 36px 36px 32px;
  }

  .card--center {
    padding: 48px 36px 40px;
  }

  .card--reveal {
    padding: 36px 36px 28px;
  }

  .tiles--amount {
    grid-template-columns: repeat(3, 1fr);
  }

  .tiles--amount .tile {
    min-height: 68px;
  }
}

@media (max-width: 359px) {
  .shell {
    padding-left: 12px;
    padding-right: 12px;
  }

  .card {
    padding: 20px 16px 18px;
  }

  .brand__word {
    font-size: 16px;
  }

  .tiles--amount .tile {
    font-size: 20px;
  }

  .btn {
    font-size: 16.5px;
    padding: 0 14px;
  }
}

@media (max-height: 760px) and (max-width: 639px) {
  .topbar {
    padding-top: calc(8px + env(safe-area-inset-top));
    padding-bottom: 4px;
  }

  .stepbar {
    margin-bottom: 6px;
  }

  .card {
    padding: 18px 16px 16px;
  }

  .kicker {
    margin-bottom: 8px;
    font-size: 13px;
  }

  .hero {
    font-size: clamp(26px, 7.4vw, 32px);
  }

  .chips {
    display: none;
  }

  .q--small {
    margin: 16px 0 10px;
    padding-top: 14px;
    font-size: 18px;
  }

  .tiles {
    gap: 8px;
  }

  .tile,
  .tiles--rows .tile {
    min-height: 54px;
  }

  .trust {
    margin-top: 12px;
  }

  .card--center {
    padding: 26px 18px 24px;
  }

  .scan {
    width: 104px;
    height: 104px;
    margin-bottom: 18px;
  }

  .scan__core {
    inset: 30px;
  }

  .card--reveal {
    padding: 20px 16px 16px;
  }

  .eyebrow {
    margin-bottom: 10px;
  }

  .reveal__headline {
    margin: 12px 0 14px;
  }

  .reveal__amt {
    font-size: 54px;
  }

  .reveal__pre,
  .reveal__post {
    font-size: 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .screen.is-entering {
    animation: fade 0.2s linear both !important;
  }

  @keyframes fade {
    from {
      opacity: 0;
    }
  }
}
