/* Four folded sides; only the sealed lid opens. */
.envelope-opening { position:fixed; inset:0; z-index:10000; display:grid; place-items:center; overflow:hidden; background:radial-gradient(ellipse at 48% 35%,#f4eae0,#d4c0b5); }
.envelope-opening[hidden] { display:none; }
.envelope-scene { position:relative; width:100vw; height:100dvh; }
.cover-paper { position:absolute; inset:0; z-index:0; background:linear-gradient(135deg,#310911,#4c101e); border-radius:inherit; }
.cover-flap { position:absolute; inset:0; background:linear-gradient(130deg,#46101b,#601a28 60%,#400d19); pointer-events:none; }
.cover-flap::after { content:''; position:absolute; inset:0; opacity:.075; background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='150' height='150'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Cpath fill='%23fff' filter='url(%23n)' d='M0 0h150v150H0z' opacity='.6'/%3E%3C/svg%3E"); }
.stationary-flap { z-index:3; }
.flap-left { clip-path:polygon(0 0,52% 50%,0 100%); background:linear-gradient(100deg,#46101b,#571623); }
.flap-bottom { clip-path:polygon(0 100%,50% 48%,100% 100%); background:linear-gradient(170deg,#501420,#3b0b16); }
.flap-cross { clip-path:polygon(0 0,50% 52%,100% 0); background:linear-gradient(25deg,#4a111e,#5b1826); }
.flap-left::before,.flap-bottom::before { content:''; position:absolute; width:150px; height:215px; background:url('../assets/images/embossed-florals.svg') no-repeat; background-size:150px 215px; opacity:.14; }
.flap-left::before { left:-30px; top:-35px; }
.flap-bottom::before { right:-25px; bottom:-35px; }
.cover-lid { position:absolute; inset:0; z-index:4; transform-origin:right center; transform-style:preserve-3d; transition:transform .9s cubic-bezier(.45,0,.2,1); }
.flap-lid { clip-path:polygon(100% 0,44% 50%,100% 100%); background:linear-gradient(110deg,#49111e,#601a28); }
.envelope-opening.is-opening .cover-lid { transform:perspective(1400px) rotateY(160deg); }
.fold-edge { position:absolute; inset:0; width:100%; height:100%; fill:none; }
.fold-edge path { stroke:#a8666b; stroke-width:1; stroke-opacity:.45; vector-effect:non-scaling-stroke; }
.fold-desktop { display:none; }
.cover-seal { position:absolute; z-index:1; left:50%; top:50%; display:grid; place-items:center; width:116px; aspect-ratio:1; transform:translate(-50%,-50%) rotate(-12deg); border-radius:44% 54% 43% 49% / 49% 42% 56% 48%; background:linear-gradient(135deg,#fce5a9,#a97637 19%,#f6d58b 32%,#b88542 58%,#fce4a2 79%,#9b652f); box-shadow:0 9px 14px #25071299,inset 0 0 0 2px #e6c68b,inset 0 0 0 5px #9f703e; }
.seal-rim { width:78%; aspect-ratio:1; display:grid; place-items:center; border:2px solid #af7c3d; border-radius:50%; box-shadow:inset 2px 2px 5px #80512e88,1px 1px 2px #fff0bf; background:radial-gradient(at 35% 25%,#f5dda3,#c99c5e); }
.cover-hitbox { position:absolute; inset:0; z-index:5; display:block; width:100%; height:100%; padding:0; border:0; border-radius:inherit; background:transparent; cursor:pointer; }
.cover-hitbox:focus-visible { outline:3px solid #e9c890; outline-offset:-6px; }
.cover-hitbox[aria-disabled="true"] { pointer-events:none; }
.envelope-scene .insert-letter { position:fixed; z-index:2; min-height:0; padding:20px; border:1px solid #c9a76c; border-radius:5px; box-shadow:0 14px 40px #16030899,0 1px 2px #0008; opacity:1; overflow:hidden; pointer-events:none; transition:none; }
@media(min-width:641px) {
 .envelope-scene { width:min(1100px,calc(100vw - 64px),calc(160dvh - 102.4px)); height:auto; aspect-ratio:1.6; border-radius:8px; box-shadow:0 24px 60px #38122245; }
 .cover-lid { transform-origin:center top; }
 .flap-cross { clip-path:polygon(100% 0,48% 50%,100% 100%); }
 .flap-lid { clip-path:polygon(0 0,50% 56%,100% 0); }
 .envelope-opening.is-opening .cover-lid { transform:perspective(1400px) rotateX(160deg); }
 .fold-mobile { display:none; }
 .fold-desktop { display:block; }
 .cover-seal { width:132px; }
}
@media(max-width:360px) { .cover-seal { width:104px; } }
@media(prefers-reduced-motion:reduce) { .cover-lid { transition:none; } }
/* Once the lid is open, the insert passes in front of it and behind the pocket. */
.envelope-opening[data-phase="extracting"] .cover-lid,
.envelope-opening[data-phase="expanding"] .cover-lid { z-index:1; }
