/* ============================================
   Nightlight Sleep — Quiz Funnel
   Warm, calming, parent-friendly
   Mobile-first, one-question-per-screen
   ============================================ */

/* --- Reset & Base --- */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --cream: #FFF9F2;
  --white: #FFFFFF;
  --card-bg: #FFFFFF;
  --card-hover: #F5F0FF;
  --card-selected: #EDE7F9;
  --lavender: #7C6DAF;
  --lavender-light: #9B8EC7;
  --lavender-dark: #5E5090;
  --gold: #D4A843;
  --gold-light: #F0D48A;
  --text-dark: #2C2C2C;
  --text-body: #4A4A4A;
  --text-muted: #7A7A7A;
  --text-hint: #A0A0A0;
  --border: #E8E2D8;
  --border-focus: #7C6DAF;
  --success: #4ade80;
  --error: #e85555;
  --font-body: 'Nunito', sans-serif;
  --radius: 14px;
  --radius-sm: 10px;
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --max-width: 480px;
  --shadow-card: 0 2px 8px rgba(124, 109, 175, 0.08);
  --shadow-hover: 0 4px 16px rgba(124, 109, 175, 0.14);
}

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

body {
  font-family: var(--font-body);
  background: var(--cream);
  color: var(--text-dark);
  min-height: 100%;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

#quiz-app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* --- Progress Bar --- */
.progress-bar-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: var(--border);
  z-index: 100;
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--lavender), var(--lavender-light));
  transition: width 0.5s ease;
  border-radius: 0 2px 2px 0;
}

/* --- Welcome Header (logo pinned to top) --- */
.welcome-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: 24px 20px 0;
}

.welcome-header .quiz-logo {
  margin-bottom: 0;
}

/* --- Screens --- */
.screen {
  display: none;
  flex: 1;
  min-height: 100vh;
  padding: 60px 20px 40px;
  animation: fadeSlideIn 0.4s ease forwards;
  position: relative;
}

.screen.active {
  display: flex;
  align-items: center;
  justify-content: center;
}

@keyframes fadeSlideIn {
  from {
    opacity: 0;
    transform: translateY(24px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.screen-content {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
}

/* --- Logo --- */
.quiz-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin: 0 auto 32px;
}

.quiz-logo img {
  height: 48px;
  width: auto;
  object-fit: contain;
}

.quiz-logo span {
  font-family: var(--font-body);
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--lavender);
  letter-spacing: 0.3px;
}

.quiz-logo.result-logo {
  margin-bottom: 24px;
}

.quiz-logo.result-logo img {
  height: 40px;
}

.quiz-logo.result-logo span {
  font-size: 1rem;
}

/* --- Typography --- */
h1 {
  font-family: var(--font-body);
  font-size: 1.75rem;
  font-weight: 800;
  line-height: 1.3;
  text-align: center;
  margin-bottom: 16px;
  color: var(--text-dark);
}

h2 {
  font-family: var(--font-body);
  font-size: 1.3rem;
  font-weight: 700;
  line-height: 1.4;
  margin-bottom: 24px;
  color: var(--text-dark);
}

h3 {
  font-family: var(--font-body);
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1.4;
  margin-bottom: 16px;
  color: var(--text-dark);
}

.subtitle {
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 12px;
}

.time-note {
  font-size: 0.85rem;
  color: var(--text-hint);
  text-align: center;
  margin-bottom: 32px;
}

.question-label {
  font-size: 0.8rem;
  color: var(--lavender);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  font-weight: 700;
  margin-bottom: 12px;
}

/* --- Buttons --- */
.btn-primary {
  display: block;
  width: 100%;
  padding: 16px 24px;
  background: var(--lavender);
  color: var(--white);
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 700;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  text-align: center;
  box-shadow: 0 2px 8px rgba(124, 109, 175, 0.25);
}

.btn-primary:hover {
  background: var(--lavender-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(124, 109, 175, 0.35);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn-secondary {
  display: block;
  width: 100%;
  padding: 14px 24px;
  background: var(--white);
  color: var(--text-dark);
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 600;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  text-align: center;
}

.btn-secondary:hover {
  background: var(--card-hover);
  border-color: var(--lavender);
}

.btn-outline {
  display: block;
  width: 100%;
  padding: 14px 24px;
  background: transparent;
  color: var(--lavender);
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 600;
  border: 2px solid var(--lavender);
  border-radius: var(--radius);
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  text-align: center;
}

.btn-outline:hover {
  background: var(--card-hover);
}

/* --- Option Cards (Q1 grid — age ranges) --- */
.options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.option-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 20px 12px;
  background: var(--card-bg);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: var(--transition);
  font-family: var(--font-body);
  min-height: 90px;
  box-shadow: var(--shadow-card);
}

.option-card:hover {
  background: var(--card-hover);
  border-color: var(--lavender);
  box-shadow: var(--shadow-hover);
}

.option-card:active {
  background: var(--card-selected);
  border-color: var(--lavender);
}

.option-icon {
  font-size: 1.6rem;
  line-height: 1;
}

.option-text {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-dark);
  text-align: center;
  line-height: 1.3;
}

/* --- Option Buttons (list questions) --- */
.options-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.option-btn {
  display: block;
  width: 100%;
  padding: 16px 20px;
  background: var(--card-bg);
  color: var(--text-body);
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 500;
  line-height: 1.4;
  text-align: left;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: var(--transition);
  box-shadow: var(--shadow-card);
}

.option-btn:hover {
  background: var(--card-hover);
  border-color: var(--lavender);
  box-shadow: var(--shadow-hover);
}

.option-btn:active {
  background: var(--card-selected);
  border-color: var(--lavender);
}

/* --- Form --- */
.form-group {
  margin-bottom: 18px;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.form-group input {
  width: 100%;
  padding: 14px 16px;
  background: var(--white);
  color: var(--text-dark);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 1rem;
  transition: var(--transition);
  outline: none;
}

.form-group input::placeholder {
  color: var(--text-hint);
}

.form-group input:focus {
  border-color: var(--lavender);
  background: #FDFBFF;
  box-shadow: 0 0 0 3px rgba(124, 109, 175, 0.1);
}

.form-group input:invalid:not(:placeholder-shown) {
  border-color: var(--error);
}

.field-hint {
  display: block;
  font-size: 0.75rem;
  color: var(--text-hint);
  margin-top: 4px;
}

.optional {
  font-weight: 400;
  color: var(--text-hint);
}

#contactForm .btn-primary {
  margin-top: 8px;
}

/* --- Result Pages --- */
.result-page {
  text-align: center;
}

.result-page h2 {
  text-align: center;
}

.result-badge {
  display: inline-block;
  padding: 6px 18px;
  background: rgba(124, 109, 175, 0.1);
  color: var(--lavender);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  border-radius: 20px;
  margin-bottom: 16px;
}

.result-score {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 20px;
}

.result-score .score-stars {
  font-size: 1.4rem;
  color: var(--gold);
  letter-spacing: 2px;
}

.result-score .score-label {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--lavender);
}

.result-intro {
  font-size: 0.95rem;
  line-height: 1.7;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 24px;
}

/* --- Package Recommendation Card --- */
.package-card {
  background: var(--white);
  border: 2px solid var(--lavender);
  border-radius: var(--radius);
  padding: 24px 20px;
  margin-bottom: 24px;
  text-align: left;
  box-shadow: 0 4px 16px rgba(124, 109, 175, 0.12);
}

.package-card .package-name {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--lavender);
  margin-bottom: 4px;
}

.package-card .package-price {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-dark);
  margin-bottom: 12px;
}

.package-card .package-includes {
  list-style: none;
  padding: 0;
  margin: 0;
}

.package-card .package-includes li {
  font-size: 0.88rem;
  line-height: 1.6;
  color: var(--text-body);
  padding: 4px 0 4px 24px;
  position: relative;
}

.package-card .package-includes li::before {
  content: "✓";
  position: absolute;
  left: 0;
  color: var(--lavender);
  font-weight: 700;
}

.package-badge {
  display: inline-block;
  padding: 3px 10px;
  background: var(--gold);
  color: var(--white);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  border-radius: 10px;
  margin-bottom: 8px;
}

/* --- Testimonial --- */
.testimonial {
  padding: 18px 20px;
  background: rgba(124, 109, 175, 0.05);
  border-radius: var(--radius);
  margin-bottom: 28px;
  border-left: 3px solid var(--lavender-light);
}

.testimonial p {
  font-size: 0.88rem;
  line-height: 1.6;
  color: var(--text-muted);
  font-style: italic;
}

.testimonial .testimonial-author {
  font-style: normal;
  font-weight: 700;
  color: var(--text-body);
  margin-top: 8px;
  font-size: 0.82rem;
}

/* --- CTA Section --- */
.cta-section {
  padding-top: 8px;
}

.cta-section h3 {
  text-align: center;
}

.btn-cta {
  font-size: 1.05rem;
  padding: 18px 24px;
}

.cta-note {
  font-size: 0.8rem;
  color: var(--text-hint);
  text-align: center;
  margin-top: 12px;
  line-height: 1.5;
}

.cta-divider {
  font-size: 0.85rem;
  color: var(--text-hint);
  text-align: center;
  margin: 16px 0;
}

/* --- HSA/FSA Badge --- */
.hsa-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 16px;
}

.hsa-badge .badge-icon {
  font-size: 1rem;
}

/* --- Loading Spinner --- */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid transparent;
  border-top-color: var(--white);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: middle;
  margin-right: 8px;
}

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

/* --- Responsive --- */
@media (min-width: 600px) {
  .screen {
    padding: 80px 24px 60px;
  }

  h1 {
    font-size: 2.1rem;
  }

  h2 {
    font-size: 1.5rem;
  }

  .option-card {
    padding: 24px 16px;
    min-height: 110px;
  }

  .option-text {
    font-size: 0.9rem;
  }
}

@media (min-width: 768px) {
  :root {
    --max-width: 520px;
  }
}

/* --- Accessibility --- */
@media (prefers-reduced-motion: reduce) {
  .screen {
    animation: none;
  }
  .progress-bar {
    transition: none;
  }
}

.option-card:focus-visible,
.option-btn:focus-visible,
.btn-primary:focus-visible,
.btn-secondary:focus-visible,
.btn-outline:focus-visible {
  outline: 2px solid var(--lavender);
  outline-offset: 2px;
}

/* ============================================
   Decorative Stars — Nightlight Theme
   ============================================ */

/* Floating background stars (subtle, fixed position) */
body::before,
body::after {
  position: fixed;
  pointer-events: none;
  z-index: 0;
  color: var(--gold-light);
  opacity: 0.18;
  font-size: 1rem;
  letter-spacing: 12px;
}

body::before {
  content: "✦  ⋆  ✧  ⋆  ✦";
  top: 15%;
  left: -10px;
  transform: rotate(-12deg);
}

body::after {
  content: "⋆  ✦  ⋆  ✧  ⋆";
  bottom: 18%;
  right: -10px;
  transform: rotate(8deg);
}

/* Star cluster - reusable class */
.stars-cluster {
  display: block;
  text-align: center;
  color: var(--gold);
  font-size: 0.7rem;
  letter-spacing: 8px;
  opacity: 0.4;
  margin: 16px auto;
  user-select: none;
}

.stars-cluster.bright {
  opacity: 0.7;
  font-size: 0.85rem;
}

/* Stars around the logo */
.quiz-logo::before {
  content: "✧";
  color: var(--gold);
  opacity: 0.5;
  font-size: 0.8rem;
  margin-right: 4px;
}

.quiz-logo::after {
  content: "✧";
  color: var(--gold);
  opacity: 0.5;
  font-size: 0.8rem;
  margin-left: 4px;
}

/* Welcome screen stars */
[data-screen="welcome"] h1::before {
  content: "✦";
  display: block;
  text-align: center;
  color: var(--gold);
  font-size: 1.2rem;
  opacity: 0.5;
  margin-bottom: 12px;
  letter-spacing: 6px;
}

/* Twinkle star accent next to question labels */
.question-label::after {
  content: " ✧";
  color: var(--gold);
  opacity: 0.5;
  font-size: 0.7rem;
}

/* Star divider above CTA section */
.cta-section::before {
  content: "⋆  ✦  ⋆";
  display: block;
  text-align: center;
  color: var(--gold);
  font-size: 0.75rem;
  letter-spacing: 6px;
  opacity: 0.4;
  margin-bottom: 20px;
}

/* Stars around result badge */
.result-badge::before {
  content: "✧ ";
  color: var(--gold);
  opacity: 0.6;
}

.result-badge::after {
  content: " ✧";
  color: var(--gold);
  opacity: 0.6;
}

/* Small star accent on package card */
.package-card::before {
  content: "✦";
  position: absolute;
  top: -8px;
  right: 16px;
  color: var(--gold);
  font-size: 1rem;
  opacity: 0.5;
}

.package-card {
  position: relative;
}

/* Floating star accents on larger screens */
@media (min-width: 600px) {
  body::before {
    font-size: 1.2rem;
    letter-spacing: 18px;
    opacity: 0.15;
    top: 20%;
    left: 20px;
  }

  body::after {
    font-size: 1.2rem;
    letter-spacing: 18px;
    opacity: 0.15;
    bottom: 22%;
    right: 20px;
  }
}

/* Subtle twinkling animation for key stars */
@keyframes twinkle {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 0.7; }
}

/* ============================================
   Star Confetti — Result Page Celebration
   ============================================ */

.confetti-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 50;
  overflow: hidden;
}

.confetti-star {
  position: absolute;
  top: -40px;
  animation: starFall linear forwards;
  opacity: 0;
}

@keyframes starFall {
  0% {
    opacity: 0;
    transform: translateY(0) rotate(0deg) scale(0.5);
  }
  10% {
    opacity: 1;
  }
  80% {
    opacity: 0.7;
  }
  100% {
    opacity: 0;
    transform: translateY(100vh) rotate(720deg) scale(0.3);
  }
}

@keyframes starFloat {
  0% {
    opacity: 0;
    transform: translateY(0) rotate(0deg);
  }
  15% {
    opacity: 0.9;
  }
  85% {
    opacity: 0.5;
  }
  100% {
    opacity: 0;
    transform: translateY(85vh) rotate(360deg);
  }
}

.confetti-star.float {
  animation-name: starFloat;
}

/* Reduce motion: skip confetti */
@media (prefers-reduced-motion: reduce) {
  .confetti-star {
    animation: none;
    display: none;
  }
}

[data-screen="welcome"] h1::before {
  animation: twinkle 3s ease-in-out infinite;
}

.package-card::before {
  animation: twinkle 4s ease-in-out infinite;
  animation-delay: 1s;
}
