* { box-sizing: border-box; }
:root { color-scheme: dark; font-family: system-ui, sans-serif; }
body { margin: 0; background: radial-gradient(ellipse at 50% 21%, #382325, #100c0d 65%); color: #fbf5e5; min-height: 100vh; }
[hidden] { display: none !important; }
main { width: min(100% - 24px, 650px); margin: auto; padding: 22px 0 28px; }
button { font: inherit; cursor: pointer; }
.envelope-button { display: block; width: 100%; max-width: 560px; margin-inline: auto; border: 0; background: none; color: inherit; padding: 0; }
.envelope { display: block; position: relative; aspect-ratio: 948 / 1038; perspective: 1000px; transform: rotateX(var(--tilt-x, 0deg)) rotateY(var(--tilt-y, 0deg)); transition: transform .18s ease-out; }
.surface, .flap, .flap-art, .seal, .shine { position: absolute; inset: 0; display: block; }
.surface, .flap-art, .seal, .pocket { background: url(assets/envelope.webp) center / 100% 100% no-repeat; }
.surface { box-shadow: 0 19px 45px #000a; }
.flap { z-index: 3; transform-origin: 50% 19%; transform-style: preserve-3d; }
.flap-art { clip-path: polygon(50% 1%, 98% 19.5%, 50% 39%, 2% 19.5%); }
.seal { z-index: 4; clip-path: ellipse(10% 9% at 50% 36.5%); }
.shine { z-index: 5; overflow: hidden; pointer-events: none; clip-path: inset(2% 2%); }
.shine::before { content: ""; position: absolute; inset: 0; background: linear-gradient(108deg, transparent 39%, #fff3bb36 51%, transparent 63%); transform: translateX(-105%); }
.envelope-button:is(:hover,:focus-visible) .shine::before { animation: sweep 1s ease-out; }
.paper-motion { display: block; position: absolute; inset: 17% 11% 29%; z-index: 2; opacity: 0; background: repeating-linear-gradient(#fff9e9 0 20px,#e9e0c9 21px,#fff9e9 22px); border-top: 5px solid #ba1926; box-shadow: 0 15px 26px #0009; }
.opening .surface { animation: face .95s ease both; }
.opening .flap { animation: hinge .92s cubic-bezier(.25,.71,.2,1) both; }
.opening .seal { animation: unseal .42s ease-in both; }
.opening .paper-motion { animation: emerge .7s .26s ease-out both; }
.opening .shine::before { animation: sweep .65s ease-out; }
@keyframes face { 35% { filter: brightness(.5); } 100% { opacity: .1; } }
@keyframes hinge { 30% { transform: rotateX(45deg); } 76% { opacity: 1; } 100% { transform: rotateX(165deg); opacity: 0; } }
@keyframes unseal { 100% { opacity: 0; transform: translateY(7%) scale(1.07); } }
@keyframes emerge { 0% { opacity: 0; transform: translateY(45%) scale(.85); } 35% { opacity: 1; } 100% { opacity: 1; transform: translateY(-23%); } }
@keyframes sweep { to { transform: translateX(105%); } }
@keyframes reveal { from { opacity: 0; transform: translateY(24px) scale(.98); } to { opacity: 1; transform: none; } }
.action { display: inline-block; margin-top: 15px; padding: 10px 22px; border: 1px solid #f6c95b; background: #f4c556; color: #211505; border-radius: 99px; font-weight: 750; }
.action.secondary { display: block; margin-inline: auto; background: #221315; color: #ffe5a0; }
button:focus-visible { outline: 3px solid #ffe29a; outline-offset: 4px; }
.letter { position: relative; width: 94%; margin: auto; color-scheme: light; background: #fffaf0; color: #231d1e; padding: clamp(20px, 5vw, 44px); border-top: 6px solid #b61925; border-radius: 8px 8px 2px 2px; box-shadow: 0 16px 44px #0009; animation: reveal .42s ease-out both; }
.brandline { display: grid; grid-template-columns: 1fr 1fr 1fr; align-items: center; gap: 8%; padding-bottom: 16px; border-bottom: 2px solid #d8a235; }
.brandline img { display: block; width: 100%; height: auto; max-height: 88px; object-fit: contain; }
.flap .logo-slot { position: absolute; display: grid; place-items: center; width: 13%; height: 11%; top: 15%; }
.flap .left { left: 23%; }
.flap .right { right: 23%; }
.flap .logo-slot img { max-width: 100%; max-height: 100%; object-fit: contain; filter: drop-shadow(0 2px 3px #000); animation: reveal .55s ease-out both; }
.letter h1 { color: #971622; font-size: clamp(1.55rem, 5vw, 2.45rem); line-height: 1.07; margin: 25px 0 18px; }
.letter p, #signature { font-size: 1rem; line-height: 1.58; overflow-wrap: anywhere; }
.letter p { margin: 0 0 14px; }
#signature { white-space: pre-line; margin-top: 20px; font-weight: 650; }
.pocket { aspect-ratio: 948 / 484; width: 100%; background-size: 100% auto; background-position: center bottom; clip-path: polygon(0 0, 50% 6%, 100% 0, 100% 100%, 0 100%); animation: reveal .42s ease-out both; }
@media (prefers-reduced-motion: reduce) { *, *::before { animation-duration: .01ms !important; animation-delay: 0ms !important; transition-duration: .01ms !important; } .envelope { transform: none; } }
