/* =============================================
   INVITATION — invitation.css
   Popup phong bì, thiệp mời, form xác nhận
   ============================================= */

/* ── 1. POPUP PHONG BÌ ─────────────────────── */

#envelope-popup {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(2.35);
  z-index: 210;   /* cao hơn hero (z-index: 20) */
  opacity: 0;
  pointer-events: none;
  transition: none;
  display: flex;             
  flex-direction: column;   
  align-items: center;        
}

#envelope-label {
  text-align: center;
  font-family: 'Courier New', Courier, monospace;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 1px;
  color: #ffffff;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
  margin-bottom: 14px;
  animation: envelope-label-pulse 2s ease-in-out infinite;
}

@keyframes envelope-label-pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.65; }
}

@media (max-width: 480px) {
  #envelope-label {
    font-size: 13px;
    margin-bottom: 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  #envelope-label {
    animation: none;
  }
}

#envelope-popup.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, -50%) scale(1);
  transition:
    opacity 0.08s ease,
    transform 0.18s cubic-bezier(0.175, 0.885, 0.32, 1.6);
}

#envelope-box {
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  box-shadow: none;
  min-width: 0;
  user-select: none;
  /* Rung nhẹ để gây chú ý sau khi hiện */
  animation: envelope-shake 0.5s ease 0.25s;
}

#envelope-box:hover {
  transform: scale(1.04);
  transition: transform 0.15s ease;
}

#envelope-box:active {
  transform: scale(0.97);
}

#envelope-icon {
  width: min(72vw, 280px);
  height: auto;
  object-fit: contain;
  display: block;
  /* Lắc lư nhẹ liên tục */
  animation: envelope-wiggle 2.8s ease-in-out 0.8s infinite;
}

@keyframes envelope-shake {
  0%   { transform: rotate(0deg);   }
  20%  { transform: rotate(-4deg);  }
  40%  { transform: rotate(4deg);   }
  60%  { transform: rotate(-3deg);  }
  80%  { transform: rotate(3deg);   }
  100% { transform: rotate(0deg);   }
}

@keyframes envelope-wiggle {
  0%, 100% { transform: rotate(0deg);  }
  25%       { transform: rotate(-6deg); }
  75%       { transform: rotate(6deg);  }
}

@media (max-width: 480px) {
  #envelope-popup {
    transform: translate(-50%, -50%) scale(2.1);
  }

  #envelope-box {
    width: auto;
  }

  #envelope-icon {
    width: min(78vw, 240px);
  }
}

/* ── 2. BACKDROP (nền mờ khi mở thiệp) ──────── */

#card-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  /* backdrop-filter: blur(4px); */
  /* -webkit-backdrop-filter: blur(4px); */
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

#card-backdrop.visible {
  opacity: 1;
  pointer-events: auto;
}


/* ── 3. THIỆP MỜI MODAL ──────────────────────── */

#card-modal {
  position: fixed;
  inset: 0;
  z-index: 210;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px;
  pointer-events: none;
  opacity: 0;
  transform: scale(0.88) translateY(-12px);
  transition: opacity 0.22s ease, transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#card-modal.visible {
  opacity: 1;
  pointer-events: auto;
  transform: scale(1) translateY(0);
}

#card-inner {
  background: #141414;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 18px;
  overflow: hidden;
  max-width: 520px;
  width: 100%;
  max-height: 90dvh;
  display: flex;
  flex-direction: column;
  box-shadow:
    0 24px 80px rgba(0, 0, 0, 0.8),
    0 4px 16px rgba(0, 0, 0, 0.5);
  scrollbar-width: none;
}
#card-inner::-webkit-scrollbar { display: none; }

/* Ảnh thiệp */
#card-image-wrap {
  width: 100%;
  height: 100%;
  aspect-ratio: auto;
  overflow: hidden;
  background: #1e1e1e;
}

#card-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Nút Yes / No */
#card-actions {
  display: flex;
  gap: 10px;
  width: min(100%, 520px);
  margin-top: 14px;
}

.card-btn {
  flex: 1;
  position: relative;
  padding: 30px 16px 22px;   /* padding dưới nhiều hơn vì ruy băng có phần đuôi nhọn */
  border: none;
  background: url('./photos/ribbon-btn.png') center center / 100% 100% no-repeat;
  font-family: Georgia, serif;
  font-size: 15px;
  font-weight: 700;
  color: #5c2e3d;             /* màu chữ nâu hồng đậm, hợp tông ruy băng */
  cursor: pointer;
  letter-spacing: 0.5px;
  text-shadow: 0 1px 1px rgba(255,255,255,0.4);
  transition: transform 0.15s ease, filter 0.15s ease;
  min-height: 64px;
}

.card-btn:hover {
  transform: translateY(-2px) scale(1.03);
  filter: brightness(1.05);
}

.card-btn:active {
  transform: scale(0.97);
}

/* Bỏ nền trắng/xám mặc định cũ */
.btn-yes,
.btn-no {
  background-color: transparent;
  border: none;
}
/* Nút đóng (×) */
#card-close {
  position: absolute;
  top: 14px;
  right: 16px;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  font-size: 18px;
  color: rgba(255, 255, 255, 0.6);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
  z-index: 1;
}
#card-close:hover { background: rgba(255,255,255,0.18); color: #fff; }

/* card-modal cần position relative để × định vị đúng */
#card-modal { position: fixed; }

#no-modal {
  position: fixed;
  inset: 0;
  z-index: 220;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  pointer-events: none;
  opacity: 0;
  transform: scale(0.9) translateY(10px);
  transition: opacity 0.2s ease, transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#no-modal.visible {
  opacity: 1;
  pointer-events: auto;
  transform: scale(1) translateY(0);
}

#no-inner {
  position: relative;
  background: #f5e9e9;
  border: 1px solid rgba(150, 90, 90, 0.25);
  border-radius: 18px;
  padding: 32px 28px;
  max-width: 420px;
  width: 100%;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
  gap: 0;
  overflow: hidden;   /* để ảnh góc không tràn ra ngoài border-radius */
}

#no-inner::before,
#no-inner::after {
  content: '';
  position: absolute;
  width: 130px;          /* chỉnh kích thước ruy băng tuỳ ý */
  height: 130px;
  background-size: contain;
  background-repeat: no-repeat;
  pointer-events: none;   /* không chặn click vào nội dung bên dưới */
  z-index: 0;
  opacity: 0.9;
}

/* Góc trên-phải */
#no-inner::before {
  top: -3px;
  right: -35px;
  background-image: url('./photos/ribbon-corner-top-right.png');
}

/* Góc dưới-trái */
#no-inner::after {
  bottom: -3px;
  left: -5px;
  background-image: url('./photos/ribbon-corner-bottom-left.png');
}

#no-inner h2 {
  font-family: Georgia, serif;
  font-size: 20px;
  color: #6b3540;          /* nâu hồng đậm, thay cho #fff */
  margin-bottom: 4px;
  text-align: center;
}

#no-success {
  text-align: center;
  font-family: system-ui, sans-serif;
  font-size: 14px;
  color: #4ade80;
  min-height: 20px;
  margin-top: 12px;
}

#no-close {
  position: absolute;
  top: 14px;
  right: 16px;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  font-size: 18px;
  color: rgba(255, 255, 255, 0.6);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
  z-index: 2;
}
#no-close:hover {
  background: rgba(120, 60, 65, 0.22);
  color: #5c2530;
}

/* ── 4. FORM XÁC NHẬN MODAL ─────────────────── */

#form-modal {
  position: fixed;
  inset: 0;
  z-index: 220;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  pointer-events: none;
  opacity: 0;
  transform: scale(0.9) translateY(10px);
  transition: opacity 0.2s ease, transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#form-modal.visible {
  opacity: 1;
  pointer-events: auto;
  transform: scale(1) translateY(0);
}

#form-inner {
  position: relative;
  background: #f5e9e9;
  border: 1px solid rgba(150, 90, 90, 0.25);
  border-radius: 18px;
  padding: 32px 28px;
  max-width: 420px;
  width: 100%;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
  gap: 0;
  overflow: hidden;   /* để ảnh góc không tràn ra ngoài border-radius */
}

#form-inner::before,
#form-inner::after {
  content: '';
  position: absolute;
  width: 130px;          /* chỉnh kích thước ruy băng tuỳ ý */
  height: 130px;
  background-size: contain;
  background-repeat: no-repeat;
  pointer-events: none;   /* không chặn click vào nội dung bên dưới */
  z-index: 0;
  opacity: 0.9;
}

/* Góc trên-phải */
#form-inner::before {
  top: -3px;
  right: -35px;
  background-image: url('./photos/ribbon-corner-top-right.png');
}

/* Góc dưới-trái */
#form-inner::after {
  bottom: -3px;
  left: -5px;
  background-image: url('./photos/ribbon-corner-bottom-left.png');
}

#form-inner h2 {
  font-family: Georgia, serif;
  font-size: 20px;
  color: #6b3540;          /* nâu hồng đậm, thay cho #fff */
  margin-bottom: 4px;
  text-align: center;
}

#form-inner label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-family: system-ui, sans-serif;
  font-size: 12px;
  font-weight: 600;
  color: #8a5560;               /* thay cho rgba(255,255,255,0.5) */
  letter-spacing: 0.8px;
  text-transform: uppercase;
  margin-bottom: 14px;
}

#form-inner input,
#form-inner textarea {
  background: rgba(255, 255, 255, 0.55);   /* thay cho rgba(255,255,255,0.07) */
  border: 1px solid rgba(150, 90, 90, 0.3);
  border-radius: 8px;
  padding: 10px 14px;
  color: #4a2a30;                           /* chữ nhập vào màu tối */
  font-family: system-ui, sans-serif;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s ease;
  resize: none;
}

#form-inner input::placeholder,
#form-inner textarea::placeholder {
  color: rgba(90, 50, 55, 0.4);
}

#form-inner input:focus,
#form-inner textarea:focus {
  border-color: rgba(150, 60, 70, 0.6);
}

#form-inner textarea {
  height: 80px;
}

#form-actions {
  display: flex;
  gap: 10px;
  margin-top: 4px;
}

#form-success {
  text-align: center;
  font-family: system-ui, sans-serif;
  font-size: 14px;
  color: #4ade80;
  min-height: 20px;
  margin-top: 12px;
}

#form-close {
  position: absolute;
  top: 14px;
  right: 16px;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  font-size: 18px;
  color: rgba(255, 255, 255, 0.6);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
  z-index: 2;              /* nằm trên cả ruy băng góc */
}
#form-close:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #5c2530;
}

/* Mobile adjustments */
@media (max-width: 480px) {
  #card-content { padding: 18px 18px 22px; }
  #card-title   { font-size: 18px; }
  #card-body    { font-size: 13px; }
  #form-inner   { padding: 22px 18px; }
  #form-close   {
    top: 16px;
    right: 16px;
  }
}

/* Tôn trọng người dùng tắt animation */
@media (prefers-reduced-motion: reduce) {
  #envelope-popup,
  #card-modal,
  #form-modal    { transition: none !important; }
  #envelope-icon { animation: none !important; }
  #envelope-box  { animation: none !important; }
}

#no-inner label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-family: system-ui, sans-serif;
  font-size: 12px;
  font-weight: 600;
  color: #8a5560;               /* thay cho rgba(255,255,255,0.5) */
  letter-spacing: 0.8px;
  text-transform: uppercase;
  margin-bottom: 14px;
}

#no-inner input,
#no-inner textarea {
  background: rgba(255, 255, 255, 0.55);   /* thay cho rgba(255,255,255,0.07) */
  border: 1px solid rgba(150, 90, 90, 0.3);
  border-radius: 8px;
  padding: 10px 14px;
  color: #4a2a30;                           /* chữ nhập vào màu tối */
  font-family: system-ui, sans-serif;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s ease;
  resize: none;
}

#no-inner input:placeholder,
#no-inner textarea:placeholder {
  border-color: rgba(90, 50, 55, 0.4);
}

#form-inner input:focus,
#form-inner textarea:focus {
  border-color: rgba(150, 60, 70, 0.6);
}

#form-inner textarea { height: 80px; }

#no-inner textarea {
  height: 120px;
}

#no-inner #form-actions {
  display: flex;
  gap: 10px;
  margin-top: 4px;
}

/* ── 6. POPUP KẾT QUẢ ─────────────────────── */

#result-modal {
  position: fixed;
  inset: 0;
  z-index: 230;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  pointer-events: none;
  opacity: 0;
  transform: scale(0.88) translateY(10px);
  transition: opacity 0.25s ease, transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#result-modal.visible {
  opacity: 1;
  pointer-events: auto;
  transform: scale(1) translateY(0);
}

#result-inner {
  background: #f5e9e9;
  border: 1px solid rgba(150, 90, 90, 0.25);
  border-radius: 18px;
  padding: 36px 28px 28px;
  max-width: 360px;
  width: 100%;
  text-align: center;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.4);
}

#result-icon {
  font-size: 48px;
  margin-bottom: 12px;
  animation: result-pop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes result-pop {
  0%   { transform: scale(0); }
  70%  { transform: scale(1.15); }
  100% { transform: scale(1); }
}

#result-title {
  font-family: Georgia, serif;
  font-size: 22px;
  color: #6b3540;
  margin-bottom: 8px;
}

#result-message {
  font-family: system-ui, sans-serif;
  font-size: 14px;
  color: #8a5560;
  line-height: 1.6;
  margin-bottom: 22px;
}

#result-close-btn {
  width: 100%;
  padding: 12px 16px;
  background: #6b3540;
  color: #fff;
  font-family: system-ui, sans-serif;
  font-weight: 600;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: opacity 0.15s ease;
}

#result-close-btn:hover {
  opacity: 0.88;
}

/* Biến thể màu khi lỗi (đỏ nhạt) */
#result-inner.error {
  border-color: rgba(220, 90, 90, 0.35);
}

#result-inner.error #result-title {
  color: #b8394a;
}

/* Dải băng tốt nghiệp trang trí góc popup kết quả */
#result-inner {
  position: relative;
  overflow: visible;   /* để dải băng có thể ló ra ngoài viền nếu muốn */
}

#result-inner::after {
  content: '';
  position: absolute;
  top: -1px;              /* âm để phần đầu ruy băng "vắt" qua mép trên popup */
  right: 20px;              /* vị trí ngang dọc theo mép trên — chỉnh để lệch trái/phải */
  width: 90px;
  height: 160px;
  background: url('./photos/sash.png') top center / contain no-repeat;
  pointer-events: none;
  z-index: 1;
  filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.25));
}

/* Đảm bảo nội dung chữ nằm trên dải băng, không bị che */
#result-icon,
#result-title,
#result-message,
#result-close-btn {
  position: relative;
  z-index: 2;
}

@media (max-width: 480px) {
  #result-inner::after {
    width: 66px;
    height: 118px;
    top: -16px;
    right: -12px;
  }
}