/* The envelope (book-envelope.js). Cream laid paper with a light grain, folds that catch a soft
   shadow, a navy chalk-stripe lining (the inside of a GW suit), a 3D flap that shades as it turns,
   and a navy wax seal pressed with the gw mark. */
.iv .env { display: none; }
.ev { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; padding: 40px 16px 90px; pointer-events: none;
  --W: min(440px, 84vw); --H: calc(var(--W) * .64); }
/* the envelope is centred a little above the middle; the Booked note hangs below it, out of flow */
.ev__wrap { position: relative; display: grid; justify-items: center; margin: calc(var(--H) * .6) 0 240px; }
.e { position: relative; width: var(--W); height: var(--H); perspective: 1400px; }
.e__body { position: absolute; inset: 0; transform-style: preserve-3d; }
.e__face { position: absolute; inset: 0; -webkit-backface-visibility: hidden; backface-visibility: hidden; }
.e__face--front { transform: rotateY(180deg); border-radius: 3px; background: linear-gradient(170deg, #f4ecdb, #e9dec7); box-shadow: 0 1px 1px rgba(0,0,0,.18); }
.e__shadow { position: absolute; left: 4%; right: 4%; bottom: -9%; height: 34%; border-radius: 50%; background: rgba(2,5,14,.75); filter: blur(22px); opacity: 0; }

/* back panel with the lining */
.e__back { position: absolute; inset: 0; z-index: 1; border-radius: 3px; background: linear-gradient(180deg, #e4d8bf, #ddd0b5); box-shadow: 0 1px 1px rgba(0,0,0,.18); }
.e__back::before { content: ""; position: absolute; inset: 3.5% 3.5% 34%; border-radius: 2px;
  background: repeating-linear-gradient(90deg, transparent 0 9px, rgba(226,200,145,.32) 9px 9.7px), linear-gradient(180deg, #1c2a4f, #121b37);
  box-shadow: inset 0 10px 18px -8px rgba(0,0,0,.6); }

/* the flap: two faces, open (rotateX 180°) until it is sealed */
.e__flap { position: absolute; left: 0; right: 0; top: 0; height: 62%; z-index: 2; transform-origin: 50% 0; transform-style: preserve-3d; transform: perspective(1100px) rotateX(180deg); }
.e__flap i { position: absolute; inset: 0; -webkit-backface-visibility: hidden; backface-visibility: hidden; clip-path: polygon(0 0, 100% 0, 53% 95.5%, 50% 100%, 47% 95.5%); }
.e__flap-out { background: linear-gradient(180deg, #ece3d0 0%, #e3d7be 100%); }
.e__flap-out::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(255,255,255,.35), transparent 30%); }
.e__flap-in { transform: rotateY(180deg); background: #e0d3b8; }
.e__flap-in::before { content: ""; position: absolute; inset: 0 7% 9%; clip-path: polygon(0 0, 100% 0, 50% 100%);
  background: repeating-linear-gradient(90deg, transparent 0 9px, rgba(226,200,145,.32) 9px 9.7px), linear-gradient(0deg, #1a2749, #111a35); }

/* the reply card */
.e__card { position: absolute; left: 7%; right: 7%; top: 8%; height: 80%; z-index: 3; display: grid; align-content: start; justify-items: center; gap: calc(var(--W) * .008);
  padding: 7% 7% 0; text-align: center; color: var(--navy); background: #faf6ec; border-radius: 2px; box-shadow: 0 1px 2px rgba(0,0,0,.14), 0 6px 14px -8px rgba(0,0,0,.4); }
.e__card::before { content: ""; position: absolute; inset: 7px; border: 1px solid rgba(138,106,58,.45); pointer-events: none; }
.e__card .foil { width: calc(var(--W) * .075); height: calc(var(--W) * .075); }
.e__card small { margin-top: 4px; font-size: calc(var(--W) * .019); font-weight: 600; letter-spacing: .3em; text-transform: uppercase; color: var(--brass-3); }
.e__card b { font-family: "Playfair Display", serif; font-weight: 600; font-size: calc(var(--W) * .047); line-height: 1.15; }
.e__card p { font-family: "Cormorant Garamond", serif; font-style: italic; font-size: calc(var(--W) * .035); color: rgba(22,33,61,.72); }
.e__card .e__card-name { font-family: var(--sign); font-style: normal; font-size: calc(var(--W) * .07); line-height: 1; color: var(--navy); }

.e__pocket { position: absolute; inset: 0; z-index: 4; width: 100%; height: 100%; overflow: visible; filter: drop-shadow(0 -1px 1px rgba(60,44,20,.12)); }
.e__cast { position: absolute; left: 0; right: 0; top: 0; height: 64%; z-index: 4; clip-path: polygon(0 0, 100% 0, 50% 100%); background: rgba(45,30,10,.6); filter: blur(5px); opacity: 0; transform-origin: 50% 0; }
.e__grain { position: absolute; inset: 0; z-index: 6; border-radius: 3px; pointer-events: none; mix-blend-mode: multiply; opacity: .42;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .45  0 0 0 0 .36  0 0 0 0 .22  0 0 0 .55 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>"); }

/* wax seal */
.e__seal { position: absolute; z-index: 7; left: 50%; top: 61%; width: calc(var(--W) * .22); aspect-ratio: 1; margin: calc(var(--W) * -.11) 0 0 calc(var(--W) * -.11); opacity: 0;
  filter: drop-shadow(0 2px 2px rgba(0,0,0,.45)) drop-shadow(0 6px 8px rgba(0,0,0,.25)); }
.e__seal svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.e__emboss { position: absolute; inset: -3%; width: 106%; height: 106%; opacity: 0; object-fit: contain; }

/* postmark (ink with a rough edge, from an SVG displacement filter) */
.e__pm { position: absolute; z-index: 8; width: 50%; color: #1f2d55; opacity: 0; mix-blend-mode: multiply; pointer-events: none; }
.e__face--back .e__pm { right: 2%; top: 5%; width: 46%; }
.e__face--front .e__pm { right: 11%; top: 2%; width: 46%; }

/* front of the envelope (Turn over) */
.e__ret { position: absolute; left: 6%; top: 8%; font-size: calc(var(--W) * .02); font-weight: 600; letter-spacing: .22em; line-height: 1.7; text-transform: uppercase; color: rgba(22,33,61,.55); }
.e__stamp { position: absolute; right: 6%; top: 8%; width: 15%; aspect-ratio: .82; background: radial-gradient(circle, transparent 2.1px, #fbf7ee 2.4px) -3.5px -3.5px / 7px 7px; filter: drop-shadow(0 1px 1px rgba(0,0,0,.18)); }
.e__stamp i { position: absolute; inset: 5px; background: linear-gradient(160deg, #22325f, #121b37); }
.e__stamp i::after { content: ""; position: absolute; inset: 22%; -webkit-mask: url(assets/brand/gw-mark.svg) center / contain no-repeat; mask: url(assets/brand/gw-mark.svg) center / contain no-repeat; background: linear-gradient(135deg, #a98544, #e8d4a0 50%, #a98544); }
.e__addr { position: absolute; left: 18%; right: 8%; top: 44%; display: grid; gap: calc(var(--W) * .012); color: var(--navy); }
.e__to { font-family: var(--sign); font-size: calc(var(--W) * .1); line-height: 1; padding: 0 .1em; justify-self: start; opacity: 0; clip-path: inset(-40% 100% -40% -6%); }
.e__addr small { padding-left: 4%; font-size: calc(var(--W) * .021); font-weight: 600; letter-spacing: .26em; text-transform: uppercase; opacity: 0; border-top: 1px solid rgba(22,33,61,.2); padding-top: 8px; }
.e__addr em { padding-left: 4%; font-family: "Cormorant Garamond", serif; font-size: calc(var(--W) * .036); color: rgba(22,33,61,.75); opacity: 0; }

/* Booked */
.ev__after { position: absolute; top: calc(100% + 30px); left: 50%; translate: -50% 0; width: min(420px, 88vw); display: grid; gap: 8px; justify-items: center; text-align: center; color: var(--cream-ink); opacity: 0; pointer-events: none; }
.ev[data-final] .ev__after { pointer-events: auto; }
.ev__k { font-size: 10.5px; font-weight: 600; letter-spacing: .3em; text-transform: uppercase; color: var(--brass-2); }
.ev__h { font-family: var(--sign); font-weight: 400; font-size: clamp(64px, 16vw, 92px); line-height: 1; color: var(--cream-ink); padding: .04em .15em .12em; }
.ev__h span { display: inline-block; clip-path: inset(-30% 100% -30% -10%); }
.ev[data-final] .ev__h span { clip-path: inset(-30% -10% -30% -10%); transition: clip-path 1200ms cubic-bezier(0.45, 0.05, 0.35, 1) 120ms; }
.ev__after p { font-family: "Cormorant Garamond", serif; font-style: italic; font-size: 19px; line-height: 1.4; color: rgba(241,234,217,.82); max-width: 30ch; }
.ev__row { margin-top: 10px; display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.ev__row a, .ev__row button { height: 46px; padding: 0 22px; border-radius: 23px; display: inline-flex; align-items: center; font-size: 11px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; transition: transform 160ms var(--ease-out); }
.ev__row a { background: var(--cream-ink); color: var(--navy); }
.ev__row button { box-shadow: inset 0 0 0 1px rgba(241,234,217,.4); color: var(--cream-ink); }
.ev__row a:active, .ev__row button:active { transform: scale(.97); }
.ev__edit { margin-top: 6px; font-size: 12px; color: rgba(241,234,217,.7); text-decoration: underline; text-underline-offset: 3px; }

@media (max-width: 820px) { .ev { padding-bottom: 70px; } .ev__wrap { margin-bottom: 250px; } }
@media (prefers-reduced-motion: reduce) { .ev[data-final] .ev__h span { transition: none; clip-path: none; } }
