/* ==============================================================================
   ENVELOPE SCREEN (Apertura interactiva de sobre con sello de lacre)
   ============================================================================== */

.envelope-wrapper {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  background: radial-gradient(circle at center, #4b0717 0%, #2b020a 70%, #170005 100%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 20px;
  perspective: 1200px;
  touch-action: none;
  overscroll-behavior: none;
  transition: opacity 0.8s ease, visibility 0.8s ease;
}

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

.envelope-container {
  width: 100%;
  max-width: 420px;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Encabezado del sobre: Monograma y Quinceañera */
.envelope-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  margin-bottom: 24px;
  z-index: 10;
  animation: fadeInDown 1s ease-out;
}

.envelope-monogram {
  display: block;
  width: 98px;
  height: auto;
  max-height: 105px;
  margin: 0 auto 10px;
  filter: drop-shadow(0 6px 16px rgba(0, 0, 0, 0.6)) drop-shadow(0 0 18px rgba(235, 175, 160, 0.4));
  object-fit: contain;
}

.envelope-title {
  font-family: var(--font-script);
  font-size: 44px;
  line-height: 1.1;
  margin: 0 auto;
  padding: 0 4px;
}

.envelope-subtitle {
  font-family: var(--font-serif);
  font-size: 14px;
  letter-spacing: 4px;
  color: var(--color-gold-primary);
  text-transform: uppercase;
  margin-top: 4px;
}

/* El Sobre Físico 3D */
.envelope {
  position: relative;
  width: 100%;
  max-width: 440px;
  aspect-ratio: 1.6 / 1;
  min-height: 190px;
  background: #500a19;
  border-radius: 8px;
  box-shadow: var(--shadow-envelope);
  overflow: visible;
  transition: transform 0.6s ease;
  margin: 0 auto;
}

@media (min-width: 768px) {
  .envelope {
    max-width: 500px;
    aspect-ratio: 1.65 / 1;
    min-height: 280px;
  }
}

/* Cuerpo del Sobre: Capas triangulares */
.envelope-back {
  position: absolute;
  inset: 0;
  background: #3e0512;
  border-radius: 8px;
}

/* Solapa Superior Triangular (La que se abre en 3D con clip-path 100% fluido) */
.envelope-flap {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 58%;
  background: linear-gradient(180deg, #6c1024 0%, #560b1b 100%);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  transform-origin: top center;
  transition: transform 0.8s cubic-bezier(0.4, 0, 0.2, 1), background 0.8s ease;
  z-index: 5;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.35));
}

.envelope.open-flap .envelope-flap {
  transform: rotateX(180deg);
  z-index: 1;
  background: #460614;
}

/* Bolsillo Frontal del Sobre (Solapas laterales) */
.envelope-pocket {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
}

.envelope-pocket::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, #580c1d 0%, #460714 100%);
  clip-path: polygon(0 0, 0 100%, 50% 50%);
}

.envelope-pocket::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(225deg, #520a1a 0%, #400512 100%);
  clip-path: polygon(100% 0, 100% 100%, 50% 50%);
}

/* Solapa Inferior Central */
.envelope-bottom-fold {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 55%;
  background: linear-gradient(0deg, #5e0d20 0%, #4e0917 100%);
  clip-path: polygon(0 100%, 100% 100%, 50% 0);
  z-index: 4;
}

/* Sello de Lacre Interactivo */
.wax-seal-btn {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 88px;
  height: 88px;
  z-index: 10;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
  outline: none;
  filter: drop-shadow(0 8px 16px rgba(25, 2, 7, 0.65));
  transition: transform 0.3s ease, filter 0.3s ease;
}

.wax-seal-btn:hover {
  transform: translate(-50%, -50%) scale(1.08);
  filter: drop-shadow(0 12px 24px rgba(25, 2, 7, 0.8)) drop-shadow(0 0 16px rgba(184, 16, 66, 0.45));
}

.wax-seal-btn img {
  width: 100%;
  height: 100%;
  display: block;
}

/* Texto de llamado a la acción alrededor o bajo el sello */
.seal-instructions {
  position: absolute;
  top: calc(50% + 56px);
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  font-family: var(--font-serif);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 2.5px;
  color: var(--color-gold-light);
  text-transform: uppercase;
  background: rgba(43, 4, 12, 0.85);
  padding: 4px 14px;
  border-radius: var(--radius-pill);
  border: 1px solid rgba(212, 175, 55, 0.4);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  pointer-events: none;
  animation: pulseGlow 2s infinite ease-in-out;
  z-index: 11;
}

@media (max-width: 400px) {
  .envelope-wrapper {
    padding: 14px 10px;
  }
  .envelope-header {
    margin-bottom: 16px;
  }
  .envelope-monogram {
    width: 82px;
    max-height: 88px;
    margin-bottom: 6px;
  }
  .envelope-title {
    font-size: 36px;
  }
  .envelope {
    min-height: 190px;
  }
  .wax-seal-btn {
    width: 74px;
    height: 74px;
  }
  .seal-instructions {
    top: calc(50% + 45px);
    font-size: 9.5px;
    padding: 3px 10px;
    letter-spacing: 1.5px;
  }
  .envelope-passes-badge {
    margin-top: 18px;
    padding: 8px 16px;
  }
  .passes-guest-name {
    font-size: 20px;
  }
}

/* Etiqueta de Pases Asignados (Video diseño.mp4) */
.envelope-passes-badge {
  margin-top: 28px;
  background: rgba(253, 250, 246, 0.95);
  border: 1px solid var(--color-gold-primary);
  border-radius: var(--radius-md);
  padding: 10px 22px;
  text-align: center;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
  z-index: 10;
  animation: fadeInUp 1s ease-out;
  max-width: 90%;
}

.passes-text {
  font-family: var(--font-serif);
  font-size: 11px;
  letter-spacing: 2px;
  color: var(--color-burgundy-primary);
  text-transform: uppercase;
  font-weight: 600;
}

.passes-guest-name {
  font-family: var(--font-script);
  font-size: 24px;
  color: var(--color-burgundy-primary);
  line-height: 1.2;
  margin-top: 2px;
}

.passes-count {
  font-family: var(--font-serif);
  font-size: 12px;
  font-weight: 700;
  color: var(--color-gold-dark);
  letter-spacing: 1px;
  margin-top: 2px;
}

.passes-dots {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin: 4px 0;
}

.passes-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: var(--color-burgundy-soft);
}

/* Animaciones del Sobre */
@keyframes pulseGlow {
  0%, 100% {
    box-shadow: 0 0 10px rgba(212, 175, 55, 0.3);
    transform: translateX(-50%) scale(1);
  }
  50% {
    box-shadow: 0 0 20px rgba(212, 175, 55, 0.7);
    transform: translateX(-50%) scale(1.03);
  }
}

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

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