/*
 * Màn chào trang chủ: logo bật ra, chữ Locket hiện từng chữ, nhãn GOLD, thanh tải,
 * rồi mưa icon logo Locket phủ kín màn hình và đổ xuống để lộ trang chủ.
 * Chỉ chạy 1 lần mỗi phiên (sessionStorage), tắt khi người dùng bật giảm chuyển động.
 */
#lgSplash {
    position: fixed; inset: 0; z-index: 9999; overflow: hidden;
    display: flex; align-items: center; justify-content: center;
    background:
        radial-gradient(60% 55% at 50% 45%, #fffafc 0%, rgba(255, 250, 252, .9) 35%, rgba(255, 228, 238, 0) 70%),
        linear-gradient(180deg, #ffb3cf 0%, #ffd3e2 30%, #ffeef5 62%, #fff6fa 100%);
    transition: background-color .35s ease;
    /* chống kẹt nếu JS lỗi: tự ẩn sau 11.5s (sau mốc của splash.js để không cắt ngang hiệu ứng) */
    animation: lgSplashFailSafe 0s linear 11.5s forwards;
}
html.lg-no-splash #lgSplash { display: none; }
#lgSplash.is-raining { background: transparent; }
#lgSplash.is-done { opacity: 0; visibility: hidden; transition: opacity .25s ease, visibility 0s .25s; }

@keyframes lgSplashFailSafe { to { opacity: 0; visibility: hidden; pointer-events: none; } }

#lgSplash canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }

.lgs-bg { position: absolute; inset: 0; transition: opacity .45s ease; }
#lgSplash.is-raining .lgs-bg { opacity: 0; }

.lgs-center { position: relative; display: flex; flex-direction: column; align-items: center; transition: opacity .3s ease, transform .4s ease; }
#lgSplash.is-raining .lgs-center { opacity: 0; transform: scale(.94); }

.lgs-icon {
    width: 84px; height: 84px; border-radius: 22px; overflow: hidden;
    box-shadow: 0 14px 30px -10px rgba(224, 80, 138, .5), 0 0 0 4px #fff;
    transform: scale(0) rotate(-14deg);
    animation: lgsPop .55s cubic-bezier(.34, 1.56, .64, 1) .05s forwards;
}
.lgs-icon img { width: 100%; height: 100%; object-fit: cover; display: block; }

.lgs-word { margin-top: 18px; display: flex; font-family: 'Fredoka', 'Nunito', system-ui, sans-serif; font-weight: 700; font-size: 72px; line-height: 1; letter-spacing: -.02em; color: #4a2b3a; }
.lgs-word span { display: inline-block; opacity: 0; transform: translateY(26px) scale(.6); animation: lgsLetter .45s cubic-bezier(.34, 1.56, .64, 1) forwards; animation-delay: calc(.38s + var(--i) * .07s); }

.lgs-pill {
    margin-top: -4px; padding: 10px 30px; border-radius: 18px;
    background: linear-gradient(180deg, #ffa3c6, #ff6fa3);
    box-shadow: inset 0 2px 0 rgba(255, 255, 255, .6), 0 10px 20px -8px rgba(201, 58, 114, .55), 0 0 0 3px #ffe4ee;
    font-family: 'Nunito', system-ui, sans-serif; font-weight: 900; font-size: 22px; letter-spacing: .45em; color: #fff;
    transform: rotate(-8deg) scale(0); opacity: 0;
    animation: lgsPill .55s cubic-bezier(.34, 1.56, .64, 1) .95s forwards;
}

.lgs-spark { position: absolute; color: #ff6fa3; font-size: 18px; opacity: 0; animation: lgsTwinkle 1.4s ease-in-out infinite; }
.lgs-spark.s1 { left: -70px; top: 10px; animation-delay: .6s; }
.lgs-spark.s2 { right: -60px; top: 120px; font-size: 12px; animation-delay: .9s; }
.lgs-spark.s3 { left: -40px; bottom: 30px; font-size: 10px; animation-delay: 1.1s; }
.lgs-spark.s4 { right: -90px; bottom: -10px; font-size: 14px; animation-delay: .75s; }

.lgs-progress { position: absolute; left: 50%; bottom: 13%; transform: translateX(-50%); width: 160px; text-align: center; transition: opacity .3s ease; }
#lgSplash.is-raining .lgs-progress { opacity: 0; }
.lgs-track { height: 4px; border-radius: 999px; background: rgba(74, 43, 58, .1); overflow: hidden; }
.lgs-bar { height: 100%; width: 0; border-radius: 999px; background: linear-gradient(90deg, #f0558d, #ff85b2); transition: width .25s ease; }
.lgs-label { margin-top: 8px; font: 700 11px/1 'Nunito', system-ui, sans-serif; color: rgba(74, 43, 58, .55); }

@keyframes lgsPop { to { transform: scale(1) rotate(0); } }
@keyframes lgsLetter { to { opacity: 1; transform: none; } }
@keyframes lgsPill { to { opacity: 1; transform: rotate(-8deg) scale(1); } }
@keyframes lgsTwinkle { 0%, 100% { opacity: 0; transform: scale(.5) rotate(0); } 50% { opacity: 1; transform: scale(1) rotate(45deg); } }

@media (max-width: 640px) {
    .lgs-icon { width: 68px; height: 68px; border-radius: 18px; }
    .lgs-word { font-size: 54px; }
    .lgs-pill { font-size: 17px; padding: 8px 24px; }
}

/* ---------- Hero hiện dần sau màn chào ----------
 * Điện thoại / sticker đang có animation hxFloat (dùng translate) nên chỉ đổi opacity + scale cho chúng.
 * Chống kẹt: script trong <head> tự thêm lg-hero-in sau 7.5s nếu splash.js không chạy.
 */
html.lg-hero-anim .hx-copy > *,
html.lg-hero-anim .hx-phone,
html.lg-hero-anim .hx-float,
html.lg-hero-anim .hx-sticker,
html.lg-hero-anim header { opacity: 0; }
html.lg-hero-anim .hx-copy > * { translate: 0 26px; }
html.lg-hero-anim header { translate: 0 -14px; }
html.lg-hero-anim .hx-phone { scale: .9; }
html.lg-hero-anim .hx-float,
html.lg-hero-anim .hx-sticker { scale: .4; }

html.lg-hero-anim.lg-hero-in .hx-copy > *,
html.lg-hero-anim.lg-hero-in header { opacity: 1; translate: 0 0; transition: opacity .6s ease, translate .8s cubic-bezier(.2, .8, .2, 1); }
html.lg-hero-anim.lg-hero-in .hx-phone,
html.lg-hero-anim.lg-hero-in .hx-float,
html.lg-hero-anim.lg-hero-in .hx-sticker { opacity: 1; scale: 1; transition: opacity .6s ease, scale .75s cubic-bezier(.34, 1.56, .64, 1); }

html.lg-hero-anim.lg-hero-in .hx-copy > :nth-child(1) { transition-delay: .05s; }
html.lg-hero-anim.lg-hero-in .hx-copy > :nth-child(2) { transition-delay: .13s; }
html.lg-hero-anim.lg-hero-in .hx-copy > :nth-child(3) { transition-delay: .21s; }
html.lg-hero-anim.lg-hero-in .hx-copy > :nth-child(4) { transition-delay: .29s; }
html.lg-hero-anim.lg-hero-in .hx-copy > :nth-child(5) { transition-delay: .37s; }
html.lg-hero-anim.lg-hero-in .hx-cam { transition-delay: .18s; }
html.lg-hero-anim.lg-hero-in .hx-home { transition-delay: .3s; }
html.lg-hero-anim.lg-hero-in .hx-float, html.lg-hero-anim.lg-hero-in .hx-sticker { transition-delay: .45s; }

@media (prefers-reduced-motion: reduce) {
    #lgSplash { display: none; }
    html.lg-hero-anim .hx-copy > *, html.lg-hero-anim .hx-phone, html.lg-hero-anim .hx-float,
    html.lg-hero-anim .hx-sticker, html.lg-hero-anim header { opacity: 1; translate: none; scale: none; }
}
