/* The paper envelope (envelope.js): real paper with a grain, a thick flap that curls as it turns, and a wax seal.
   Its own stylesheet, so any page can show the envelope: the guest page, and the choice of an envelope while an invitation is made. */
/* the envelope takes the proportions of its invitation (--pe-shape: its height as a share of its width, set by envelope.js);
   a tall one is held to about half the screen's height */
.pe { position: relative; width: min(86vw, 600px, 112vh, calc(50vh / var(--pe-shape, 0.64))); aspect-ratio: var(--pe-ratio, 1000 / 640); perspective: 1500px; }
.pe > * { position: absolute; }
/* the envelope's own shadow: it grows gradually from the edge (no dark stripe under the bottom edge), then wide and soft, to the right and down (the light is upper left) */
.pe__shadow { inset: 1.2%; border-radius: 3px; background: rgba(30, 20, 10, .5);
  box-shadow: 3px 5px 10px rgba(30, 20, 10, .26), 16px 24px 36px rgba(30, 20, 10, .32), 34px 46px 70px rgba(30, 20, 10, .2); }
.pe__back, .pe__front { inset: 0; width: 100%; height: 100%; display: block; }
.pe__back { z-index: 1; }
.pe__front { z-index: 3; }
.pe__shade { z-index: 2; left: 5%; right: 5%; top: 0; height: 46%; background: radial-gradient(60% 80% at 50% 0%, rgba(40, 30, 20, .3), transparent 70%); opacity: var(--shade, 0); }
/* the invitation lies in the pocket; whatever is below the envelope's bottom stays hidden in it */
/* the card inside is cut a little short of the envelope's sides and bottom, so no light hairline of it shows along the bottom edge */
.pe__pocket { z-index: 2; inset: 0; -webkit-clip-path: inset(-800% 2px 3px 2px); clip-path: inset(-800% 2px 3px 2px); }
/* the flap is thick paper: it turns on its hinge along the top edge and throws a real shadow while it is closed */
.pe__flapshadow, .pe__sealshadow { mix-blend-mode: multiply; opacity: calc(1 - var(--lift, 0)); }
.pe__flapshadow { z-index: 4; left: 0; top: 0; width: 100%; height: var(--flapshadow-h, 67.03%); }
.pe__flap { z-index: 5; left: 0; top: 0; width: 100%; height: var(--flap-h, 57.66%); transform-origin: 50% 0; transform-style: preserve-3d; transform: rotateX(var(--flap, 0deg)); }
.pe__flap.is-behind { z-index: 0; }
/* it is paper, not board: nine strips, each hinged on the one above, curl a little while the flap turns (--bend) and lie flat at rest.
   Every strip shows its own ninth of the flap's faces, its edge and its shade (--n is the strip's place, --w how freely it bends).
   The faces and the shade reach a little under the next strip (--over, set with the picture's own numbers by envelope.js) */
.pe__strip { position: absolute; left: 0; top: 0; width: 100%; height: calc(100% / 9); transform-style: preserve-3d; }
.pe__strip .pe__strip { top: 100%; height: 100%; transform-origin: 50% 0; transform: rotateX(calc(var(--bend, 0deg) * var(--w, 1))) translateZ(-.3px); } /* a hair behind the strip above, so the two never cut through each other */
.pe__face, .pe__strip > .pe__flapin { position: absolute; left: 0; top: 0; width: 100%; height: var(--over, 105%); -webkit-backface-visibility: hidden; backface-visibility: hidden; }
.pe__face > canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.pe__strip > .pe__flapin { transform: rotateX(180deg) translateZ(6px); }
.pe__edge { position: absolute; inset: 0; background: var(--paper-edge); transform: translateZ(calc(var(--i) * -1px));
  -webkit-mask: var(--flap-mask) 0 calc(var(--n) * 12.5%) / 100% 900% no-repeat; mask: var(--flap-mask) 0 calc(var(--n) * 12.5%) / 100% 900% no-repeat; }
.pe__flapdark { position: absolute; inset: 0; opacity: var(--flapDark, 0); will-change: opacity; /* its shade changes every frame: kept as its own layer, so the paper under it is not repainted */
  background: linear-gradient(180deg, rgba(30, 22, 14, 0), rgba(30, 22, 14, .55)) 0 calc(var(--n) * var(--dstep, 12.577%)) / 100% var(--dsize, 858.14%) no-repeat;
  -webkit-mask: var(--flap-mask) 0 calc(var(--n) * var(--dstep, 12.577%)) / 100% var(--dsize, 858.14%) no-repeat; mask: var(--flap-mask) 0 calc(var(--n) * var(--dstep, 12.577%)) / 100% var(--dsize, 858.14%) no-repeat; }
/* the wax seal is pressed on the point of the flap, half on it and half over the envelope, and lifts with it */
.pe__seal { position: absolute; left: var(--seal-l, 40.5%); top: var(--seal-t, -170%); width: var(--seal-w, 19%); aspect-ratio: 1; transform-style: preserve-3d; } /* it rides on the flap's last strip */
.pe__seal canvas { position: absolute; inset: 0; width: 100%; height: 100%; -webkit-backface-visibility: hidden; backface-visibility: hidden; }
.pe__sealf { transform: translateZ(12px); }
.pe__sealb { transform: translateZ(0.4px) rotateX(180deg); }
/* walls: seen from the side they are the solid body of the paper and of the wax */
.pe__wall { position: absolute; left: var(--l); width: var(--w); top: var(--t); height: var(--h); transform-origin: 50% 0; transform: rotateX(var(--turn)); }
.pe__strip > .pe__wall { --h: 6px; --turn: -90deg; background: var(--paper-edge); }
.pe__seal > .pe__wall { --h: 12px; --turn: 90deg; border-radius: 6px;
  background: linear-gradient(90deg, rgba(0, 0, 0, .28), rgba(0, 0, 0, 0) 14%, rgba(0, 0, 0, 0) 86%, rgba(0, 0, 0, .28)), linear-gradient(180deg, var(--wax-side), var(--wax-lit) 50%, var(--wax-side)); }
.pe__side { position: absolute; inset: 0; background: var(--wax-side); transform: translateZ(calc(var(--i) * 0.7px)) scale(var(--s, 1));
  -webkit-mask: var(--seal-mask) center / 100% 100%; mask: var(--seal-mask) center / 100% 100%; }
.pe__side:first-child { filter: drop-shadow(1px 2.5px 2px rgba(40, 22, 12, .5)); }
.pe__sealshadow { z-index: 4; left: var(--seal-l, 40.5%); top: var(--sealshadow-t, 40.4%); width: var(--seal-w, 19%); aspect-ratio: 1; }
/* until their masks are made, the flap's edge plates and shade and the wax's slices stay hidden (they would show as plain shapes) */
.pe:not(.is-masked) .pe__edge, .pe:not(.is-masked) .pe__flapdark, .pe__seal:not(.is-masked) .pe__side { display: none; }
