/* ============================================================================
   QUIZ.CSS — the questionnaire, in the site's LIGHT premium system.
   Matches the homepage: warm off-white ground, dark ink, Hanken Grotesk
   headlines, Space Grotesk body, Archivo (expanded) stamped numbers/labels.
   Purely presentational — the quiz logic/flow/validation live in quiz.js.
   ========================================================================== */

:root {
  --bg: #e8e7e3;
  --bg-2: #e0dfd9;
  --panel: #f7f6f2;
  --panel-2: #fdfdfb;
  --ink: #18181b;
  --ink-dim: #55555c;
  --ink-faint: #6b6b73;
  --line: rgba(22, 22, 30, 0.14);
  --line-2: rgba(22, 22, 30, 0.08);
  --accent: #2b46c8;
  --accent-soft: #33509a;
  --green: #1f9d63;
  --red: #c0402b;
  --serif: "Fraunces", Georgia, serif;
  --sans: "Space Grotesk", ui-sans-serif, system-ui, sans-serif;
  --head: "Hanken Grotesk", "Space Grotesk", ui-sans-serif, system-ui, sans-serif;
  --card: "Archivo", "Archivo Expanded", ui-sans-serif, system-ui, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  background:
    radial-gradient(120% 80% at 50% -10%, rgba(255,255,255,0.6), transparent 55%),
    radial-gradient(95% 70% at 85% 115%, rgba(204,196,182,0.35), transparent 60%),
    linear-gradient(180deg, #ecebe7 0%, #e7e6e1 58%, #e2e1db 100%);
  background-attachment: fixed;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px; line-height: 1.5;
  min-height: 100vh;
  overflow-x: clip;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: inherit; text-decoration: none; }
.container { width: min(1180px, 92%); margin: 0 auto; }

/* Stamped technical accent (numbers + small labels) */
.mono { font-family: var(--card); font-stretch: 125%; }

/* ---------- Wordmark (matches homepage nav) ---------- */
.logo {
  font-family: var(--sans); font-weight: 700; font-size: 1.05rem;
  letter-spacing: -0.02em; text-transform: uppercase; color: var(--ink);
  display: inline-flex; align-items: baseline; line-height: 1;
}
.logo .wm-dot { color: var(--accent); font-size: 1.15em; }

/* ============================================================================
   SHELL + AMBIENT CARD
   ========================================================================== */
.quiz-shell { position: relative; min-height: 100vh; display: flex; flex-direction: column; z-index: 1; }

/* One restrained, softly-floating card echoing the homepage — pure ambience,
   sits far behind the form and never competes for attention. */
.quiz-bg { position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }
.bg-card {
  position: absolute; right: -6vw; bottom: -8vh;
  width: 460px; height: 290px; border-radius: 24px;
  background:
    radial-gradient(120% 90% at 20% 12%, rgba(255,255,255,0.35), transparent 55%),
    linear-gradient(150deg, #3552d8 0%, #2b46c8 46%, #1f2f8f 100%);
  box-shadow: 0 50px 90px -40px rgba(24,24,40,0.45);
  transform: rotate(-14deg) rotateX(6deg);
  opacity: 0.16; filter: blur(0.5px);
  animation: bgFloat 11s ease-in-out infinite;
}
.bg-card::before {  /* EMV chip */
  content: ""; position: absolute; left: 40px; top: 96px;
  width: 54px; height: 40px; border-radius: 8px;
  background: linear-gradient(135deg, #f8e6a3, #dcb659 55%, #b28a2c);
  opacity: 0.9;
}
.bg-card::after {  /* embossed number band */
  content: ""; position: absolute; left: 40px; right: 40px; bottom: 60px; height: 12px;
  background:
    repeating-linear-gradient(90deg, rgba(255,255,255,0.55) 0 8px, transparent 8px 14px,
      rgba(255,255,255,0.55) 14px 22px, transparent 22px 40px);
  border-radius: 3px; opacity: 0.6;
}
@keyframes bgFloat {
  0%, 100% { transform: rotate(-14deg) rotateX(6deg) translateY(0); }
  50%      { transform: rotate(-12deg) rotateX(6deg) translateY(-22px); }
}

/* ============================================================================
   PROGRESS + TOPBAR
   ========================================================================== */
.quiz-progress-wrap {
  position: sticky; top: 0; z-index: 30;
  background: rgba(236, 235, 231, 0.72);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line-2);
}
.quiz-progress { height: 3px; width: 100%; background: rgba(22,22,30,0.10); }
.quiz-progress-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--accent-soft), var(--accent));
  border-radius: 0 3px 3px 0;
  transition: width 0.55s cubic-bezier(0.4, 0, 0.2, 1);
}
.quiz-topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px clamp(20px, 4vw, 40px);
}
.quiz-step-label {
  font-family: var(--card); font-stretch: 125%; font-weight: 700;
  font-size: 0.82rem; letter-spacing: 0.04em; color: var(--ink-faint);
}
.quiz-step-label b { color: var(--ink); font-weight: 800; }

/* ============================================================================
   MAIN LAYOUT — calm centred form + persistent live summary
   ========================================================================== */
.quiz-main {
  flex: 1; position: relative; z-index: 2; min-width: 0;
  display: flex; align-items: center; justify-content: center;
  gap: clamp(28px, 5vw, 72px);
  padding: clamp(28px, 6vh, 72px) clamp(20px, 5vw, 56px) 64px;
}
.quiz-stage { width: min(620px, 100%); min-width: 0; }

.quiz-card { will-change: transform, opacity, filter; min-width: 0; }
.quiz-card { animation: qIn 0.5s cubic-bezier(0.22, 0.9, 0.3, 1) both; }
.quiz-card.leaving { animation: qOut 0.23s cubic-bezier(0.4, 0, 1, 1) forwards; }
@keyframes qIn {
  from { opacity: 0; transform: translateY(16px) scale(0.992); filter: blur(7px); }
  to   { opacity: 1; transform: none; filter: blur(0); }
}
@keyframes qOut {
  to { opacity: 0; transform: translateY(-12px) scale(0.994); filter: blur(5px); }
}

/* ---------- Question ---------- */
.quiz-question {
  font-family: var(--head); font-weight: 700;
  font-size: clamp(1.7rem, 4vw, 2.55rem); line-height: 1.04;
  letter-spacing: -0.03em; color: var(--ink);
  max-width: 15ch; margin-bottom: 14px; overflow-wrap: break-word;
}
.quiz-hint {
  color: var(--ink-dim); font-size: 1rem; line-height: 1.6;
  max-width: 46ch; margin-bottom: 30px;
}

/* ---------- Monthly / Yearly segmented control ---------- */
.period-toggle {
  display: inline-flex; position: relative;
  background: rgba(22,22,30,0.05);
  border: 1px solid var(--line);
  border-radius: 999px; padding: 4px; margin-bottom: 20px;
}
.period-toggle button {
  border: none; cursor: pointer; background: transparent;
  color: var(--ink-dim); font-family: var(--card); font-stretch: 125%;
  font-weight: 700; font-size: 0.76rem; letter-spacing: 0.04em; text-transform: uppercase;
  padding: 8px 20px; border-radius: 999px;
  transition: color 0.2s ease;
}
.period-toggle button.active {
  background: var(--ink); color: var(--panel-2);
  box-shadow: 0 4px 14px -6px rgba(24,24,30,0.5);
}

/* ---------- Amount input ---------- */
.amount-input-wrap {
  display: flex; align-items: center; min-width: 0;
  background: var(--panel-2);
  border: 1.5px solid var(--line);
  border-radius: 16px; padding: 8px 22px; margin-bottom: 16px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.amount-input-wrap:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(43, 70, 200, 0.14);
}
.amount-input-wrap .dollar {
  font-family: var(--card); font-stretch: 125%; font-weight: 800;
  font-size: 1.7rem; color: var(--ink-faint); margin-right: 8px;
}
input.amount {
  flex: 1; min-width: 0; background: transparent; border: none; outline: none;
  color: var(--ink); font-family: var(--card); font-stretch: 125%;
  font-weight: 800; font-size: 2.1rem; letter-spacing: -0.01em; padding: 8px 0;
}
input.amount::placeholder { color: rgba(24,24,30,0.22); }
input.amount::-webkit-outer-spin-button,
input.amount::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input.amount { -moz-appearance: textfield; }
.amount-period {
  font-family: var(--card); font-stretch: 125%; font-weight: 700;
  font-size: 0.82rem; letter-spacing: 0.02em; color: var(--ink-faint); white-space: nowrap;
}

/* ---------- Over-budget notice (validation only; hides when clean) ---------- */
.remaining-line[hidden] { display: none; }
.remaining-line {
  display: flex; align-items: flex-start; gap: 9px;
  font-size: 0.9rem; line-height: 1.45; color: var(--red);
  background: rgba(192, 64, 43, 0.07);
  border: 1px solid rgba(192, 64, 43, 0.28);
  border-radius: 12px; padding: 11px 15px; margin-bottom: 18px;
  max-width: 52ch;
}
.remaining-line::before { content: "⚠"; font-size: 0.95rem; line-height: 1.5; }

/* ---------- Quick-pick chips ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 9px; margin-bottom: 30px; }
.chip {
  border: 1px solid var(--line); background: transparent; color: var(--ink-dim);
  border-radius: 999px; padding: 8px 16px; cursor: pointer;
  font-family: var(--card); font-stretch: 125%; font-weight: 700;
  font-size: 0.82rem; letter-spacing: 0.01em;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease, transform 0.12s ease;
}
.chip:hover { border-color: var(--ink-faint); color: var(--ink); transform: translateY(-1px); }
.chip.selected { background: var(--ink); border-color: var(--ink); color: var(--panel-2); }

/* ---------- Choice questions ---------- */
.choices { display: grid; gap: 12px; margin-bottom: 30px; }
.choice {
  text-align: left; cursor: pointer;
  background: var(--panel-2); border: 1.5px solid var(--line);
  border-radius: 16px; padding: 18px 20px; color: var(--ink);
  font-family: var(--sans); font-size: 1rem;
  display: flex; align-items: center; gap: 15px;
  transition: border-color 0.16s ease, background 0.16s ease, transform 0.12s ease, box-shadow 0.16s ease;
}
.choice:hover { border-color: var(--ink-faint); transform: translateY(-2px); box-shadow: 0 16px 30px -22px rgba(24,24,30,0.4); }
.choice.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(43, 70, 200, 0.16), 0 16px 30px -22px rgba(43,70,200,0.5);
}
.choice-icon {
  font-size: 1.3rem; flex-shrink: 0; width: 44px; height: 44px;
  display: grid; place-items: center; border-radius: 12px;
  background: rgba(22,22,30,0.05);
}
.choice-title { font-weight: 600; font-family: var(--head); font-size: 1.02rem; letter-spacing: -0.01em; }
.choice-desc { color: var(--ink-dim); font-size: 0.88rem; margin-top: 2px; }

/* ---------- Nav / buttons ---------- */
.quiz-nav { display: flex; align-items: center; gap: 14px; }
.quiz-nav .spacer { flex: 1; }
.btn {
  cursor: pointer; border: none; font-family: var(--sans);
  border-radius: 999px; transition: transform 0.18s ease, box-shadow 0.25s ease, background 0.2s ease;
}
.btn-primary {
  background: var(--ink); color: var(--panel-2);
  font-weight: 600; font-size: 1rem; padding: 14px 30px;
  box-shadow: 0 12px 30px -10px rgba(24,24,30,0.42);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 18px 40px -12px rgba(43,70,200,0.4); background: #000; }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-back {
  background: transparent; border: none; cursor: pointer; color: var(--ink-faint);
  font-family: var(--sans); font-size: 0.92rem; padding: 12px 6px;
  transition: color 0.2s ease;
}
.btn-back:hover { color: var(--ink); }

.enter-hint { color: var(--ink-faint); font-size: 0.8rem; margin-top: 16px; letter-spacing: 0.01em; }
.enter-hint kbd {
  font-family: var(--card); font-stretch: 125%; font-weight: 700; font-size: 0.72rem;
  background: rgba(22,22,30,0.06); border: 1px solid var(--line);
  border-radius: 5px; padding: 2px 7px; color: var(--ink);
}

/* ============================================================================
   LIVE SUMMARY — "the engine so far" (persistent, updates as they type)
   ========================================================================== */
.quiz-summary {
  width: 268px; flex: 0 1 268px; min-width: 212px; align-self: center;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 20px; padding: 22px 22px 20px;
  box-shadow: 0 30px 60px -34px rgba(24,24,30,0.34);
}
.qs-label {
  font-family: var(--card); font-stretch: 125%; font-weight: 700;
  font-size: 0.66rem; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--ink-faint); margin-bottom: 16px;
  display: flex; align-items: center; gap: 8px;
}
.qs-label::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%;
  background: var(--green); box-shadow: 0 0 0 0 rgba(31,157,99,0.5);
  animation: qsPulse 1.8s ease-in-out infinite;
}
@keyframes qsPulse { 0%,100% { box-shadow: 0 0 0 0 rgba(31,157,99,0.5); } 50% { box-shadow: 0 0 0 5px rgba(31,157,99,0); } }
.qs-row {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  padding: 9px 0; font-size: 0.86rem; color: var(--ink-dim);
}
.qs-row b {
  font-family: var(--card); font-stretch: 125%; font-weight: 800;
  font-size: 1.05rem; color: var(--ink); letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}
.qs-rule { height: 1px; background: var(--line); margin: 6px 0; }
.qs-else b { color: var(--accent); }
.qs-else span { color: var(--ink); font-weight: 500; }
.qs-hint { margin-top: 8px; font-size: 0.72rem; line-height: 1.45; color: var(--ink-faint); }
.qs-val-bump { animation: qsBump 0.4s ease; }
@keyframes qsBump { 0% { transform: scale(1); } 35% { transform: scale(1.09); } 100% { transform: scale(1); } }

/* ============================================================================
   RESPONSIVE
   ========================================================================== */
@media (max-width: 960px) {
  .quiz-main { flex-direction: column; align-items: stretch; gap: 24px; padding-top: 30px; }
  .quiz-stage { width: 100%; max-width: 620px; margin: 0 auto; }
  .quiz-summary { width: 100%; max-width: 620px; min-width: 0; flex: none; margin: 0 auto; align-self: stretch;
    display: grid; grid-template-columns: 1fr 1fr; gap: 4px 18px; align-items: baseline; }
  .qs-label { grid-column: 1 / -1; margin-bottom: 4px; }
  .qs-rule { grid-column: 1 / -1; }
  .qs-hint { grid-column: 1 / -1; }
  .bg-card { display: none; }
}
@media (max-width: 560px) {
  .quiz-topbar { padding: 14px 18px; }
  .quiz-question { font-size: clamp(1.5rem, 7vw, 2rem); max-width: 100%; }
  input.amount { font-size: 1.8rem; }
  .quiz-summary { grid-template-columns: 1fr; }
  .qs-row { padding: 7px 0; }
}

@media (prefers-reduced-motion: reduce) {
  .quiz-card, .quiz-card.leaving { animation: none !important; }
  .bg-card, .qs-label::before { animation: none !important; }
  * { transition-duration: 0.001ms !important; }
}
