/* The invitation suite in its envelope: her olive envelope with the pine liner, closed with a wax seal.
   envelope.js positions the envelope (px) and the cards; everything inside the envelope is in % of its body
   (the concept's rows 766–1633, 1240 × 867). Layers, back to front (z-index):
   cards already read (10–19), docked back and flap (20), cards inside/out/moving (30–39), front pocket (40),
   cover with ambient dust (41), opening envelope (50), addressee (55), reading hint (60), confetti (80), nav (90).
   The cover and opening envelope stay in those layers and hand off through opacity only.
   Cards change layer only through z-index, set by envelope.js while nothing moves. */
.env-scene {
  position: fixed; inset: 0; z-index: 50; overflow: hidden;
  background:
    url("paper-grain.webp") repeat,
    url("forest-atmosphere.webp") center / cover no-repeat,
    #ece5d8;
  touch-action: none; user-select: none; -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.env-intro {
  position: absolute; z-index: 55; left: 16px; right: 16px; text-align: center;
  color: #6b1f2c; pointer-events: none;
}
.env-intro-kicker, .env-intro-date { margin: 0; text-transform: uppercase; font-size: 11px; letter-spacing: .24em; }
.env-intro h1 {
  margin: 10px 0 12px; font: 500 clamp(38px, 11.2vw, 58px)/1.12 "Cormorant Garamond", serif;
  letter-spacing: -.015em;
}
.env-amp { display: inline-block; margin: 0 .15em; font: 400 .92em/1 "Pinyon Script", cursive; }
.env-intro-date { letter-spacing: .18em; }
.env-garden { position: absolute; inset: 0; z-index: 1; pointer-events: none; overflow: hidden; }
.env-fern {
  position: absolute; width: clamp(140px, 20vw, 270px); bottom: -36px; left: -38px;
  transform-origin: 8% 96%; animation: env-fern-sway 6.8s ease-in-out infinite alternate;
}
.env-fern-right { position: absolute; inset: 0; transform: scaleX(-1); }
.env-fern-right .env-fern { width: clamp(120px, 17vw, 230px); bottom: -46px; animation-duration: 7.7s; animation-delay: -2.8s; }
.env-fern.env-fern-fine { width: clamp(90px, 13vw, 180px); left: -48px; bottom: 18px; opacity: .8; animation-duration: 6.3s; animation-delay: -2s; }
.env-fern-right .env-fern-fine { bottom: 4px; animation-duration: 7.4s; animation-delay: -4s; }
@keyframes env-fern-sway { from { transform: rotate(-4deg); } to { transform: translateY(-3px) rotate(4.2deg); } }
/* Hanging greenery in the top corners. Layers: .env-canopy (pointer parallax, GSAP) > .env-canopy-drop (lowers in
   once; GSAP rustle on opening) > .env-strand (its own sway, pivoting where its stem meets the top edge) > img.
   Each strand image is --w wide with its stem at the top centre, so `left` places the stem at left + --w / 2.
   The mirror and the drop use the individual scale/translate properties so they never fight GSAP's transform. */
.env-canopy { --w: clamp(190px, 25vw, 360px); position: absolute; top: 0; left: 0; width: var(--w); height: 100%; }
.env-canopy-right { left: auto; right: 0; scale: -1 1; }
.env-canopy-drop { position: absolute; inset: 0; animation: env-canopy-drop 2.6s cubic-bezier(.2, .75, .25, 1) .35s both; }
.env-strand {
  position: absolute; top: -14px; width: var(--w); transform-origin: 50% 0;
  animation: env-strand-sway 7.2s ease-in-out infinite alternate;
}
.env-strand img { display: block; width: 100%; }
.env-strand-1 { left: calc(var(--w) * -.32); }
.env-strand-3 { left: calc(var(--w) * .1); top: -24px; width: calc(var(--w) * .9); opacity: .95; animation-duration: 6.1s; animation-delay: -2.4s; }
.env-strand-2 { left: calc(var(--w) * .49); top: -30px; width: calc(var(--w) * .78); opacity: .9; animation-duration: 8.3s; animation-delay: -5s; }
.env-canopy-right .env-strand-1 { animation-delay: -3.1s; }
.env-canopy-right .env-strand-2 { left: calc(var(--w) * .55); width: calc(var(--w) * .66); }
/* Morning light: a warm band crosses the leaves now and then, clipped to the art. */
.env-strand::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(170deg, transparent 38%, rgba(255, 232, 178, .3) 50%, transparent 62%) 0 130% / 100% 300% no-repeat;
  -webkit-mask: var(--canopy-art) 0 0 / 100% 100% no-repeat; mask: var(--canopy-art) 0 0 / 100% 100% no-repeat;
  animation: env-canopy-light 12s ease-in-out 3s infinite;
}
.env-strand-2::after { animation-delay: 3.5s; }
.env-strand-3::after { animation-delay: 4.1s; }
@keyframes env-canopy-drop { from { translate: 0 -55%; opacity: 0; } 35% { opacity: 1; } to { translate: 0 0; opacity: 1; } }
@keyframes env-strand-sway { from { transform: rotate(-1.8deg); } to { transform: rotate(2deg); } }
@keyframes env-canopy-light { 0% { background-position: 0 130%; } 40%, 100% { background-position: 0 -30%; } }
@media (max-width: 600px) { .env-canopy { --w: min(40vw, 170px); } }
/* Needles and small leaves shaken loose on opening (envelope.js rustle()). */
.env-falling {
  position: absolute; width: 1.5px; height: 13px; border-radius: 1px; pointer-events: none;
  background: linear-gradient(#8a8a4a, #5c6b34);
}
.env-falling-leaf { width: 7px; height: 11px; border-radius: 0 70% 0 70%; background: linear-gradient(135deg, #8f9a55, #5d6e36); }
.is-compact .env-intro h1 { font-size: 36px; }
@media (max-height: 460px) {
  .is-compact .env-intro h1 { margin: 6px 0; font-size: 32px; }
}
.env-for {
  position: absolute; left: 0; right: 0; margin: 0; padding: 0 16px; z-index: 55;
  font-family: "Pinyon Script", cursive; color: #6b1f2c;
  font-size: clamp(30px, 8.4vw, 46px); line-height: 1.15; text-align: center;
}
.env-live { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

/* Ambient gold dust, and the particle layer for crumbs and sparkles. */
.env-dust, .env-fx { position: absolute; inset: 0; pointer-events: none; }
.env-dust { z-index: 4; }
.env-fx { position: fixed; z-index: 80; }
.env-confetti { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.env-dust i {
  position: absolute; border-radius: 50%;
  background: radial-gradient(circle, #fff6dc 0, #e2c27e 45%, rgba(214, 178, 106, 0) 72%);
}
/* ---------- the envelope ---------- */
.env, .env-landed { position: absolute; aspect-ratio: 1240 / 867; }
.env { z-index: 50; perspective: 1800px; cursor: pointer; transform-origin: 0 0; will-change: transform, opacity; }
.env-landed { z-index: 20; pointer-events: none; }
.env:focus-visible { outline: 2px solid #6b1f2c; outline-offset: 8px; border-radius: 6px; }
.env-shadow, .env-back, .env-front, .env-flap { position: absolute; left: 0; width: 100%; }
.env-shadow {
  inset: 4% 3% -4% 3%; width: auto; border-radius: 4%; background: rgba(50, 40, 20, .36); filter: blur(16px);
  will-change: transform, opacity;   /* its own layer: the idle float composites the blur instead of repainting it */
}
.env-back, .env-front { top: 0; height: 100%; display: block; pointer-events: none; }
.env-back { z-index: 1; }
.env-front { z-index: 3; }
.env-trace { position: absolute; z-index: 3; opacity: 0; pointer-events: none; background-repeat: no-repeat; will-change: opacity; }
.env-pocket { position: fixed; z-index: 40; pointer-events: none; }
/* Keep the docked scene's stacking order fixed beneath the cover. Only the opening envelope sits above it.
   Decoding and will-change are preparation hints, not a guarantee that Safari rasterizes occluded cards. */
.env-cover { position: absolute; inset: 0; z-index: 41; pointer-events: none; background: inherit; will-change: opacity; }

/* Cards: each is a child of the scene for good. envelope.js sizes every card's box to the reading spot and moves
   it by transform (about its bottom centre) and z-index only. Hidden until the envelope has opened and docked. */
.env-card {
  position: absolute; margin: 0; transform-origin: 50% 100%;
  /* Fallback shadow for a card without baked artwork; baked cards carry their own (below). */
  filter: drop-shadow(0 10px 14px rgba(40, 28, 16, .32)) drop-shadow(0 2px 3px rgba(40, 28, 16, .24));
  will-change: transform, opacity;                          /* its own GPU layer: moving it never repaints the SVG */
}
.env-card > * { display: block; width: 100%; height: 100%; }
.env-card.has-baked-shadow { filter: none; }
.env-card.has-baked-shadow > svg { overflow: visible; }
.env-card.in-deck { cursor: pointer; }

/* Top flap: hinged on the envelope's top edge. Open = 0deg (liner showing), closed = 180deg. */
.env-flap {
  z-index: 4; top: -72.2%; height: 72.43%;
  transform-origin: 50% 99.68%; transform-style: preserve-3d; will-change: transform;
  transform: rotateX(180deg);
}
.env-flap > * { position: absolute; inset: 0; width: 100%; height: 100%; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.env-flap-out { transform: rotateX(180deg); overflow: visible; }
.env-flap-paper { position: absolute; inset: 0; width: 100%; height: 100%; }
.env-landed > .env-flap { transform: none; transform-style: flat; will-change: auto; }

/* ---------- the wax seal (on the flap's point; 260 of 1240 wide, centred at 618, 530) ---------- */
.env-seal { position: absolute; z-index: 5; left: 39.35%; top: 46.14%; width: 20.97%; aspect-ratio: 1; will-change: transform, opacity; }
.env-seal-face { position: absolute; inset: 0; width: 100%; height: 100%; display: block; pointer-events: none; }
/* A slow band of light across the wax every few seconds. */
.env-glint { position: absolute; inset: 7%; border-radius: 50%; overflow: hidden; pointer-events: none; }
.env-glint::before {
  content: ""; position: absolute; top: -20%; bottom: -20%; left: -60%; width: 38%;
  background: linear-gradient(90deg, transparent, rgba(255, 236, 214, .5), transparent);
  transform: skewX(-18deg); animation: env-glint 6s ease-in-out 1.2s infinite;
}
@keyframes env-glint { 0%, 55% { transform: translateX(0) skewX(-18deg); } 85%, 100% { transform: translateX(490%) skewX(-18deg); } }
/* A quiet breath of light around the wax, with no extra moving artwork. */
.env-seal-halo {
  position: absolute; inset: 6%; border-radius: 50%; pointer-events: none;
  border: 1px solid rgba(201, 164, 96, .6); opacity: .2;
  animation: env-seal-halo 3.6s ease-in-out infinite;
}
@keyframes env-seal-halo { 50% { transform: scale(1.15); opacity: .65; } }
.env-seal.is-opening .env-seal-halo, .env-seal.is-opening .env-glint { opacity: 0; }
.env-seal.is-opening .env-seal-halo, .env-seal.is-opening .env-glint::before { animation-play-state: paused; }

/* ---------- words on the envelope ---------- */
.env-hint {
  position: absolute; left: 0; width: 100%; z-index: 6; top: 107%; margin: 0; text-align: center; pointer-events: none;
  font-family: "Cormorant Garamond", serif; font-weight: 600; text-transform: uppercase;
  letter-spacing: .32em; font-size: 12px; color: #7d6a5a;
  animation: env-breathe 2.8s ease-in-out infinite;
}
@keyframes env-breathe { 50% { opacity: .45; } }
.env-read-hint {
  position: fixed; z-index: 60; top: auto; bottom: calc(68px + env(safe-area-inset-bottom, 0px));
  color: #6d5b46; opacity: 0; animation: none; letter-spacing: .2em; font-size: 11px;
}
.env-nav {
  position: fixed; z-index: 90; left: 0; width: 100%;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px)); display: flex;
  align-items: center; justify-content: center; gap: 14px; opacity: 0;
}
.env-dots { display: flex; gap: 8px; padding: 7px 10px; border-radius: 99px; background: rgba(52, 57, 24, .82); }
.env-dots i {
  width: 6px; height: 6px; border-radius: 50%; background: rgba(239, 230, 200, .4);
  transition: background .4s, transform .4s;
}
.env-dots i.is-on { background: #e6cf98; transform: scale(1.35); box-shadow: 0 0 6px rgba(240, 210, 140, .7); }
.env-step {
  width: 44px; height: 44px; border-radius: 50%; border: 1px solid rgba(239, 230, 200, .45); padding: 0;
  background: rgba(52, 57, 24, .82); color: #efe6c8; box-shadow: 0 2px 6px rgba(20, 22, 6, .3); font: 400 22px/1 "Cormorant Garamond", serif; cursor: pointer;
  display: grid; place-items: center; transition: opacity .3s, background .3s, transform .12s;
}
.env-finish-label { display: none; }
.env-step.is-finish > .ui-icon { display: none; }
.env-step.is-finish > .env-finish-label { display: inline; }
@media (hover: hover) { .env-step:hover { background: rgba(40, 44, 16, .95); } }   /* hover sticks on touch screens */
.env-step:active:not(:disabled) { transform: scale(.92); }
.env-step:focus-visible { outline: 2px solid #e6cf98; outline-offset: 2px; }
.env-step:disabled { opacity: .25; cursor: default; }
/* Last card: › becomes a "Continue" pill that leads on to the page. */
.env-step.is-finish {
  width: auto; padding: 0 20px 1px; border-radius: 99px; border-color: rgba(230, 207, 152, .8);
  font: 600 12px/1 "Cormorant Garamond", serif; letter-spacing: .24em; text-transform: uppercase;
  background: #6b1f2c; color: #f6ead0;
}
@media (hover: hover) { .env-step.is-finish:hover { background: #551824; } }

@media (prefers-reduced-motion: reduce) {
  .env-glint::before, .env-seal-halo, .env-hint, .env-fern, .env-canopy-drop, .env-strand, .env-strand::after { animation: none; }
}
