/* =============================================
   ENVELOPE — Landing Page & Wax Seal
   ============================================= */

/* ===== PAGE CONTAINER ===== */
#envelope-page {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  background: linear-gradient(
    160deg,
    var(--lavender-light) 0%,
    var(--blush-light) 30%,
    var(--ivory) 60%,
    var(--sage-light) 100%
  );
  z-index: 1000;
  transition: opacity 0.8s ease, transform 0.8s ease;
}

#envelope-page.hidden {
  opacity: 0;
  transform: scale(1.05);
  pointer-events: none;
}

/* ===== FLOATING PETALS ===== */
.petal {
  position: absolute;
  width: 12px;
  height: 12px;
  background: var(--blush);
  border-radius: 50% 0 50% 50%;
  opacity: 0.3;
  animation: floatPetal linear infinite;
  pointer-events: none;
}

.petal:nth-child(1)  { left: 8%;  animation-duration: 9s;  animation-delay: 0s;   width: 10px; height: 10px; }
.petal:nth-child(2)  { left: 18%; animation-duration: 13s; animation-delay: 1.5s; width: 8px;  height: 8px;  background: var(--lavender); }
.petal:nth-child(3)  { left: 32%; animation-duration: 10s; animation-delay: 3s;   width: 14px; height: 14px; }
.petal:nth-child(4)  { left: 48%; animation-duration: 11s; animation-delay: 0.5s; width: 9px;  height: 9px;  background: var(--sage); }
.petal:nth-child(5)  { left: 62%; animation-duration: 8s;  animation-delay: 2s;   width: 11px; height: 11px; background: var(--lavender); }
.petal:nth-child(6)  { left: 75%; animation-duration: 12s; animation-delay: 4s;   width: 8px;  height: 8px; }
.petal:nth-child(7)  { left: 85%; animation-duration: 10s; animation-delay: 1s;   width: 12px; height: 12px; background: var(--sage); }
.petal:nth-child(8)  { left: 92%; animation-duration: 7s;  animation-delay: 3.5s; width: 7px;  height: 7px;  background: var(--lavender); }

/* ===== ENVELOPE WRAPPER ===== */
.envelope-wrapper {
  perspective: 1000px;
  cursor: pointer;
  animation: envelopeEntrance 1s var(--ease-out-expo) forwards;
  opacity: 0;
}

.envelope-tap-hint {
  font-family: 'Montserrat', sans-serif;
  font-size: 0.7rem;
  font-weight: 400;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--brown-light);
  margin-top: 32px;
  opacity: 0;
  animation: fadeInUp 1s ease 1.5s forwards;
}

/* ===== ENVELOPE STRUCTURE ===== */
.envelope {
  position: relative;
  width: 300px;
  height: 220px;
}

/* — Layer 1: Colorful inner lining (bottom of sandwich) — */
.envelope-lining {
  position: absolute;
  inset: 0;
  border-radius: 6px;
  background: linear-gradient(
    180deg,
    var(--blush-light) 0%,
    #f8d7d4 30%,
    var(--lavender-light) 60%,
    var(--sage-light) 100%
  );
  z-index: 1;
  box-shadow:
    0 12px 40px rgba(92, 64, 51, 0.18),
    0 4px 12px rgba(92, 64, 51, 0.1);
}

/* — Layer 2: White paper (middle of sandwich) — */
.envelope-paper {
  position: absolute;
  top: 30px;
  left: 8px;
  right: 8px;
  bottom: 8px;
  background: #fff;
  border-radius: 3px;
  z-index: 2;
  pointer-events: none;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.04);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: transform 0.9s cubic-bezier(0.16, 1, 0.3, 1);
}

.envelope.opened .envelope-paper {
  transform: translateY(-110px);
  transition-delay: 1.2s;
}

/* — Layer 3: Envelope body with triangle cutout (top of sandwich) — */
.envelope-body {
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(
      45deg,
      transparent,
      transparent 3px,
      rgba(255,255,255,0.02) 3px,
      rgba(255,255,255,0.02) 6px
    ),
    linear-gradient(
      155deg,
      var(--paper-light) 0%,
      var(--paper) 40%,
      var(--paper-dark) 100%
    );
  border-radius: 6px;
  box-shadow:
    0 12px 40px rgba(92, 64, 51, 0.18),
    0 4px 12px rgba(92, 64, 51, 0.1),
    inset 0 1px 0 rgba(255,255,255,0.4);
  z-index: 3;
  overflow: hidden;
  /* Triangle cutout at the top — reveals lining + paper beneath */
  clip-path: polygon(
    0 0,
    0 100%,
    100% 100%,
    100% 0,
    50% 45%
  );
}

/* — Names & date on the body (visible below the flap) — */
.envelope-text {
  position: absolute;
  bottom: 0px;
  left: 0;
  width: 100%;
  height: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 2;
  gap: 4px;
  padding: 12px 0;
}

.envelope-names {
  font-family: 'Great Vibes', cursive;
  font-size: 1.8rem;
  color: var(--brown);
  text-shadow: 0 1px 2px rgba(92, 64, 51, 0.08);
  line-height: 1.2;
}

.envelope-date {
  font-family: 'Montserrat', sans-serif;
  font-size: 0.6rem;
  font-weight: 400;
  letter-spacing: 4px;
  text-transform: uppercase;
  color: var(--brown-light);
  margin-top: 2px;
}

.envelope-ornament {
  width: 40px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  margin-top: 4px;
}

/* ===== ENVELOPE FLAP ===== */
.envelope-flap-wrapper {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100px;
  transform-origin: top center;
  z-index: 5;
  transition: transform 1.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.envelope.opened .envelope-flap-wrapper {
  transform: rotateX(-180deg);
  z-index: 1;
  transition: transform 1.4s cubic-bezier(0.4, 0, 0.2, 1), z-index 0s 1.2s;
}

/* Static flap shadow on the envelope body */
.envelope-flap-shadow {
  position: absolute;
  top: 0;
  left: 4%;
  right: 4%;
  height: 55%;
  clip-path: polygon(0 0, 50% 85%, 100% 0);
  background: linear-gradient(
    180deg,
    rgba(92, 64, 51, 0.08) 0%,
    rgba(92, 64, 51, 0.03) 50%,
    transparent 100%
  );
  z-index: 2;
  pointer-events: none;
  transition: opacity 0.6s ease;
}

.envelope-flap-shadow.hidden {
  opacity: 0;
}

/* Front face of the flap (facing the user when closed) */
.envelope-flap-front {
  position: absolute;
  inset: 0;
  clip-path: polygon(0 0, 50% 100%, 100% 0);
  background:
    repeating-linear-gradient(
      45deg,
      transparent,
      transparent 3px,
      rgba(255,255,255,0.02) 3px,
      rgba(255,255,255,0.02) 6px
    ),
    linear-gradient(
      175deg,
      var(--paper-light) 0%,
      var(--paper) 50%,
      var(--paper-dark) 100%
    );
}

/* Subtle depth on the flap face */
.envelope-flap-front::after {
  content: '';
  position: absolute;
  inset: 0;
  clip-path: polygon(0 0, 50% 100%, 100% 0);
  background: linear-gradient(
    180deg,
    rgba(0,0,0,0.0) 0%,
    rgba(0,0,0,0.05) 100%
  );
  pointer-events: none;
}

/* Back face of the flap (inner lining, visible when opened) */
.envelope-flap-back {
  position: absolute;
  inset: 0;
  clip-path: polygon(0 0, 50% 100%, 100% 0);
  background: linear-gradient(
    180deg,
    var(--blush-light) 0%,
    #f8d7d4 30%,
    var(--lavender-light) 60%,
    var(--sage-light) 100%
  );
  z-index: -1;
}

/* ===== WAX SEAL ===== */
.wax-seal {
  position: absolute;
  bottom: -31px;
  left: 50%;
  transform: translateX(-50%);
  width: 62px;
  height: 62px;
  z-index: 12;
  filter: drop-shadow(0 3px 6px rgba(139, 37, 0, 0.35));
  transition: opacity 0.6s ease;
}

.envelope.opened .wax-seal {
  opacity: 0;
}

/* Irregular drip shape behind the seal */
.wax-seal::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 74px;
  height: 74px;
  border-radius: 42% 58% 55% 45% / 48% 44% 56% 52%;
  background: radial-gradient(
    ellipse at 35% 35%,
    var(--seal-red-light) 0%,
    var(--seal-red) 55%,
    var(--seal-red-dark) 100%
  );
  z-index: -1;
}

/* Main seal circle */
.wax-seal-body {
  width: 100%;
  height: 100%;
  background: radial-gradient(
    ellipse at 38% 35%,
    #c44a27 0%,
    var(--seal-red-light) 25%,
    var(--seal-red) 55%,
    var(--seal-red-dark) 100%
  );
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow:
    inset 0 3px 6px rgba(255, 160, 120, 0.2),
    inset 0 -3px 8px rgba(0, 0, 0, 0.25),
    inset 2px 0 4px rgba(0, 0, 0, 0.1),
    inset -2px 0 4px rgba(0, 0, 0, 0.05);
  position: relative;
  overflow: hidden;
}

/* Glossy highlight on the seal */
.wax-seal-body::after {
  content: '';
  position: absolute;
  top: 6px;
  left: 10px;
  width: 20px;
  height: 12px;
  background: radial-gradient(
    ellipse at center,
    rgba(255, 200, 180, 0.35) 0%,
    transparent 70%
  );
  border-radius: 50%;
  transform: rotate(-20deg);
}

/* Heart SVG inside the seal */
.wax-seal-heart {
  width: 24px;
  height: 24px;
  position: relative;
  z-index: 2;
}

.wax-seal-heart svg {
  width: 100%;
  height: 100%;
  fill: rgba(255, 180, 160, 0.3);
  stroke: rgba(255, 200, 180, 0.4);
  stroke-width: 1;
  filter: drop-shadow(0 1px 1px rgba(0,0,0,0.2));
}

/* Seal pulse animation (hint to tap) */
.wax-seal-pulse {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 62px;
  height: 62px;
  border-radius: 50%;
  border: 2px solid var(--seal-red-light);
  opacity: 0;
  animation: sealPulse 2.5s ease-in-out infinite;
  pointer-events: none;
}

/* ===== INVITATION CARD (peeks out after opening) ===== */
.envelope-card {
  display: none;
}

/* Animation classes applied by JS */
.envelope-card.anim-peek {
  animation: cardPeek 0.9s var(--ease-out-expo) forwards;
}

.envelope-card-label {
  font-family: 'Montserrat', sans-serif;
  font-size: 0.85rem;
  font-weight: 500;
  letter-spacing: 4px;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 4px;
}

.envelope-card-names {
  font-family: 'Great Vibes', cursive;
  font-size: 1.3rem;
  color: var(--brown);
}

.envelope-card-line {
  width: 30px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  margin: 6px 0;
}

.envelope-card-date {
  font-family: 'Cormorant Garamond', serif;
  font-size: 0.7rem;
  font-weight: 400;
  letter-spacing: 3px;
  color: var(--brown-light);
}

/* ===== KEYFRAMES ===== */
@keyframes floatPetal {
  0%   { transform: translateY(-20px) rotate(0deg); opacity: 0; }
  10%  { opacity: 0.3; }
  90%  { opacity: 0.3; }
  100% { transform: translateY(100vh) rotate(360deg); opacity: 0; }
}

@keyframes envelopeEntrance {
  from { opacity: 0; transform: translateY(30px) scale(0.92); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 0.7; transform: translateY(0); }
}

@keyframes sealPulse {
  0%   { transform: translate(-50%, -50%) scale(1);   opacity: 0.5; }
  100% { transform: translate(-50%, -50%) scale(1.6); opacity: 0; }
}

@keyframes cardPeek {
  0%   { transform: translateX(-50%) translateY(0); opacity: 0; }
  30%  { opacity: 1; }
  100% { transform: translateX(-50%) translateY(-80px); opacity: 1; }
}
