/* ==========================================================================
   3D ENVELOPE OPENING ANIMATION (STRICT LAYERING & SEQUENTIAL TIMELINE)
   ========================================================================== */

/* 3D Envelope Container */
.envelope-wrapper {
  position: relative;
  width: 360px;
  height: 240px;
  perspective: 1200px;
  cursor: pointer;
  margin: 40px auto;
  z-index: 10;
  transition: transform 0.4s ease;
}

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

.envelope {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.8s cubic-bezier(0.25, 1, 0.5, 1), opacity 0.6s ease;
}

/* LỚP 1 (Đáy - z-index: 1): Mặt lưng bao thư */
.envelope-back {
  position: absolute;
  inset: 0;
  background: #E8DFD8;
  border-radius: 6px;
  box-shadow: 0 15px 45px rgba(0, 0, 0, 0.4);
  z-index: 1;
}

/* LỚP 2 (Giữa - z-index: 2): Ruột thiệp cưới. Ban đầu nằm gọn 100% bên trong bao thư */
.wedding-card {
  position: absolute;
  top: 12px;
  left: 15px;
  right: 15px;
  height: 215px; /* Nhỏ hơn chiều cao bao thư (240px) để đuôi thiệp không lộ ra ngoài trước khi rút */
  background: #FFFDF9;
  border-radius: 6px;
  border: 1px solid rgba(212, 175, 55, 0.4);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  padding: 1.25rem 1rem;
  text-align: center;
  z-index: 2;
  transform: translateY(0);
  transition: transform 0.8s cubic-bezier(0.25, 1, 0.5, 1),
              top 0.8s cubic-bezier(0.25, 1, 0.5, 1),
              height 0.8s cubic-bezier(0.25, 1, 0.5, 1),
              border-radius 0.8s cubic-bezier(0.25, 1, 0.5, 1),
              box-shadow 0.8s cubic-bezier(0.25, 1, 0.5, 1);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}

/* LỚP 3 (Mặt trước - z-index: 3): Hai tai bên và nắp đáy bao thư che phía trước thiệp */
.envelope-pocket {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0;
  height: 0;
  border-left: 180px solid #DFD4CA;
  border-right: 180px solid #DFD4CA;
  border-bottom: 130px solid #CFC4BA;
  border-top: 110px solid transparent;
  border-radius: 0 0 6px 6px;
  z-index: 3;
  pointer-events: none;
  transition: opacity 0.6s ease;
}

/* LỚP 4 (Nắp gập trên - Flap - z-index: 5 lúc đóng, che miệng bao thư) */
.envelope-flap {
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  border-left: 180px solid transparent;
  border-right: 180px solid transparent;
  border-top: 130px solid #D6CBC2;
  transform-origin: top center;
  z-index: 5;
  transition: transform 0.7s cubic-bezier(0.4, 0, 0.2, 1),
              z-index 0s 0.35s,
              opacity 0.6s ease;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.15));
}

/* Con dấu sáp (z-index: 6 nằm trên cùng) */
.wax-seal {
  position: absolute;
  top: 95px;
  left: 50%;
  transform: translateX(-50%);
  width: 52px;
  height: 52px;
  background: radial-gradient(circle at 35% 35%, #9E1A1A, #570C0D);
  border-radius: 50%;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35), inset 0 2px 4px rgba(255, 255, 255, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #D4AF37;
  font-family: var(--font-serif-display);
  font-size: 1.25rem;
  font-weight: 700;
  z-index: 6;
  border: 1px solid rgba(212, 175, 55, 0.4);
  cursor: pointer;
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.wax-seal:hover {
  transform: translateX(-50%) scale(1.08);
  box-shadow: 0 6px 16px rgba(123, 17, 19, 0.5);
}

.wax-seal-hint {
  position: absolute;
  bottom: -32px;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255, 255, 255, 0.85);
  font-size: 0.76rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
  animation: pulseHint 1.8s infinite;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

@keyframes pulseHint {
  0%, 100% { opacity: 0.6; transform: translateX(-50%) translateY(0); }
  50% { opacity: 1; transform: translateX(-50%) translateY(-3px); }
}

/* ==================== BƯỚC 1: MỞ NẮP HOÀN TOÀN (0s - 0.7s) ==================== */
/* Nắp lật 180° lên trên, sau góc 90° (0.35s) z-index hạ xuống 1 lùi về sau lưng thiệp */
.envelope-wrapper.step-1-flap-open .envelope-flap {
  transform: rotateX(180deg);
  z-index: 1;
}

.envelope-wrapper.step-1-flap-open .wax-seal {
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) scale(0.3);
}

.envelope-wrapper.step-1-flap-open .wax-seal-hint {
  opacity: 0;
  pointer-events: none;
}

/* Tấm thiệp ở Bước 1 ĐỨNG YÊN 100% bên trong bao thư (transform: translateY(0)) */


/* ==================== BƯỚC 2: RÚT THIỆP LÊN (0.7s - 1.5s) ==================== */
/* Nâng z-index của thiệp lên 10 để nổi trên mặt túi bao thư (z-index 3), trượt thẳng đứng lên trên */
.envelope-wrapper.step-2-card-slide .wedding-card {
  z-index: 10 !important;
  transform: translateY(-130px) !important;
  height: 380px !important;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35) !important;
}


/* ==================== BƯỚC 3: MỞ RỘNG TOÀN MÀN HÌNH MƯỢT MÀ (1.5s - 2.2s) ==================== */
/* Vỏ bao thư phía sau GIỮ NGUYÊN KÍCH THƯỚC (KHÔNG PHÓNG TO), CHỈ MỜ DẦN (opacity: 0) */
.envelope-wrapper.step-3-fullscreen-expand .envelope-back,
.envelope-wrapper.step-3-fullscreen-expand .envelope-pocket,
.envelope-wrapper.step-3-fullscreen-expand .envelope-flap {
  opacity: 0 !important;
  pointer-events: none !important;
  transition: opacity 0.6s ease !important;
}

/* CHỈ CÓ TẤM THIỆP PHÓNG TO & MỞ RỘNG CĂN GIỮA TUYỆT ĐỐI MÀN HÌNH MÔ PHỎNG ĐIỆN THOẠI */
.envelope-wrapper.step-3-fullscreen-expand .wedding-card {
  position: absolute !important;
  top: -25px !important;
  left: 50% !important;
  right: auto !important;
  transform: translateX(-50%) !important;
  width: 380px !important;
  max-width: 96% !important;
  height: 580px !important;
  border-radius: 18px !important;
  padding: 1.5rem 1.25rem 2.5rem !important;
  box-shadow: 0 25px 70px rgba(0, 0, 0, 0.5) !important;
  overflow-y: auto !important;
  z-index: 30 !important;
  justify-content: flex-start !important;
  transition: opacity 0.8s ease, transform 0.8s cubic-bezier(0.25, 1, 0.5, 1), top 0.8s cubic-bezier(0.25, 1, 0.5, 1), height 0.8s cubic-bezier(0.25, 1, 0.5, 1), box-shadow 0.8s ease !important;
  scroll-behavior: auto !important;
  overscroll-behavior: contain !important;
  -webkit-overflow-scrolling: touch !important;
}

.envelope-wrapper.step-3-fullscreen-expand .wedding-card::-webkit-scrollbar {
  width: 4px;
}

.envelope-wrapper.step-3-fullscreen-expand .wedding-card::-webkit-scrollbar-thumb {
  background: rgba(212, 175, 55, 0.4);
  border-radius: 9999px;
}

/* Sticky Auto-Scroll Floating Dock Bar inside Expanded Wedding Card */
.studio-autoscroll-bar-dock {
  position: sticky !important;
  bottom: 0.5rem !important;
  margin: 1.25rem auto 0 !important;
  width: max-content !important;
  z-index: 100 !important;
  display: flex !important;
  align-items: center !important;
  gap: 0.5rem !important;
  background: rgba(25, 22, 22, 0.92) !important;
  backdrop-filter: blur(16px) !important;
  -webkit-backdrop-filter: blur(16px) !important;
  border: 1.5px solid #D4AF37 !important;
  border-radius: 9999px !important;
  padding: 0.4rem 0.85rem !important;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5) !important;
  color: #FFF !important;
  font-size: 0.84rem !important;
  pointer-events: auto !important;
}

.studio-autoscroll-bar-dock button,
.studio-autoscroll-bar-dock .speed-pill,
.studio-autoscroll-bar-dock .autoscroll-main-btn {
  pointer-events: auto !important;
  cursor: pointer !important;
  background: transparent !important;
  border: none !important;
  color: #FFFFFF !important;
  font-weight: 600 !important;
  font-size: 0.8rem !important;
  padding: 0.3rem 0.6rem !important;
  border-radius: 9999px !important;
  transition: all 0.2s ease !important;
}

.studio-autoscroll-bar-dock .autoscroll-main-btn {
  background: linear-gradient(135deg, #D4AF37, #AA7C11) !important;
  color: #111111 !important;
  font-weight: 700 !important;
  padding: 0.35rem 0.8rem !important;
  box-shadow: 0 2px 8px rgba(212, 175, 55, 0.4) !important;
}

.studio-autoscroll-bar-dock .autoscroll-main-btn.active {
  background: linear-gradient(135deg, #10B981, #047857) !important;
  color: #FFFFFF !important;
  box-shadow: 0 2px 10px rgba(16, 185, 129, 0.5) !important;
}

.studio-autoscroll-bar-dock .speed-pill {
  background: rgba(255, 255, 255, 0.12) !important;
  color: #FFFFFF !important;
  border: 1px solid rgba(255, 255, 255, 0.25) !important;
  font-weight: 500 !important;
}

.studio-autoscroll-bar-dock .speed-pill:hover,
.studio-autoscroll-bar-dock .speed-pill.active {
  background: #D4AF37 !important;
  color: #111111 !important;
  border-color: #D4AF37 !important;
  font-weight: 700 !important;
}

/* Full View Invitation Card (Khi phóng to / Trên trang thiệp công khai) */
.full-invitation-card {
  width: 100%;
  max-width: 480px;
  background: #FFFDF9;
  border-radius: var(--radius-lg);
  box-shadow: 0 25px 70px rgba(0, 0, 0, 0.4);
  padding: 3.5rem 2rem 3rem;
  position: relative;
  text-align: center;
  border: 1px solid rgba(212, 175, 55, 0.5);
  margin: 2rem auto;
  animation: cardFadeInUp 1s ease-out;
}

.full-invitation-card::before {
  content: "";
  position: absolute;
  inset: 12px;
  border: 1px solid rgba(212, 175, 55, 0.3);
  border-radius: calc(var(--radius-lg) - 6px);
  pointer-events: none;
}

.card-header-badge {
  font-family: var(--font-serif-display);
  font-size: 0.8rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--primary-gold-hover);
  margin-bottom: 1.5rem;
}

.card-couple-names {
  font-family: var(--font-serif-display);
  font-size: 2.2rem;
  line-height: 1.2;
  color: var(--burgundy);
  margin-bottom: 1.5rem;
  letter-spacing: 0.04em;
}

.card-couple-names .sep {
  display: block;
  font-family: var(--font-serif-text);
  font-style: italic;
  font-size: 1.5rem;
  color: var(--primary-gold);
  margin: 0.2rem 0;
}

.card-invitation-text {
  font-family: var(--font-serif-text);
  font-size: 1.08rem;
  font-style: normal;
  color: var(--text-muted);
  margin-bottom: 2rem;
  line-height: 1.65;
}

.card-wedding-details {
  border-top: 1px dashed var(--border-light);
  border-bottom: 1px dashed var(--border-light);
  padding: 1.5rem 0;
  margin-bottom: 2rem;
}

.card-detail-item {
  margin-bottom: 0.75rem;
}
.card-detail-item:last-child { margin-bottom: 0; }

.card-detail-item .label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--primary-gold-hover);
  font-weight: 600;
  display: block;
}

.card-detail-item .val {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-main);
}

/* QR Code & Banking Section */
.card-bank-qr {
  margin: 1.5rem 0;
  padding: 1rem;
  background: var(--bg-surface-alt);
  border-radius: var(--radius-md);
  display: inline-block;
  border: 1px solid var(--border-subtle);
}

.card-bank-qr img {
  width: 140px;
  height: 140px;
  display: block;
  margin: 0 auto 0.5rem;
}

.card-bank-qr span {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* Animations Keyframes */
@keyframes cardFadeInUp {
  from {
    opacity: 0;
    transform: translateY(40px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes floatGentle {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

.float-animation {
  animation: floatGentle 3s ease-in-out infinite;
}

/* ==========================================================================
   ENHANCED ENTRANCE ANIMATIONS (ITEM FADE IN DOWN & POPUP / MODAL ANIMATIONS)
   ========================================================================== */

/* 1. Item Xuất hiện dần dần từ trên xuống dưới, từ mờ thành rõ nét (Fade In Down) */
@keyframes fadeInDown {
  0% {
    opacity: 0;
    transform: translateY(-28px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Áp dụng trực tiếp qua class */
.animate-fade-in-down,
.fade-in-down {
  opacity: 0;
  animation: fadeInDown 1.2s cubic-bezier(0.16, 1, 0.3, 1) both;
}

/* Scroll reveal khi cuộn trang */
.scroll-reveal-down,
[data-animate="fade-down"] {
  opacity: 0;
  transform: translateY(-28px);
  transition: opacity 1.2s cubic-bezier(0.16, 1, 0.3, 1), transform 1.2s cubic-bezier(0.16, 1, 0.3, 1);
  will-change: opacity, transform;
}

.scroll-reveal-down.revealed,
[data-animate="fade-down"].revealed {
  opacity: 1;
  transform: translateY(0);
}

/* Stagger Delay hỗ trợ xuất hiện lần lượt từng Item */
.stagger-1, .stagger-items > *:nth-child(1) { animation-delay: 0.1s; transition-delay: 0.1s; }
.stagger-2, .stagger-items > *:nth-child(2) { animation-delay: 0.2s; transition-delay: 0.2s; }
.stagger-3, .stagger-items > *:nth-child(3) { animation-delay: 0.3s; transition-delay: 0.3s; }
.stagger-4, .stagger-items > *:nth-child(4) { animation-delay: 0.4s; transition-delay: 0.4s; }
.stagger-5, .stagger-items > *:nth-child(5) { animation-delay: 0.5s; transition-delay: 0.5s; }
.stagger-6, .stagger-items > *:nth-child(6) { animation-delay: 0.6s; transition-delay: 0.6s; }
.stagger-7, .stagger-items > *:nth-child(7) { animation-delay: 0.7s; transition-delay: 0.7s; }
.stagger-8, .stagger-items > *:nth-child(8) { animation-delay: 0.8s; transition-delay: 0.8s; }

/* 2. Hiệu ứng Popup / Modal xuất hiện mượt mà (Scale + Fade In Down) */
@keyframes popupEntrance {
  0% {
    opacity: 0;
    transform: translateY(-30px) scale(0.94);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.animate-popup,
.modal-overlay.active .modal-container,
.modal-overlay.active .confirm-modal-container {
  animation: popupEntrance 1.2s cubic-bezier(0.16, 1, 0.3, 1) forwards !important;
}

/* 3. Hiệu ứng Popover / DatePicker Unfold Down (Style UXERFLOW / Stripe Dashboard) */
@keyframes popoverUnfoldDown {
  0% {
    opacity: 0;
    transform: translateY(-20px) scaleY(0.82) scaleX(0.92);
    clip-path: inset(0 0 100% 0 round 16px);
  }
  70% {
    clip-path: inset(0 0 0 0 round 16px);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scaleY(1) scaleX(1);
    clip-path: inset(0 0 0 0 round 16px);
  }
}

.popover-unfold,
.dropdown-unfold,
.unfold-down {
  transform-origin: top center;
  overflow: hidden;
  will-change: transform, opacity, clip-path;
}

.popover-unfold.active,
.dropdown-unfold.active,
.unfold-down.active {
  animation: popoverUnfoldDown 1.2s cubic-bezier(0.16, 1, 0.3, 1) forwards !important;
}


