@font-face{font-family:TimThu;src:url('/assets/trai-tim-hat-sang/fonts/dancing-script-700.woff2') format('woff2');font-weight:400 700;font-display:swap}
:root{color-scheme:dark;--rose:#ae4c68;--ink:#62404f}
*{box-sizing:border-box}
html,body{margin:0;width:100%;height:100%;overflow:hidden;background:#050205}
body{font-family:system-ui,-apple-system,'Segoe UI',sans-serif}
button{font:inherit;touch-action:manipulation;cursor:pointer}
[hidden]{display:none!important}
#heartContainer{width:100%;height:100%;transition:opacity .4s}
#heart{position:absolute;inset:0;width:100%;height:100%;cursor:pointer}
.heart-tooltip{position:fixed;z-index:10;bottom:max(38px,calc(env(safe-area-inset-bottom,0px) + 28px));left:50%;transform:translate(-50%,8px);display:flex;align-items:center;justify-content:center;gap:9px;max-width:calc(100vw - 40px);min-height:44px;padding:10px 16px;border:1px solid #efb5c7;border-radius:999px;color:#85374f;background:linear-gradient(135deg,#fffaf5,#ffe8ef);font-size:13px;font-weight:550;line-height:1.5;box-shadow:0 4px 22px #d5446a26,inset 0 1px #fff;opacity:0;visibility:hidden;transition:opacity .4s,transform .4s,background .2s}
.heart-tooltip.visible{opacity:1;visibility:visible;transform:translate(-50%,0)}
.heart-tooltip svg{width:22px;height:22px;flex:none;fill:none;stroke:currentColor;stroke-width:1.4;stroke-linecap:round;stroke-linejoin:round}
.heart-tooltip .icon-heart{fill:#d75c7e;stroke:#fff4f7;stroke-width:1}
#tooltipText{max-width:300px;text-align:center;overflow-wrap:anywhere}
.hint-spark{font-size:19px;color:#bb6681}
.heart-tooltip:hover{background:#fff6f8;box-shadow:0 4px 26px #d5446a44}
.heart-tooltip:focus-visible,.paper-button:focus-visible{outline:2px solid #fcaac5;outline-offset:4px}
#heart:focus-visible{outline:2px solid #eaa5bf;outline-offset:-6px}
.envelope-container{--scene-top:78px;--scene-bottom:max(24px,env(safe-area-inset-bottom,0px));--scene-gap:13px;--toolbar-height:44px;position:fixed;inset:0;z-index:200;display:grid;place-items:center;padding:var(--scene-top) max(16px,env(safe-area-inset-right,0px)) var(--scene-bottom);background:radial-gradient(ellipse at 50% 65%,#38152688,#08050bea 75%);backdrop-filter:blur(8px);-webkit-backdrop-filter:blur(8px);opacity:0;visibility:hidden;pointer-events:none;transition:opacity .32s,visibility .32s}
.envelope-container.active{opacity:1;visibility:visible;pointer-events:auto}
.envelope-scene{position:relative;width:min(420px,100%);height:min(680px,100%);min-height:0;display:flex;flex-direction:column;gap:var(--scene-gap);z-index:2;container-type:inline-size}
.letter-toolbar{display:flex;align-items:center;justify-content:space-between;gap:8px;flex:none;min-height:var(--toolbar-height)}
.letter-caption{color:#dbb6c4;font:12px/1.4 system-ui,sans-serif;letter-spacing:.03em}
.letter-caption>span{font-size:18px;vertical-align:-1px;margin-right:4px}
.letter-actions{display:flex;align-items:center;gap:6px;flex:none}
.paper-button{display:flex;gap:5px;justify-content:center;align-items:center;min-height:44px;padding:8px 12px;color:#f9e2eb;background:#462331aa;border:1px solid #bf829b66;border-radius:999px;font-size:12px;white-space:nowrap;box-shadow:inset 0 1px #fff1;transition:background .2s,transform .2s}
.paper-button>span{font-size:19px;font-weight:400;line-height:1}
.paper-button:hover{background:#683448;transform:translateY(-1px)}
.paper-button:active{transform:translateY(1px)}
#revealLetter{color:#693c4c;background:#fff1ed;border-color:#f6c7d6}
.envelope-wrapper{position:relative;flex:1;min-height:0;isolation:isolate;perspective:1100px;transform:translateY(18px) scale(.94);opacity:0;transition:transform .5s cubic-bezier(.2,.7,.2,1),opacity .3s;--paper-texture: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='.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Cpath fill='%238c5265' opacity='.055' filter='url(%23n)' d='M0 0h150v150H0z'/%3E%3C/svg%3E")}
.active .envelope-wrapper{transform:translateY(0) scale(1);opacity:1}
/* Size the sealed envelope by its width, and reserve a stable reading area for the opened paper. */
.envelope-wrapper{--pocket:min(calc(100cqw / 2.25),26dvh);--shell-height:min(calc(100cqw / 1.85),max(66px,calc(100dvh - 2 * (var(--scene-top) + var(--toolbar-height) + var(--scene-gap)))));--shell-width:calc(var(--shell-height) * 1.85);--envelope-bottom:calc((100% - var(--shell-height) + var(--scene-top) - var(--scene-bottom) + var(--toolbar-height) + var(--scene-gap)) / 2)}
/* Lower before unsealing; on close, return only after the flap has folded most of the way. */
.is-opening .envelope-wrapper{--envelope-bottom:0px}
.is-open .envelope-wrapper{--shell-height:var(--pocket);--shell-width:100cqw}
.envelope-back{position:absolute;bottom:var(--envelope-bottom);height:var(--shell-height);z-index:0;background:linear-gradient(145deg,#e2a4b5,#d090a4);border-radius:5px;box-shadow:0 20px 45px #0006,0 1px 2px #0003}
.envelope-flap{position:absolute;bottom:calc(var(--envelope-bottom) + var(--shell-height) * .43);height:calc(var(--shell-height) * .57);z-index:5;transform-origin:50% 0;transform:rotateX(0deg);background:var(--paper-texture),linear-gradient(155deg,#f7ccda,#e9afc2);clip-path:polygon(0 0,100% 0,50% 100%);filter:drop-shadow(0 2px 2px #59304744)}
.stamp-heart{position:absolute;top:15%;left:50%;display:grid;place-items:center;width:36px;height:36px;margin-left:-18px;border-radius:50%;border:3px double #e99ab1;color:#ffe1e8;background:radial-gradient(circle at 35% 30%,#d86d8d,#a93e61);font:18px Georgia,serif;box-shadow:0 2px 4px #6f294c55,inset 0 0 4px #86304d88;transition:opacity .22s,transform .3s}
.is-opening .stamp-heart{opacity:0;transform:scale(.65) rotate(-15deg)}
.is-unsealed .envelope-flap{transform:rotateX(180deg);z-index:0}
.letter{position:absolute;top:0;bottom:calc(var(--pocket) - 22px);left:13px;right:13px;z-index:2;display:flex;flex-direction:column;min-height:0;padding:16px 26px 32px;border:1px solid #e8d0c3;border-radius:4px 4px 2px 2px;background:var(--paper-texture),linear-gradient(110deg,#fffcf6,#fff8f0 58%,#f9f0e6);box-shadow:0 5px 20px #32131c26,inset 0 0 24px #c9a28b0c;opacity:0;transform:translateY(calc(var(--pocket) * .7)) scale(.94);transition:transform .8s cubic-bezier(.22,.7,.2,1),opacity .3s;overflow:hidden;color-scheme:light}
.is-open .letter{opacity:1;transform:translateY(0) scale(1)}
.paper-ornament{flex:none;position:relative;color:#bf7f91;text-align:center;font:21px/1.4 Georgia,serif;margin-bottom:8px}
.paper-ornament::before,.paper-ornament::after{content:'';position:absolute;top:50%;width:27%;height:1px;background:linear-gradient(90deg,transparent,#d9b4bb);left:10%}
.paper-ornament::after{left:auto;right:10%;transform:rotate(180deg)}
.letter-scroll{flex:1;min-height:0;overflow-y:auto;overscroll-behavior:contain;touch-action:pan-y;scrollbar-width:none;outline:none;-webkit-overflow-scrolling:touch;position:relative;padding:0 2px}
.letter-scroll:focus-visible{outline:1px dashed #c58a9d;outline-offset:2px}
.letter-content{position:relative}
.letter-copy{font-family:TimThu,'Segoe Print',cursive;font-size:clamp(19px,4.9vw,23px);font-weight:700;color:var(--ink);line-height:1.7;text-align:left;overflow-wrap:anywhere}
.letter-copy strong{display:block;text-align:center;font-size:clamp(27px,6.5vw,33px);font-weight:700;line-height:1.5;color:#a74966;margin:0 0 18px;white-space:pre-wrap}
.letter-copy p{margin:0 0 18px;white-space:pre-wrap}
.letter-copy p:last-child{margin-bottom:3px;text-align:right;color:#a74966;font-size:1.07em}
.letter-reserve{visibility:hidden;pointer-events:none}
.text{position:absolute;top:0;left:0;width:100%}
.cursor{display:inline-block;width:1px;height:.85em;background:#bc6883;margin-left:2px;animation:blink .9s step-end infinite}
@keyframes blink{50%{opacity:0}}
.scroll-hint{position:absolute;bottom:10px;left:0;right:0;text-align:center;color:#986b79;font:10px/1.3 system-ui,sans-serif;letter-spacing:.04em;pointer-events:none}
.scroll-hint span{padding-left:5px}
.envelope-front{position:absolute;bottom:var(--envelope-bottom);height:var(--shell-height);z-index:3;overflow:hidden;border-radius:0 0 5px 5px;background:var(--paper-texture),linear-gradient(155deg,#f9d5df,#edb9c9);clip-path:polygon(0 0,50% 57%,100% 0,100% 100%,0 100%);box-shadow:inset 0 -1px #b9718a88;pointer-events:none}
.envelope-front::before,.envelope-front::after{content:'';position:absolute;inset:0;background:linear-gradient(140deg,#fff2f466,#e6a6bc44);clip-path:polygon(0 0,50% 57%,0 100%);border-left:1px solid #fff5}
.envelope-front::after{transform:scaleX(-1)}
/* All folded layers resize and travel together, keeping their edges aligned. */
.envelope-back,.envelope-front,.envelope-flap{left:calc((100% - var(--shell-width)) / 2);right:auto;width:var(--shell-width);transition:bottom .8s cubic-bezier(.22,.7,.2,1),left .8s cubic-bezier(.22,.7,.2,1),width .8s cubic-bezier(.22,.7,.2,1),height .8s cubic-bezier(.22,.7,.2,1),transform .65s cubic-bezier(.4,0,.2,1)}
.envelope-note{position:absolute;bottom:18px;left:0;right:0;text-align:center;color:#a66a7f;font-size:10px;letter-spacing:.06em;z-index:1}
.envelope-note span{font:15px Georgia,serif;padding-left:4px;vertical-align:-1px}
.envelope-hearts-container{position:absolute;inset:0;overflow:hidden;pointer-events:none;z-index:1}
.envelope-heart{position:absolute;left:var(--x);bottom:10%;color:#c985a3;font-size:var(--size);opacity:0;animation:float-heart 3.8s ease-out both;animation-delay:var(--delay)}
@keyframes float-heart{15%{opacity:.45}100%{opacity:0;transform:translate(var(--drift),-65vh) rotate(25deg)}}
@media(max-width:420px){.envelope-container{--scene-top:72px;--scene-bottom:max(18px,env(safe-area-inset-bottom,0px));--scene-gap:10px}.letter{left:8px;right:8px;padding:14px 18px 30px}.letter-caption{font-size:10px;max-width:110px}.paper-button{padding:8px 10px;font-size:11px}.paper-ornament{margin-bottom:6px}}
@media(max-height:540px){.envelope-container{--scene-top:64px;--scene-bottom:12px;--scene-gap:5px}.letter{padding:8px 25px 28px;bottom:calc(var(--pocket) - 14px)}.paper-ornament{display:none}.letter-copy{font-size:19px;line-height:1.6}.letter-copy strong{font-size:25px;margin-bottom:10px}.envelope-note{bottom:9px;font-size:9px}.stamp-heart{width:26px;height:26px;margin-left:-13px;font-size:13px}}
@media(min-width:600px) and (max-height:540px){.envelope-container{--scene-top:16px}}
@media(prefers-reduced-motion:reduce){*,*::before,*::after{animation:none!important;transition-duration:.01ms!important}.envelope-heart{display:none}}
