/* ============================================================
   Kids Birthday Invitation — Style Sheet
   All theme colors via CSS custom properties set by JS from JSON.
   ============================================================ */

/* --- Theme variables (defaults; overridden by JS) --- */
:root {
  --primary: #7A3E9D;
  --secondary: #F7C948;
  --accent: #FF6B81;
  --background: #FFF9F0;
  --surface: #FFFFFF;
  --text: #30243A;
  --muted: #756B7A;

  --font-heading: "Fredoka", "Trebuchet MS", Arial, sans-serif;
  --font-body: "Nunito", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

  --radius: 20px;
  --radius-sm: 14px;
  --radius-lg: 28px;
  --shadow-sm: 0 4px 14px rgba(48, 36, 58, 0.08);
  --shadow-md: 0 8px 30px rgba(48, 36, 58, 0.12);
  --shadow-lg: 0 20px 50px rgba(48, 36, 58, 0.18);
  --transition: 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  --max-width: 900px;
}

/* --- Reset --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-body);
  background: var(--background);
  color: var(--text);
  line-height: 1.6;
  overflow-x: hidden;
  min-height: 100vh;
}
img { max-width: 100%; height: auto; display: block; }
a { color: var(--primary); text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
ul { list-style: none; }
:focus-visible { outline: 3px solid var(--secondary); outline-offset: 3px; border-radius: 4px; }

/* --- Loading screen --- */
.loading-screen {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 20px; background: var(--background);
  transition: opacity 0.6s ease, visibility 0.6s ease;
}
.loading-screen.hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.loading-balloon { font-size: 3rem; animation: balloon-bob 2s ease-in-out infinite; }
.loading-text { font-family: var(--font-heading); font-size: 1.1rem; color: var(--muted); letter-spacing: 0.03em; }
@keyframes balloon-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-12px); } }

/* --- Error screen --- */
.error-screen {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; align-items: center; justify-content: center; padding: 24px;
  background: var(--background);
}
.error-content { text-align: center; max-width: 400px; }
.error-emoji { font-size: 3rem; margin-bottom: 12px; }
.error-title { font-family: var(--font-heading); font-size: 1.4rem; color: var(--primary); margin-bottom: 8px; }
.error-message { color: var(--muted); font-size: 1rem; }

/* --- Opening screen --- */
.opening-screen {
  position: fixed; inset: 0; z-index: 9000;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 24px; overflow: hidden;
  background: linear-gradient(160deg, var(--background) 0%, var(--surface) 100%);
  transition: opacity 0.6s ease, visibility 0.6s ease, transform 0.6s ease;
}
.opening-screen.hidden { opacity: 0; visibility: hidden; transform: scale(1.05); pointer-events: none; }
.opening-decorations { position: absolute; inset: 0; pointer-events: none; z-index: 0; }
.opening-balloons { position: absolute; inset: 0; }
.opening-content { position: relative; z-index: 2; max-width: 420px; }
.opening-emoji { font-size: 3.5rem; margin-bottom: 16px; animation: balloon-bob 3s ease-in-out infinite; }
.opening-eyebrow {
  font-family: var(--font-heading); font-size: 0.8rem; letter-spacing: 0.25em;
  text-transform: uppercase; color: var(--secondary); margin-bottom: 16px; font-weight: 600;
}
.opening-title {
  font-family: var(--font-heading); font-size: clamp(2rem, 8vw, 3rem);
  color: var(--primary); font-weight: 700; margin-bottom: 8px; line-height: 1.1;
}
.opening-subtitle { font-size: 1.1rem; color: var(--muted); margin-bottom: 16px; }
.opening-name-wrap { margin-bottom: 20px; }
.opening-name {
  font-family: var(--font-heading); font-size: clamp(2.5rem, 12vw, 4.5rem);
  color: var(--accent); font-weight: 700; line-height: 1.05;
  text-shadow: 0 3px 0 rgba(0,0,0,0.06);
}
.opening-age {
  font-family: var(--font-heading); font-size: clamp(1.2rem, 5vw, 1.8rem);
  color: var(--primary); font-weight: 600; margin-top: 4px;
}
.opening-emoji-cake { font-size: 3rem; margin-bottom: 28px; animation: gentle-bounce 2.5s ease-in-out infinite; }
@keyframes gentle-bounce { 0%, 100% { transform: translateY(0) rotate(-3deg); } 50% { transform: translateY(-8px) rotate(3deg); } }
.opening-button {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 16px 40px; border-radius: 50px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff; font-family: var(--font-heading); font-size: 1.15rem; font-weight: 600;
  box-shadow: 0 8px 24px rgba(122, 62, 157, 0.4);
  transition: transform var(--transition), box-shadow var(--transition);
  animation: button-pulse 2s ease-in-out infinite;
}
.opening-button:hover { transform: translateY(-3px) scale(1.04); box-shadow: 0 14px 36px rgba(122, 62, 157, 0.5); }
.opening-button:active { transform: translateY(-1px) scale(1.01); }
@keyframes button-pulse { 0%, 100% { box-shadow: 0 8px 24px rgba(122, 62, 157, 0.4); } 50% { box-shadow: 0 8px 32px rgba(255, 107, 129, 0.5); } }

/* --- Confetti layer --- */
.confetti-layer { position: absolute; inset: 0; pointer-events: none; z-index: 1; overflow: hidden; }
.confetti-canvas { position: fixed; inset: 0; z-index: 8000; pointer-events: none; }

/* --- Main app --- */
.invitation-app { opacity: 0; transition: opacity 0.6s ease; }
.invitation-app.ready { opacity: 1; }

/* --- Floating decorations --- */
.floating-decorations { position: fixed; inset: 0; pointer-events: none; z-index: 1; overflow: hidden; }
.float-emoji {
  position: absolute; font-size: 2rem; opacity: 0.25;
  animation: float-around 8s ease-in-out infinite;
}
@keyframes float-around {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  33% { transform: translateY(-20px) rotate(8deg); }
  66% { transform: translateY(10px) rotate(-6deg); }
}

/* --- Section base --- */
.section-inner { max-width: var(--max-width); margin: 0 auto; padding: 0 20px; }
.section-heading {
  font-family: var(--font-heading); font-size: clamp(1.6rem, 5vw, 2.4rem);
  color: var(--primary); text-align: center; margin-bottom: 40px;
  font-weight: 700; letter-spacing: 0.01em;
}

/* --- Reveal animation --- */
.reveal { opacity: 0; transform: translateY(30px); transition: opacity 0.7s ease, transform 0.7s ease; }
.reveal.visible { opacity: 1; transform: translateY(0); }
@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; transition: none; }
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

/* --- Hero --- */
.hero {
  position: relative; min-height: 100vh; min-height: 100svh;
  display: flex; align-items: center; justify-content: center;
  text-align: center; padding: 80px 20px 40px; overflow: hidden;
  background: linear-gradient(180deg, var(--background) 0%, var(--surface) 100%);
}
.hero-balloons { position: absolute; inset: 0; pointer-events: none; z-index: 0; }
.hero-content { position: relative; z-index: 2; max-width: 500px; }
.hero-eyebrow {
  font-family: var(--font-heading); font-size: clamp(1.4rem, 5vw, 2rem);
  color: var(--primary); font-weight: 700; margin-bottom: 4px;
}
.hero-subtitle-text { font-size: 1rem; color: var(--muted); margin-bottom: 16px; }
.hero-name-wrap { margin-bottom: 8px; }
.hero-name {
  font-family: var(--font-heading); font-size: clamp(3rem, 14vw, 5.5rem);
  color: var(--accent); font-weight: 700; line-height: 1; letter-spacing: -0.02em;
  text-shadow: 0 4px 0 rgba(0,0,0,0.05);
}
.hero-age-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 60px; height: 60px; padding: 0 16px; border-radius: 50px;
  background: var(--secondary); color: var(--text);
  font-family: var(--font-heading); font-size: 1.5rem; font-weight: 700;
  box-shadow: var(--shadow-sm); margin-top: 12px;
}
.hero-turning { font-size: 1.1rem; color: var(--muted); margin-bottom: 24px; }
.hero-photo-wrap {
  width: 180px; height: 180px; margin: 0 auto 20px; border-radius: 50%; overflow: hidden;
  border: 5px solid var(--secondary); box-shadow: var(--shadow-md); background: var(--surface);
}
.hero-photo-wrap img { width: 100%; height: 100%; object-fit: cover; }
.hero-cake { font-size: 3rem; animation: gentle-bounce 3s ease-in-out infinite; }
.hero-scroll-hint {
  position: absolute; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 2;
  color: var(--muted); font-size: 0.75rem; letter-spacing: 0.1em; text-transform: uppercase;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.hero-scroll-arrow {
  width: 2px; height: 30px; background: var(--secondary); border-radius: 2px; position: relative; overflow: hidden;
}
.hero-scroll-arrow::after {
  content: ""; position: absolute; top: -50%; left: 0; width: 100%; height: 50%;
  background: var(--accent); animation: scroll-line 2s ease-in-out infinite;
}
@keyframes scroll-line { 0% { top: -50%; } 100% { top: 100%; } }

/* --- Message --- */
.message-section { padding: 80px 0; }
.message-card {
  max-width: 560px; margin: 0 auto; text-align: center; padding: 48px 32px;
  border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-md);
  border: 2px solid rgba(247, 201, 72, 0.2); position: relative;
}
.message-deco, .message-deco-bottom { font-size: 1.5rem; margin: 0 0 16px; }
.message-deco-bottom { margin: 16px 0 0; }
.message-headline {
  font-family: var(--font-heading); font-size: clamp(1.4rem, 5vw, 2rem);
  color: var(--primary); margin-bottom: 16px; font-weight: 700;
}
.message-text { font-size: 1.1rem; color: var(--muted); line-height: 1.8; }

/* --- Countdown --- */
.countdown-section { padding: 60px 0; text-align: center; background: var(--primary); color: #fff; }
.countdown-title { font-family: var(--font-heading); font-size: clamp(1.4rem, 4.5vw, 2rem); color: #fff; margin-bottom: 36px; font-weight: 700; }
.countdown-grid { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; }
.countdown-item {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  min-width: 76px; padding: 20px 14px; border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.15); backdrop-filter: blur(6px);
  border: 1px solid rgba(255, 255, 255, 0.2);
}
.countdown-number {
  font-family: var(--font-heading); font-size: clamp(1.8rem, 6vw, 2.8rem); font-weight: 700;
  color: #fff; line-height: 1;
}
.countdown-label { font-size: 0.7rem; letter-spacing: 0.12em; text-transform: uppercase; color: rgba(255, 255, 255, 0.75); }
.countdown-complete {
  display: flex; align-items: center; justify-content: center; gap: 16px;
  font-family: var(--font-heading); font-size: clamp(1.5rem, 5vw, 2.2rem); font-weight: 700; color: #fff;
}
.countdown-complete-emoji { font-size: 2.5rem; animation: gentle-bounce 1.5s ease-in-out infinite; }

/* --- Event details --- */
.event-section { padding: 80px 0; }
.event-card {
  max-width: 520px; margin: 0 auto; padding: 40px 32px; border-radius: var(--radius-lg);
  background: var(--surface); box-shadow: var(--shadow-md); border: 2px solid rgba(247, 201, 72, 0.2);
}
.event-row { display: flex; align-items: flex-start; gap: 16px; }
.event-icon { font-size: 1.8rem; flex-shrink: 0; width: 48px; height: 48px; display: flex; align-items: center; justify-content: center; border-radius: 50%; background: var(--background); }
.event-info { flex: 1; }
.event-label { font-family: var(--font-heading); font-size: 0.8rem; letter-spacing: 0.15em; text-transform: uppercase; color: var(--secondary); margin-bottom: 4px; font-weight: 600; }
.event-value { font-size: 1.15rem; color: var(--text); font-weight: 600; }
.event-sub-value { font-size: 0.95rem; color: var(--muted); margin-top: 2px; }
.event-divider { height: 1px; background: rgba(48, 36, 58, 0.08); margin: 20px 0; }
.event-map-btn-wrap { margin-top: 28px; text-align: center; }
.event-map-btn {
  display: inline-flex; align-items: center; gap: 8px; padding: 12px 28px; border-radius: 50px;
  background: var(--primary); color: #fff; font-weight: 700; font-size: 0.95rem;
  transition: transform var(--transition), background var(--transition);
}
.event-map-btn:hover { transform: translateY(-2px); background: var(--accent); }

/* --- Activities --- */
.activities-section { padding: 80px 0; background: var(--surface); }
.activities-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 20px; }
.activity-card {
  text-align: center; padding: 32px 20px; border-radius: var(--radius);
  background: var(--background); border: 2px solid rgba(247, 201, 72, 0.15);
  transition: transform var(--transition), box-shadow var(--transition);
}
.activity-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); }
.activity-icon { font-size: 2.5rem; margin-bottom: 12px; display: block; }
.activity-title { font-family: var(--font-heading); font-size: 1.2rem; color: var(--primary); margin-bottom: 8px; font-weight: 600; }
.activity-description { font-size: 0.9rem; color: var(--muted); line-height: 1.5; }

/* --- Gallery --- */
.gallery-section { padding: 80px 0; }
.gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
.gallery-item {
  border-radius: var(--radius); overflow: hidden; cursor: pointer; position: relative;
  box-shadow: var(--shadow-sm); transition: transform var(--transition), box-shadow var(--transition);
  aspect-ratio: 4/3; background: var(--surface);
}
.gallery-item:hover { transform: scale(1.03); box-shadow: var(--shadow-md); }
.gallery-item img { width: 100%; height: 100%; object-fit: cover; }
.gallery-caption {
  position: absolute; bottom: 0; left: 0; right: 0; padding: 16px 12px 12px;
  color: #fff; font-size: 0.9rem; font-family: var(--font-heading); font-weight: 500;
  background: linear-gradient(transparent, rgba(48, 36, 58, 0.75)); opacity: 0; transition: opacity var(--transition);
}
.gallery-item:hover .gallery-caption { opacity: 1; }

/* --- RSVP --- */
.rsvp-section { padding: 80px 0; }
.rsvp-card {
  max-width: 520px; margin: 0 auto; text-align: center; padding: 48px 32px;
  border-radius: var(--radius-lg); background: linear-gradient(135deg, var(--primary), var(--accent));
  box-shadow: var(--shadow-lg); color: #fff;
}
.rsvp-deco { font-size: 2.5rem; margin-bottom: 12px; }
.rsvp-title { font-family: var(--font-heading); font-size: clamp(1.5rem, 5vw, 2rem); color: #fff; margin-bottom: 12px; font-weight: 700; }
.rsvp-message { font-size: 1.05rem; color: rgba(255, 255, 255, 0.88); margin-bottom: 28px; line-height: 1.6; }
.rsvp-button {
  display: inline-flex; align-items: center; gap: 10px; padding: 14px 36px; border-radius: 50px;
  background: #fff; color: var(--primary); font-family: var(--font-heading); font-weight: 700; font-size: 1.05rem;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15); transition: transform var(--transition), box-shadow var(--transition);
}
.rsvp-button:hover { transform: translateY(-2px); box-shadow: 0 10px 28px rgba(0, 0, 0, 0.2); }

/* --- Footer --- */
.footer { text-align: center; padding: 48px 20px; background: var(--text); color: rgba(255, 255, 255, 0.85); }
.footer-message { font-family: var(--font-heading); font-size: 1.1rem; margin-bottom: 8px; font-weight: 500; }
.footer-made-with { font-size: 0.9rem; color: var(--secondary); }

/* --- Music control --- */
.music-control {
  position: fixed; bottom: 20px; left: 20px; z-index: 100;
  width: 52px; height: 52px; border-radius: 50%; background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 1.3rem;
  box-shadow: var(--shadow-md); transition: transform var(--transition), background var(--transition);
}
.music-control:hover { transform: scale(1.1); background: var(--accent); }
.music-control.playing { animation: music-spin 3s linear infinite; }
@keyframes music-spin { to { transform: rotate(360deg); } }

/* --- Lightbox --- */
.lightbox {
  position: fixed; inset: 0; z-index: 9500; background: rgba(0, 0, 0, 0.92);
  display: flex; align-items: center; justify-content: center; padding: 20px;
  opacity: 0; transition: opacity var(--transition);
}
.lightbox.open { opacity: 1; }
.lightbox-image { max-width: 90vw; max-height: 80vh; border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); }
.lightbox-caption { position: absolute; bottom: 60px; left: 0; right: 0; text-align: center; color: #fff; font-family: var(--font-heading); font-size: 1.05rem; }
.lightbox-counter { position: absolute; top: 20px; left: 50%; transform: translateX(-50%); color: rgba(255,255,255,0.7); font-size: 0.9rem; }
.lightbox-close, .lightbox-prev, .lightbox-next {
  position: absolute; color: #fff; width: 48px; height: 48px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; background: rgba(255,255,255,0.12);
  font-size: 1.5rem; transition: background var(--transition);
}
.lightbox-close:hover, .lightbox-prev:hover, .lightbox-next:hover { background: rgba(255,255,255,0.25); }
.lightbox-close { top: 20px; right: 20px; }
.lightbox-prev { left: 12px; top: 50%; transform: translateY(-50%); }
.lightbox-next { right: 12px; top: 50%; transform: translateY(-50%); }

/* --- Balloon decorations (CSS) --- */
.balloon {
  position: absolute; width: 50px; height: 62px; border-radius: 50%;
  animation: balloon-float 6s ease-in-out infinite;
}
.balloon::after {
  content: ""; position: absolute; bottom: -8px; left: 50%; transform: translateX(-50%);
  width: 0; height: 0; border-left: 6px solid transparent; border-right: 6px solid transparent;
  border-top: 8px solid currentColor;
}
.balloon::before {
  content: ""; position: absolute; bottom: -50px; left: 50%; width: 1px; height: 50px;
  background: rgba(0,0,0,0.1);
}
@keyframes balloon-float {
  0%, 100% { transform: translateY(0) rotate(-4deg); }
  50% { transform: translateY(-16px) rotate(4deg); }
}

/* --- Responsive --- */
@media (max-width: 768px) {
  .section-inner { padding: 0 16px; }
  .activities-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .activity-card { padding: 24px 16px; }
  .gallery-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .countdown-item { min-width: 68px; padding: 16px 10px; }
  .countdown-number { font-size: 1.6rem; }
  .message-card, .event-card, .rsvp-card { padding: 32px 20px; }
  .hero-photo-wrap { width: 140px; height: 140px; }
  .lightbox-prev { left: 6px; }
  .lightbox-next { right: 6px; }
}

@media (max-width: 480px) {
  .activities-grid { grid-template-columns: 1fr; }
  .gallery-grid { grid-template-columns: 1fr; }
  .countdown-grid { gap: 8px; }
  .countdown-item { min-width: 64px; padding: 14px 8px; }
  .countdown-number { font-size: 1.4rem; }
  .opening-emoji { font-size: 2.5rem; }
  .hero { padding: 70px 16px 40px; }
  .music-control { width: 46px; height: 46px; bottom: 16px; left: 16px; }
  .rsvp-button { padding: 12px 28px; font-size: 0.95rem; }
}

@media (min-width: 769px) {
  .activities-grid { grid-template-columns: repeat(3, 1fr); }
  .gallery-grid { grid-template-columns: repeat(3, 1fr); }
}

/* --- Utility --- */
.hidden { display: none !important; }
.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;
}
