@import url('https://fonts.googleapis.com/css2?family=Be+Vietnam+Pro:ital,wght@0,300;0,400;0,500;0,600;0,700;1,400&family=EB+Garamond:ital,wght@0,400;0,500;0,600;0,700;0,800;1,400;1,600&family=Lora:ital,wght@0,400;0,500;0,600;0,700;1,400;1,600&display=swap');

:root {
  /* HUST Official Red Palette (Đại học Bách Khoa Hà Nội) */
  --hust-red-primary: #C41E3A;
  --hust-red-deep: #990000;
  --hust-crimson: #881337;
  --hust-ruby: #B91C1C;
  --hust-dark: #3B0711;
  --hust-obsidian: #0A0406;

  /* Imperial Gold Accents */
  --gold-primary: #D4AF37;
  --gold-light: #F7E7CE;
  --gold-dark: #996515;
  --gold-champagne: #F3E5AB;
  --gold-shimmer: linear-gradient(135deg, #BF953F 0%, #FCF6BA 25%, #B38728 50%, #FBF5B7 75%, #AA771C 100%);
  --gold-foil: linear-gradient(90deg, #d4af37 0%, #fff2b2 30%, #d4af37 60%, #aa771c 100%);
}

/* Strict Zero-Scroll Single-Screen Viewport Constraints */
*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  width: 100%;
  height: 100%;
  height: 100vh;
  height: 100dvh;
  max-height: 100vh;
  max-height: 100dvh;
  margin: 0;
  padding: 0;
  overflow: hidden !important;
  background-color: var(--hust-obsidian);
  color: #F3E5AB;
  font-family: 'Be Vietnam Pro', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  user-select: none;
  -webkit-font-smoothing: antialiased;
}

/* Prestigious Academic Typography Utility Classes with Native Vietnamese Support */
.font-garamond { font-family: 'EB Garamond', 'Lora', 'Times New Roman', Times, serif; }
.font-lora { font-family: 'Lora', 'EB Garamond', 'Times New Roman', Times, serif; }
.font-vietnam { font-family: 'Be Vietnam Pro', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif; }

/* Legacy Compatibility Aliases */
.font-cinzel { font-family: 'EB Garamond', 'Lora', 'Times New Roman', Times, serif; }
.font-cormorant { font-family: 'Lora', 'EB Garamond', 'Times New Roman', Times, serif; }
.font-playfair { font-family: 'EB Garamond', 'Lora', 'Times New Roman', Times, serif; }
.font-montserrat { font-family: 'Be Vietnam Pro', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif; }

/* Metallic Red & Gold Shimmer Text */
.text-gold-gradient {
  background: var(--gold-shimmer);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-size: 200% auto;
  animation: shineGold 6s linear infinite;
}

@keyframes shineGold {
  to { background-position: 200% center; }
}

/* Campus Photo Background Styling */
#campus-bg {
  background-size: cover;
  background-position: center center;
  background-repeat: no-repeat;
}

/* 3D Envelope Wrapper */
.envelope-wrapper {
  perspective: 1200px;
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: all 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.envelope-container {
  width: 500px;
  max-width: 90vw;
  height: 330px;
  position: relative;
  background: #140609;
  border-radius: 8px;
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.95), 0 0 45px rgba(196, 30, 58, 0.35), 0 0 20px rgba(212, 175, 55, 0.2);
  transform-style: preserve-3d;
  cursor: pointer;
  transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.5s ease;
}

.envelope-container:hover {
  transform: translateY(-4px) scale(1.015);
  box-shadow: 0 35px 80px rgba(0, 0, 0, 0.98), 0 0 55px rgba(196, 30, 58, 0.5), 0 0 30px rgba(212, 175, 55, 0.35);
}

/* 3D Envelope Flaps */
.envelope-flap-top {
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  border-left: 250px solid transparent;
  border-right: 250px solid transparent;
  border-top: 180px solid #28080F;
  transform-origin: top center;
  transition: transform 0.9s cubic-bezier(0.77, 0, 0.175, 1), z-index 0.2s ease;
  z-index: 10;
  filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.75));
}

.envelope-flap-left {
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  border-top: 165px solid transparent;
  border-bottom: 165px solid transparent;
  border-left: 250px solid #1A0508;
  z-index: 6;
}

.envelope-flap-right {
  position: absolute;
  top: 0;
  right: 0;
  width: 0;
  height: 0;
  border-top: 165px solid transparent;
  border-bottom: 165px solid transparent;
  border-right: 250px solid #1A0508;
  z-index: 6;
}

.envelope-flap-bottom {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0;
  height: 0;
  border-left: 250px solid transparent;
  border-right: 250px solid transparent;
  border-bottom: 185px solid #20060B;
  z-index: 7;
}

@media (max-width: 555px) {
  .envelope-container {
    width: 92vw;
    height: 290px;
  }
  .envelope-flap-top {
    border-left-width: 46vw;
    border-right-width: 46vw;
    border-top-width: 155px;
  }
  .envelope-flap-left {
    border-top-width: 145px;
    border-bottom-width: 145px;
    border-left-width: 46vw;
  }
  .envelope-flap-right {
    border-top-width: 145px;
    border-bottom-width: 145px;
    border-right-width: 46vw;
  }
  .envelope-flap-bottom {
    border-left-width: 46vw;
    border-right-width: 46vw;
    border-bottom-width: 160px;
  }
  .wax-seal {
    top: 145px;
  }
  .wax-ribbon {
    top: 175px;
  }
}

/* Wax Seal with HUST Ruby & Gold */
.wax-seal {
  position: absolute;
  top: 160px;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 84px;
  height: 84px;
  background: radial-gradient(circle at 35% 35%, #DC2626 0%, #C41E3A 40%, #990000 70%, #4C0519 100%);
  border-radius: 50%;
  z-index: 25;
  box-shadow: 0 10px 30px rgba(0,0,0,0.85), 0 0 30px rgba(196, 30, 58, 0.75), inset 0 2px 4px rgba(255,255,255,0.4), inset 0 -3px 6px rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.3s ease, opacity 0.5s ease;
  animation: sealPulse 2.8s infinite ease-in-out;
}

@keyframes sealPulse {
  0%, 100% {
    transform: translate(-50%, -50%) scale(1);
    box-shadow: 0 10px 30px rgba(0,0,0,0.85), 0 0 25px rgba(196, 30, 58, 0.65);
  }
  50% {
    transform: translate(-50%, -50%) scale(1.06);
    box-shadow: 0 14px 38px rgba(0,0,0,0.95), 0 0 40px rgba(212, 175, 55, 0.6), 0 0 35px rgba(196, 30, 58, 0.85);
  }
}

.wax-seal-inner {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  border: 1.5px dashed rgba(212, 175, 55, 0.85);
  background: radial-gradient(circle, #25060B 0%, #120204 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 0 12px rgba(0, 0, 0, 0.9), 0 0 6px rgba(212, 175, 55, 0.35);
}

/* Ribbons beneath wax seal */
.wax-ribbon {
  position: absolute;
  top: 195px;
  left: 50%;
  transform: translateX(-50%);
  width: 32px;
  height: 65px;
  z-index: 12;
  pointer-events: none;
  transition: opacity 0.5s ease;
}
.wax-ribbon::before, .wax-ribbon::after {
  content: '';
  position: absolute;
  width: 13px;
  height: 55px;
  background: linear-gradient(180deg, #D4AF37 0%, #C41E3A 60%, #4C0519 100%);
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 80%, 0 100%);
  box-shadow: 0 4px 10px rgba(0,0,0,0.6);
}
.wax-ribbon::before {
  left: 2px;
  transform: rotate(-14deg);
}
.wax-ribbon::after {
  right: 2px;
  transform: rotate(14deg);
}

/* Opened Envelope State */
.envelope-container.is-opened .envelope-flap-top {
  transform: rotateX(180deg);
  z-index: 1;
}

.envelope-container.is-opened .wax-seal,
.envelope-container.is-opened .wax-ribbon,
.envelope-container.is-opened .open-prompt {
  opacity: 0;
  pointer-events: none;
}

/* Luxury Invitation Card (Focal Presentation) */
.invitation-card-container {
  width: 92vw;
  max-width: 530px;
  max-height: 92vh;
  max-height: 92dvh;
  position: absolute;
  background: radial-gradient(120% 120% at 50% 0%, rgba(38, 11, 16, 0.97) 0%, rgba(14, 5, 8, 0.99) 100%);
  border: 1.5px solid rgba(212, 175, 55, 0.55);
  border-radius: 14px;
  box-shadow: 0 25px 70px rgba(0, 0, 0, 0.95), 0 0 40px rgba(196, 30, 58, 0.35), 0 0 25px rgba(212, 175, 55, 0.2);
  outline: 1px solid rgba(212, 175, 55, 0.25);
  outline-offset: -7px;
  overflow: hidden;
  transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.6s ease;
  transform-style: preserve-3d;
  will-change: transform;
}

@media (max-height: 700px) {
  .invitation-card-container {
    max-height: 96vh;
    max-height: 96dvh;
  }
}

/* Crisp rendering for high-resolution downscaled PNG emblem */
img[src*="hust-logo.png"] {
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
}

/* Card Decorative Corner Accents */
.card-corner {
  position: absolute;
  width: 22px;
  height: 22px;
  pointer-events: none;
  z-index: 5;
}
.card-corner-tl { top: 12px; left: 12px; border-top: 2px solid #D4AF37; border-left: 2px solid #D4AF37; }
.card-corner-tr { top: 12px; right: 12px; border-top: 2px solid #D4AF37; border-right: 2px solid #D4AF37; }
.card-corner-bl { bottom: 12px; left: 12px; border-bottom: 2px solid #D4AF37; border-left: 2px solid #D4AF37; }
.card-corner-br { bottom: 12px; right: 12px; border-bottom: 2px solid #D4AF37; border-right: 2px solid #D4AF37; }

/* Subtle Gold Watermark in Card Background */
.card-watermark {
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle at 50% 50%, rgba(212, 175, 55, 0.04) 0%, transparent 70%);
  pointer-events: none;
}

/* Confetti canvas */
#confetti-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 60;
}
