/* ============================================================
   THE CREDIT UNION CHALLENGE — STYLES
   Brand tokens live at the top as CSS custom properties.
   To re-skin for another client/event, edit the :root block.
   ============================================================ */

:root {
  /* Brand colors — America's Credit Unions */
  --color-purple-1: #342649; /* primary dark background */
  --color-purple-2: #57447B; /* elevated surfaces / secondary buttons */
  --color-purple-3: #927FBA; /* accents, borders, large text/icons only (3:1 contrast on purple-1) */
  --color-purple-4: #D6C8E2; /* secondary text on dark, dividers */
  --color-cream: #F7EDE4;    /* primary text on dark; light surfaces */
  --color-cream-light: #FCF7F4;
  --color-pink-1: #DDBAD6;
  --color-pink-2: #F0DCEB;
  --color-pink-3: #FCE9F1;
  --color-pale-purple: #8B6984; /* decorative only — insufficient contrast for text */

  --color-success: #2E7D32; /* verified 5.1:1 with white text */
  --color-success-cream: #4CAF7D;
  --color-danger: #BF3F36;  /* verified 4.6:1 with cream text, 5.3:1 with white */

  --font-display: "Source Serif 4", Georgia, "Times New Roman", serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  --radius-pill: 50px;
  --radius-card: 16px;
  --radius-input: 10px;

  --shadow-card: 0 12px 32px rgba(20, 12, 32, 0.35);
  --shadow-soft: 0 4px 14px rgba(20, 12, 32, 0.25);

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);

  --app-max-width: 480px;
  --transition-fast: 160ms ease;
  --transition-med: 320ms cubic-bezier(0.22, 1, 0.36, 1);
}

/* ------------------------- Reset ------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}
body {
  font-family: var(--font-body);
  background: var(--color-purple-1);
  color: var(--color-cream);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
h1, h2, h3, p { margin: 0; }
button { font-family: inherit; }
img { max-width: 100%; display: block; }
ul, ol { list-style: none; margin: 0; padding: 0; }

/* Desktop: center the app like a phone card on a branded backdrop */
@media (min-width: 640px) {
  body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
      radial-gradient(circle at 30% 20%, rgba(146, 127, 186, 0.35), transparent 55%),
      radial-gradient(circle at 80% 80%, rgba(221, 186, 214, 0.15), transparent 50%),
      var(--color-purple-1);
    padding: 32px 16px;
  }
  #app {
    max-width: var(--app-max-width);
    width: 100%;
    height: min(860px, 92vh);
    border-radius: 28px;
    box-shadow: var(--shadow-card);
    overflow: hidden;
    border: 1px solid rgba(247, 237, 228, 0.08);
  }
}

#app {
  position: relative;
  min-height: 100dvh;
  width: 100%;
  background: var(--color-purple-1);
  overflow: hidden;
}

.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;
}

/* The hidden attribute must always win, even over display rules below
   (e.g. .results-state's display:flex would otherwise un-hide it). */
[hidden] {
  display: none !important;
}

/* Focus visibility (WCAG) */
a:focus-visible,
button:focus-visible,
input:focus-visible {
  outline: 3px solid var(--color-pink-1);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Headings receive focus programmatically for screen readers (tabindex="-1");
   suppress the visual ring there — it reads as a stray box to sighted users. */
[tabindex="-1"]:focus {
  outline: none;
}

/* ------------------------- Screens ------------------------- */
.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  padding: calc(28px + var(--safe-top)) calc(20px + var(--safe-right)) calc(24px + var(--safe-bottom)) calc(20px + var(--safe-left));
  overflow-y: auto;
}
.screen.active {
  display: flex;
  z-index: 1;
}
.screen.entering {
  animation: screen-in var(--transition-med) both;
}
/* Outgoing screen stays visible briefly and fades up-and-out underneath
   the incoming one (screens are absolutely stacked), giving a crossfade
   instead of an abrupt jump. JS removes .leaving when the swap ends. */
.screen.leaving {
  display: flex;
  z-index: 0;
  pointer-events: none;
  animation: screen-out 220ms ease-in both;
}
@keyframes screen-in {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes screen-out {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(-12px); }
}

/* Question-to-question transition: old card slides up and out, new card
   slides in, answers cascade in one after another. */
.question-swap-out .question-card,
.question-swap-out .fact-card {
  animation: q-out 170ms ease-in both;
}
.question-swap-in .question-card {
  animation: q-in var(--transition-med) both;
}
.question-swap-in .answer-btn {
  animation: q-in var(--transition-med) both;
}
.question-swap-in .answer-btn:nth-child(1) { animation-delay: 60ms; }
.question-swap-in .answer-btn:nth-child(2) { animation-delay: 110ms; }
.question-swap-in .answer-btn:nth-child(3) { animation-delay: 160ms; }
.question-swap-in .answer-btn:nth-child(4) { animation-delay: 210ms; }
@keyframes q-out {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(-14px); }
}
@keyframes q-in {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .screen.entering,
  .screen.leaving,
  .question-swap-out .question-card,
  .question-swap-out .fact-card,
  .question-swap-in .question-card,
  .question-swap-in .answer-btn {
    animation: none;
  }
}

.screen-inner {
  display: flex;
  flex-direction: column;
  flex: 1;
  width: 100%;
  margin: 0 auto;
}

.eyebrow {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-pink-1);
  margin-bottom: 8px;
}

.display-heading {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(2rem, 8vw, 2.6rem);
  line-height: 1.08;
  color: var(--color-cream);
  margin-bottom: 16px;
}
.display-heading.heading-md {
  font-size: clamp(1.5rem, 6vw, 1.9rem);
  margin-bottom: 10px;
}

/* ------------------------- Splash ------------------------- */
#screen-splash {
  /* .screen is already position:absolute — it is the positioning context
     for .splash-glow; do not override position here or the screen
     collapses to content height and vertical centering breaks. */
  justify-content: center;
}
.splash-glow {
  position: absolute;
  inset: -20% -20% auto -20%;
  height: 60%;
  background: radial-gradient(circle, rgba(146, 127, 186, 0.45), transparent 65%);
  filter: blur(10px);
  z-index: 0;
  animation: glow-pulse 7s ease-in-out infinite;
}
@keyframes glow-pulse {
  0%, 100% { opacity: 0.7; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.08); }
}
.splash-inner {
  position: relative;
  z-index: 1;
  align-items: flex-start;
  justify-content: center;
  text-align: left;
  gap: 4px;
}
.splash-logo {
  width: 148px;
  height: auto;
  margin-bottom: 28px;
}
.splash-hook {
  font-size: 1.05rem;
  line-height: 1.5;
  color: var(--color-purple-4);
  margin-bottom: 28px;
  max-width: 42ch;
}
.splash-meta {
  margin-top: 14px;
  font-size: 0.85rem;
  color: var(--color-purple-4);
}

/* ------------------------- Buttons ------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  cursor: pointer;
  border-radius: var(--radius-pill);
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 1rem;
  min-height: 52px;
  padding: 14px 28px;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast), opacity var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

.btn-large { width: 100%; font-size: 1.08rem; }

.btn-primary {
  background: var(--color-cream);
  color: var(--color-purple-1);
  box-shadow: var(--shadow-soft);
}
.btn-primary:hover { background: var(--color-cream-light); }

.btn-secondary {
  background: var(--color-purple-2);
  color: var(--color-cream);
  box-shadow: var(--shadow-soft);
}
.btn-secondary:hover { background: #634f8c; }

.btn-outline {
  background: transparent;
  color: var(--color-cream);
  border: 2px solid var(--color-purple-3);
}
.btn-outline:hover { background: rgba(146, 127, 186, 0.15); }

.skip-link {
  display: block;
  width: 100%;
  text-align: center;
  background: none;
  border: none;
  color: var(--color-purple-4);
  font-size: 0.9rem;
  font-weight: 500;
  text-decoration: underline;
  padding: 12px;
  margin-top: 4px;
  cursor: pointer;
  min-height: 44px;
}

/* ------------------------- Quiz screen ------------------------- */
.quiz-inner { gap: 20px; }

.quiz-header { display: flex; flex-direction: column; gap: 12px; }

.progress-track {
  width: 100%;
  height: 10px;
  border-radius: var(--radius-pill);
  background: var(--color-purple-2);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0%;
  border-radius: var(--radius-pill);
  background: linear-gradient(90deg, var(--color-pink-1), var(--color-cream));
  transition: width 420ms cubic-bezier(0.22, 1, 0.36, 1);
}

.quiz-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--color-purple-4);
}

.score-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--color-purple-2);
  color: var(--color-cream);
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  font-weight: 700;
  transition: transform 220ms ease;
}
.score-chip.bump { animation: chip-bump 420ms ease; }
@keyframes chip-bump {
  0% { transform: scale(1); }
  40% { transform: scale(1.18); }
  100% { transform: scale(1); }
}
.score-chip-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-pink-1);
}

.question-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.question-text {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.25rem, 5.5vw, 1.55rem);
  line-height: 1.32;
  color: var(--color-cream);
}
.question-text:focus { outline: none; }

.answers-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.answer-btn {
  text-align: left;
  width: 100%;
  min-height: 56px;
  padding: 14px 18px;
  border-radius: var(--radius-card);
  border: 2px solid var(--color-purple-2);
  background: var(--color-purple-2);
  color: var(--color-cream);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 1rem;
  line-height: 1.35;
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast), transform var(--transition-fast);
  display: flex;
  align-items: center;
  gap: 10px;
  -webkit-tap-highlight-color: transparent;
}
.answer-btn:hover:not(:disabled) {
  border-color: var(--color-purple-3);
  background: #61508a;
}
.answer-btn:active:not(:disabled) { transform: scale(0.985); }
.answer-btn:disabled { cursor: default; }

.answer-btn .answer-icon {
  display: inline-flex;
  width: 20px;
  height: 20px;
  flex: none;
  visibility: hidden;
}
.answer-btn.correct .answer-icon,
.answer-btn.wrong .answer-icon { visibility: visible; }

.answer-btn.correct {
  background: var(--color-success);
  border-color: var(--color-success);
  color: #ffffff;
}
.answer-btn.wrong {
  background: var(--color-danger);
  border-color: var(--color-danger);
  color: #ffffff;
  animation: shake 420ms ease;
}
.answer-btn.dim { opacity: 0.55; }

@keyframes shake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-8px); }
  40%, 60% { transform: translateX(8px); }
}
@media (prefers-reduced-motion: reduce) {
  .answer-btn.wrong { animation: none; }
}

/* Did-you-know fact card */
.fact-card {
  margin-top: 4px;
  background: var(--color-cream);
  color: var(--color-purple-1);
  border-radius: var(--radius-card);
  padding: 18px 20px;
  box-shadow: var(--shadow-card);
  animation: fact-in var(--transition-med) both;
}
@keyframes fact-in {
  from { opacity: 0; transform: translateY(24px); }
  to { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .fact-card, .screen.entering { animation: none; }
}
.fact-label {
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--color-purple-2);
  margin-bottom: 6px;
}
.fact-text {
  font-size: 0.98rem;
  line-height: 1.5;
  margin-bottom: 16px;
}

/* ------------------------- Lead form ------------------------- */
.lead-inner { justify-content: center; gap: 4px; }
.lead-copy {
  color: var(--color-purple-4);
  font-size: 1rem;
  line-height: 1.5;
  margin-bottom: 24px;
}
.honeypot {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}
.form-row { margin-bottom: 16px; display: flex; flex-direction: column; gap: 6px; }
.form-row label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-purple-4);
}
.optional-tag { font-weight: 400; opacity: 0.8; }
.form-row input {
  min-height: 48px;
  padding: 12px 14px;
  border-radius: var(--radius-input);
  border: 2px solid var(--color-purple-2);
  background: var(--color-cream);
  color: var(--color-purple-1);
  font-size: 1rem;
  font-family: var(--font-body);
}
.form-row input::placeholder { color: var(--color-pale-purple); }
.form-row input:focus {
  outline: none;
  border-color: var(--color-pink-1);
}
.form-row input:invalid[data-touched="true"] {
  border-color: var(--color-danger);
}
.form-error {
  background: rgba(191, 63, 54, 0.15);
  border: 1px solid var(--color-danger);
  color: var(--color-cream);
  padding: 10px 14px;
  border-radius: var(--radius-input);
  font-size: 0.9rem;
  margin-bottom: 14px;
}
.consent-copy {
  font-size: 0.78rem;
  color: var(--color-purple-4);
  text-align: center;
  margin-top: 12px;
  line-height: 1.4;
}

/* ------------------------- Results ------------------------- */
.results-inner { align-items: center; text-align: center; justify-content: flex-start; gap: 10px; padding-top: 8px; }

.score-ring-wrap {
  position: relative;
  width: 160px;
  height: 160px;
  margin: 8px auto 18px;
}
.score-ring { transform: rotate(-90deg); }
.score-ring-track {
  fill: none;
  stroke: var(--color-purple-2);
  stroke-width: 12;
}
.score-ring-fill {
  fill: none;
  stroke: var(--color-pink-1);
  stroke-width: 12;
  stroke-linecap: round;
  stroke-dasharray: 440;
  stroke-dashoffset: 440;
  transition: stroke-dashoffset 1.1s cubic-bezier(0.22, 1, 0.36, 1);
}
.score-ring-label {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.score-ring-number {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 2.6rem;
  color: var(--color-cream);
  line-height: 1;
}
.score-ring-total { font-size: 0.9rem; color: var(--color-purple-4); }

.results-state { display: flex; flex-direction: column; align-items: center; gap: 10px; }

.win-eyebrow { color: var(--color-pink-1); }

.prize-text {
  font-size: 1.02rem;
  line-height: 1.55;
  color: var(--color-cream);
  background: var(--color-purple-2);
  border-radius: var(--radius-card);
  padding: 16px 18px;
  margin: 6px 0;
}

.verify-strip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--color-purple-4);
  margin-bottom: 4px;
}
.verify-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-success-cream);
  animation: dot-pulse 1.6s ease-in-out infinite;
}
@media (prefers-reduced-motion: reduce) {
  .verify-dot { animation: none; }
}
@keyframes dot-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.7); }
}
.live-clock { font-variant-numeric: tabular-nums; font-weight: 600; }

.backup-prize-text {
  font-size: 0.85rem;
  color: var(--color-purple-4);
  line-height: 1.5;
}

.recap-text {
  font-size: 0.98rem;
  line-height: 1.55;
  color: var(--color-purple-4);
  max-width: 38ch;
}

.share-btn { margin-top: 18px; }
.share-toast {
  font-size: 0.85rem;
  color: var(--color-pink-1);
  margin-top: 8px;
}

/* ------------------------- Confetti canvas ------------------------- */
#confetti-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 999;
}

/* ------------------------- Small screens ------------------------- */
@media (max-width: 360px) {
  .screen { padding-left: 16px; padding-right: 16px; }
  .display-heading { font-size: 1.8rem; }
}
