/* ==========================================================================
   Envelope Interativo 3D & Animação de Abertura do Convite
   ========================================================================== */

.envelope-screen {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at center, #2e2621 0%, #161210 100%);
  padding: 1.5rem;
  overflow: hidden;
  transition: opacity 1.2s cubic-bezier(0.16, 1, 0.3, 1), visibility 1.2s;
}

.envelope-screen.opened,
.envelope-screen.fade-out {
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

/* Partículas e Brilhos de Fundo */
.envelope-bg-particles {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image: 
    radial-gradient(circle at 20% 30%, rgba(223, 186, 112, 0.15) 0%, transparent 40%),
    radial-gradient(circle at 80% 70%, rgba(184, 124, 124, 0.12) 0%, transparent 45%);
}

.envelope-instructions {
  text-align: center;
  color: var(--gold-200);
  margin-bottom: 2rem;
  z-index: 2;
  animation: fadeInDown 1s ease-out;
}

.envelope-instructions .subtitle {
  font-family: var(--font-script);
  font-size: 2.2rem;
  color: var(--gold-300);
  line-height: 1;
}

.envelope-instructions .title {
  font-family: var(--font-serif);
  font-size: 1.8rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: #ffffff;
  margin-top: 0.3rem;
  font-weight: 300;
}

/* Container do Envelope 3D */
.envelope-container {
  position: relative;
  width: 340px;
  height: 230px;
  perspective: 1200px;
  cursor: pointer;
  z-index: 5;
  transition: transform 0.4s ease;
}

@media (min-width: 480px) {
  .envelope-container {
    width: 420px;
    height: 280px;
  }
}

.envelope-container:hover {
  transform: translateY(-5px) scale(1.02);
}

.envelope-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
  background: #f7f3eb;
  border-radius: 8px;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.6), 0 0 40px rgba(197, 168, 128, 0.2);
  transform-style: preserve-3d;
}

/* Cartão Interno que desliza */
.invitation-card-preview {
  position: absolute;
  top: 10px;
  left: 15px;
  right: 15px;
  height: calc(100% - 20px);
  background: #ffffff;
  border-radius: 6px;
  border: 1px solid var(--gold-300);
  padding: 1.5rem 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  box-shadow: 0 4px 15px rgba(0,0,0,0.06);
  transition: transform 1.2s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.8s ease;
  z-index: 2;
}

.invitation-card-preview .couple-names {
  font-family: var(--font-serif);
  font-size: 1.6rem;
  color: var(--text-primary);
  letter-spacing: 0.05em;
}

.invitation-card-preview .wedding-date {
  font-size: 0.85rem;
  color: var(--primary);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  margin-top: 0.4rem;
}

/* Abas do Envelope */
.envelope-pocket {
  position: absolute;
  inset: 0;
  background: var(--envelope-body-bg);
  border-radius: 8px;
  overflow: hidden;
  z-index: 3;
}

.envelope-pocket::before {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--envelope-liner);
  clip-path: polygon(0% 100%, 50% 48%, 100% 100%);
  z-index: 4;
}

.envelope-pocket::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--envelope-body-bg);
  clip-path: polygon(0 0, 0 100%, 50% 50%, 100% 100%, 100 0);
  z-index: 3;
}

/* Aba Superior que Dobra em 3D */
.envelope-flap {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--envelope-flap-bg);
  clip-path: polygon(0 0, 50% 55%, 100% 0);
  transform-origin: top;
  transition: transform 0.9s cubic-bezier(0.4, 0, 0.2, 1), z-index 0.2s 0.3s;
  z-index: 5;
}

/* Sinete de Cera com Paleta Dinâmica */
.wax-seal {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--seal-gradient);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35), inset 0 2px 4px rgba(255, 255, 255, 0.6), inset 0 -2px 6px rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 6;
  transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.5s ease;
  animation: sealPulse 2.5s infinite ease-in-out;
}

.wax-seal-inner {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: 1.5px dashed rgba(255, 255, 255, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-serif);
  font-size: 1.3rem;
  font-weight: 700;
  color: #fff8e8;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

@keyframes sealPulse {
  0%, 100% {
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35), 0 0 0 0 rgba(196, 115, 125, 0.5);
  }
  50% {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45), 0 0 0 14px rgba(196, 115, 125, 0);
  }
}

/* Botão de Toque */
.open-invitation-btn {
  margin-top: 2.5rem;
  z-index: 10;
  animation: fadeInUp 1.2s ease-out;
}

/* Estados da Animação de Abertura */
.envelope-container.is-opening .envelope-flap {
  transform: rotateX(180deg);
  z-index: 1;
}

.envelope-container.is-opening .wax-seal {
  transform: translate(-50%, -50%) scale(1.3);
  opacity: 0;
}

.envelope-container.is-opening .invitation-card-preview {
  transform: translateY(-120px);
  z-index: 6;
  box-shadow: 0 15px 35px rgba(0,0,0,0.25);
}

@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); }
}
