/* invitation.css — the envelope and the invitation card (page 2).
 *
 * The envelope is a CSS placeholder (no image asset). Layering front→back:
 * flap (4) → front pocket (3) → invitation (2). The invitation sits behind the
 * opaque front pocket, so it is hidden while inside; when the envelope opens
 * the flap lifts up and the invitation rises out the top.
 */

/* Full-screen: the stage grows to fill, the countdown sits at the bottom. */
.page--invitation {
  justify-content: space-between;
  --bg: #e3d6c2;    /* invitation backgroud */
}

.invitation-stage {
  flex: 1 1 auto;
  display: flex;
  align-items: flex-end; /* envelope low, leaving room above for the card to rise */
  justify-content: center;
  width: 100%;
  padding-bottom: clamp(1rem, 4vh, 2rem);
}

/* --- envelope geometry (all derived from one width) --- */
.envelope {
  --env-w: min(88vw, 480px);
  --env-h: calc(var(--env-w) * 0.6);
  --flap-h: calc(var(--env-h) * 0.55);
  --inv-w: calc(var(--env-w) * 0.82);
  --inv-h: var(--env-h);

  --env-front: #849bcc;
  --env-flap: #6f89c1;
  --env-back: #6078b2;

  position: relative;
  width: var(--env-w);
  height: var(--env-h);
  perspective: 1400px; /* gives the flap a 3D lift */
}

/* V notch cut into the top centre of the front pocket — a transparent
 * triangle so the card (behind the front at z2) shows through. The flap
 * (z4) still covers this cut when closed. width/height are relative to
 * the front pocket's own dimensions. */
.envelope__back {
  position: absolute;
  inset: 0;
  z-index: 0;
  background: var(--env-back);
  border-radius: 0 0 8px 8px;
  box-shadow: 0 20px 45px rgba(35, 48, 59, 0.22);
}

.envelope__front {
  position: absolute;
  inset: 0;
  z-index: 2;
  background: var(--env-front);
  border-radius: 0 0 8px 8px;
  box-shadow: 0 20px 45px rgba(35, 48, 59, 0.22);
  clip-path: polygon(
    0% 0%,
    50% 45%,
    100% 0%,
    100% 100%,
    0% 100%
  );
}

/* Flap — a downward triangle that folds up when opened */
.envelope__flap {
  position: absolute;
  top: 0;
  left: 2;
  width: 100%;
  height: var(--flap-h);
  z-index: 3;
  background: var(--env-flap);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  transform-origin: top center;
  transform: rotateX(0deg);
  transition:
    transform 0.55s cubic-bezier(0.22, 1, 0.36, 1),
    z-index 0s 0.55s; /* drop behind once the lift is done */
}

/* Invitation card image — behind the front pocket, rises out when opened */
.invitation {
  position: absolute;
  left: 50%;
  top: 0;
  width: var(--inv-w);
  height: var(--inv-h);
  z-index: 1;
  border-radius: 4px;
  box-shadow: 0 12px 30px rgba(35, 48, 59, 0.18);
  opacity: 0;
}

/* Two-step animation: slide out from behind the envelope, then slide
 * down in front of it. The invitation (z5) is in front of everything
 * during both steps so the motion is clearly visible. */
@keyframes invitationReveal {
  0% {
    transform: translate(-50%, 0) scale(0.4);
    z-index: 1;
    opacity: 1;
    height: var(--inv-h);
  }
  40% {
    /* Step 1: lifted up and out of the envelope, scale up slightly */
  transform: translate(-50%, -70%) scale(0.6);
    z-index: 1;
    height: auto;
  }
  100% {
    /* Step 2: slide down in front of the envelope */
    transform: translate(-50%, -48%) scale(1.2);
    z-index: 5;
    opacity: 1;
    height: auto;
  }
}

/* --- the opened state (added by JS) --- */
.envelope.open .envelope__flap {
  transform: rotateX(180deg);
  background: var(--env-back);
  z-index: 1;
}
.envelope.open .invitation {
  animation: invitationReveal 2.2s cubic-bezier(0.22, 1, 0.36, 1) 0.5s forwards;
}

/* --- invitation typography --- */
.invitation__kicker {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 0.62rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.invitation__names {
  margin: 0.1rem 0 0;
  font-family: var(--font);
  font-weight: 400;
  font-size: clamp(1.6rem, 6vw, 2.4rem);
  letter-spacing: 0.02em;
  color: var(--ink);
}

.invitation__divider {
  width: 42px;
  height: 1px;
  margin: 0.35rem 0;
  background: var(--ink-soft);
  opacity: 0.5;
}

.invitation__line {
  margin: 0;
  font-family: var(--font);
  font-style: italic;
  font-size: clamp(0.85rem, 2.6vw, 1rem);
  color: var(--ink);
}

.invitation__date {
  margin: 0.3rem 0 0;
  font-family: var(--font-sans);
  font-size: clamp(0.75rem, 2.4vw, 0.9rem);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink);
}

.invitation__venue {
  margin: 0.15rem 0 0;
  font-family: var(--font-sans);
  font-size: clamp(0.68rem, 2.2vw, 0.82rem);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

/* Respect reduced motion: reveal in place, no flip/slide */
@media (prefers-reduced-motion: reduce) {
  .envelope__flap,
  .invitation {
    transition: none;
  }
}

body.bg-cream {
  --bg: #e3d6c2;    /* invitation backgroud */
}