/* ==========================================================================
   Ultra-Luxury 3D Envelope & Wax Seal Opening Experience (Flawless 60fps)
   ========================================================================== */

:root {
  --burgundy-deep: #120104;
  --burgundy-dark: #220308;
  --burgundy-main: #4a0d18;
  --burgundy-rich: #6b1d2f;
  --gold-primary: #d4af37;
  --gold-foil: #c59b7b;
  --gold-light: #f4e8cf;
  --pearl-ivory: #faf6f0;
  --cream-card: #fdfbf7;
}

/* Fullscreen Envelope Screen (Clean Spotlight Backdrop) */
.envelope-screen {
  position: relative;
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: calc(env(safe-area-inset-top, 20px) + 16px) 16px calc(env(safe-area-inset-bottom, 20px) + 20px);
  background: radial-gradient(circle at 50% 38%, #3a0812 0%, #170205 70%, #0a0002 100%);
  overflow: hidden;
  perspective: 1200px;
  z-index: 50;
  transition: opacity 1s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Ambient Floating Petals & Gold Sparkles */
.petals-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2;
}

/* Header Text Above Envelope */
.envelope-intro-header {
  position: relative;
  z-index: 10;
  text-align: center;
  animation: fadeInDown 1s ease-out;
  padding-top: 6px;
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.envelope-screen.is-opening .envelope-intro-header {
  opacity: 0;
  transform: translateY(-20px);
  pointer-events: none;
}

.envelope-tagline {
  font-family: 'Montserrat', sans-serif;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--gold-light);
  margin-bottom: 6px;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.85);
}

.envelope-names {
  font-family: 'Great Vibes', cursive;
  font-size: 3.2rem;
  color: var(--pearl-ivory);
  text-shadow: 
    0 2px 14px rgba(0, 0, 0, 0.9),
    0 0 25px rgba(212, 175, 55, 0.45);
  line-height: 1.1;
  white-space: nowrap;
}

/* Central Realistic Envelope Container (Single Envelope) */
.envelope-wrapper {
  position: relative;
  width: 330px;
  max-width: 92vw;
  height: 460px;
  max-height: 62vh;
  z-index: 10;
  perspective: 1500px;
  margin: auto 0;
  transition: transform 0.9s cubic-bezier(0.4, 0, 0.2, 1);
}

.envelope-base {
  position: relative;
  width: 100%;
  height: 100%;
  background: #380710 url('../assets/images/burgundy_envelope.jpg') center/cover no-repeat;
  border-radius: 14px;
  box-shadow: 
    0 30px 70px -15px rgba(0, 0, 0, 0.95),
    0 0 0 1px rgba(212, 175, 55, 0.35);
  overflow: visible;
  perspective: 1500px;
}

/* Interior Golden Silk Lining */
.envelope-interior {
  position: absolute;
  inset: 0;
  background: 
    radial-gradient(ellipse at 50% 30%, rgba(244, 232, 207, 0.3) 0%, rgba(56, 7, 16, 0.85) 100%),
    #2b050c;
  border-radius: 14px;
  z-index: 1;
}

/* Inner Formal Invitation Card (Slides Up on Tap) */
.envelope-letter {
  position: absolute;
  top: 14px;
  left: 14px;
  right: 14px;
  height: 92%;
  background: var(--cream-card);
  border-radius: 8px;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.35);
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 18px;
  text-align: center;
  border: 1px solid rgba(197, 155, 123, 0.45);
  transition: transform 1.2s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 1.2s ease;
  transform: translateY(0);
}

.envelope-letter::before {
  content: '';
  position: absolute;
  inset: 7px;
  border: 1px solid rgba(212, 175, 55, 0.45);
  border-radius: 5px;
  pointer-events: none;
}

.mini-card-monogram {
  font-family: 'Great Vibes', cursive;
  font-size: 2.2rem;
  color: var(--burgundy-rich);
  margin-bottom: 4px;
  line-height: 1;
  white-space: nowrap;
}

.mini-card-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--burgundy-main);
  margin-bottom: 6px;
}

.mini-card-names {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.55rem;
  font-weight: 600;
  color: #240b10;
  line-height: 1.25;
  margin-bottom: 8px;
  white-space: nowrap;
}

.mini-card-divider {
  width: 50px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold-primary), transparent);
  margin: 0 auto 8px;
}

.mini-card-date {
  font-family: 'Montserrat', sans-serif;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.15em;
  color: #554447;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.mini-card-venue {
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-size: 1rem;
  color: #775c60;
}

/* ==========================================================================
   Envelope Physical Front Pocket (100% Covers Card, ZERO White Gaps)
   ========================================================================== */
.envelope-pocket {
  position: absolute;
  inset: 0;
  background: #3e0a14 url('../assets/images/burgundy_envelope.jpg') center bottom / cover no-repeat;
  /* Mathematically full coverage: covers [0,0]->[0,100%]->[100%,100%]->[100%,0]->[50%,55%] */
  clip-path: polygon(0 0, 0 100%, 100% 100%, 100% 0, 50% 55%);
  border-radius: 14px;
  filter: drop-shadow(0 -5px 12px rgba(0, 0, 0, 0.6));
  z-index: 4;
  pointer-events: none;
}

/* Gold Edge Trim on Pocket V */
.envelope-pocket::before {
  content: '';
  position: absolute;
  inset: 0;
  clip-path: polygon(0 0, 50% 55%, 100% 0, 100% 1.5%, 50% 56.5%, 0 1.5%);
  background: linear-gradient(90deg, rgba(212, 175, 55, 0.4) 0%, rgba(244, 232, 207, 0.95) 50%, rgba(212, 175, 55, 0.4) 100%);
  pointer-events: none;
}

/* ==========================================================================
   Top Folding Flap (3D Perspective Flip)
   ========================================================================== */
.flap-top {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 56%;
  background: #4a0d18 url('../assets/images/burgundy_envelope.jpg') center top / cover no-repeat;
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.75));
  border-top-left-radius: 14px;
  border-top-right-radius: 14px;
  transform-origin: top center;
  transition: transform 1s cubic-bezier(0.4, 0, 0.2, 1);
  transform-style: preserve-3d;
  z-index: 5;
  pointer-events: none;
}

/* Gold Edge Trim on Top Flap */
.flap-top::after {
  content: '';
  position: absolute;
  inset: 0;
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  background: linear-gradient(180deg, rgba(212, 175, 55, 0.2) 0%, transparent 75%);
  border-bottom: 2px solid rgba(212, 175, 55, 0.85);
  pointer-events: none;
}

/* Ultra-Crisp Ivory Wax Seal (Transparent PNG, No Halos) */
.wax-seal {
  position: absolute;
  top: 55.5%;
  left: 50%;
  width: 110px;
  height: 110px;
  margin-top: -55px;
  margin-left: -55px;
  z-index: 10;
  cursor: pointer;
  background-image: url('../assets/images/wax_seal.png');
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  filter: drop-shadow(0 12px 24px rgba(0, 0, 0, 0.9));
  border-radius: 50%;
  border: none;
  background-color: transparent;
  transition: transform 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275), filter 0.35s ease, opacity 0.4s ease;
  animation: sealBreathing 2.8s infinite ease-in-out;
  -webkit-tap-highlight-color: transparent;
  outline: none;
}

.wax-seal:hover, .wax-seal:focus-visible {
  transform: scale(1.06);
  filter: drop-shadow(0 16px 30px rgba(0, 0, 0, 0.95)) drop-shadow(0 0 25px rgba(212, 175, 55, 0.7));
}

.wax-seal:active {
  transform: scale(0.96);
}

/* Wax Breaking Animation (Clean Fade & Pop) */
.wax-seal.breaking {
  transform: scale(1.15);
  opacity: 0;
  pointer-events: none;
}

/* Prompt Below Envelope */
.envelope-prompt {
  position: relative;
  z-index: 10;
  margin-bottom: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: opacity 0.5s ease;
}

.prompt-text {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--gold-light);
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.9);
  animation: shimmerText 3s infinite ease-in-out;
}

.prompt-icon {
  width: 24px;
  height: 24px;
  color: var(--gold-primary);
  animation: bounceIndicator 1.8s infinite ease-in-out;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.7));
}

/* ==========================================================================
   Envelope Opening Sequence States (Smooth & Glitch-Free)
   ========================================================================== */

/* Step 1: Flap Opens (3D Rotate Upwards) */
.envelope-wrapper.flap-opened .flap-top {
  transform: rotateX(180deg);
  z-index: 1;
}

/* Step 2: Letter Slides Out to Elegant Preview Position */
.envelope-wrapper.card-pulled .envelope-letter {
  transform: translateY(-135px);
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.6);
  z-index: 6;
}

/* Step 3: Complete Reveal & Settle */
.envelope-wrapper.reveal-complete {
  transform: translateY(20px);
}

.envelope-wrapper.reveal-complete ~ .envelope-prompt {
  opacity: 1;
  pointer-events: auto;
  margin-top: 14px;
}

/* Flying Wax Glitter Particles */
.wax-particle {
  position: fixed;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  pointer-events: none;
  z-index: 999;
  box-shadow: 0 0 10px rgba(212, 175, 55, 0.85);
  animation: particleFly 0.85s cubic-bezier(0.1, 0.8, 0.2, 1) forwards;
}

@keyframes particleFly {
  0% {
    opacity: 1;
    transform: translate(0, 0) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(var(--tx), var(--ty)) scale(0.2);
  }
}

/* Keyframes */
@keyframes sealBreathing {
  0%, 100% {
    transform: scale(1);
    filter: drop-shadow(0 12px 24px rgba(0, 0, 0, 0.9)) drop-shadow(0 0 10px rgba(212, 175, 55, 0.25));
  }
  50% {
    transform: scale(1.04);
    filter: drop-shadow(0 16px 30px rgba(0, 0, 0, 0.95)) drop-shadow(0 0 25px rgba(212, 175, 55, 0.7));
  }
}

@keyframes shimmerText {
  0%, 100% {
    opacity: 0.85;
  }
  50% {
    opacity: 1;
    text-shadow: 0 0 15px rgba(244, 232, 207, 0.85), 0 2px 8px rgba(0, 0, 0, 0.9);
  }
}

@keyframes bounceIndicator {
  0%, 20%, 50%, 80%, 100% {
    transform: translateY(0);
  }
  40% {
    transform: translateY(7px);
  }
  60% {
    transform: translateY(3px);
  }
}

@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
