/* ========================================================
   3. ENVELOPE OPENING OVERLAY (IMAGE 2 MATCH)
   ======================================================== */
.envelope-screen {
  position: fixed;
  inset: 0;
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #2f4529;
  background: linear-gradient(145deg, #42623a 0%, #30472a 45%, #1f311a 100%);
  overflow: hidden;
  padding: 16px;
  transition: opacity 2.4s cubic-bezier(0.4, 0, 0.2, 1), visibility 2.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.invite-opening .envelope-screen,
.invite-open .envelope-screen {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* Opening Shockwave & Motion Blur Transition */
.envelope-seal::before,
.envelope-seal::after {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  pointer-events: none;
  opacity: 0;
}

.invite-opening .envelope-seal {
  transform: scale(1.22);
  box-shadow: 0 0 45px rgba(212, 175, 55, 0.75);
  transition: transform 2.2s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 2.2s ease;
}

.invite-opening .envelope-seal::before {
  border: 3px solid rgba(82, 116, 72, 0.85);
  animation: seal-shockwave-1 2.4s cubic-bezier(0.15, 0.85, 0.35, 1) forwards;
}

.invite-opening .envelope-seal::after {
  border: 2px solid rgba(113, 154, 102, 0.7);
  animation: seal-shockwave-2 2.4s cubic-bezier(0.15, 0.85, 0.35, 1) 0.25s forwards;
}

@keyframes seal-shockwave-1 {
  0% {
    transform: scale(0.95);
    opacity: 0.95;
    box-shadow: 0 0 0 0 rgba(82, 116, 72, 0.5);
  }
  100% {
    transform: scale(2.8);
    opacity: 0;
    box-shadow: 0 0 25px rgba(82, 116, 72, 0);
  }
}

@keyframes seal-shockwave-2 {
  0% {
    transform: scale(0.95);
    opacity: 0.85;
    box-shadow: 0 0 0 0 rgba(113, 154, 102, 0.4);
  }
  100% {
    transform: scale(3.6);
    opacity: 0;
    box-shadow: 0 0 35px rgba(113, 154, 102, 0);
  }
}

/* Flowers, Card & Content slide upwards & fade out smoothly */
.invite-opening .envelope-box {
  transform: translateY(-85px) scale(0.97);
  opacity: 0;
  transition: transform 2.4s cubic-bezier(0.2, 0.8, 0.25, 1), opacity 2.1s cubic-bezier(0.4, 0, 0.2, 1);
}

.invite-opening .envelope-flower-left {
  filter: blur(8px);
  opacity: 0;
  transform: rotate(20deg) translateY(-65px) scale(0.97);
  transition: filter 2.3s ease, opacity 2.1s cubic-bezier(0.4, 0, 0.2, 1), transform 2.4s cubic-bezier(0.2, 0.8, 0.25, 1);
}

.invite-opening .envelope-card {
  filter: blur(8px);
  opacity: 0;
  transform: translateY(-85px) scale(0.96);
  transition: filter 2.3s ease, opacity 2.1s cubic-bezier(0.4, 0, 0.2, 1), transform 2.4s cubic-bezier(0.2, 0.8, 0.25, 1);
}

.invite-opening .envelope-names,
.invite-opening .envelope-divider,
.invite-opening .envelope-date,
.invite-opening .envelope-invite-text,
.invite-opening .btn-open {
  filter: blur(6px);
  opacity: 0;
  transform: translateY(-45px);
  transition: filter 1.9s ease, opacity 1.8s ease, transform 2.0s cubic-bezier(0.2, 0.8, 0.25, 1);
}

.invite-opening .ambient-particles {
  filter: blur(8px);
  opacity: 0;
  transform: translateY(-50px);
  transition: filter 2.3s ease, opacity 2.2s ease, transform 2.4s ease;
}

/* Falling ambient particles */
.ambient-particles {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 1;
}

/* Velvet Envelope Card Container (Larger & More Spacious) */
.envelope-box {
  position: relative;
  z-index: 10;
  width: min(660px, 94vw);
  perspective: 1000px;
}

.envelope-card {
  position: relative;
  background: #f6f7f0 url("../assets/rough-paper.png?v=cool1") center / cover;
  border-radius: 18px;
  padding: 44px 40px 38px;
  text-align: center;
  box-shadow: 
    0 26px 65px rgba(7, 12, 6, 0.55),
    0 8px 22px rgba(0, 0, 0, 0.25);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.5);
}

/* Decorative Lotus Flower on Left tilted 30deg to the right */
.envelope-flower-left {
  position: absolute;
  top: 10px;
  left: -85px;
  width: clamp(170px, 42vw, 225px);
  height: auto;
  pointer-events: none;
  opacity: 0.98;
  z-index: 2;
  transform: rotate(15deg);
  transform-origin: 35% 85%;
  animation: flower-sway-left 6s ease-in-out infinite;
  filter: drop-shadow(2px 6px 14px rgba(23, 34, 20, 0.18));
}

@keyframes flower-sway-left {
  0%, 100% {
    transform: rotate(15deg) translateY(0) scale(1);
  }
  35% {
    transform: rotate(17.2deg) translateY(-4px) scale(1.02);
  }
  70% {
    transform: rotate(13deg) translateY(2px) scale(0.99);
  }
}

/* Dark Wine Wax Seal Badge at Top Center */
.envelope-seal {
  position: relative;
  margin: 0 auto 18px;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #304829, #1d2e18, #0f190c);
  box-shadow: 0 6px 20px rgba(12, 20, 9, 0.45), inset 0 1px 2px rgba(255, 255, 255, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  cursor: pointer;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  animation: seal-pulse 2.4s ease-in-out infinite;
}

.envelope-seal:hover {
  transform: scale(1.08);
  box-shadow: 0 8px 24px rgba(17, 28, 14, 0.55);
}

.envelope-seal svg {
  width: 26px;
  height: 26px;
  fill: #ffffff;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.3));
}

@keyframes seal-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

/* Couple Names (Slender & Elegant Serif) */
.envelope-names {
  position: relative;
  z-index: 5;
  font-family: "Cormorant Garamond", "Playfair Display", Georgia, serif;
  color: #2a3e24;
  margin: 0 auto 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.envelope-name-line {
  font-size: clamp(1.85rem, 4.8vw, 2.75rem);
  font-weight: 400;
  line-height: 1.16;
  letter-spacing: 0.015em;
  color: #293d23;
}

.envelope-name-amp {
  font-family: "Cormorant Garamond", "Playfair Display", Georgia, serif;
  font-size: clamp(1.4rem, 3.6vw, 1.95rem);
  font-weight: 400;
  color: #293d23;
  line-height: 1.15;
  margin: 2px 0 3px;
}

/* Elegant Divider */
.envelope-divider {
  position: relative;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin: 8px auto 10px;
  max-width: 140px;
}

.envelope-divider .line {
  flex: 1;
  height: 1px;
  background: linear-gradient(to right, transparent, #31492b 40%, #31492b 100%);
  opacity: 0.65;
}

.envelope-divider .line:last-child {
  background: linear-gradient(to left, transparent, #31492b 40%, #31492b 100%);
}

.envelope-divider .ornament {
  color: #31492b;
  font-size: 0.85rem;
  opacity: 0.8;
  line-height: 1;
}

/* Date & Subtext (Mảnh mai, thanh thoát, tao nhã) */
.envelope-date {
  position: relative;
  z-index: 5;
  font-family: "Cormorant Garamond", "Lora", Georgia, serif;
  font-size: clamp(1rem, 2.3vw, 1.15rem);
  color: #5b6558;
  margin-bottom: 6px;
  font-weight: 400;
  letter-spacing: 0.02em;
}

.envelope-invite-text {
  position: relative;
  z-index: 5;
  font-family: "Cormorant Garamond", "Lora", Georgia, serif;
  font-size: clamp(1rem, 2.1vw, 2rem);
  color: #6b7668;
  font-style: normal;
  font-weight: 400;
  letter-spacing: 0.03em;
  margin-bottom: 22px;
}

/* Pill Open Button */
.btn-open {
  position: relative;
  z-index: 5;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 36px;
  background: #23341e;
  color: #fbfbf4;
  font-family: "Cormorant Garamond", "Lora", Georgia, serif;
  font-size: 0.95rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  border-radius: 999px;
  box-shadow: 0 7px 20px rgba(20, 33, 17, 0.42);
  overflow: hidden;
  transition: transform 0.25s ease, box-shadow 0.25s ease, background-color 0.25s ease;
  cursor: pointer;
}

.btn-open:hover {
  background: #2d4227;
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(20, 33, 17, 0.58);
}

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

.btn-open .shimmer {
  position: absolute;
  top: 0;
  left: -100%;
  width: 60%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.35), transparent);
  animation: btn-shimmer 3s ease-in-out infinite;
  pointer-events: none;
}

@keyframes btn-shimmer {
  0% { left: -100%; }
  35%, 100% { left: 140%; }
}

/* Loading only covers the invitation cover while route/config data is pending. */
#envelope-screen .cover-loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.55);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  cursor: wait;
}
#envelope-screen .cover-loading-overlay[hidden] { display: none; }
#envelope-screen .cover-loading-spinner {
  width: 44px;
  height: 44px;
  color: var(--red-primary);
  border: 3px solid color-mix(in srgb, currentColor 25%, transparent);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: coverLoadingSpin 0.9s linear infinite;
}
@keyframes coverLoadingSpin { to { transform: rotate(360deg); } }
#envelope-screen[aria-busy="true"] { cursor: wait; }
#envelope-screen button:disabled { cursor: wait; }
