html.invitation-visible { overflow: hidden; }
.invitation {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  overflow: hidden;
  perspective: 1400px;
}
.invitation::backdrop { background: transparent; }
.envelope {
  position: absolute;
  inset: 0;
  perspective: 1400px;
  transform-style: preserve-3d;
}
.envelope-side, .envelope-bottom, .envelope-flap {
  position: absolute;
  inset: 0;
  background: #788b6c url('images/envelope-paper.png') center / 100% 100% no-repeat;
  backface-visibility: hidden;
  will-change: transform;
}
.envelope-side { display: none; }
.envelope-left { clip-path: polygon(0 0, 52% 58%, 0 100%); }
.envelope-right { clip-path: polygon(100% 0, 48% 58%, 100% 100%); }
.envelope-bottom {
  z-index: 2;
  clip-path: polygon(0 13%, 50% 70%, 100% 13%, 100% 100%, 0 100%);
  transform-origin: center bottom;
}
.envelope-flap {
  z-index: 3;
  clip-path: polygon(0 0, 100% 0, 100% 15%, 50% 71%, 0 15%);
  transform-origin: center top;
}
.wax-seal {
  position: absolute;
  z-index: 4;
  top: 69%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: clamp(100px, 11vw, 145px);
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 8px;
  border: 5px double #ffe0a4;
  border-radius: 46% 52% 47% 51%;
  background: radial-gradient(circle at 32% 22%, #e6bc7e, #b27c3f 58%, #865029);
  color: #fff7df;
  box-shadow: inset 0 0 0 6px #c7915438, inset 2px 3px 8px #fff6c24d, 1px 8px 12px #263c2473;
  cursor: pointer;
}
.wax-seal::before {
  content: '';
  position: absolute;
  inset: 10px;
  border: 1px solid #f4d197a3;
  border-radius: 50%;
}
.seal-initials { font: 500 clamp(30px, 4vw, 45px)/1 Georgia, serif; letter-spacing: -3px; text-shadow: 0 1px #7d4b25; }
.seal-initials i { font-size: .65em; padding: 0 3px; }
.seal-prompt { font: 12px/1.1 'DM Sans', sans-serif; text-transform: uppercase; letter-spacing: .18em; }
.wax-seal:hover { filter: brightness(1.08); }
.wax-seal:focus-visible { outline: 3px solid #fff3db; outline-offset: 9px; }
.invitation-glow {
  position: absolute;
  z-index: 5;
  top: 69%;
  left: 50%;
  width: 35vmax;
  height: 35vmax;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(.1);
  background: radial-gradient(circle, #fff7d973, #f6d78d26 45%, transparent 70%);
}
.invitation-sparkles { position: absolute; z-index: 6; inset: 0; pointer-events: none; }
.invitation-sparkles span {
  position: absolute;
  top: 69%;
  left: 50%;
  width: 4px;
  height: 4px;
  border-radius: 1px;
  background: #fff1ae;
  box-shadow: 0 0 8px #fff5b5;
  opacity: 0;
}
.is-opening .wax-seal { animation: seal-release .55s ease-in both; }
.is-opening .envelope-flap { animation: flap-open 1s .25s cubic-bezier(.45,0,.2,1) both; }
.is-opening .envelope { animation: envelope-away 1.1s 1.25s cubic-bezier(.5,0,.15,1) both; }
.is-opening .invitation-glow { animation: seal-glow 1.9s .1s ease-out both; }
.is-opening .invitation-sparkles span { animation: sparkle-drift 1.6s calc(.15s + var(--delay)) ease-out both; }
@keyframes seal-release {
  35% { transform: translate(-50%, -50%) scale(1.06); }
  100% { transform: translate(-50%, -35%) rotate(-9deg) scale(.88); opacity: 0; }
}
@keyframes flap-open {
  75% { opacity: 1; }
  100% { transform: rotateX(170deg); opacity: 0; }
}
@keyframes envelope-away {
  to { transform: translateY(105%); opacity: .5; }
}
@keyframes seal-glow {
  25% { opacity: .9; }
  100% { transform: translate(-50%, -50%) scale(4); opacity: 0; }
}
@keyframes sparkle-drift {
  15% { opacity: 1; }
  100% { transform: translate(var(--x), var(--y)) rotate(120deg); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .invitation * { animation: none !important; }
}
