
/* ========================================================
   THANH MAI ENVELOPE OPENING ANIMATION (CHUẨN MẪU THÙY LINH)
   ======================================================== */
.sh-opening {
  position: fixed;
  inset: 0;
  z-index: 99999;
  overflow: hidden;
  cursor: pointer;
  background: radial-gradient(circle at center, #FAF7F2 0%, #E8E2D5 100%);
  color: #1C1814;
  font-family: 'Be Vietnam Pro', sans-serif;
  transition: opacity 1.05s cubic-bezier(0.4, 0, 0.2, 1), visibility 1.05s ease;
  --env-heart: url('assets/envelope/heart-rose.webp');
}

.sh-opening.is-done {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.sh-frame {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

@media (min-width: 768px) {
  .sh-frame {
    position: relative;
    width: min(480px, 100vw);
    height: 100vh;
    margin: 0 auto;
    box-shadow: 0 0 60px rgba(45, 30, 20, 0.18);
  }
}

.sh-opening--envelope {
  background:
    radial-gradient(78% 54% at 50% 42%, rgba(255, 255, 255, 0.94), rgba(245, 239, 228, 0.58) 58%, rgba(235, 224, 205, 0.48) 100%),
    radial-gradient(110% 92% at 50% 78%, rgba(107, 31, 39, 0.075), rgba(245, 239, 228, 0) 66%),
    linear-gradient(180deg, #FBF7EF 0%, #F5EFE4 58%, #EDE2D1 100%);
  color: #1C1814;
}
.sh-opening--envelope.is-done { transition-duration: 1.05s; }
@media (min-width: 768px) {
  /* Below 768 .sh-frame is full-bleed (inset:0) and completely covers this
     background, so deepening it here is invisible on mobile — it only shows
     in the >=768 gutter around the centred card. Was ~11 RGB units from the
     frame's own #F5EFE4 (see box-shadow comment below); deepen it so the card
     reads as sitting ON a background, not blending into it. */
  .sh-opening--envelope {
    background:
      radial-gradient(58% 44% at 50% 40%, rgba(255, 255, 255, 0.4), transparent 70%),
      linear-gradient(180deg, #E7D9C0 0%, #D9C6A0 55%, #C6B080 100%);
  }
}
.sh-envelope-frame {
  background:
    radial-gradient(86% 48% at 50% 43%, rgba(255,255,255,0.82), rgba(245,239,228,0.24) 58%, transparent 76%),
    radial-gradient(116% 92% at 50% 112%, rgba(107,31,39,0.075), transparent 58%),
    #F5EFE4;
  perspective: 1400px;
  perspective-origin: 50% 34%;
}
/* Full-bleed mobile: no card, so no shadow. At >=768 the base .sh-frame rule
   (line ~24) turns into a centred 480px column — restore a deliberate shadow
   + brass hairline there instead of flattening it to box-shadow:none, or the
   "centred card" reads as an undefined washed-out blob (the envelope's own
   background and the outer .sh-opening--envelope background are only ~11 RGB
   units apart, so without a shadow/edge there's nothing to see the card by). */
@media (max-width: 767px) {
  .sh-opening--envelope .sh-frame { box-shadow: none; }
}
@media (min-width: 768px) {
  .sh-opening--envelope .sh-frame {
    box-shadow:
      0 0 0 1px rgba(158, 128, 96, 0.45),
      0 42px 110px -24px rgba(45, 30, 20, 0.5),
      0 14px 40px -20px rgba(107, 31, 39, 0.28);
  }
}
.sh-envelope-bg {
  position: absolute; inset: 0;
  background:
    radial-gradient(42% 18% at 50% 59%, rgba(77,53,30,0.20), rgba(77,53,30,0.08) 38%, transparent 70%),
    radial-gradient(62% 38% at 50% 39%, rgba(255,255,255,0.78), rgba(255,255,255,0.20) 64%, transparent 82%);
  z-index: 0;
}
.sh-envelope-bg::after {
  content: '';
  position: absolute;
  inset: -8%;
  background: radial-gradient(92% 78% at 50% 46%, transparent 42%, rgba(64, 43, 28, 0.13) 100%);
  pointer-events: none;
}
.sh-envelope-stage {
  position: absolute;
  left: 50%; top: 50%;
  width: min(96vw, 470px);
  aspect-ratio: 941 / 1672;
  transform: translate(-50%, -50%) scale(0.98);
  /* round 2: flat (no preserve-3d). With the stage's old filter gone, a
     preserve-3d stage depth-sorted the swinging flap against the seal/card
     (the lifting flap tip cut a V out of the seal). Flattened, the layers
     keep their z-index order; the flap carries its own perspective(). */
  overflow: visible;
  z-index: 8;
  will-change: transform;
}
/* batch-0925d: static contact shadow under the envelope, replacing the
   per-frame filter:drop-shadow() that used to sit on .sh-envelope-stage
   (a full re-raster every frame — jank risk on low-end Android/Zalo).
   Round 2: HEAD's footprint by
   construction — a static box on the body art's opaque bbox (body layer
   10%/27.91%/80%/38.18% of the stage x body-v2 alpha bbox 9..951 x 11..805 of
   960x814) casting the SAME shadows as box-shadow (box-shadow blur = 2x the
   drop-shadow() blur: both engines use drop-shadow's length as the std-dev).
   Outer box-shadows never paint inside the box, so nothing shows through the
   pocket mouth. Never animated except riding the parent .is-done fade. */
.sh-env-ground {
  position: absolute;
  left: 10.75%;
  top: 28.427%;
  width: 78.5%;
  height: 37.238%;
  border-radius: 0.6% 0.6% 2.9% 2.9% / 0.8% 0.8% 3.4% 3.4%;
  box-shadow:
    0 42px 68px rgba(77, 53, 30, 0.13),
    0 11px 36px rgba(107, 31, 39, 0.08);
  z-index: 0;
  pointer-events: none;
}
.sh-env-layer {
  position: absolute;
  transform: translate(-50%, -50%);
  pointer-events: none;
}
/* round 2: will-change only on the layers that actually animate (§4.5) */
.sh-env-card { will-change: transform, opacity; }
.sh-env-flap { will-change: transform; }
.sh-env-seal { will-change: transform, opacity; }
.sh-env-layer img { display: block; width: 100%; height: auto; }
.sh-env-mouth {
  position: absolute;
  inset: 0;
  z-index: 1;
  overflow: hidden;
  /* round 2: bottom edge lifted from 33.95% to 34.6% so the now-opaque card
     stays behind the body art (its alpha ends at 65.67% of the stage). */
  clip-path: inset(0 12.71% 34.6% 12.71%);
  pointer-events: none;
}
.sh-env-back {
  left: 50%;
  top: 46.78%;
  width: 79.29%;
  z-index: 0;
  opacity: 1; /* batch-0925d: always visible, no fade-in — reads as the inside of the envelope from frame 0 */
}
/* round 2: the backwall's drop-shadow filter is gone (§4.5 — it rode the
   push-in stage); the mouth clip hides its edges anyway. */
.sh-env-card {
  left: 50%;
  /* round 2 (G4 pocket sides): taller card + longer rise so a wide 2nd name
     line clears the pocket's rising V SIDES, not only its tip. Card top at
     the start is unchanged (31% of the stage); the extra height stays
     inside the pocket, keeping the bottom >=18% of the card below the tip. */
  /* round 3: the card now STARTS with its whole text block below the V
     tip, hidden behind the pocket front (top 78.5% -> card top at 50.5% of
     the stage, tip at 51.5%), and rises 77.2% of its height to the SAME
     rest position as round 2. While the flap peels, its edge opens a 1-3px
     seam along the V; with the text sitting under that seam, its ink
     blinked through as specks (250-650ms). Now only plain card paper is
     under the seam, and the names emerge from the pocket as the card rises. */
  /* round 4 (§12/§13): the REST position is computed, not a % rise:
     - --stage-h: the stage's own height (width min(96vw,470px), aspect 1672/941);
     - rest top = 2.79% of it (round 3's 7.27% raised by 8% of the card height,
       so the card bottom stays 13% of the card below the V tip) — but never
       higher than 12px inside the frame (the stage is centred in a 100vh frame
       and pushed in to at most x1.02), which is what binds at 320x568 and on
       desktop, where the stage (835px) is taller than the frame;
     - the start (text hidden below the V tip, round-3 speck fix) stays at
       card top = 50.5% of the stage; --card-drop is the rise distance. */
  --stage-h: calc(min(96vw, 470px) * 1.776833);
  --card-rest: max(calc(var(--stage-h) * 0.0279), calc(var(--stage-h) / 2 - (50vh - 12px) / 1.02));
  --card-drop: calc(var(--stage-h) * 0.505 - var(--card-rest));
  top: calc(var(--card-rest) + 28%);
  width: 64%;
  height: 56%;
  z-index: 1;
  /* round 2 (punch 7): no pop-in at 1250ms any more. Round 3: the card
     fades in at 150-300ms — BEFORE the flap starts moving at 350ms — while
     the closed flap + seal cover the whole mouth, so it is simply THERE when
     the flap swings clear (fading while the flap lifted let 1-3px of card
     ink blink through the flap-edge seam at 450-600ms). It is not opaque at rest only because its pale edge shows
     through the flap/notch antialias seam (R1). */
  opacity: 0;
  transform: translate(-50%, -50%) translateY(var(--card-drop)) scale(0.98);
}
@supports (height: 100svh) {
  /* mobile browsers whose 100vh is the LARGE viewport: clamp to the small one */
  .sh-env-card { --card-rest: max(calc(var(--stage-h) * 0.0279), calc(var(--stage-h) / 2 - (50svh - 12px) / 1.02)); }
}
.sh-env-letter {
  position: relative;
  /* round 5 (§14 "anchor to the pocket, no magic %-per-width-band"): a column
     of [spacer, text..., spacer]. Until JS runs, both spacers share the free
     space equally (plain centring, a safe no-JS fallback). opening-sequence.js
     (placeEnvelopeLetter) measures the SAME live V geometry g4-pocket.cjs
     checks (body-v3's fitted notch lines, read off the body <img>'s rendered
     rect — not a %-of-stage guess) and the actual rendered text lines at the
     card's REST transform, then sets --letter-anchor-px = the exact px height
     the bottom spacer needs so the lowest line's ink sits 16px clear of the V
     (tip and sides), and adds .is-anchored to switch the bottom spacer from
     flexible to that fixed height. The top spacer stays flex:1 and absorbs
     whatever content leaves over, so longer content (2-line guest, 30-char
     names) grows the block upward without moving the anchored bottom. Padding
     is symmetric (6%/6%) and always holds regardless of the spacers. */
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  padding: 6% 9%;
  /* batch-1017c: base couple-name size = a fraction of the card width (min(96vw,470px) * 0.64) */
  --env-ls: calc(min(96vw, 470px) * 0.64 * 0.106);
  --env-u: var(--env-ls);
  overflow: hidden;
  border-radius: 16px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.24), rgba(250,246,238,0.06)),
    url('assets/envelope/letter-paper-v2.webp') center / cover,
    #F8F2E8;
  box-shadow:
    0 26px 32px rgba(77, 53, 30, 0.18),
    0 5px 10px rgba(107, 31, 39, 0.08);
}
.sh-env-letter > * { flex: none; }
.sh-env-letter::before,
.sh-env-letter::after { content: ''; flex: 1 1 0; min-height: 0; }
.sh-env-letter.is-anchored::after { flex: 0 0 var(--letter-anchor-px, 0px); }
/* batch-0925d: shadow PNGs laid along the pocket's V lip, on top of the
   card but below the body, so the card reads as sitting inside the pocket
   as it rises. Round 3 (§11): placement DERIVED like the flap cast-shadows
   (r2/place_lipshade.py) — the pocket's two V edges are body-v3's fitted
   notch lines; each shadow core lies parallel to its edge, 3px inside the
   mouth (at 390px), centred on the lip and spanning 1.15x its length, same
   geometry both sides. The body covers the outer half of each soft band, so
   what shows is a shade hugging the lip on the card. % of the stage box. */
.sh-env-lip-shade {
  position: absolute;
  inset: 0;
  z-index: 2;
  opacity: 0;
  pointer-events: none;
}
.sh-env-lip-shade img {
  position: absolute;
  height: auto;
  opacity: 0.26; /* core dRGB ~20 on the card (r2/lipshade_measure.py) */
}
.sh-env-lip-shade--left { width: 59.016%; left: 30.196%; top: 38.975%; transform: translate(-50%, -50%) rotate(6.009deg); }
.sh-env-lip-shade--right { width: 59.811%; left: 69.259%; top: 38.969%; transform: translate(-50%, -50%) rotate(-5.189deg); }
/* batch-1017c: the letter is two layouts of the approved paper (README material pack).
   --plain (no ?to=): names / & / names / divider / date, no invite line.
   --guest (?to=): names / & / names / date / divider / kicker / guest.
   --env-ls is the couple-name size in px. Every ornament / date / kicker / guest size below is a
   ratio of --env-u, the "ornament unit": fitEnvelopeNames() (opening-sequence.js) sets it from the
   wider name's rendered line width (width / 6.15, clamped to 0.6-1.15 x --env-ls), so the block keeps
   the target's proportions whatever the names' length; until JS runs it falls back to --env-ls.
   --env-gs is the guest line's fraction of --env-u (JS shrinks 0.64 -> 0.48). Kicker and guest never
   render below 10px. */
.sh-env-letter-names {
  min-height: 0;
  /* round 2 (G8): ink room for stacked Vietnamese diacritics / descenders /
     side bearings — padding widens the clip box, the equal negative margin
     keeps the layout footprint exactly where it was. */
  padding: 0.32em 0.12em 0.2em;
  margin: -0.32em -0.12em -0.2em;
  box-sizing: content-box; /* round 3: the templates' `* { box-sizing: border-box }` would let the padding eat the height */
  font-family: var(--font-name, 'Cormorant Garamond', serif);
  font-weight: var(--env-nw, 400); /* per-template: 500 only where that weight is already loaded */
  font-style: normal;
  font-size: var(--env-ls);
  line-height: 1.0;
  color: #38240F;
  text-align: center;
  text-wrap: balance;
  overflow: hidden;
}
.sh-env-letter-name {
  display: -webkit-box;
  max-height: 2.05em;
  padding: 0.32em 0.12em 0.2em;   /* same ink room as the names block (G8) */
  margin: -0.32em -0.12em -0.2em;
  /* round 3 (G8, live-page regression): max-height is the 2-line CONTENT
     box. All templates reset `* { box-sizing: border-box }`, which made
     the padding eat into it and sliced two-line names in half. */
  box-sizing: content-box;
  overflow: hidden;
  overflow-wrap: anywhere;
  hyphens: auto;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.sh-env-letter .sh-env-letter-amp { /* beats `.sh-env-layer img { width: 100% }` */
  display: block;
  width: auto;
  height: calc(var(--env-u) * var(--amp-h));
  margin: calc(var(--env-u) * var(--amp-mt)) auto calc(var(--env-u) * var(--amp-mb));
}
.sh-env-letter .sh-env-letter-divider {
  display: block;
  height: auto;
  width: calc(var(--env-u) * var(--div-w));
  max-width: 100%;
  margin: calc(var(--env-u) * var(--div-mt)) auto 0;
}
.sh-env-letter-date {
  margin-top: calc(var(--env-u) * var(--date-mt));
  font-family: var(--font-name, 'Cormorant Garamond', serif);
  font-weight: 400;
  font-style: normal;
  font-variant-numeric: lining-nums;
  font-size: calc(var(--env-u) * var(--date-fs));
  letter-spacing: 0.2em;
  text-indent: 0.2em; /* the trailing letter-space would otherwise push the centred text left */
  line-height: 1.3;
  text-align: center;
  text-wrap: balance;
  color: #5A4632;
}
.sh-env-letter-kicker {
  margin-top: calc(var(--env-u) * var(--kick-mt));
  font-family: var(--font-name, 'Cormorant Garamond', serif);
  font-weight: 400;
  font-style: normal;
  font-size: max(10px, calc(var(--env-u) * var(--kick-fs))); /* legibility floor */
  letter-spacing: 0.18em;
  text-indent: 0.18em;
  text-transform: uppercase;
  line-height: 1.3;
  text-align: center;
  color: #9F2838;
}
/* Per-layout rhythm, all in units of --env-u (target: material pack preview 01 / 03). */
.sh-env-letter--plain {
  --amp-h: 0.7; --amp-mt: 0.22; --amp-mb: 0.2;
  --div-w: 3.84; --div-mt: 0.183;
  --date-fs: 0.66; --date-mt: 0.25;
}
.sh-env-letter--guest {
  --amp-h: 0.7; --amp-mt: 0.47; --amp-mb: 0.11;
  --div-w: 3.42; --div-mt: 0.07;
  --date-fs: 0.6; --date-mt: 0.46;
  --kick-fs: 0.43; --kick-mt: 0.46;
  --guest-mt: 0.17;
}
/* Guest line (?to= personalization): the last line of the --guest layout. Upright, same face as the
   names. Clamped to 2 lines so a 60-char name can never grow past a bounded height inside this
   fixed card; the padding / negative margin keep ink room for stacked diacritics. */
.sh-env-letter-guest {
  display: -webkit-box;
  box-sizing: content-box;
  padding: 0.3em 0.05em 0.3em;
  margin: calc(var(--env-u) * var(--guest-mt) - 0.3em) -0.05em -0.3em;
  font-family: var(--font-name, 'Cormorant Garamond', serif);
  font-weight: 400;
  font-style: normal;
  font-size: max(10px, calc(var(--env-u) * var(--env-gs, 0.64))); /* legibility floor */
  line-height: 1.2;
  color: #38240F;
  text-align: center;
  text-wrap: balance;
  overflow-wrap: anywhere;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.sh-env-body {
  left: 50%;
  top: 47%;
  width: 80%;
  z-index: 2;
  /* round 2: its own compositing layer, as in HEAD (where every layer had
     will-change) — without it the body's hairline fret/fold lines
     rasterize ~0.3px differently and the closed state drifts from HEAD
     (R1). A static promotion, not a will-change: the body never animates. */
  transform: translate(-50%, -50%) translateZ(0);
}
.sh-env-body > img:first-child {
  /* HEAD's static edge shadow on the body art, kept: the body never moves
     (only the whole stage's composited push-in scales it), and dropping it
     re-samples every fret line in WebKit (R1 1.07% vs 0.39%). */
  filter:
    drop-shadow(0 8px 8px rgba(77, 53, 30, 0.08))
    drop-shadow(0 1px 2px rgba(158, 128, 96, 0.12));
}

/* Side-panel shading under the closed flap — HEAD's .sh-env-shadow spans,
   kept pixel-for-pixel so the closed state is unchanged (R1: removing them
   alone moves 1.63% of the 390x844 frame, over the 0.5% bar). Only change:
   the static filter: blur(0.4px) is dropped (no filters inside the moving
   stage, §4.5). They fade out with the flap cast-shadows as the flap lifts. */
.sh-env-shadow {
  position: absolute;
  top: 22%;
  width: 31%;
  height: 42%;
  opacity: 0.54;
  mix-blend-mode: multiply;
}
.sh-env-shadow--left {
  left: 6%;
  background: linear-gradient(104deg, rgba(67,48,31,0.18), rgba(67,48,31,0.03) 58%, transparent 100%);
  clip-path: polygon(0 6%, 100% 47%, 74% 100%, 0 100%);
}
.sh-env-shadow--right {
  right: 6%;
  background: linear-gradient(256deg, rgba(67,48,31,0.18), rgba(67,48,31,0.03) 58%, transparent 100%);
  clip-path: polygon(0 47%, 100% 6%, 100% 100%, 26% 100%);
}

/* Flap cast-shadows (Daniel's shadow_left/right art). Round 2: placement is
   DERIVED, not eyeballed — r2/fit_flapshadow.py fits flap-v2's two lower
   edges (alpha 0.5 crossings, 47.29deg / 133.53deg) and the art's own shadow
   core (alpha-weighted principal axis), lays the core parallel to each edge
   with its centre line 2px below it (at 390px), scaled so the core spans
   1.3x the edge, and fits the opacity against HEAD's flap drop-shadow (which
   this replaces — no filter on the rotating flap, §4.5). The art is already
   diagonal: the round-1 rotate(+-43deg)/scaleX(-1) turned it into bars.
   The wrapper clips the shadows to the envelope body (body-v3 alpha mask)
   and to the rows above the V tip (the flap edges end there). */
.sh-env-flapshadows {
  position: absolute;
  inset: 0;
  -webkit-mask: url('assets/envelope/body-v3.webp') 0 0 / 100% 100% no-repeat;
  mask: url('assets/envelope/body-v3.webp') 0 0 / 100% 100% no-repeat;
  clip-path: inset(0 0 38.16% 0); /* V tip = row 503.4 of 814 in body-v3 */
  pointer-events: none;
}
.sh-env-body .sh-env-flapshadow {
  position: absolute;
  height: auto;
  opacity: 0.25;
  transform-origin: 50% 50%;
}
.sh-env-body .sh-env-flapshadow--left { width: 84.705%; left: 26.088%; top: 32.772%; transform: translate(-50%, -50%) rotate(5.99deg); }
.sh-env-body .sh-env-flapshadow--right { width: 85.852%; left: 74.643%; top: 30.933%; transform: translate(-50%, -50%) rotate(-5.167deg); }
.sh-env-flap {
  left: 50%;
  top: 39.64%;
  width: 78.57%;
  aspect-ratio: 960 / 531;
  z-index: 3;
  transform-origin: 50% 0.98%;
  /* round 2 (punch 3): translate BEFORE perspective — perspective(...) first
     projected about the un-centred box and skewed the swing to the left. */
  transform: translate(-50%, -50%) perspective(1000px) rotateX(0deg);
  transform-style: preserve-3d;
}
.sh-env-flap-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
/* round 2 (punch 2): the face swap no longer relies on backface culling
   (WebKit ignored it here) — each face's opacity steps at the 90deg
   keyframe, like the z-index step. */
.sh-env-flap-inner { transform: rotateX(180deg); opacity: 0; }
.sh-env-flap-face img { display: block; width: 100%; height: 100%; object-fit: contain; }
/* Light fall-off overlays, masked to each face's own art (punch 4 — the
   unmasked rectangles darkened the body around the flap). */
.sh-env-flap-face::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(40, 26, 16, 0.34), rgba(40, 26, 16, 0) 62%);
  -webkit-mask: url('assets/envelope/flap-v2.webp') 0 0 / 100% 100% no-repeat;
  mask: url('assets/envelope/flap-v2.webp') 0 0 / 100% 100% no-repeat;
  opacity: 0;
  pointer-events: none;
}
.sh-env-flap-inner::after {
  background: linear-gradient(0deg, rgba(255, 244, 224, 0.5), rgba(255, 244, 224, 0) 55%);
  -webkit-mask-image: url('assets/envelope/flap-inner-v3.webp');
  mask-image: url('assets/envelope/flap-inner-v3.webp');
}
/* The seal's contact shadow: HEAD's drop-shadow(0 5px 7px) on the seal <img>
   re-made as a static box-shadow on a circle (seal-v2's alpha is a perfect
   disc) so no filter rides the moving seal; it fades as the seal lifts. */
.sh-env-sealshadow {
  position: absolute;
  left: 50.18%;
  top: 51.77%;
  width: 16.66%;
  aspect-ratio: 1;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 5px 14px rgba(77, 53, 30, 0.26);
  z-index: 4;
  pointer-events: none;
}
.sh-env-seal {
  left: 50.18%;
  top: 51.77%;
  width: 16.66%;
  z-index: 4;
}
/* Only Lâm Môn re-hues the seal (the static hue exception of §4.5). */
.t-lammon .sh-env-seal img {
  filter: hue-rotate(var(--seal-hue, 0deg)) saturate(var(--seal-sat, 1));
}
.sh-envelope-hint {
  position: absolute;
  left: 50%;
  bottom: clamp(34px, 7svh, 70px);
  z-index: 12;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 9px;
  font-family: var(--font-date, 'Be Vietnam Pro', sans-serif);
  font-size: 10px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: rgba(28, 24, 20, 0.58);
  animation: sh-env-hint 2.2s ease-in-out infinite;
  white-space: nowrap;
}
.sh-envelope-hint::before,
.sh-envelope-hint::after {
  content: '';
  width: 20px;
  height: 0.5px;
  background: rgba(158, 128, 96, 0.58);
}
.sh-opening--envelope .sh-photo,
.sh-opening--envelope .sh-scrim,
.sh-opening--envelope .sh-vignette,
.sh-opening--envelope .sh-doors,
.sh-opening--envelope .sh-mono,
.sh-opening--envelope .sh-watermark { display: none; }
.sh-envelope-ambient {
  position: absolute;
  inset: 0;
  z-index: 7;
  overflow: hidden;
  pointer-events: none;
}
.sh-env-crane,
.sh-env-dust {
  position: absolute;
  color: var(--accent);
  opacity: 0;
  will-change: transform, opacity;
}
.sh-env-crane {
  width: 90px;
  height: 131px;
  background-repeat: no-repeat;
  background-size: 100% 100%;
}
.sh-env-crane--a,
.sh-env-crane--c { background-image: url('assets/envelope/crane-left.webp'); }
.sh-env-crane--b { background-image: url('assets/envelope/crane-right.webp'); }
.sh-env-crane--a { left: 10%; top: 24%; transform: scale(0.72); }
.sh-env-crane--b { right: 7%; top: 39%; transform: scale(0.58); }
.sh-env-crane--c { left: 24%; top: 66%; transform: scale(0.50); }
.sh-env-dust {
  width: 4px;
  height: 4px;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(202,164,106,0.95), transparent 72%);
}
.sh-env-dust--a { left: 18%; top: 44%; }
.sh-env-dust--b { left: 77%; top: 36%; }
.sh-env-dust--c { left: 63%; top: 70%; }

/* ─── batch-0925d: hearts (replace the removed petals) ───
   Outer .sh-env-heart handles position/size + the rise (translateY+opacity);
   inner .sh-env-heart-sway handles the side-to-side sway (translateX+rotate,
   alternate) and carries the per-template background image. */
.sh-envelope-hearts {
  position: absolute;
  inset: 0;
  z-index: 9;
  overflow: hidden;
  pointer-events: none;
}
.sh-env-heart {
  position: absolute;
  width: var(--heart-size, 24px);
  height: var(--heart-size, 24px);
  opacity: 0;
  will-change: transform, opacity;
}
.sh-env-heart-sway {
  position: absolute;
  inset: 0;
  background: var(--env-heart) center / contain no-repeat;
  will-change: transform;
}
/* round 2 (punch 9): each side heart starts at/just below the envelope's top
   edge (35-42% of the frame) and rises 30-34% of the frame height, so even at
   the end of its rise its top stays >= 4% inside the frame — never cut by
   the frame edge while visible (r2/gate-hearts.cjs). Heart 3 moved 18% -> 14%
   so at 320px it stays clear of a long guest/name line. */
.sh-env-heart--1 { left: 10%; top: 36%; --heart-size: 30px; --heart-delay: 1150ms; --heart-duration: 3800ms; --heart-rise: -32vh; --heart-sway: 7px; --heart-peak: 0.85; }
.sh-env-heart--2 { left: 88%; top: 35%; --heart-size: 26px; --heart-delay: 1300ms; --heart-duration: 3600ms; --heart-rise: -31vh; --heart-sway: 8px; --heart-peak: 0.8; }
.sh-env-heart--3 { left: 14%; top: 40%; --heart-size: 22px; --heart-delay: 1450ms; --heart-duration: 4000ms; --heart-rise: -31vh; --heart-sway: 6px; --heart-peak: 0.75; }
.sh-env-heart--4 { left: 82%; top: 37%; --heart-size: 34px; --heart-delay: 1600ms; --heart-duration: 3400ms; --heart-rise: -33vh; --heart-sway: 9px; --heart-peak: 0.85; }
.sh-env-heart--5 { left: 7%;  top: 42%; --heart-size: 18px; --heart-delay: 1750ms; --heart-duration: 3900ms; --heart-rise: -31vh; --heart-sway: 6px; --heart-peak: 0.7; }
.sh-env-heart--6 { left: 92%; top: 38%; --heart-size: 20px; --heart-delay: 1900ms; --heart-duration: 3300ms; --heart-rise: -34vh; --heart-sway: 7px; --heart-peak: 0.75; }
.sh-env-heart--7 { left: 44%; top: 23%; --heart-size: 14px; --heart-delay: 1150ms; --heart-duration: 900ms; --heart-rise: -6vh; --heart-sway: 4px; --heart-peak: 0.55; }
.sh-env-heart--8 { left: 58%; top: 21%; --heart-size: 16px; --heart-delay: 1650ms; --heart-duration: 950ms; --heart-rise: -6vh; --heart-sway: 4px; --heart-peak: 0.55; }

.sh-opening--envelope.is-opening .sh-env-seal { animation: sh-env-seal-release 0.85s cubic-bezier(.22,.61,.36,1) forwards; }
.sh-opening--envelope.is-opening .sh-env-flapshadow,
.sh-opening--envelope.is-opening .sh-env-shadow { animation: sh-env-flapshadow-out 0.8s 0.25s ease forwards; }
.sh-opening--envelope.is-opening .sh-env-sealshadow { animation: sh-env-flapshadow-out 0.4s 0.11s ease-out forwards; }
.sh-opening--envelope.is-opening .sh-env-flap { animation: sh-env-flap-open 1.25s 0.35s linear forwards; }
.sh-opening--envelope.is-opening .sh-env-flap-front { animation: sh-env-flap-front-face 1.25s 0.35s linear forwards; }
.sh-opening--envelope.is-opening .sh-env-flap-inner { animation: sh-env-flap-inner-face 1.25s 0.35s linear forwards; }
.sh-opening--envelope.is-opening .sh-env-flap-front::after { animation: sh-env-flap-front-shade 1.25s 0.35s linear forwards; }
.sh-opening--envelope.is-opening .sh-env-flap-inner::after { animation: sh-env-flap-inner-shade 1.25s 0.35s linear forwards; }
.sh-opening--envelope.is-opening .sh-env-card { animation: sh-env-card-in 0.15s 0.15s linear forwards, sh-env-card-rise 2.7s 1.25s cubic-bezier(.33,0,.15,1) forwards; }
.sh-opening--envelope.is-opening .sh-env-lip-shade { animation: sh-env-lip-shade-in 0.45s 1.25s ease forwards; }
.sh-opening--envelope.is-opening .sh-envelope-stage { animation: sh-env-stage-push 2.1s 3.95s cubic-bezier(.4,0,.2,1) forwards; }
.sh-opening--envelope.is-opening .sh-env-heart {
  animation: sh-env-heart-rise var(--heart-duration, 3600ms) var(--heart-delay, 1200ms) ease-out forwards;
}
.sh-opening--envelope.is-opening .sh-env-heart-sway {
  animation: sh-env-heart-sway calc(var(--heart-duration, 3600ms) / 2) var(--heart-delay, 1200ms) ease-in-out infinite alternate;
}
.sh-opening--envelope.is-opening .sh-envelope-hint {
  opacity: 0;
  animation: none;
  transition: opacity 0.3s ease;
}
.sh-envelope-skip-hint {
  position: absolute;
  left: 50%;
  bottom: clamp(34px, 7svh, 70px);
  z-index: 12;
  transform: translateX(-50%);
  font-family: var(--font-date, 'Be Vietnam Pro', sans-serif);
  font-size: 9.5px;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: rgba(28, 24, 20, 0.46);
  opacity: 0;
  pointer-events: none;
  white-space: nowrap;
}
.sh-opening--envelope.is-opening .sh-envelope-skip-hint {
  animation: sh-env-skip-hint-in 0.8s 1s ease forwards;
}
@keyframes sh-env-skip-hint-in { to { opacity: 1; } }
.sh-opening--envelope.is-opening .sh-env-crane { animation: sh-env-drift 13s linear infinite; }
.sh-opening--envelope.is-opening .sh-env-crane--b { animation-delay: 2.3s; }
.sh-opening--envelope.is-opening .sh-env-crane--c { animation-delay: 5.2s; }
.sh-opening--envelope.is-opening .sh-env-dust { animation: sh-env-twinkle 4.8s ease-in-out infinite; }
.sh-opening--envelope.is-opening .sh-env-dust--b { animation-delay: 1.4s; }
.sh-opening--envelope.is-opening .sh-env-dust--c { animation-delay: 2.8s; }
@keyframes sh-env-hint { 0%, 100% { opacity: 0.56; } 50% { opacity: 0.96; } }

/* Seal: 0-110ms tiny press, then lift + dissolve (legacy logo feel) — no
   rotation, transform/opacity only. */
@keyframes sh-env-seal-release {
  0% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  13% { transform: translate(-50%, -50%) scale(0.96); opacity: 1; }
  55% { opacity: 1; }
  100% { transform: translate(-50%, -50%) translateY(-6%) scale(1.22); opacity: 0; }
}
@keyframes sh-env-flapshadow-out { to { opacity: 0; } }

/* Flap: 0deg -> 20deg slow (paper starting to peel) -> 128deg fast (swings
   through) -> 180deg soft landing. z-index drops behind the mouth/card at
   the ~90deg moment (47.9%/48%) — the rotateX values either side of that
   split are the values the original 22%/62% straight segment would have
   there, so only z-index steps; the visible rotation stays continuous.
   Round 2: translate(-50%,-50%) comes BEFORE perspective() (punch 3). */
@keyframes sh-env-flap-open {
  0%    { transform: translate(-50%, -50%) perspective(1000px) rotateX(0deg);    z-index: 3; }
  22%   { transform: translate(-50%, -50%) perspective(1000px) rotateX(20deg);   z-index: 3; }
  47.9% { transform: translate(-50%, -50%) perspective(1000px) rotateX(89.9deg); z-index: 3; }
  48%   { transform: translate(-50%, -50%) perspective(1000px) rotateX(90.2deg); z-index: 0; }
  62%   { transform: translate(-50%, -50%) perspective(1000px) rotateX(128deg);  z-index: 0; }
  100%  { transform: translate(-50%, -50%) perspective(1000px) rotateX(180deg);  z-index: 0; }
}
/* Face swap at the same 90deg keyframe (punch 2 / §10): discrete opacity
   step, so it never depends on backface-visibility being honoured. */
@keyframes sh-env-flap-front-face {
  0%, 47.9%  { opacity: 1; }
  48%, 100%  { opacity: 0; }
}
@keyframes sh-env-flap-inner-face {
  0%, 47.9%  { opacity: 0; }
  48%, 100%  { opacity: 1; }
}
@keyframes sh-env-flap-front-shade {
  0% { opacity: 0; }
  48% { opacity: 0.9; }
  100% { opacity: 0.9; }
}
@keyframes sh-env-flap-inner-shade {
  0%, 48% { opacity: 0; }
  100% { opacity: 0.65; }
}
@keyframes sh-env-lip-shade-in { to { opacity: 1; } }
@keyframes sh-env-card-in { to { opacity: 1; } }
@keyframes sh-env-card-rise {
  0%   { transform: translate(-50%, -50%) translateY(var(--card-drop)) scale(0.98); }
  100% { transform: translate(-50%, -50%) translateY(0) scale(1.0); }
}
/* Push-in x1.00 -> x1.04 of the resting size (punch 10): the stage rests at
   scale(0.98), so the push starts exactly there (no jump) and ends at
   0.98 x 1.04 = 1.0192 — round 1 ran 0.98 -> 1.04 (a 6.1% push). */
@keyframes sh-env-stage-push {
  from { transform: translate(-50%, -50%) scale(0.98); }
  to   { transform: translate(-50%, -50%) scale(1.0192); }
}
@keyframes sh-env-heart-rise {
  0%   { opacity: 0; transform: translateY(0); }
  14%  { opacity: var(--heart-peak, 0.85); }
  60%  { opacity: var(--heart-peak, 0.85); }
  100% { opacity: 0; transform: translateY(var(--heart-rise, -34vh)); }
}
@keyframes sh-env-heart-sway {
  from { transform: translateX(calc(var(--heart-sway, 8px) * -1)) rotate(-4deg); }
  to   { transform: translateX(var(--heart-sway, 8px)) rotate(4deg); }
}
@keyframes sh-env-drift {
  0% { opacity: 0; transform: translate3d(0, 0, 0) rotate(-4deg); }
  15% { opacity: 0.16; }
  84% { opacity: 0.10; }
  100% { opacity: 0; transform: translate3d(28px, -150px, 0) rotate(4deg); }
}
@keyframes sh-env-twinkle {
  0%, 100% { opacity: 0; transform: scale(0.55); }
  48% { opacity: 0.72; transform: scale(1); }
}

/* ─── Reduced motion ───
   Daniel's machine reports reduced-motion and he wants the FULL
   choreography to still play (same timings) — only trim the "extra" hearts
   down to 4 and drop their sway, keep cranes/dust off. */
@media (prefers-reduced-motion: reduce) {
  .sh-photo { animation: none; transform: none; }
  .sh-env-heart--5, .sh-env-heart--6, .sh-env-heart--7, .sh-env-heart--8 { display: none; }
  .sh-opening--envelope.is-opening .sh-env-heart-sway { animation: none; }
  .sh-opening--envelope.is-opening .sh-env-crane,
  .sh-opening--envelope.is-opening .sh-env-dust { animation: none; }
}

/* ═══════════════════════════════════════════════════════
   Per-template theme blocks
   Each defines: --font-name, --font-eyebrow, --font-date,
   --accent, --occasion, --font-occasion (hySu only), --photo, --scrim, --btn-*