@import url("https://fonts.googleapis.com/css2?family=Great+Vibes&display=swap");

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  background: linear-gradient(135deg, #1a0011 0%, #2d0a1e 30%, #4a1042 60%, #1a0011 100%);
  background-size: 400% 400%;
  animation: gradientShift 20s ease infinite;
  font-family: 'Cormorant Garamond', serif;
  overflow-x: hidden;
  position: relative;
}

@keyframes gradientShift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* ===== CONFETTI CANVAS ===== */
#confetti {
  position: fixed;
  inset: 0;
  z-index: 100;
  pointer-events: none;
}

/* ===== FLOATING PETALS ===== */
.petals-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.bg-petal {
  position: absolute;
  top: -20px;
  background: radial-gradient(ellipse, #d52d58, #b81b43);
  border-radius: 50% 0 50% 50%;
  opacity: 0;
  animation: petalFall linear infinite;
  filter: blur(0.5px);
}

@keyframes petalFall {
  0% {
    transform: translateY(0) rotate(0deg) translateX(0);
    opacity: 0;
  }
  10% { opacity: 0.25; }
  50% {
    transform: translateY(50vh) rotate(180deg) translateX(50px);
    opacity: 0.2;
  }
  90% { opacity: 0.1; }
  100% {
    transform: translateY(110vh) rotate(360deg) translateX(-30px);
    opacity: 0;
  }
}

/* ===== PAGE WRAPPER ===== */
.page-wrapper {
  position: relative;
  z-index: 1;
  max-width: 750px;
  margin: 0 auto;
  padding: 50px 20px 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
}

/* ===== PAGE TITLE ===== */
.page-title {
  text-align: center;
  margin-bottom: 40px;
  animation: fadeInDown 1.2s ease-out;
}

.title-for {
  display: block;
  font-family: 'Quicksand', sans-serif;
  font-size: 1.3rem;
  font-weight: 300;
  color: rgba(255, 182, 203, 0.7);
  letter-spacing: 10px;
  text-transform: uppercase;
}

.title-name {
  display: block;
  font-family: 'Great Vibes', cursive;
  font-size: 5rem;
  background: linear-gradient(135deg, #ff6b9d, #ffa3c4, #ff4d6d, #ff8fab);
  background-size: 300% 300%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: nameShimmer 4s ease-in-out infinite;
  filter: drop-shadow(0 0 40px rgba(255, 107, 157, 0.6));
}

@keyframes nameShimmer {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

@keyframes fadeInDown {
  0% { opacity: 0; transform: translateY(-40px); }
  100% { opacity: 1; transform: translateY(0); }
}

/* ===== LETTER ===== */
.letter-wrapper {
  position: relative;
  width: 100%;
  max-width: 680px;
  animation: letterAppear 1.5s ease-out 0.5s both;
}

@keyframes letterAppear {
  0% {
    opacity: 0;
    transform: scale(0.9) rotate(-3deg);
  }
  100% {
    opacity: 1;
    transform: scale(1) rotate(0deg);
  }
}

.letter-shadow {
  position: absolute;
  inset: 10px -5px -10px -5px;
  background: rgba(255, 77, 109, 0.08);
  border-radius: 12px;
  filter: blur(20px);
  transform: rotate(1.5deg);
  z-index: -1;
}

.letter {
  position: relative;
  background: linear-gradient(170deg, rgba(255, 255, 255, 0.12) 0%, rgba(255, 255, 255, 0.06) 100%);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 50px 45px;
  box-shadow:
    0 8px 40px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  transition: transform 0.5s ease, box-shadow 0.5s ease;
}

.letter:hover {
  transform: translateY(-4px);
  box-shadow:
    0 12px 50px rgba(0, 0, 0, 0.4),
    0 0 60px rgba(255, 77, 109, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

/* Corner decorations */
.letter-decoration {
  position: absolute;
  width: 40px;
  height: 40px;
  opacity: 0.2;
}

.letter-decoration::before,
.letter-decoration::after {
  content: '';
  position: absolute;
  background: linear-gradient(135deg, #ff6b9d, transparent);
}

.top-left { top: 12px; left: 12px; }
.top-left::before { width: 25px; height: 1px; top: 0; left: 0; }
.top-left::after { width: 1px; height: 25px; top: 0; left: 0; }

.top-right { top: 12px; right: 12px; }
.top-right::before { width: 25px; height: 1px; top: 0; right: 0; }
.top-right::after { width: 1px; height: 25px; top: 0; right: 0; }

.bottom-left { bottom: 12px; left: 12px; }
.bottom-left::before { width: 25px; height: 1px; bottom: 0; left: 0; }
.bottom-left::after { width: 1px; height: 25px; bottom: 0; left: 0; }

.bottom-right { bottom: 12px; right: 12px; }
.bottom-right::before { width: 25px; height: 1px; bottom: 0; right: 0; }
.bottom-right::after { width: 1px; height: 25px; bottom: 0; right: 0; }

/* ===== LETTER CONTENT ===== */
.letter-content {
  position: relative;
}

.salutation {
  font-family: 'Great Vibes', cursive;
  font-size: 2.2rem;
  color: #ff8fab;
  margin-bottom: 25px;
  text-shadow: 0 0 30px rgba(255, 107, 157, 0.3);
  opacity: 0;
  transform: translateY(15px);
  transition: opacity 0.8s ease, transform 0.8s ease;
}

.salutation.revealed {
  opacity: 1;
  transform: translateY(0);
}

.letter-body {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.2rem;
  line-height: 1.9;
  color: rgba(255, 220, 230, 0.85);
  margin-bottom: 18px;
  text-align: justify;
  opacity: 0;
  transform: translateY(15px);
  transition: opacity 0.8s ease, transform 0.8s ease;
}

.letter-body.revealed {
  opacity: 1;
  transform: translateY(0);
}

.letter-body:nth-child(2) { transition-delay: 0.2s; }
.letter-body:nth-child(3) { transition-delay: 0.4s; }
.letter-body:nth-child(4) { transition-delay: 0.6s; }
.letter-body:nth-child(5) { transition-delay: 0.8s; }

/* ===== SIGNATURE ===== */
.signature {
  margin-top: 35px;
  text-align: right;
  padding-right: 20px;
  opacity: 0;
  transform: translateY(15px);
  transition: opacity 0.8s ease 1s, transform 0.8s ease 1s;
}

.signature.revealed {
  opacity: 1;
  transform: translateY(0);
}

.closing {
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-size: 1.2rem;
  color: rgba(255, 182, 203, 0.8);
}

.signed-name {
  font-family: 'Great Vibes', cursive;
  font-size: 2.5rem;
  background: linear-gradient(135deg, #ff6b9d, #ffa3c4);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 0 15px rgba(255, 107, 157, 0.4));
  margin-top: 5px;
}

/* ===== WAX SEAL ===== */
.wax-seal {
  position: absolute;
  bottom: -20px;
  right: 40px;
  width: 60px;
  height: 60px;
  background: radial-gradient(circle at 35% 35%, #e63956, #b81b43, #8b1233);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow:
    0 4px 15px rgba(0, 0, 0, 0.4),
    inset 0 2px 4px rgba(255, 255, 255, 0.2),
    inset 0 -2px 4px rgba(0, 0, 0, 0.3);
  animation: sealAppear 0.6s ease-out 2s both;
}

.seal-heart {
  color: rgba(255, 255, 255, 0.85);
  font-size: 1.5rem;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

@keyframes sealAppear {
  0% {
    opacity: 0;
    transform: scale(0) rotate(-180deg);
  }
  70% {
    transform: scale(1.1) rotate(10deg);
  }
  100% {
    opacity: 1;
    transform: scale(1) rotate(0deg);
  }
}

/* ===== BACK LINK ===== */
.back-link {
  display: inline-block;
  margin-top: 40px;
  font-family: 'Quicksand', sans-serif;
  font-size: 0.95rem;
  color: rgba(255, 182, 203, 0.5);
  text-decoration: none;
  letter-spacing: 1px;
  transition: color 0.3s ease, transform 0.3s ease;
  animation: fadeInUp 1s ease-out 2.5s both;
}

.back-link:hover {
  color: rgba(255, 182, 203, 0.9);
  transform: translateX(-5px);
}

.back-link span {
  display: inline-block;
  transition: transform 0.3s ease;
}

.back-link:hover span {
  transform: translateX(-3px);
}

@keyframes fadeInUp {
  0% { opacity: 0; transform: translateY(20px); }
  100% { opacity: 1; transform: translateY(0); }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .page-wrapper {
    padding: 30px 15px 30px;
  }

  .title-name {
    font-size: 3.5rem;
  }

  .letter {
    padding: 35px 25px;
  }

  .salutation {
    font-size: 1.8rem;
  }

  .letter-body {
    font-size: 1.05rem;
    line-height: 1.8;
  }

  .signed-name {
    font-size: 2rem;
  }

  .wax-seal {
    width: 50px;
    height: 50px;
    bottom: -15px;
    right: 25px;
  }

  .seal-heart {
    font-size: 1.2rem;
  }
}

@media (max-width: 480px) {
  .title-name {
    font-size: 2.8rem;
  }

  .title-for {
    font-size: 1rem;
    letter-spacing: 6px;
  }

  .letter {
    padding: 25px 20px;
    border-radius: 8px;
  }

  .letter-body {
    font-size: 1rem;
    text-align: left;
  }
}
