/* ────────────────────────────────────────────────────────────────────────────
   CoFi public lead application — styles.
   Brand palette matches the CoFi Lending logo: violet → magenta gradient.
   Mobile-first, consumer-grade, with a celebratory rate-reveal moment.
──────────────────────────────────────────────────────────────────────────── */
:root {
  /* Core brand pulled from the logo: #5f26e9 (violet) → #dd3385 (magenta),
     with #8015a5 as the mid violet. */
  --navy: #2e1a52;        /* deep violet — headings & dark buttons */
  --navy-deep: #211139;
  --blue: #5f26e9;        /* primary interactive (was blue) */
  --blue-mid: #4c1cc4;    /* primary hover */
  --steel: #8015a5;       /* deep accent violet */
  --gold: #dd3385;        /* accent (was gold) — magenta */
  --gold-lite: #ec6aa8;
  --gold-dim: #b8256e;
  --page: #f4f1fb;        /* faint lavender page wash */
  --surface: #ffffff;
  --surface-2: #f7f4fd;
  --border: #e2dbf4;
  --border-soft: #efeafa;
  --ink: #1e1633;
  --ink-med: #574f6b;
  --ink-light: #9088a6;
  --ok: #1e8a5e;
  --warn: #b84040;
  --radius: 20px;
  --shadow: 0 10px 40px rgba(60, 26, 120, 0.12), 0 2px 8px rgba(60, 26, 120, 0.07);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Inter', ui-sans-serif, system-ui, sans-serif;
  color: var(--ink);
  background: var(--page);
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* Decorative background */
.bg-decor {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(900px 500px at 85% -5%, rgba(221, 51, 133, 0.12), transparent 60%),
    radial-gradient(800px 600px at 8% 110%, rgba(95, 38, 233, 0.14), transparent 60%),
    linear-gradient(180deg, #f6f2fd 0%, var(--page) 100%);
}

/* ─── Topbar ─────────────────────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px clamp(16px, 5vw, 40px);
  flex-wrap: wrap;
}
.brand img { height: 30px; width: auto; display: block; }
.trust { display: flex; gap: 16px; flex-wrap: wrap; }
.trust-item {
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-med);
  white-space: nowrap;
}
@media (max-width: 560px) {
  .trust { gap: 10px; }
  .trust-item:nth-child(3) { display: none; }
}

/* ─── Progress ───────────────────────────────────────────────────────────── */
.progress-wrap {
  max-width: 620px;
  margin: 4px auto 0;
  padding: 0 clamp(16px, 5vw, 24px);
  width: 100%;
  transition: opacity 0.4s ease;
}
.progress-meta {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-light);
  margin-bottom: 6px;
}
.progress-track {
  height: 6px;
  background: rgba(45, 45, 86, 0.10);
  border-radius: 999px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 12%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--blue), var(--gold));
  transition: width 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

/* ─── Stage / card ───────────────────────────────────────────────────────── */
.stage {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: clamp(20px, 4vw, 40px) clamp(16px, 5vw, 24px) 40px;
}
.wizard { width: 100%; max-width: 620px; }
.card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(24px, 5vw, 44px);
}
.step-icon { font-size: 34px; line-height: 1; margin-bottom: 14px; }
.step-title {
  font-size: clamp(22px, 4.4vw, 30px);
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0 0 8px;
  line-height: 1.15;
}
.step-subtitle { font-size: 15px; color: var(--ink-med); margin: 0 0 26px; line-height: 1.5; }

/* ─── Fields ─────────────────────────────────────────────────────────────── */
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 18px 16px; }
.field { grid-column: 1 / -1; min-width: 0; }
.field-half { grid-column: span 1; }
@media (max-width: 480px) { .field-half { grid-column: 1 / -1; } }
.field-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 8px;
}
.field.invalid .input,
.field.invalid .input-money { border-color: var(--warn); box-shadow: 0 0 0 3px rgba(184, 64, 64, 0.12); }

.input {
  width: 100%;
  font: inherit;
  font-size: 15px;
  color: var(--ink);
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 13px 14px;
  transition: border-color 0.15s, box-shadow 0.15s;
  appearance: none;
}
.input::placeholder { color: var(--ink-light); }
.input:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(54, 119, 166, 0.16);
}
select.input {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%238498b0' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 40px;
  cursor: pointer;
}
textarea.input { resize: vertical; min-height: 96px; line-height: 1.5; }

.input-money { position: relative; display: flex; align-items: center; }
.money-prefix {
  position: absolute;
  left: 14px;
  color: var(--ink-med);
  font-weight: 600;
  font-size: 15px;
  pointer-events: none;
}
.input-money .input { padding-left: 28px; }

.years-months { display: flex; gap: 12px; }
.ym-group { flex: 1; position: relative; }
.ym-input { padding-right: 62px; }
.ym-suffix {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-light);
  pointer-events: none;
}

/* "Application in review" (no rate matched) */
.processing-icon { font-size: 44px; margin: 8px 0 4px; }
.processing-msg {
  color: var(--ink-med);
  font-size: 15px;
  line-height: 1.55;
  max-width: 30rem;
  margin: 10px auto 22px;
}

/* Percent input (guarantor ownership %) */
.input-pct { position: relative; }
.input-pct .input { padding-right: 34px; }
.pct-suffix {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 15px;
  font-weight: 600;
  color: var(--ink-med);
  pointer-events: none;
}

/* Guarantors — repeatable sub-cards */
.guarantor-list { display: flex; flex-direction: column; gap: 16px; margin-top: 8px; }
.guarantor-card {
  border: 1.5px solid var(--border);
  border-radius: 16px;
  padding: 18px 18px 20px;
  background: var(--surface-soft, rgba(54, 119, 166, 0.03));
}
.guarantor-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.guarantor-title { font-size: 15px; font-weight: 700; color: var(--navy, #2d2d56); }
.guarantor-remove {
  background: none;
  border: none;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--warn, #b84040);
  padding: 4px 6px;
}
.guarantor-remove:hover { text-decoration: underline; }
.guarantor-me { margin-bottom: 14px; }
.btn-add {
  margin-top: 16px;
  width: 100%;
  border: 1.5px dashed var(--border);
  color: var(--blue);
  font-weight: 600;
}
.btn-add:hover { border-color: var(--blue); background: rgba(54, 119, 166, 0.05); }

.form-section {
  grid-column: 1 / -1;
  margin-top: 14px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--border-soft);
  padding-bottom: 8px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--blue-mid);
}

.field-note { margin-top: 7px; font-size: 12.5px; color: var(--ink-light); }
.field-note.warn { color: var(--gold-dim); font-weight: 500; }
.ltc-note { font-weight: 500; color: var(--blue-mid); }

/* ─── Option cards ───────────────────────────────────────────────────────── */
.cards { display: grid; gap: 12px; }
.cards.cols-2 { grid-template-columns: 1fr 1fr; }
.cards.cols-3 { grid-template-columns: repeat(3, 1fr); }
.cards.cols-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 520px) {
  .cards.cols-3, .cards.cols-4 { grid-template-columns: 1fr 1fr; }
}
.opt-card {
  font: inherit;
  text-align: left;
  cursor: pointer;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: 14px;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  transition: transform 0.12s ease, border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
.opt-card:hover { border-color: var(--blue); transform: translateY(-2px); }
.opt-card.selected {
  border-color: var(--blue);
  background: linear-gradient(180deg, rgba(54, 119, 166, 0.08), rgba(54, 119, 166, 0.02));
  box-shadow: 0 0 0 3px rgba(54, 119, 166, 0.16);
}
.opt-emoji { font-size: 24px; line-height: 1; margin-bottom: 4px; }
.opt-label { font-size: 14.5px; font-weight: 600; color: var(--ink); }
.opt-hint { font-size: 12px; color: var(--ink-light); }

/* ─── Checkbox ───────────────────────────────────────────────────────────── */
.check { display: flex; gap: 12px; align-items: flex-start; cursor: pointer; }
.check input {
  width: 22px; height: 22px; margin: 0; flex: none;
  accent-color: var(--blue); cursor: pointer; margin-top: 1px;
}
.check-label { font-size: 13.5px; color: var(--ink-med); line-height: 1.5; }
.check-label a { color: var(--blue); text-decoration: underline; font-weight: 500; }

/* ─── Errors ─────────────────────────────────────────────────────────────── */
.form-error {
  display: none;
  margin-top: 16px;
  background: #fbf0f0;
  border: 1px solid #f0d4d4;
  color: var(--warn);
  font-size: 13.5px;
  font-weight: 500;
  padding: 11px 14px;
  border-radius: 10px;
}
.form-error.show { display: block; }

/* ─── Nav buttons ────────────────────────────────────────────────────────── */
.nav { display: flex; justify-content: space-between; align-items: center; margin-top: 28px; gap: 12px; }
.btn {
  font: inherit;
  font-weight: 600;
  font-size: 15px;
  border-radius: 12px;
  padding: 13px 22px;
  border: 1.5px solid transparent;
  cursor: pointer;
  transition: transform 0.12s ease, filter 0.15s, background 0.15s;
}
.btn:active { transform: scale(0.98); }
.btn-ghost { background: transparent; color: var(--ink-med); padding-left: 4px; padding-right: 4px; }
.btn-ghost:hover { color: var(--ink); }
.btn-primary {
  color: #fff;
  background: linear-gradient(135deg, var(--blue), var(--steel));
  box-shadow: 0 6px 18px rgba(29, 83, 128, 0.28);
}
.btn-primary:hover { filter: brightness(1.06); }
.btn-lg { font-size: 16px; padding: 16px 28px; width: 100%; margin-top: 8px; }

/* ─── Step transition ────────────────────────────────────────────────────── */
.step-enter { animation: stepIn 0.45s cubic-bezier(0.22, 1, 0.36, 1); }
@keyframes stepIn {
  from { opacity: 0; transform: translateY(14px) scale(0.99); }
  to { opacity: 1; transform: none; }
}

/* ─── Rate reveal ────────────────────────────────────────────────────────── */
.reveal { text-align: center; overflow: hidden; position: relative; }
.reveal-kicker {
  font-size: 13px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--gold-dim); margin-bottom: 18px;
}
.reveal-lead { font-size: 17px; color: var(--ink-med); }
.reveal-aslow { font-size: 15px; color: var(--ink-light); margin-top: 2px; }
.reveal-rate {
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1;
  margin: 6px 0 10px;
  background: linear-gradient(135deg, var(--blue), var(--gold-dim));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-size: clamp(64px, 18vw, 104px);
}
.reveal-pct { font-size: 0.45em; vertical-align: super; }
.reveal-sub { font-size: 14.5px; color: var(--ink-med); max-width: 420px; margin: 0 auto 22px; line-height: 1.5; }
.reveal-factors { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; margin-bottom: 26px; }
.chip {
  display: flex; flex-direction: column; align-items: center;
  background: var(--surface-2); border: 1px solid var(--border-soft);
  border-radius: 12px; padding: 10px 16px; min-width: 92px;
}
.chip-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-light); }
.chip-value { font-size: 15px; font-weight: 700; color: var(--ink); margin-top: 2px; }
.reveal-disclaimer { font-size: 11px; color: var(--ink-light); line-height: 1.5; margin: 20px 0 0; }

/* ─── Confirmation ───────────────────────────────────────────────────────── */
.confirm { text-align: center; }
.confirm-check {
  width: 64px; height: 64px; border-radius: 50%; margin: 0 auto 18px;
  display: flex; align-items: center; justify-content: center;
  font-size: 32px; color: #fff; font-weight: 700;
  background: linear-gradient(135deg, var(--ok), #2bb377);
  box-shadow: 0 8px 24px rgba(30, 138, 94, 0.32);
  animation: pop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes pop { from { transform: scale(0); } to { transform: scale(1); } }
.confirm-ref {
  display: inline-flex; flex-direction: column; align-items: center; gap: 4px;
  background: var(--surface-2); border: 1px dashed var(--border);
  border-radius: 14px; padding: 14px 28px; margin: 8px 0 14px;
}
.confirm-ref-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-light); }
.confirm-ref-code { font-size: 24px; font-weight: 800; letter-spacing: 0.05em; color: var(--navy); font-variant-numeric: tabular-nums; }
.confirm-rate { font-size: 15px; color: var(--ink-med); margin-bottom: 22px; }
.confirm-rate strong { color: var(--blue); }
.confirm-steps { list-style: none; padding: 0; margin: 0 auto 24px; max-width: 380px; text-align: left; display: grid; gap: 12px; }
.confirm-steps li { display: flex; align-items: center; gap: 12px; font-size: 14.5px; color: var(--ink-med); }
.confirm-steps li span {
  flex: none; width: 26px; height: 26px; border-radius: 50%;
  background: var(--surface-2); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: var(--blue);
}
.link-cofi { color: var(--blue); font-weight: 600; font-size: 14.5px; text-decoration: none; }
.link-cofi:hover { text-decoration: underline; }

/* ─── Confetti ───────────────────────────────────────────────────────────── */
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 50; overflow: hidden; }
.confetti i {
  position: absolute; top: -16px; width: 9px; height: 14px; border-radius: 2px;
  animation: fall 2.8s cubic-bezier(0.2, 0.6, 0.4, 1) forwards;
}
@keyframes fall {
  to { transform: translateY(105vh) rotate(540deg); opacity: 0; }
}

/* ─── Footer ─────────────────────────────────────────────────────────────── */
.footer { text-align: center; padding: 24px 20px 32px; color: var(--ink-light); font-size: 12px; line-height: 1.6; }
.footer p { margin: 0; }
.footer-fine { font-size: 11px; opacity: 0.85; margin-top: 4px; }

@media (prefers-reduced-motion: reduce) {
  .step-enter, .confirm-check, .confetti i { animation: none !important; }
  .progress-fill { transition: none; }
}
