.intro {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  align-content: center;
  gap: clamp(1.6rem, 5vh, 2.6rem);
  padding: 2rem 1rem;
  background: linear-gradient(180deg, #ffffff 0%, #eaf6ff 48%, #cfe6fa 100%);
  overflow: hidden;
  transition:
    opacity 0.8s ease,
    transform 0.9s cubic-bezier(0.5, 0, 0.75, 0);
}

.intro.is-leaving {
  opacity: 0;
  transform: scale(1.14);
  pointer-events: none;
}

.intro__sky {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
}

.intro__glow {
  width: 26rem;
  height: 26rem;
  max-width: 90vw;
  max-height: 90vw;
  border-radius: 50%;
  background: radial-gradient(
    circle,
    rgba(255, 255, 255, 0.95) 0%,
    rgba(207, 233, 252, 0.6) 45%,
    rgba(207, 233, 252, 0) 70%
  );
  animation: glow-pulse 5s ease-in-out infinite;
}

.intro__ring {
  position: absolute;
  width: 14rem;
  height: 14rem;
  border-radius: 50%;
  border: 1px solid rgba(63, 149, 216, 0.28);
  opacity: 0;
  animation: ring-out 4.4s ease-out infinite;
}

.intro__ring--2 {
  animation-delay: 1.8s;
}

.intro__eyebrow {
  position: relative;
  z-index: 3;
  font-family: var(--font-display);
  font-size: clamp(1.15rem, 4.6vw, 1.55rem);
  color: var(--ink);
  text-align: center;
  opacity: 0;
  animation: intro-fade-up 0.8s ease 0.35s forwards;
}

@keyframes intro-fade-up {
  from {
    opacity: 0;
    transform: translateY(0.8rem);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.is-opening .intro__eyebrow,
.is-opening .intro__open {
  opacity: 0;
  transform: translateY(-0.5rem);
  transition:
    opacity 0.45s ease,
    transform 0.45s ease;
  animation: none;
  pointer-events: none;
}

/* Envelope */

.envelope {
  position: relative;
  z-index: 2;
  width: min(17rem, 72vw);
  aspect-ratio: 3 / 2;
  perspective: 900px;
  opacity: 0;
  animation: envelope-in 0.9s cubic-bezier(0.2, 1.3, 0.4, 1) 0.1s forwards;
}

@keyframes envelope-in {
  from {
    opacity: 0;
    transform: scale(0.72) translateY(1.5rem);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.envelope::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -1.7rem;
  width: 62%;
  height: 0.9rem;
  transform: translateX(-50%);
  border-radius: 50%;
  background: rgba(63, 149, 216, 0.18);
  filter: blur(7px);
  transition: all 0.9s ease;
}

.is-opening .envelope::after {
  width: 50%;
  opacity: 0.7;
}

.envelope__back,
.envelope__front,
.envelope__flap {
  position: absolute;
  inset: 0;
}

/* Reads as the envelope's inner lining once the flap swings away, so the
   pocket's V stays visible instead of blending into a flat rectangle. */
.envelope__back {
  z-index: 1;
  border-radius: 0.9rem;
  background: linear-gradient(170deg, #a9d2ef 0%, #8bbfe6 55%, #7cb4e0 100%);
  box-shadow:
    inset 0 -14px 24px rgba(28, 84, 128, 0.22),
    0 22px 44px rgba(45, 116, 170, 0.24);
}

.envelope__card {
  position: absolute;
  z-index: 2;
  left: 6%;
  width: 88%;
  height: 88%;
  bottom: 6%;
  padding: 1.1rem 1rem;
  border-radius: 0.7rem;
  background: #ffffff;
  box-shadow: 0 10px 22px rgba(45, 116, 170, 0.2);
  display: grid;
  align-content: center;
  gap: 0.62rem;
  transition: transform 0.95s cubic-bezier(0.24, 0.9, 0.3, 1) 0.42s;
}

.envelope__card-line {
  height: 0.42rem;
  border-radius: 999px;
  background: linear-gradient(90deg, #d7ecfb, #eaf6ff);
}

.envelope__card-line.short {
  width: 58%;
}

/* Stays on its own layer: behind the pocket so it reads as sliding out of it,
   but above the flap once that has dropped away. */
.is-opening .envelope__card {
  transform: translateY(-78%) rotate(-2.5deg);
}

/* drop-shadow follows the clip-path, so the V seam keeps a soft edge no matter
   what sits behind it. A box-shadow would trace the unclipped rectangle. */
.envelope__front {
  z-index: 3;
  border-radius: 0.9rem;
  background: linear-gradient(200deg, #f8fcff, #d8ecfc);
  clip-path: polygon(0 100%, 0 26%, 50% 66%, 100% 26%, 100% 100%);
  filter: drop-shadow(0 -2px 3px rgba(28, 84, 128, 0.28));
}

.envelope__flap {
  z-index: 4;
  height: 66%;
  border-radius: 0.9rem 0.9rem 0 0;
  background: linear-gradient(180deg, #e6f4ff, #c2dff6);
  /* Mirrors the pocket's V so the closed envelope has no gap along the seam.
     39.4% is the pocket's 26% shoulder expressed in this element's height. */
  clip-path: polygon(0 0, 100% 0, 100% 39.4%, 50% 100%, 0 39.4%);
  transform-origin: top center;
  transform: rotateX(0deg);
  transition:
    transform 0.85s cubic-bezier(0.62, -0.16, 0.35, 1.12),
    z-index 0s linear 0.42s;
}

/* Drops behind the envelope halfway through the swing, so the card that
   follows it out is never covered. */
.is-opening .envelope__flap {
  z-index: 0;
  transform: rotateX(-180deg);
}

.envelope__seal {
  position: absolute;
  z-index: 6;
  left: 50%;
  top: 52%;
  width: 2.4rem;
  height: 2.4rem;
  margin: -1.2rem 0 0 -1.2rem;
  border-radius: 50%;
  background: radial-gradient(circle at 34% 30%, #ffffff, #9ecdf0 70%);
  box-shadow: 0 4px 10px rgba(45, 116, 170, 0.3);
  transition:
    transform 0.65s cubic-bezier(0.3, 1.4, 0.5, 1),
    opacity 0.5s ease;
}

.is-opening .envelope__seal {
  transform: translateY(-1.6rem) scale(0.35) rotate(42deg);
  opacity: 0;
}

/* Open button */

.intro__open {
  position: relative;
  z-index: 3;
  padding: 0.85rem 2.6rem;
  border-radius: 999px;
  font-size: 1.02rem;
  font-weight: 700;
  color: var(--white);
  background: linear-gradient(160deg, #57a8e2, #2b7cbb);
  box-shadow: 0 12px 26px rgba(45, 116, 170, 0.34);
  opacity: 0;
  animation:
    intro-fade-up 0.7s ease 0.85s forwards,
    open-pulse 2.6s ease-in-out 1.8s infinite;
  transition:
    transform 0.25s ease,
    box-shadow 0.25s ease;
}

.intro__open:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 32px rgba(45, 116, 170, 0.42);
}

.intro__open:active {
  transform: translateY(1px);
}

@keyframes open-pulse {
  0%,
  100% {
    box-shadow: 0 12px 26px rgba(45, 116, 170, 0.34);
  }
  50% {
    box-shadow:
      0 12px 26px rgba(45, 116, 170, 0.34),
      0 0 0 0.7rem rgba(63, 149, 216, 0.12);
  }
}

@media (prefers-reduced-motion: reduce) {
  .intro,
  .intro * {
    animation: none !important;
    transition: none !important;
  }

  .envelope,
  .intro__eyebrow,
  .intro__open {
    opacity: 1;
  }
}
