/* Opening sequence: sealed envelope → seal lifts → flap opens → invite card rises → fades into the hero.
   Only shown when <html> has .intro-playing (set inline in <head>). ~4.4s, tap or any key to skip. */

.intro { display: none; }

.intro-playing { overflow: hidden; }
.intro-playing .intro {
  display: grid; place-items: center;
  position: fixed; inset: 0; z-index: 200;
  background:
    radial-gradient(120% 80% at 50% 45%, #FCFBF7 0%, #F1EADF 100%);
  animation: intro-out .8s 3.7s cubic-bezier(.4, 0, .2, 1) forwards;
  cursor: pointer;
}
/* Hold the hero's own entrance until the envelope has gone */
.intro-playing .hero__img,
.intro-playing .hero__content { animation-play-state: paused; }

.intro.is-skipping { animation: intro-out .45s ease forwards !important; }

.intro__stage {
  --w: min(84vw, 560px);
  position: relative; width: var(--w); aspect-ratio: 1.5;
  perspective: 1400px;
  container-type: inline-size;
  animation: env-in .9s cubic-bezier(.2, .7, .2, 1) both;
}

/* Envelope parts share one paper colour so it reads as a single object */
.env__back, .env__front, .env__flap { position: absolute; inset: 0; }
.env__back {
  background: #E9DFD1;
  border-radius: 3px;
  box-shadow: 0 30px 60px -30px rgba(45, 34, 26, .45), 0 2px 6px rgba(45, 34, 26, .08);
  animation: env-away .9s 3.05s cubic-bezier(.5, 0, .75, 0) forwards;
}
/* Terracotta liner, seen through the open envelope and on the inside of the flap */
.env__back::after, .env__flap::after {
  content: "";
  position: absolute;
  background:
    repeating-linear-gradient(135deg, rgba(255, 236, 220, .07) 0 1px, transparent 1px 7px),
    linear-gradient(to bottom, #8F4029, #A5543A);
}
.env__back::after { inset: 4% 4% 30% 4%; border-radius: 2px; }
.env__front {
  z-index: 3;
  background:
    linear-gradient(to top right, transparent calc(50% - .5px), rgba(45, 34, 26, .08) 50%, transparent calc(50% + .5px)) left / 50% 100% no-repeat,
    linear-gradient(to top left, transparent calc(50% - .5px), rgba(45, 34, 26, .08) 50%, transparent calc(50% + .5px)) right / 50% 100% no-repeat,
    #F2EBE0;
  clip-path: polygon(0 0, 50% 54%, 100% 0, 100% 100%, 0 100%);
  border-radius: 0 0 3px 3px;
  animation: env-away .9s 3.05s cubic-bezier(.5, 0, .75, 0) forwards;
}
.env__flap {
  z-index: 4;
  height: 60%;
  transform-origin: 50% 0;
  transform-style: preserve-3d;
  animation: flap-open .85s 1.25s cubic-bezier(.6, 0, .25, 1) forwards, env-away .9s 3.05s cubic-bezier(.5, 0, .75, 0) forwards;
}
.env__flap::after {
  inset: 0; z-index: 1;
  clip-path: polygon(4% 0, 96% 0, 50% 92%);
  /* Swap to the liner exactly as the flap passes vertical, so its inside shows once open */
  opacity: 0;
  animation: liner-show .85s 1.25s linear forwards;
}
.env__flap::before {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(to bottom, #EFE6DA, #E6DACA);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  filter: drop-shadow(0 2px 2px rgba(45, 34, 26, .12));
}

/* Wax seal sits on the flap's point */
.env__seal {
  position: absolute; left: 50%; top: 100%;
  width: 17cqw; aspect-ratio: 1; margin: -8.5cqw 0 0 -8.5cqw;
  border-radius: 50%;
  display: grid; place-items: center;
  background:
    radial-gradient(circle at 35% 30%, #B8644A 0%, #9A4A30 45%, #6E2F1C 100%);
  box-shadow:
    inset 0 0 0 .9cqw rgba(0, 0, 0, .12),
    inset 0 0 0 1.6cqw rgba(255, 255, 255, .06),
    0 3px 8px rgba(45, 34, 26, .35);
  animation: seal-lift .55s .85s cubic-bezier(.4, 0, .2, 1) forwards;
}
.env__seal span {
  font-family: var(--display); color: #F3E6DA; font-size: 4.6cqw; letter-spacing: .04em;
  text-shadow: 0 -1px 0 rgba(0, 0, 0, .25);
}
.env__seal i { font-style: normal; font-size: .8em; margin: 0 .05em; }

/* The invitation itself */
.env__card {
  position: absolute; z-index: 2;
  left: 6%; right: 6%; top: 13%; height: 84%;
  background: #FCFBF7;
  border-radius: 2px;
  box-shadow: 0 10px 30px -12px rgba(45, 34, 26, .35);
  display: grid; place-items: center;
  animation:
    card-rise 1s 2s cubic-bezier(.2, .7, .2, 1) forwards,
    card-present .9s 3.05s cubic-bezier(.5, 0, .2, 1) forwards;
}
.env__card-inner {
  position: absolute; inset: 4cqw;
  border: 1px solid rgba(130, 113, 109, .45);
  display: grid; place-content: center; text-align: center; gap: 1.4cqw;
  color: var(--ink);
}
.env__card p { margin: 0; }
.env__kicker, .env__place {
  font-family: var(--display); font-size: 2.5cqw; letter-spacing: .32em; text-transform: uppercase; color: var(--taupe);
}
.env__names { font-family: var(--display); font-size: 9cqw; line-height: 1.05; }
.env__names span { font-size: .75em; color: var(--clay); }
.env__date { font-family: var(--display); font-size: 3.6cqw; letter-spacing: .18em; margin-bottom: 1cqw !important; }

.intro__skip {
  position: absolute; bottom: max(24px, env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%);
  background: none; border: 0; padding: 12px 20px; cursor: pointer;
  font-family: var(--display); font-size: .8rem; letter-spacing: .3em; text-transform: uppercase; color: var(--taupe);
  opacity: 0; animation: fade-in .6s 1s forwards;
}

@keyframes env-in {
  from { opacity: 0; transform: translateY(28px) scale(.96); }
  to { opacity: 1; transform: none; }
}
@keyframes seal-lift {
  40% { transform: scale(1.08); }
  to { transform: scale(.6) translateY(-10%); opacity: 0; }
}
@keyframes flap-open {
  0% { transform: rotateX(0); z-index: 4; }
  49% { z-index: 4; }
  50% { z-index: 1; }
  100% { transform: rotateX(180deg); z-index: 1; }
}
@keyframes card-rise {
  to { transform: translateY(-46%); }
}
@keyframes card-present {
  from { transform: translateY(-46%); }
  to { transform: translateY(-6%) scale(1.12); box-shadow: 0 30px 70px -20px rgba(45, 34, 26, .4); }
}
/* uses the standalone translate property so it composes with the flap's rotateX instead of replacing it */
@keyframes env-away {
  to { translate: 0 70%; opacity: 0; }
}
@keyframes liner-show {
  0%, 49.9% { opacity: 0; }
  50%, 100% { opacity: 1; }
}
@keyframes fade-in { to { opacity: 1; } }
@keyframes intro-out {
  to { opacity: 0; visibility: hidden; }
}
