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

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Lora', Georgia, serif;
  background: #1a0a0a;
  color: #f5e6d3;
  min-height: 100vh;
  overflow-x: hidden;
}

.hidden {
  display: none !important;
}

/* === Envelope Screen === */
#envelope-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: radial-gradient(ellipse at center, #2d0a0a 0%, #1a0505 60%, #0d0202 100%);
  position: relative;
  overflow: hidden;
}

/* Floating hearts background */
.floating-hearts {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.floating-heart {
  position: absolute;
  font-size: 1.2rem;
  opacity: 0;
  animation: floatHeart 6s ease-in-out infinite;
}

@keyframes floatHeart {
  0% {
    opacity: 0;
    transform: translateY(100vh) scale(0.5) rotate(0deg);
  }
  20% {
    opacity: 0.6;
  }
  80% {
    opacity: 0.3;
  }
  100% {
    opacity: 0;
    transform: translateY(-20vh) scale(1.2) rotate(20deg);
  }
}

/* Envelope wrapper */
.envelope-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  z-index: 2;
}

.envelope-label {
  font-family: 'Dancing Script', cursive;
  font-size: clamp(1.2rem, 4vw, 1.6rem);
  color: rgba(232, 165, 152, 0.85);
  margin-bottom: 2rem;
  text-align: center;
  letter-spacing: 1px;
  opacity: 0;
  animation: fadeInUp 1s ease forwards 0.5s;
}

/* Envelope */
.envelope {
  width: 300px;
  height: 210px;
  position: relative;
  transition: transform 0.3s ease;
  animation: fadeInUp 0.8s ease forwards 0.2s;
  opacity: 0;
}

.envelope:hover {
  transform: scale(1.05);
}

.envelope-back {
  position: absolute;
  width: 100%;
  height: 100%;
  background: linear-gradient(145deg, #d4796f, #b85550, #a33b35);
  border-radius: 10px;
  box-shadow:
    0 12px 40px rgba(0, 0, 0, 0.6),
    0 0 80px rgba(183, 73, 65, 0.15),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.envelope-front {
  position: absolute;
  bottom: 0;
  width: 100%;
  height: 60%;
  background: linear-gradient(180deg, #d4635c, #c04e48);
  border-radius: 0 0 10px 10px;
  clip-path: polygon(0 40%, 50% 0, 100% 40%, 100% 100%, 0 100%);
  z-index: 3;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.15);
}

.envelope-front::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 0%, rgba(0,0,0,0.08) 100%);
  border-radius: 0 0 10px 10px;
}

.envelope-flap {
  position: absolute;
  top: 0;
  width: 100%;
  height: 55%;
  background: linear-gradient(180deg, #e8877f, #d4635c);
  clip-path: polygon(0 0, 50% 100%, 100% 0);
  transform-origin: top center;
  transition: transform 0.6s ease;
  z-index: 4;
}

.envelope.opened .envelope-flap {
  transform: rotateX(180deg);
  z-index: 1;
}

/* Wax seal */
.wax-seal {
  position: absolute;
  bottom: -8px;
  left: 50%;
  transform: translateX(-50%);
  width: 42px;
  height: 42px;
  background: radial-gradient(circle at 35% 35%, #e25050, #8b1a1a);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  color: #ffd7d0;
  box-shadow:
    0 3px 10px rgba(0, 0, 0, 0.5),
    inset 0 1px 2px rgba(255, 255, 255, 0.25),
    inset 0 -2px 4px rgba(0, 0, 0, 0.3);
  z-index: 5;
  transition: opacity 0.3s ease;
}

.envelope.opened .wax-seal {
  opacity: 0;
}

.envelope-letter {
  position: absolute;
  width: 80%;
  height: 70%;
  background: linear-gradient(180deg, #fdf8f0, #f5e8d8);
  border-radius: 4px;
  top: 15%;
  left: 10%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  transition: transform 0.6s ease 0.3s, opacity 0.4s ease 0.6s;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.letter-preview {
  font-family: 'Dancing Script', cursive;
  font-size: 1.2rem;
  color: #8b5e5e;
}

.envelope.opened .envelope-letter {
  transform: translateY(-120px) scale(1.1);
  opacity: 0;
}

.tap-hint {
  margin-top: 2rem;
  font-family: 'Lora', Georgia, serif;
  font-size: 0.9rem;
  color: rgba(245, 200, 180, 0.45);
  animation: pulse 2.5s ease-in-out infinite;
  z-index: 2;
  letter-spacing: 1px;
  opacity: 0;
  animation: pulse 2.5s ease-in-out infinite, fadeInUp 1s ease forwards 0.8s;
}

@keyframes pulse {
  0%, 100% { opacity: 0.35; transform: scale(1); }
  50% { opacity: 0.7; transform: scale(1.03); }
}

/* === Letter Screen === */
#letter-screen {
  min-height: 100vh;
  background: #f5efe6;
  padding: 0;
}

.letter-paper-bg {
  min-height: 100vh;
  background:
    repeating-linear-gradient(
      transparent,
      transparent 31px,
      rgba(180, 160, 140, 0.08) 31px,
      rgba(180, 160, 140, 0.08) 32px
    ),
    linear-gradient(180deg, #f5efe6 0%, #ede4d8 50%, #f0e8dc 100%);
  position: relative;
}

.letter-paper-bg::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(200, 160, 120, 0.06) 0%, transparent 70%),
    radial-gradient(ellipse at 80% 30%, rgba(200, 160, 120, 0.04) 0%, transparent 70%);
  pointer-events: none;
}

.letter-container {
  max-width: 660px;
  margin: 0 auto;
  padding: 3rem 2.5rem 4rem;
  position: relative;
}

/* Decorative ornament */
.letter-ornament {
  text-align: center;
  font-size: 1.5rem;
  color: #c9a08a;
  margin-bottom: 2rem;
  opacity: 0;
  animation: fadeInUp 1s ease forwards 0.2s;
  letter-spacing: 1rem;
}

.letter-ornament.bottom {
  margin-top: 2rem;
  margin-bottom: 0;
  animation: none;
}

.letter-ornament.bottom.visible,
.letter-ornament.bottom {
  opacity: 0.5;
}

/* Letter header */
.letter-header {
  text-align: center;
  margin-bottom: 3rem;
  opacity: 0;
  animation: fadeInUp 1s ease forwards 0.3s;
}

.letter-date {
  font-size: 0.85rem;
  color: #a08878;
  margin-bottom: 1rem;
  letter-spacing: 3px;
  text-transform: uppercase;
  font-weight: 400;
}

.header-divider {
  width: 60px;
  height: 1px;
  background: linear-gradient(90deg, transparent, #c9a08a, transparent);
  margin: 1rem auto;
}

.letter-greeting {
  font-family: 'Dancing Script', cursive;
  font-size: clamp(2rem, 6vw, 2.8rem);
  font-weight: 700;
  color: #8b4f4f;
  line-height: 1.4;
}

/* Sections */
.letter-section {
  margin-bottom: 2.5rem;
}

.letter-text {
  font-size: 1.1rem;
  line-height: 2;
  color: #4a3830;
  text-align: left;
  font-style: italic;
  text-indent: 2em;
}
}

.letter-closing {
  margin-top: 2rem;
  font-size: 1.15rem;
}

.letter-signature {
  margin-top: 2rem;
  text-align: right;
  font-size: 1rem;
  color: #8b6b5e;
  line-height: 1.8;
}

.signature-name {
  font-family: 'Dancing Script', cursive;
  font-size: 1.8rem;
  color: #8b4f4f;
}

/* Photos */
.photo-section {
  margin: 2.5rem 0;
  display: flex;
  justify-content: center;
}

.photo-frame {
  background: #fff;
  padding: 10px 10px 35px;
  border-radius: 2px;
  box-shadow:
    0 4px 20px rgba(0, 0, 0, 0.12),
    0 1px 4px rgba(0, 0, 0, 0.08);
  transform: rotate(1deg);
  max-width: 85%;
  transition: transform 0.4s ease, box-shadow 0.4s ease;
}

.photo-frame:hover {
  transform: rotate(0deg) scale(1.02);
  box-shadow:
    0 8px 30px rgba(0, 0, 0, 0.18),
    0 2px 6px rgba(0, 0, 0, 0.1);
}

.photo-rotate-left {
  transform: rotate(-2deg);
}

.photo-rotate-left:hover {
  transform: rotate(0deg) scale(1.02);
}

.photo-rotate-right {
  transform: rotate(2.5deg);
}

.photo-rotate-right:hover {
  transform: rotate(0deg) scale(1.02);
}

.photo-featured {
  max-width: 90%;
  transform: rotate(0deg);
  padding: 12px 12px 40px;
}

.photo {
  width: 100%;
  display: block;
  border-radius: 1px;
  aspect-ratio: 4/3;
  object-fit: cover;
}

.photo-caption {
  font-family: 'Dancing Script', cursive;
  font-size: 0.95rem;
  color: #8b6b5e;
  text-align: center;
  margin-top: 10px;
}

/* Hearts footer */
.hearts-footer {
  text-align: center;
  font-size: 2rem;
  margin: 3rem 0;
  letter-spacing: 1rem;
}

.hearts-footer span {
  display: inline-block;
  animation: heartBeat 1.5s ease-in-out infinite;
}

.hearts-footer span:nth-child(2) {
  animation-delay: 0.3s;
}

.hearts-footer span:nth-child(3) {
  animation-delay: 0.6s;
}

@keyframes heartBeat {
  0%, 100% { transform: scale(1); }
  15% { transform: scale(1.25); }
  30% { transform: scale(1); }
}

/* Song section */
.song-section {
  text-align: center;
  margin-top: 2rem;
  padding: 2rem;
  border-top: 1px solid rgba(180, 150, 130, 0.25);
}

.song-label {
  font-size: 0.85rem;
  color: #a08878;
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-bottom: 0.5rem;
}

.song-title {
  font-family: 'Dancing Script', cursive;
  font-size: 1.5rem;
  color: #8b4f4f;
  margin-bottom: 0.8rem;
}

.song-link {
  color: #a08878;
  text-decoration: none;
  font-size: 0.9rem;
  transition: color 0.3s;
}

.song-link:hover {
  color: #8b4f4f;
}

/* === Fade-in on scroll === */
.fade-in-section {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.8s ease, transform 0.8s ease;
}

.fade-in-section.visible {
  opacity: 1;
  transform: translateY(0);
}

/* === Animations === */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* === Typewriter cursor === */
.typewriter-cursor {
  display: inline-block;
  width: 2px;
  height: 1.2em;
  background: #8b4f4f;
  margin-left: 2px;
  vertical-align: text-bottom;
  animation: blink 0.8s step-end infinite;
}

@keyframes blink {
  50% { opacity: 0; }
}

/* === Responsive === */
@media (max-width: 480px) {
  .letter-container {
    padding: 2rem 1.2rem 3rem;
  }

  .envelope {
    width: 250px;
    height: 175px;
  }

  .envelope-label {
    font-size: 1.1rem;
  }

  .wax-seal {
    width: 36px;
    height: 36px;
    font-size: 0.85rem;
  }

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

  .photo-frame {
    max-width: 95%;
  }

  .letter-greeting {
    font-size: clamp(1.6rem, 6vw, 2.2rem);
  }
}
