/* ==========================================================================
   LUXURY ENVELOPE OPENING EXPERIENCE
   ========================================================================== */

.envelope-screen {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 50% 40%, #2f2018 0%, #1a110c 60%, #0d0806 100%);
  overflow: hidden;
  transition: opacity 1.2s cubic-bezier(0.4, 0, 0.2, 1), visibility 1.2s;
}

.envelope-screen.opened {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* Background Ambient Canvas for particles */
#envelopeCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* Atmospheric Golden Vignette & Glow */
.envelope-glow {
  position: absolute;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(212, 175, 55, 0.15) 0%, rgba(212, 175, 55, 0) 70%);
  border-radius: 50%;
  pointer-events: none;
  animation: pulseGlow 6s ease-in-out infinite alternate;
}

@keyframes pulseGlow {
  0% { transform: scale(0.9); opacity: 0.6; }
  100% { transform: scale(1.15); opacity: 1; }
}

/* Header Text Above Envelope */
.envelope-intro {
  text-align: center;
  margin-bottom: 24px;
  z-index: 10;
  color: #f7eed7;
  padding: 0 20px;
  animation: fadeInDown 1.4s ease-out;
}

.envelope-bismillah {
  font-family: 'Amiri', serif;
  font-size: clamp(1.2rem, 3vw, 1.7rem);
  color: #dfba6c;
  margin-bottom: 6px;
  text-shadow: 0 2px 8px rgba(0,0,0,0.6);
  direction: rtl;
}

.envelope-subtitle {
  font-family: 'Cormorant Garamond', serif;
  font-size: clamp(0.95rem, 2.2vw, 1.25rem);
  letter-spacing: 4px;
  text-transform: uppercase;
  color: #cbb493;
  font-weight: 500;
  margin-bottom: 4px;
}

.envelope-title {
  font-family: 'Playfair Display', serif;
  font-size: clamp(1.4rem, 3.8vw, 2.2rem);
  color: #fff9e6;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
}

.envelope-guest-pill {
  display: inline-block;
  margin-top: 8px;
  padding: 4px 16px;
  background: rgba(212, 175, 55, 0.12);
  border: 1px solid rgba(212, 175, 55, 0.35);
  border-radius: 20px;
  font-family: 'Poppins', sans-serif;
  font-size: 0.8rem;
  letter-spacing: 1px;
  color: #ffd885;
}

/* Envelope Container & 3D Stage */
.envelope-stage {
  position: relative;
  width: min(92vw, 480px);
  height: 310px;
  perspective: 1200px;
  z-index: 10;
  margin-bottom: 30px;
}

.envelope-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7),
              0 0 35px rgba(212, 175, 55, 0.15);
  border-radius: 8px;
  cursor: pointer;
  transform-style: preserve-3d;
  transition: transform 0.4s ease;
}

.envelope-wrapper:hover {
  transform: translateY(-4px) scale(1.01);
}

/* Envelope Back and Base Pocket */
.envelope-back {
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, #442e20 0%, #301f15 100%);
  border-radius: 8px;
  border: 1px solid rgba(212, 175, 55, 0.3);
}

/* Inside Lining (Patterned Silk / Damask gold) */
.envelope-lining {
  position: absolute;
  inset: 8px;
  background: radial-gradient(circle at 50% 50%, #3a271c 0%, #291b12 100%);
  border: 1px dashed rgba(212, 175, 55, 0.25);
  border-radius: 6px;
}

/* The Sliding Invitation Card inside the pocket */
.envelope-card {
  position: absolute;
  left: 5%;
  right: 5%;
  top: 10px;
  height: 285px;
  background: #fdfaf3;
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  border: 1px solid #d4af37;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  text-align: center;
  transition: transform 1.2s cubic-bezier(0.34, 1.56, 0.64, 1), z-index 0.2s 0.6s;
  z-index: 2;
  overflow: hidden;
  background-image: 
    radial-gradient(#d4af37 0.5px, transparent 0.5px),
    radial-gradient(#d4af37 0.5px, #fdfaf3 0.5px);
  background-size: 20px 20px;
  background-position: 0 0, 10px 10px;
}

.envelope-card-border {
  position: absolute;
  inset: 6px;
  border: 1px solid rgba(212, 175, 55, 0.4);
  pointer-events: none;
}

.envelope-card-corner {
  position: absolute;
  width: 20px;
  height: 20px;
  border-color: #d4af37;
  border-style: solid;
}
.envelope-card-corner.tl { top: 8px; left: 8px; border-width: 2px 0 0 2px; }
.envelope-card-corner.tr { top: 8px; right: 8px; border-width: 2px 2px 0 0; }
.envelope-card-corner.bl { bottom: 8px; left: 8px; border-width: 0 0 2px 2px; }
.envelope-card-corner.br { bottom: 8px; right: 8px; border-width: 0 2px 2px 0; }

.envelope-card-bismillah {
  font-family: 'Amiri', serif;
  font-size: 1.15rem;
  color: #b0811e;
  direction: rtl;
  margin-top: 4px;
}

.envelope-card-names {
  font-family: 'Playfair Display', serif;
  font-size: 1.35rem;
  color: #2b1c10;
  font-weight: 700;
  line-height: 1.2;
}

.envelope-card-amp {
  font-family: 'Great Vibes', cursive;
  font-size: 1.5rem;
  color: #c4952d;
  display: block;
  margin: 2px 0;
}

.envelope-card-date {
  font-family: 'Cinzel', serif;
  font-size: 0.85rem;
  letter-spacing: 2px;
  color: #8c631b;
  font-weight: 600;
}

.envelope-card-venue {
  font-family: 'Cormorant Garamond', serif;
  font-size: 0.95rem;
  font-style: italic;
  color: #594535;
}

/* Front Pocket Flaps */
.envelope-pocket {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 3;
}

/* Left & Right Triangular Side Folds */
.envelope-pocket::before {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 155px 0 155px 240px;
  border-color: transparent transparent transparent #382417;
  filter: drop-shadow(2px 0 3px rgba(0,0,0,0.3));
}

.envelope-pocket::after {
  content: '';
  position: absolute;
  bottom: 0;
  right: 0;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 155px 240px 155px 0;
  border-color: transparent #342114 transparent transparent;
  filter: drop-shadow(-2px 0 3px rgba(0,0,0,0.3));
}

/* Bottom Fold of Pocket */
.envelope-bottom-flap {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 0;
  border-style: solid;
  border-width: 0 240px 170px 240px;
  border-color: transparent transparent #422c1d transparent;
  z-index: 4;
  filter: drop-shadow(0 -2px 5px rgba(0,0,0,0.4));
}

/* Responsive adjustment for border triangle widths */
@media (max-width: 520px) {
  .envelope-pocket::before { border-width: 155px 0 155px 46vw; }
  .envelope-pocket::after { border-width: 155px 46vw 155px 0; }
  .envelope-bottom-flap { border-width: 0 46vw 170px 46vw; }
}

/* Top Triangular Flap */
.envelope-top-flap {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 0;
  border-style: solid;
  border-width: 165px 240px 0 240px;
  border-color: #4e3422 transparent transparent transparent;
  transform-origin: top center;
  transform-style: preserve-3d;
  transition: transform 1s cubic-bezier(0.4, 0, 0.2, 1), z-index 0.3s;
  z-index: 6;
  filter: drop-shadow(0 4px 10px rgba(0,0,0,0.5));
}

@media (max-width: 520px) {
  .envelope-top-flap { border-width: 165px 46vw 0 46vw; }
}

/* Golden Edge on Top Flap */
.envelope-flap-edge {
  position: absolute;
  top: -165px;
  left: -240px;
  right: -240px;
  height: 165px;
  background: linear-gradient(135deg, rgba(212,175,55,0.3) 0%, transparent 60%);
  pointer-events: none;
}

/* Wax Seal Centered on Top Flap */
.envelope-wax-seal {
  position: absolute;
  top: -30px;
  left: 50%;
  transform: translateX(-50%);
  width: 78px;
  height: 78px;
  z-index: 7;
  cursor: pointer;
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), filter 0.3s;
  filter: drop-shadow(0 6px 12px rgba(0,0,0,0.6));
}

.envelope-wax-seal:hover {
  transform: translateX(-50%) scale(1.08) rotate(3deg);
  filter: drop-shadow(0 8px 18px rgba(212, 175, 55, 0.45));
}

.envelope-wax-seal img,
.envelope-wax-seal svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* Opening Animations when active */
.envelope-wrapper.is-opening .envelope-top-flap {
  transform: rotateX(180deg);
  z-index: 1;
  transition: transform 1s cubic-bezier(0.4, 0, 0.2, 1), z-index 0.4s 0.5s;
}

.envelope-wrapper.is-opening .envelope-wax-seal {
  opacity: 0;
  transform: translateX(-50%) scale(1.3);
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.envelope-wrapper.is-opening .envelope-card {
  transform: translateY(-160px);
  z-index: 8;
  transition: transform 1.2s 0.6s cubic-bezier(0.34, 1.2, 0.64, 1);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
}

/* Interactive Open Invitation Action Button */
.envelope-action {
  z-index: 10;
  text-align: center;
}

.btn-open-invitation {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 14px 38px;
  background: linear-gradient(135deg, #ffd97d 0%, #d4af37 40%, #b8860b 80%, #916515 100%);
  color: #21150c;
  font-family: 'Cinzel', serif;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 3px;
  text-transform: uppercase;
  border: none;
  border-radius: 50px;
  cursor: pointer;
  box-shadow: 0 10px 25px rgba(212, 175, 55, 0.35),
              0 0 15px rgba(255, 235, 160, 0.4) inset;
  transition: all 0.35s ease;
  overflow: hidden;
}

.btn-open-invitation::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.5), transparent);
  transition: left 0.75s ease;
}

.btn-open-invitation:hover::before {
  left: 100%;
}

.btn-open-invitation:hover {
  transform: translateY(-3px) scale(1.03);
  box-shadow: 0 14px 32px rgba(212, 175, 55, 0.5),
              0 0 25px rgba(255, 235, 160, 0.6) inset;
  color: #120a05;
}

.btn-open-invitation:active {
  transform: translateY(0) scale(0.98);
}

.btn-open-invitation .btn-icon {
  display: inline-flex;
  animation: bounceRight 2s infinite ease-in-out;
}

@keyframes bounceRight {
  0%, 100% { transform: translateX(0); }
  50% { transform: translateX(4px); }
}

.envelope-hint {
  margin-top: 10px;
  font-family: 'Poppins', sans-serif;
  font-size: 0.75rem;
  color: #9a8069;
  letter-spacing: 1px;
}

/* Reduced Motion Setting */
@media (prefers-reduced-motion: reduce) {
  .envelope-wrapper:hover { transform: none; }
  .envelope-glow { animation: none; }
  .btn-open-invitation .btn-icon { animation: none; }
  .envelope-wrapper.is-opening .envelope-top-flap { transition: opacity 0.5s; opacity: 0; }
  .envelope-wrapper.is-opening .envelope-card { transform: none; }
}

