/* ============================================
   BASE RESET / ROOT
   ============================================ */

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

:root {
  --cream:       #fdf6e3;
  --soft-gold:   #d4a843;
  --warm-white:  #fefcf3;
  --parchment:   #f5e6c8;
  --petal-gold:  #f0c040;
  --petal-hover: #fed850;
  --petal-active:#e6a817;
  --leaf-green:  #5a7247;
  --brown-center:#6b3a0a;
  --text-dark:   #3e2c1c;
  --text-soft:   #6b5440;
  --letter-shadow: 0 8px 40px rgba(60,40,10,0.12),
                   0 2px 8px rgba(60,40,10,0.08);
  --font-cursive:  'Caveat', cursive;
  --font-serif:    'Cormorant Garamond', Georgia, 'Times New Roman', serif;
}

html {
  scroll-behavior: smooth;
}

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

/* ============================================
   BACKGROUND
   ============================================ */

.bg-gradient {
  position: fixed;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(ellipse at 30% 20%, #fdf2d4 0%, transparent 60%),
    radial-gradient(ellipse at 80% 80%, #fae6c0 0%, transparent 50%),
    linear-gradient(180deg, #fefcf3 0%, #fdf1de 40%, #f8e0b8 100%);
  pointer-events: none;
}

#particles {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

/* ============================================
   PAGE
   ============================================ */

.page {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 60px 20px 80px;
  gap: 80px;
}

/* ============================================
   LETTER
   ============================================ */

.letter-section {
  opacity: 0;
  transform: translateY(30px);
  animation: letterIn 1.4s ease-out 0.3s forwards;
  width: 100%;
  max-width: 580px;
}

@keyframes letterIn {
  to { opacity: 1; transform: translateY(0); }
}

.letter {
  background: linear-gradient(180deg, #fffef8 0%, #faf2e1 60%, #f3e4c4 100%);
  border-radius: 3px;
  box-shadow: var(--letter-shadow);
  padding: 48px 44px;
  position: relative;
  background-image:
    repeating-linear-gradient(
      transparent, transparent 34px,
      rgba(160,130,90,0.06) 34px, rgba(160,130,90,0.06) 35px
    );
}

.letter::before {
  content: '';
  position: absolute;
  left: 30px;
  top: 0;
  bottom: 0;
  width: 1px;
  background: rgba(200,80,80,0.15);
}

.letter-inner {
  padding-left: 20px;
}

.letter-salutation {
  font-family: var(--font-cursive);
  font-size: 2rem;
  font-weight: 600;
  color: var(--soft-gold);
  margin-bottom: 24px;
}

.letter-text {
  font-size: 1.12rem;
  line-height: 1.85;
  color: var(--text-soft);
  margin-bottom: 16px;
  text-align: justify;
}

.letter-text:last-of-type {
  margin-bottom: 28px;
}

.letter-verse {
  font-family: var(--font-cursive);
  font-size: 1.4rem;
  color: var(--soft-gold);
  text-align: right;
  margin-top: 8px;
}

/* ============================================
   SUNFLOWER SECTION
   ============================================ */

.sunflower-section {
  opacity: 0;
  transform: translateY(30px);
  animation: sectionIn 1.4s ease-out 0.8s forwards;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

@keyframes sectionIn {
  to { opacity: 1; transform: translateY(0); }
}

.sunflower-hint {
  font-family: var(--font-cursive);
  font-size: 1.2rem;
  color: var(--text-soft);
  opacity: 0.7;
  margin-bottom: 16px;
  text-align: center;
  transition: opacity 0.8s ease;
}

/* --- Container: responsive sizing --- */
.sunflower-container {
  width: clamp(220px, 55vw, 320px);
  touch-action: none; /* prevent scroll hijack on petals */
}

.sunflower-svg {
  width: 100%;
  height: auto;
  display: block;
  overflow: visible;
  transition: transform 0.2s ease;
}

/* --- Stem --- */
.stem {
  stroke-dasharray: 200;
  stroke-dashoffset: 200;
  animation: stemGrow 1.2s ease-out 1.2s forwards;
}

@keyframes stemGrow {
  to { stroke-dashoffset: 0; }
}

/* --- Leaves --- */
.leaf {
  animation: leafShow 0.8s ease-out 1.8s forwards;
}

@keyframes leafShow {
  to { opacity: 0.85; }
}

/* --- Center --- */
.sunflower-center {
  opacity: 0;
  animation: centerShow 0.6s ease-out 2s forwards;
}

.sunflower-center-inner {
  opacity: 0;
  animation: centerShow 0.6s ease-out 2.2s forwards;
}

@keyframes centerShow {
  to { opacity: 1; }
}

/* ============================================
   PETALS
   ============================================ */

/* Each petal is a <path> drawn in absolute SVG coordinates
   at its exact position around the flower center */

.petal {
  fill: #f0c040;
  cursor: pointer;
  transition: fill 0.2s ease, filter 0.2s ease, transform 0.8s ease, opacity 0.7s ease;
  /* invisible stroke edge for wider tap target on mobile */
  stroke: transparent;
  stroke-width: 8;
  stroke-linejoin: round;
}

.petal:hover {
  fill: #fed850;
  filter: brightness(1.12);
}

/* Sway for all petals */
.petals-group {
  animation: sway 4s ease-in-out infinite;
  transform-origin: 200px 200px;
}

@keyframes sway {
  0%, 100% { transform: rotate(0deg); }
  25%      { transform: rotate(0.6deg); }
  75%      { transform: rotate(-0.6deg); }
}

/* ============================================
   PHRASE DISPLAY
   ============================================ */

.phrase-container {
  min-height: 44px;
  margin-top: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.phrase {
  font-family: var(--font-cursive);
  font-size: clamp(1.2rem, 4vw, 1.5rem);
  color: var(--soft-gold);
  opacity: 0;
  transform: translateY(8px) scale(0.95);
  transition: opacity 0.45s ease, transform 0.45s ease;
  text-align: center;
  white-space: nowrap;
}

.phrase.visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

/* ============================================
   FINAL SECTION
   ============================================ */

.final-section {
  width: 100%;
  max-width: 520px;
  opacity: 0;
  transform: translateY(20px);
  display: flex;
  justify-content: center;
}

.final-section.animated {
  animation: finalIn 1.6s ease-out forwards;
}

@keyframes finalIn {
  to { opacity: 1; transform: translateY(0); }
}

.final-card {
  background: linear-gradient(135deg, #fffef8 0%, #faf2e1 100%);
  border-radius: 4px;
  box-shadow: var(--letter-shadow);
  padding: 40px 36px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.final-card::after {
  content: '';
  position: absolute;
  inset: 0;
  border: 1px solid rgba(212,168,67,0.2);
  border-radius: 4px;
  pointer-events: none;
}

.final-message {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  font-style: italic;
  font-weight: 300;
  line-height: 1.9;
  color: var(--text-soft);
}

.final-heart {
  font-size: 2rem;
  color: var(--soft-gold);
  margin-top: 20px;
  opacity: 0;
  animation: pulseHeart 2s ease-in-out 1s both;
}

@keyframes pulseHeart {
  0%   { opacity: 0; transform: scale(0.7); }
  50%  { opacity: 1; transform: scale(1.15); }
  100% { opacity: 0.8; transform: scale(1); }
}

/* Sunflower fade-out */
.sunflower-section.fading {
  transition: opacity 1.2s ease-out;
  opacity: 0;
}

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

@media (max-width: 600px) {
  .page {
    padding: 40px 16px 60px;
    gap: 50px;
  }

  .sunflower-container {
    width: clamp(200px, 70vw, 280px);
  }

  .letter {
    padding: 32px 24px;
  }

  .letter-salutation {
    font-size: 1.6rem;
  }

  .letter-text {
    font-size: 1rem;
    line-height: 1.75;
  }

  .letter::before {
    left: 18px;
  }

  .letter-inner {
    padding-left: 14px;
  }

  .final-card {
    padding: 28px 20px;
  }

  .final-message {
    font-size: 1.1rem;
  }
}

@media (max-width: 380px) {
  .sunflower-container {
    width: clamp(180px, 75vw, 240px);
  }

  .letter {
    padding: 24px 18px;
  }
}

/* ============================================
   REDUCED MOTION
   ============================================ */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
