/* ============================================================
   CHAPTERS.CSS — Per-chapter component styles
   WITH MOBILE FIXES FOR CHAPTER 4 GAME
   WITH LARGER VIDEO STYLES FOR CHAPTER 3
============================================================ */

/* ── INTRO ─────────────────────────────────────────────────── */
.heart-ring {
  width: 140px; height: 140px;
  margin: 0 auto 20px;
}
.heart-ring svg {
  width: 100%; height: 100%;
  animation: pulse3d 2.5s ease-in-out infinite;
  filter: drop-shadow(0 0 18px rgba(195,142,180,0.7));
}
@keyframes pulse3d {
  0%,100% { transform: scale(1) rotate(0deg);   filter: drop-shadow(0 0 18px rgba(195,142,180,0.7)); }
  50%      { transform: scale(1.12) rotate(3deg); filter: drop-shadow(0 0 34px rgba(195,142,180,1));   }
}
.intro-subtitle {
  font-family: 'Playfair Display', serif;
  font-style: italic;
  font-size: clamp(1rem, 3vw, 1.25rem);
  color: var(--text-mid);
  text-align: center;
}

/* ── CHAPTER 1 — STAR CATCH ─────────────────────────────────── */
#starCanvas {
  border-radius: 18px;
  border: 2px solid var(--glass-border);
  background: rgba(20, 0, 35, 0.9);
  width: 100%;
  max-width: 480px;
  display: block;
  cursor: none;
  touch-action: none;
  box-shadow: 0 8px 40px rgba(139,94,126,0.3);
}
#starScore {
  font-family: 'Dancing Script', cursive;
  font-size: 1.5rem;
  color: var(--gold);
  text-shadow: 0 0 12px rgba(240,198,122,0.4);
  text-align: center;
}

/* ── CHAPTER 2 — HIDDEN HEARTS ──────────────────────────────── */
#ch2-hunt {
  position: relative;
  width: 100%;
  max-width: 520px;
  height: 360px;
  border-radius: 20px;
  background: rgba(255,255,255,0.12);
  border: 1px solid var(--glass-border);
  overflow: hidden;
}
#ch2-hunt .hint-text {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%,-50%);
  color: rgba(195,142,180,0.5);
  font-family: 'Dancing Script', cursive;
  font-size: 1.3rem;
  pointer-events: none;
  text-align: center;
  line-height: 1.7;
}
.hunt-heart {
  position: absolute;
  width: 38px; height: 38px;
  cursor: pointer;
  filter: drop-shadow(0 0 6px rgba(195,142,180,0.6));
  animation: floatY 3s ease-in-out infinite;
  z-index: 5;
  transition: transform 0.2s;
}
.hunt-heart:nth-child(2) { animation-delay: -0.5s; }
.hunt-heart:nth-child(3) { animation-delay: -1.2s; }
.hunt-heart:nth-child(4) { animation-delay: -1.8s; }
.hunt-heart:nth-child(5) { animation-delay: -2.4s; }
.hunt-heart:hover { transform: scale(1.4) !important; filter: drop-shadow(0 0 14px rgba(195,142,180,1)); }

#ch2-counter {
  font-family: 'Dancing Script', cursive;
  font-size: 1.2rem;
  color: var(--rose);
  text-align: center;
}

/* Love card flip grid */
#ch2-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 16px;
  max-width: 680px;
  width: 100%;
}
.love-card {
  perspective: 900px;
  height: 160px;
  cursor: pointer;
}
.love-card-inner {
  position: relative;
  width: 100%; height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.75s cubic-bezier(0.4,0,0.2,1);
  border-radius: 18px;
}
.love-card.flipped .love-card-inner { transform: rotateY(180deg); }
.love-card-front, .love-card-back {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
  text-align: center;
}
.love-card-front {
  background: linear-gradient(135deg, var(--rose), var(--deep));
  color: white;
  font-family: 'Dancing Script', cursive;
  font-size: 2rem;
}
.love-card-back {
  background: linear-gradient(135deg, var(--blush), var(--white));
  color: var(--deep);
  font-family: 'Playfair Display', serif;
  font-style: italic;
  font-size: 0.92rem;
  font-weight: 600;
  transform: rotateY(180deg);
  border: 2px solid var(--glass-border);
  box-shadow: 0 8px 28px rgba(139,94,126,0.2);
  line-height: 1.4;
}

/* ── CHAPTER 3 — TYPEWRITER & PUZZLE ────────────────────────── */
#typewriter-text {
  font-family: 'Playfair Display', serif;
  font-style: italic;
  font-size: clamp(0.98rem, 2.5vw, 1.18rem);
  color: var(--text-mid);
  line-height: 1.95;
  max-width: 560px;
  text-align: center;
  min-height: 110px;
  white-space: pre-line;
}
.cursor {
  display: inline-block;
  width: 2px; height: 1.1em;
  background: var(--rose);
  margin-left: 2px;
  vertical-align: text-bottom;
  animation: blink 0.9s infinite;
}

/* ── CHAPTER 3 LARGER VIDEOS ─────────────────────────────────── */
.videos-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 35px;
  margin: 30px auto;
  width: 100%;
  max-width: 800px;
}

.video-card {
  width: 100%;
  max-width: 700px;
  background: linear-gradient(135deg, rgba(255,255,255,0.15), rgba(255,255,255,0.05));
  border-radius: 24px;
  overflow: hidden;
  backdrop-filter: blur(12px);
  border: 2px solid var(--glass-border);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

.video-card:hover {
  transform: translateY(-5px) scale(1.01);
  box-shadow: 0 25px 45px rgba(139,94,126,0.5);
  border-color: var(--gold);
}

.memory-video {
  width: 100%;
  min-height: 350px;
  height: auto;
  aspect-ratio: 16 / 9;
  object-fit: contain;
  background: #0a0a0a;
  display: block;
}

.video-caption {
  font-family: 'Dancing Script', cursive;
  font-size: 1.3rem;
  color: var(--gold);
  text-align: center;
  padding: 15px;
  margin: 0;
  background: rgba(0,0,0,0.5);
  font-weight: 600;
  letter-spacing: 1px;
}

/* Puzzle section styling */
.puzzle-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 20px 0;
  width: 100%;
}

/* Photo placeholder */
.photo-placeholder {
  width: 260px; height: 200px;
  border-radius: 18px;
  overflow: hidden;
  border: 2px solid var(--glass-border);
  background: linear-gradient(135deg, var(--blush), var(--rose));
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow);
}
.photo-placeholder span {
  color: white;
  font-family: 'Dancing Script', cursive;
  font-size: 1.1rem;
  text-align: center;
  padding: 16px;
  line-height: 1.6;
}
.photo-placeholder img {
  width: 100%; height: 100%;
  object-fit: cover;
}

/* Puzzle */
#puzzleArea {
  position: relative;
  width: 300px; height: 300px;
}
#puzzleContainer {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  width: 300px; height: 300px;
}
.puzzle-piece {
  background: linear-gradient(135deg, var(--rose) 0%, var(--blush) 100%);
  border-radius: 7px;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.6rem;
  user-select: none;
  border: 2px solid rgba(255,255,255,0.5);
}
.puzzle-piece:hover  { transform: scale(1.06); box-shadow: 0 4px 14px rgba(139,94,126,0.5); }
.puzzle-piece.correct  {
  border-color: var(--gold);
  background: linear-gradient(135deg, var(--gold) 0%, var(--rose) 100%);
  animation: pulse 0.6s ease;
}
#puzzleHint {
  font-size: 0.9rem;
  color: var(--text-mid);
  font-style: italic;
  text-align: center;
  margin-top: 15px;
}

/* ── CHAPTER 4 — TIMELINE ────────────────────────────────────── */
#timeline {
  max-width: 600px;
  width: 100%;
  padding: 0 10px;
}
.tl-item {
  display: flex;
  gap: 18px;
  margin-bottom: 32px;
  opacity: 0;
  transform: translateX(-30px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}
.tl-item.revealed { opacity: 1; transform: none; }
.tl-line {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
}
.tl-dot {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--rose), var(--gold));
  border: 3px solid white;
  box-shadow: 0 0 14px rgba(195,142,180,0.6);
  flex-shrink: 0;
}
.tl-connector {
  width: 2px; flex: 1;
  background: linear-gradient(to bottom, var(--rose), var(--blush));
  margin-top: 4px;
  min-height: 36px;
}
.tl-card {
  background: var(--glass-bg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--glass-border);
  border-radius: 18px;
  padding: 18px 22px;
  flex: 1;
  box-shadow: 0 4px 18px rgba(139,94,126,0.12);
  cursor: pointer;
  transition: box-shadow 0.2s, transform 0.2s;
}
.tl-card:hover { box-shadow: 0 8px 28px rgba(139,94,126,0.22); transform: translateY(-2px); }
.tl-date  {
  font-family: 'Dancing Script', cursive;
  font-size: 0.88rem;
  color: var(--rose);
  margin-bottom: 4px;
}
.tl-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.05rem;
  color: var(--deep);
  margin-bottom: 6px;
}
.tl-desc {
  font-size: 0.86rem;
  color: var(--text-mid);
  line-height: 1.65;
}

/* Memory Trail - FIXED FOR MOBILE */
#memTrailArea {
  position: relative;
  width: 100%;
  max-width: 520px;
  min-height: 400px;
  height: auto;
  aspect-ratio: 1 / 0.8;
  border-radius: 20px;
  background: rgba(255,255,255,0.08);
  border: 2px solid var(--glass-border);
  overflow: visible;
  margin: 20px auto;
}

.trail-heart {
  position: absolute;
  width: 44px;
  height: 44px;
  cursor: pointer;
  animation: glowPulse 1.8s ease-in-out infinite;
  display: none;
  z-index: 15;
  transition: transform 0.2s ease;
}

.trail-heart.active {
  display: block;
}

.trail-heart:hover {
  transform: scale(1.2);
}

.trail-heart svg {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 0 8px rgba(240,198,122,0.8));
}

.trail-popup {
  position: fixed;
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  padding: 13px 16px;
  font-family: 'Playfair Display', serif;
  font-style: italic;
  font-size: 0.88rem;
  color: var(--deep);
  max-width: 220px;
  text-align: center;
  animation: fadeInUp 0.5s ease forwards;
  pointer-events: none;
  z-index: 100;
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}

#trailCounter {
  font-size: 0.9rem;
  color: var(--text-mid);
  font-style: italic;
  text-align: center;
  margin-top: 15px;
  padding: 8px;
  background: rgba(255,255,255,0.1);
  border-radius: 30px;
  display: inline-block;
  width: auto;
}

/* ── FINAL CHAPTER ───────────────────────────────────────────── */
#screen-final .title-script { color: var(--blush); }
#screen-final .body-text { color: rgba(255,255,255,0.78); }

#giftBox {
  width: 130px; height: 130px;
  margin: 0 auto 16px;
  cursor: pointer;
  filter: drop-shadow(0 0 28px rgba(240,198,122,0.7));
  transition: transform 0.3s;
  animation: floatY 3s ease-in-out infinite;
}
#giftBox:hover { transform: scale(1.1) rotate(-3deg); animation: none; }
#giftBox.opened {
  animation: giftOpen 0.85s cubic-bezier(0.34,1.56,0.64,1) forwards;
  pointer-events: none;
}
@keyframes giftOpen {
  0%   { transform: scale(1); opacity: 1; }
  35%  { transform: scale(1.35) rotate(6deg); }
  65%  { transform: scale(0.85) rotate(-4deg); }
  100% { transform: scale(0); opacity: 0; }
}

#birthday-msg {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  animation: fadeInUp 1s ease forwards;
  text-align: center;
  max-width: 540px;
}
#birthday-msg.show { display: flex; }

.birthday-subtitle {
  font-family: 'Playfair Display', serif;
  font-style: italic;
  color: var(--gold);
  font-size: clamp(1rem, 2.5vw, 1.2rem);
  line-height: 1.6;
}

/* Letter */
#letterArea {
  width: 100%; max-width: 540px;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(240,198,122,0.3);
  border-radius: 20px;
  padding: 26px 30px;
}
#letterArea p.letter-label {
  font-family: 'Dancing Script', cursive;
  font-size: 1rem;
  color: var(--gold);
  margin-bottom: 10px;
}
#letterText {
  width: 100%;
  min-height: 180px;
  background: transparent;
  border: none;
  outline: none;
  color: rgba(255,255,255,0.85);
  font-family: 'Dancing Script', cursive;
  font-size: 1.15rem;
  line-height: 1.85;
  resize: vertical;
}
#letterText::placeholder { color: rgba(255,255,255,0.3); }
.letter-hint {
  font-size: 0.72rem;
  color: rgba(255,255,255,0.3);
  margin-top: 8px;
  font-style: italic;
}

/* ── BONUS CHAPTER ───────────────────────────────────────────── */
#screen-bonus .title-script { color: var(--gold); }
#screen-bonus .body-text    { color: rgba(255,255,255,0.7); }

#bonus-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 14px;
  max-width: 700px;
  width: 100%;
}
.bonus-card {
  perspective: 900px;
  height: 140px;
  cursor: pointer;
}
.bonus-card-inner {
  position: relative;
  width: 100%; height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.7s cubic-bezier(0.4,0,0.2,1);
  border-radius: 16px;
}
.bonus-card:hover .bonus-card-inner { transform: rotateY(180deg); }
.bonus-front, .bonus-back {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  padding: 10px;
  text-align: center;
}
.bonus-front {
  background: linear-gradient(135deg, #3d1a5c, #6b2a4a);
  border: 1px solid rgba(240,198,122,0.35);
  font-size: 1.8rem;
}
.bonus-back {
  background: linear-gradient(135deg, rgba(240,198,122,0.12), rgba(195,142,180,0.12));
  border: 1px solid rgba(240,198,122,0.4);
  transform: rotateY(180deg);
  color: var(--gold);
  font-family: 'Playfair Display', serif;
  font-style: italic;
  font-size: 0.82rem;
  line-height: 1.55;
}

/* ── RESPONSIVE (MOBILE FIXES) ───────────────────────────────── */
@media (max-width: 768px) {
  #ch2-cards    { grid-template-columns: repeat(2, 1fr); }
  #bonus-cards  { grid-template-columns: repeat(2, 1fr); }
  #puzzleArea,
  #puzzleContainer { width: 240px; height: 240px; }
  .love-card    { height: 130px; }
  
  /* Memory Trail Mobile Fixes */
  #memTrailArea {
    min-height: 450px;
    aspect-ratio: 1 / 0.9;
  }
  
  .trail-heart {
    width: 36px;
    height: 36px;
  }
  
  .trail-popup {
    max-width: 180px;
    font-size: 0.78rem;
    padding: 10px 12px;
    z-index: 200;
  }
  
  .tl-card {
    padding: 12px 16px;
  }
  
  .tl-title {
    font-size: 0.95rem;
  }
  
  .tl-desc {
    font-size: 0.8rem;
  }
  
  /* Videos Mobile Fixes */
  .videos-container {
    gap: 25px;
    padding: 0 10px;
  }
  
  .video-card {
    max-width: 100%;
  }
  
  .memory-video {
    min-height: 250px;
  }
  
  .video-caption {
    font-size: 1.1rem;
    padding: 12px;
  }
}

@media (max-width: 480px) {
  #ch2-cards    { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  #bonus-cards  { grid-template-columns: repeat(2, 1fr); }
  #puzzleArea,
  #puzzleContainer { width: 200px; height: 200px; }
  .puzzle-piece { font-size: 1.2rem; }
  .love-card    { height: 110px; }
  .love-card-back { font-size: 0.75rem; }
  
  /* Memory Trail Mobile Fixes */
  #memTrailArea {
    min-height: 400px;
  }
  
  .trail-heart {
    width: 30px;
    height: 30px;
  }
  
  .trail-popup {
    max-width: 160px;
    font-size: 0.7rem;
    padding: 8px 10px;
  }
  
  .glass-card {
    padding: 20px 16px;
  }
  
  .title-serif {
    font-size: 1.6rem;
  }
  
  .body-text {
    font-size: 0.9rem;
  }
  
  #trailCounter {
    font-size: 0.8rem;
  }
  
  /* Videos Mobile Fixes */
  .video-card {
    max-width: 100%;
  }
  
  .memory-video {
    min-height: 200px;
  }
  
  .video-caption {
    font-size: 0.9rem;
    padding: 10px;
  }
  
  .videos-container {
    gap: 20px;
  }
}

/* Touch-friendly adjustments */
@media (hover: none) and (pointer: coarse) {
  .trail-heart {
    min-width: 44px;
    min-height: 44px;
  }
  
  .hunt-heart {
    min-width: 44px;
    min-height: 44px;
  }
  
  .puzzle-piece {
    cursor: pointer;
  }
  
  .btn-primary, .btn-ghost {
    padding: 14px 24px;
    min-height: 48px;
  }
}
/* ── LETTER DISPLAY (non-editable, styled box like glass-card) ── */
.letter-display {
  width: 100%;
  min-height: 160px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(240,198,122,0.35);
  border-radius: 18px;
  padding: 24px 26px;
  color: rgba(255,255,255,0.88);
  font-family: 'Dancing Script', cursive;
  font-size: clamp(1rem, 3.5vw, 1.2rem);
  line-height: 1.9;
  text-align: right;
  direction: rtl;
  white-space: pre-wrap;
  word-break: break-word;
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
  margin-top: 4px;
}

@media (max-width: 480px) {
  .letter-display {
    padding: 18px 16px;
    font-size: 1rem;
    min-height: 130px;
  }
}