/* ========================================
   HAPPY BIRTHDAY, AAKRITI
   A Digital Storybook SPA
   ======================================== */

/* ----- CSS Variables ----- */
:root {
  --bg-primary: #FCFBF9;
  --bg-secondary: #FFFEFC;
  --rose-gold: #D4A0A0;
  --rose-gold-light: #F0D6D6;
  --rose-gold-dark: #B87575;
  --terracotta: #C8654E;
  --terracotta-light: #E8A090;
  --gold: #D4A574;
  --gold-light: #F0DDC0;
  --charcoal: #2C2C2C;
  --text-muted: #8A8A8A;
  --text-light: #6B6B6B;
  --border-light: #E8E4DF;
  --shadow-soft: 0 4px 24px rgba(0, 0, 0, 0.06);
  --shadow-medium: 0 8px 40px rgba(0, 0, 0, 0.10);
  --shadow-glow: 0 0 30px rgba(212, 160, 160, 0.3);

  --font-title: 'Playfair Display', Georgia, serif;
  --font-script: 'Italianno', cursive;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;

  --nav-height: 64px;
  --content-padding: 100px 24px 100px;
  --transition-duration: 0.6s;
}

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-body);
  background: var(--bg-primary);
  color: var(--charcoal);
  height: 100%;
  overflow: hidden;
  line-height: 1.7;
}

/* ----- App Shell ----- */
#app {
  position: relative;
  width: 100%;
  height: 100vh;
  overflow: hidden;
  background: var(--bg-primary);
}

/* ----- Shared Container ----- */
.container {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
}

/* ========================================
   SPLASH SCREEN
   ======================================== */
#splash {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 1;
  visibility: visible;
  transition: opacity 0.8s ease, visibility 0.8s ease;
  overflow: hidden;
}

#splash.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.splash-bg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(160deg, #FCFBF9 0%, #F5E6E8 40%, #FCFBF9 100%);
  z-index: 0;
}

.splash-content {
  position: relative;
  z-index: 2;
  text-align: center;
  padding: 40px 24px;
  max-width: 560px;
}

.splash-greeting {
  font-family: var(--font-script);
  font-size: 2.2rem;
  color: var(--rose-gold-dark);
  margin-bottom: 0.25rem;
  letter-spacing: 1px;
  opacity: 0;
  animation: fadeInDown 1s ease 0.3s forwards;
}

.splash-title {
  font-family: var(--font-title);
  font-size: 3.8rem;
  font-weight: 700;
  color: var(--charcoal);
  line-height: 1.15;
  margin-bottom: 1.25rem;
  opacity: 0;
  animation: fadeInDown 1s ease 0.6s forwards;
}

.splash-title .heart {
  color: var(--terracotta);
  display: inline-block;
  animation: heartbeat 1.4s ease 1.5s infinite;
}

.splash-subtitle {
  font-size: 1.05rem;
  color: var(--text-light);
  line-height: 1.7;
  margin-bottom: 2.5rem;
  opacity: 0;
  animation: fadeInDown 1s ease 0.9s forwards;
}

#unlock-btn {
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 500;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: #fff;
  background: linear-gradient(135deg, var(--rose-gold) 0%, var(--terracotta) 100%);
  border: none;
  border-radius: 50px;
  padding: 16px 40px;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: var(--shadow-glow);
  position: relative;
  overflow: hidden;
  opacity: 0;
  animation: fadeInUp 1s ease 1.2s forwards;
}

#unlock-btn:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 0 40px rgba(212, 160, 160, 0.4);
}

#unlock-btn:active {
  transform: translateY(0) scale(0.98);
}

/* Splash floating petals */
.splash-petals {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: none;
  overflow: hidden;
}

.splash-petals span {
  position: absolute;
  width: 8px;
  height: 8px;
  background: var(--rose-gold-light);
  border-radius: 50%;
  opacity: 0;
  animation: petalFloat 8s ease-in-out infinite;
}

.splash-petals span:nth-child(1) { left: 10%; animation-delay: 0s; }
.splash-petals span:nth-child(2) { left: 25%; animation-delay: 1.2s; width: 6px; height: 6px; }
.splash-petals span:nth-child(3) { left: 50%; animation-delay: 2.5s; width: 10px; height: 10px; }
.splash-petals span:nth-child(4) { left: 70%; animation-delay: 3.8s; width: 5px; height: 5px; }
.splash-petals span:nth-child(5) { left: 85%; animation-delay: 5s; }
.splash-petals span:nth-child(6) { left: 40%; animation-delay: 6.5s; width: 7px; height: 7px; }

/* ========================================
   CHAPTERS (Shared)
   ======================================== */
.chapter {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: var(--content-padding);
  padding-bottom: calc(100px + var(--nav-height));
  opacity: 0;
  transform: translateY(24px);
  transition: opacity var(--transition-duration) ease,
              transform var(--transition-duration) ease;
  pointer-events: none;
  will-change: opacity, transform;
}

.chapter.active {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* Chapter decorative header */
.chapter-num {
  display: block;
  font-family: var(--font-script);
  font-size: 1.8rem;
  color: var(--rose-gold);
  margin-bottom: 0.2rem;
  letter-spacing: 2px;
}

.chapter-title {
  font-family: var(--font-title);
  font-size: 2.4rem;
  font-weight: 700;
  color: var(--charcoal);
  line-height: 1.25;
  margin-bottom: 0.35rem;
}

.chapter-location {
  font-size: 1rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.chapter-location .emoji {
  font-size: 1.1rem;
}

.chapter-date {
  font-family: var(--font-body);
  font-size: 0.85rem;
  color: var(--gold);
  font-weight: 500;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  margin-bottom: 1.5rem;
}

/* Story text */
.story {
  background: var(--bg-secondary);
  border-radius: 16px;
  padding: 28px 32px;
  box-shadow: var(--shadow-soft);
  margin-bottom: 2rem;
  line-height: 1.8;
}

.story p {
  font-size: 0.98rem;
  color: var(--charcoal);
}

.story p + p {
  margin-top: 1rem;
}

/* ========================================
   PHOTO ALBUM & GALLERY
   ======================================== */

/* ---- Shared Card ---- */
.photo-card,
.collage-item,
.masonry-item {
  position: relative;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: var(--shadow-soft);
  transition: transform 0.4s ease, box-shadow 0.4s ease;
  background: var(--bg-secondary);
  cursor: pointer;
}

.photo-card:hover,
.collage-item:hover,
.masonry-item:hover {
  transform: scale(1.03);
  box-shadow: var(--shadow-medium);
}

.photo-card img,
.photo-card video,
.collage-item img,
.collage-item video,
.masonry-item img,
.masonry-item video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: var(--rose-gold-light);
}

/* ---- Distance Layout (Chapter 1) ---- */
.photo-album.distance-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  width: 100%;
}

.photo-album.distance-layout .photo-card:first-child {
  grid-row: 1 / 3;
}

.photo-album.distance-layout .photo-card:first-child img,
.photo-album.distance-layout .photo-card:first-child video {
  height: 100%;
  object-fit: cover;
}

.photo-stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.photo-stack .photo-card img {
  aspect-ratio: 4 / 3;
}

/* ---- Collage Grid (Chapter 2) ---- */
.photo-collage {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 12px;
  width: 100%;
}

.collage-item img,
.collage-item video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.collage-featured {
  grid-column: 1;
  grid-row: 1 / 3;
}

.collage-item:not(.collage-featured) img,
.collage-item:not(.collage-featured) video {
  aspect-ratio: 1;
}

.collage-item:last-child {
  grid-column: 2 / 4;
  grid-row: 2;
}

.collage-item:last-child img,
.collage-item:last-child video {
  aspect-ratio: 2 / 1;
}

/* ---- Masonry Grid (Chapter 3) ---- */
.masonry-grid {
  column-count: 2;
  column-gap: 14px;
  width: 100%;
}

.masonry-item {
  break-inside: avoid;
  margin-bottom: 14px;
}

.masonry-item img,
.masonry-item video {
  width: 100%;
  object-fit: cover;
}

.masonry-item:nth-child(1) img { aspect-ratio: 4 / 5; }
.masonry-item:nth-child(2) img { aspect-ratio: 1 / 1.2; }
.masonry-item:nth-child(3) img { aspect-ratio: 1.1 / 1; }
.masonry-item:nth-child(3) video { aspect-ratio: 1.1 / 1; }
.masonry-item:nth-child(4) img { aspect-ratio: 1 / 1.4; }

/* ---- Caption Overlay ---- */
.photo-caption {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 14px 16px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.65));
  color: #fff;
  font-size: 0.78rem;
  font-weight: 500;
  line-height: 1.35;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.35s ease, transform 0.35s ease;
  pointer-events: none;
}

.photo-card:hover .photo-caption,
.collage-item:hover .photo-caption,
.masonry-item:hover .photo-caption {
  opacity: 1;
  transform: translateY(0);
}

@media (hover: none) and (pointer: coarse) {
  .photo-caption {
    opacity: 1;
    transform: translateY(0);
    padding: 10px 12px;
    font-size: 0.72rem;
  }
}

/* ---- Video Play Indicator ---- */
.video-card video::-webkit-media-controls {
  z-index: 2;
}

.video-card::after {
  content: '\25B6';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 2.4rem;
  color: #fff;
  opacity: 0.6;
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;
  text-shadow: 0 2px 16px rgba(0, 0, 0, 0.5);
  z-index: 1;
}

.video-card:hover::after {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1.15);
}

.video-card.playing::after {
  opacity: 0;
  pointer-events: none;
}

/* ========================================
   BIRTHDAY CARD (Chapter 4)
   ======================================== */
.birthday-title {
  font-size: 2.6rem;
  color: var(--terracotta);
  text-align: center;
}

.birthday-card {
  background: var(--bg-secondary);
  border-radius: 20px;
  padding: 40px 36px;
  box-shadow: var(--shadow-soft);
  text-align: center;
  position: relative;
  border: 1px solid var(--border-light);
}

.card-ornament {
  font-size: 1.6rem;
  color: var(--rose-gold);
  line-height: 1;
}

.card-ornament.top {
  margin-bottom: 1.2rem;
}

.card-ornament.bottom {
  margin-top: 1.2rem;
}

.card-body p {
  font-size: 1rem;
  line-height: 1.9;
  color: var(--charcoal);
}

.card-body p + p {
  margin-top: 1rem;
}

.card-signature {
  margin-top: 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.signature-label {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.signature-name {
  font-family: var(--font-script);
  font-size: 2.4rem;
  color: var(--rose-gold-dark);
  line-height: 1;
}

/* confetti canvas overlay */
#confetti-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 100;
}

/* ========================================
   LIGHTBOX
   ======================================== */
.lightbox {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 90;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.4s ease, visibility 0.4s ease;
  padding: 40px;
  cursor: pointer;
}

.lightbox.active {
  opacity: 1;
  visibility: visible;
}

.lightbox-img {
  max-width: 90vw;
  max-height: 85vh;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 8px 60px rgba(0, 0, 0, 0.5);
  cursor: default;
}

.lightbox.active .lightbox-img {
  animation: lightboxIn 0.4s ease forwards;
}

@keyframes lightboxIn {
  from {
    opacity: 0;
    transform: scale(0.92);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.lightbox-close {
  position: absolute;
  top: 20px;
  right: 24px;
  background: none;
  border: none;
  color: #fff;
  font-size: 2.5rem;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.2s ease;
  line-height: 1;
  z-index: 2;
  padding: 8px;
}

.lightbox-close:hover {
  opacity: 1;
}

@media (max-width: 480px) {
  .lightbox {
    padding: 20px;
  }

  .lightbox-img {
    max-width: 100vw;
    max-height: 80vh;
  }

  .lightbox-close {
    top: 12px;
    right: 16px;
    font-size: 2rem;
  }
}

/* ========================================
   NAVIGATION
   ======================================== */
#navigation {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 30;
  background: rgba(252, 251, 249, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border-light);
  padding: 0 16px;
  padding-bottom: env(safe-area-inset-bottom, 0);
  transform: translateY(100%);
  transition: transform 0.5s ease;
}

#navigation.visible {
  transform: translateY(0);
}

.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 720px;
  margin: 0 auto;
  height: var(--nav-height);
  gap: 12px;
}

.nav-btn {
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-light);
  background: none;
  border: 1px solid var(--border-light);
  border-radius: 40px;
  padding: 8px 18px;
  cursor: pointer;
  transition: all 0.25s ease;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
}

.nav-btn:hover:not(:disabled) {
  border-color: var(--rose-gold);
  color: var(--rose-gold-dark);
}

.nav-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.nav-btn-primary {
  background: linear-gradient(135deg, var(--rose-gold) 0%, var(--terracotta) 100%);
  color: #fff;
  border: none;
  padding: 8px 22px;
}

.nav-btn-primary:hover {
  box-shadow: var(--shadow-glow);
  color: #fff;
}

.nav-arrow {
  font-size: 1.1rem;
  line-height: 1;
}

/* Progress dots */
.nav-dots {
  display: flex;
  align-items: center;
  gap: 8px;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border-light);
  transition: all 0.3s ease;
}

.dot.active {
  background: var(--rose-gold);
  box-shadow: 0 0 8px rgba(212, 160, 160, 0.4);
  transform: scale(1.3);
}

/* ========================================
   AUDIO TOGGLE
   ======================================== */
#audio-toggle {
  position: fixed;
  bottom: calc(var(--nav-height) + 16px + env(safe-area-inset-bottom, 0));
  right: 16px;
  z-index: 40;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--border-light);
  background: rgba(252, 251, 249, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  opacity: 0;
  transform: scale(0.8);
  pointer-events: none;
  box-shadow: var(--shadow-soft);
}

#audio-toggle.visible {
  opacity: 1;
  transform: scale(1);
  pointer-events: auto;
}

#audio-toggle:hover {
  box-shadow: var(--shadow-medium);
  transform: scale(1.1);
}

/* ========================================
   ANIMATIONS
   ======================================== */
@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

@keyframes heartbeat {
  0%, 100% { transform: scale(1); }
  14% { transform: scale(1.25); }
  28% { transform: scale(1); }
  42% { transform: scale(1.2); }
  56% { transform: scale(1); }
}

@keyframes petalFloat {
  0% {
    opacity: 0;
    transform: translateY(100vh) rotate(0deg);
  }
  20% {
    opacity: 0.6;
  }
  80% {
    opacity: 0.6;
  }
  100% {
    opacity: 0;
    transform: translateY(-10vh) rotate(720deg);
  }
}

@keyframes sparkle {
  0%, 100% { opacity: 0; transform: scale(0) rotate(0deg); }
  50% { opacity: 1; transform: scale(1) rotate(180deg); }
}

/* ========================================
   SCROLLBAR STYLING
   ======================================== */
.chapter::-webkit-scrollbar {
  width: 4px;
}

.chapter::-webkit-scrollbar-track {
  background: transparent;
}

.chapter::-webkit-scrollbar-thumb {
  background: var(--rose-gold-light);
  border-radius: 4px;
}

.chapter::-webkit-scrollbar-thumb:hover {
  background: var(--rose-gold);
}

/* ========================================
   RESPONSIVE
   ======================================== */

/* Tablet */
@media (max-width: 768px) {
  .splash-title {
    font-size: 2.8rem;
  }

  .splash-greeting {
    font-size: 1.8rem;
  }

  .chapter-title {
    font-size: 1.9rem;
  }

  .chapter {
    padding: 80px 20px 100px;
    padding-bottom: calc(80px + var(--nav-height));
  }

  .story {
    padding: 24px 20px;
  }

  .story p {
    font-size: 0.92rem;
  }

  .birthday-card {
    padding: 32px 24px;
  }

  .birthday-title {
    font-size: 2rem;
  }

  .photo-collage {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto;
  }

  .collage-featured {
    grid-column: 1 / 3;
    grid-row: auto;
  }

  .collage-featured img,
  .collage-featured video {
    aspect-ratio: 4 / 3;
  }

  .collage-item:last-child {
    grid-column: 1 / 3;
    grid-row: auto;
  }

  .collage-item:last-child img,
  .collage-item:last-child video {
    aspect-ratio: 2 / 1;
  }
}

/* Mobile */
@media (max-width: 480px) {
  .splash-title {
    font-size: 2.2rem;
  }

  .splash-greeting {
    font-size: 1.5rem;
  }

  .splash-subtitle {
    font-size: 0.92rem;
  }

  #unlock-btn {
    font-size: 0.82rem;
    padding: 14px 28px;
  }

  .chapter-title {
    font-size: 1.6rem;
  }

  .chapter-num {
    font-size: 1.4rem;
  }

  .chapter-date {
    font-size: 0.75rem;
  }

  .chapter {
    padding: 60px 16px 90px;
    padding-bottom: calc(60px + var(--nav-height));
  }

  .story {
    padding: 20px 16px;
    border-radius: 12px;
  }

  .story p {
    font-size: 0.88rem;
  }

  .photo-album.distance-layout {
    grid-template-columns: 1fr;
  }

  .photo-album.distance-layout .photo-card:first-child {
    grid-row: auto;
  }

  .photo-album.distance-layout .photo-card:first-child img,
  .photo-album.distance-layout .photo-card:first-child video {
    aspect-ratio: 4 / 3;
  }

  .photo-collage {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto;
  }

  .collage-featured {
    grid-column: 1 / 3;
    grid-row: auto;
  }

  .collage-featured img,
  .collage-featured video {
    aspect-ratio: 4 / 3;
  }

  .collage-item:not(.collage-featured) img,
  .collage-item:not(.collage-featured) video {
    aspect-ratio: 1;
  }

  .collage-item:last-child {
    grid-column: 1 / 3;
    grid-row: auto;
  }

  .collage-item:last-child img,
  .collage-item:last-child video {
    aspect-ratio: 2 / 1;
  }

  .masonry-grid {
    column-count: 1;
  }

  .photo-card,
  .collage-item,
  .masonry-item {
    border-radius: 10px;
  }

  .birthday-card {
    padding: 24px 18px;
    border-radius: 14px;
  }

  .birthday-title {
    font-size: 1.6rem;
  }

  .card-body p {
    font-size: 0.88rem;
  }

  .signature-name {
    font-size: 2rem;
  }

  .nav-btn {
    font-size: 0.78rem;
    padding: 6px 14px;
  }

  .nav-btn-primary {
    padding: 6px 16px;
  }

  .nav-dots {
    gap: 6px;
  }

  .dot {
    width: 6px;
    height: 6px;
  }

  #audio-toggle {
    width: 38px;
    height: 38px;
    font-size: 1rem;
    right: 12px;
    bottom: calc(var(--nav-height) + 12px + env(safe-area-inset-bottom, 0));
  }

  :root {
    --nav-height: 56px;
  }
}

/* Small mobile */
@media (max-width: 360px) {
  .photo-collage {
    grid-template-columns: 1fr;
  }

  .collage-featured {
    grid-column: 1;
  }

  .collage-item:last-child {
    grid-column: 1;
  }

  .splash-title {
    font-size: 1.8rem;
  }
}
