/* ============================================================
   TĨNH ĐAO — IMMERSIVE LAYER
   Hiệu ứng "thế giới bí ẩn, tuyệt mật"
   Dùng chung cho trang chủ + các trang chi tiết Premium.
   Mọi chuyển động: chậm, có trọng lượng, kiềm chế.
   ============================================================ */

:root {
    --imm-crimson: #C81D25;
    --imm-coral:   #FF5A5F;
    --imm-teal:    #087E8B;
    --imm-ease:    cubic-bezier(0.16, 1, 0.3, 1);
}

/* Tôn trọng người dùng tắt animation */
@media (prefers-reduced-motion: reduce) {
    .imm-reveal { opacity: 1 !important; transform: none !important; }
    #imm-gate { display: none !important; }
    .imm-fog, .imm-grain, .imm-cursor-light { display: none !important; }
}

/* ====== 1. MÀN MỞ KHÓA TRUY CẬP (ACCESS GATE) ====== */
#imm-gate {
    position: fixed;
    inset: 0;
    z-index: 99999;
    background:
        radial-gradient(ellipse 80% 60% at 50% 50%, rgba(11,57,84,0.25) 0%, transparent 60%),
        #030305;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: opacity 1.1s var(--imm-ease), visibility 1.1s var(--imm-ease);
    overflow: hidden;
}
#imm-gate.imm-gate-open {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}
/* Hai cánh cửa tách ra */
#imm-gate .imm-door {
    position: absolute;
    top: 0; bottom: 0;
    width: 50.5%;
    background: linear-gradient(180deg, #0a1420 0%, #050505 50%, #0a0d12 100%);
    z-index: 1;
    transition: transform 1.2s var(--imm-ease);
    box-shadow: 0 0 80px rgba(0,0,0,0.9);
}
#imm-gate .imm-door.left  { left: 0;  border-right: 1px solid rgba(200,29,37,0.25); }
#imm-gate .imm-door.right { right: 0; border-left:  1px solid rgba(200,29,37,0.25); }
#imm-gate.imm-gate-open .imm-door.left  { transform: translateX(-100%); }
#imm-gate.imm-gate-open .imm-door.right { transform: translateX(100%); }

#imm-gate .imm-gate-core {
    position: relative;
    z-index: 3;
    text-align: center;
    transition: opacity 0.5s ease, transform 0.6s var(--imm-ease);
}
#imm-gate.imm-gate-open .imm-gate-core { opacity: 0; transform: scale(0.92); }

#imm-gate .imm-seal {
    width: 78px; height: 78px;
    margin: 0 auto 26px;
    border: 1.5px solid var(--imm-crimson);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    position: relative;
    box-shadow: 0 0 30px rgba(200,29,37,0.4), inset 0 0 22px rgba(200,29,37,0.18);
    animation: imm-seal-pulse 2.2s ease-in-out infinite;
}
#imm-gate .imm-seal::before {
    content: "";
    position: absolute; inset: 7px;
    border: 1px solid rgba(8,126,139,0.45);
    border-radius: 50%;
}
#imm-gate .imm-seal span {
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 30px; font-weight: 700;
    color: var(--imm-coral);
    letter-spacing: 1px;
}
@keyframes imm-seal-pulse {
    0%,100% { box-shadow: 0 0 30px rgba(200,29,37,0.4), inset 0 0 22px rgba(200,29,37,0.18); }
    50%     { box-shadow: 0 0 48px rgba(200,29,37,0.6), inset 0 0 28px rgba(200,29,37,0.28); }
}

#imm-gate .imm-gate-label {
    font-size: 11px;
    letter-spacing: 6px;
    text-transform: uppercase;
    color: rgba(191,215,234,0.5);
    margin-bottom: 14px;
}
#imm-gate .imm-gate-status {
    font-size: 14px;
    letter-spacing: 2px;
    color: #e8eef4;
    font-weight: 500;
    min-height: 20px;
}
#imm-gate .imm-gate-status .imm-dots::after {
    content: "";
    animation: imm-dots 1.4s steps(4, end) infinite;
}
@keyframes imm-dots {
    0% { content: ""; } 25% { content: "."; }
    50% { content: ".."; } 75% { content: "..."; }
}
#imm-gate .imm-gate-bar {
    width: 200px; height: 2px;
    margin: 22px auto 0;
    background: rgba(191,215,234,0.12);
    overflow: hidden;
    border-radius: 2px;
}
#imm-gate .imm-gate-bar span {
    display: block; height: 100%;
    width: 0;
    background: linear-gradient(90deg, var(--imm-teal), var(--imm-coral));
    box-shadow: 0 0 12px rgba(255,90,95,0.6);
    transition: width 0.2s linear;
}

/* ====== 2. VÂN NHIỄU (FILM GRAIN) ====== */
.imm-grain {
    position: fixed;
    inset: -50%;
    width: 200%; height: 200%;
    z-index: 9990;
    pointer-events: none;
    opacity: 0.045;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    animation: imm-grain-move 0.6s steps(3) infinite;
}
@keyframes imm-grain-move {
    0%   { transform: translate(0,0); }
    33%  { transform: translate(-2%, 1%); }
    66%  { transform: translate(1%, -2%); }
    100% { transform: translate(0,0); }
}

/* ====== 3. ÁNH SÁNG THEO CON TRỎ (TORCH) ====== */
.imm-cursor-light {
    position: fixed;
    top: 0; left: 0;
    width: 520px; height: 520px;
    margin-left: -260px; margin-top: -260px;
    z-index: 9985;
    pointer-events: none;
    background: radial-gradient(circle, rgba(255,90,95,0.06) 0%, rgba(8,126,139,0.04) 35%, transparent 70%);
    transition: transform 0.18s ease-out, opacity 0.4s ease;
    opacity: 0;
    will-change: transform;
}
.imm-cursor-light.imm-on { opacity: 1; }

/* ====== 4. SƯƠNG / KHÓI (FOG) cho hero ====== */
.imm-fog {
    position: absolute;
    inset: 0;
    z-index: 1;
    pointer-events: none;
    overflow: hidden;
}
.imm-fog::before,
.imm-fog::after {
    content: "";
    position: absolute;
    width: 160%; height: 160%;
    top: -30%; left: -30%;
    background: radial-gradient(ellipse 50% 40% at 30% 40%, rgba(11,57,84,0.22) 0%, transparent 55%),
                radial-gradient(ellipse 40% 50% at 70% 60%, rgba(8,126,139,0.14) 0%, transparent 55%);
    filter: blur(8px);
    animation: imm-fog-drift 38s ease-in-out infinite;
}
.imm-fog::after {
    animation-duration: 52s;
    animation-direction: reverse;
    opacity: 0.7;
}
@keyframes imm-fog-drift {
    0%   { transform: translate(0,0) rotate(0deg) scale(1); }
    50%  { transform: translate(4%, -3%) rotate(4deg) scale(1.08); }
    100% { transform: translate(0,0) rotate(0deg) scale(1); }
}

/* ====== 5. SCROLL REVEAL có trọng lượng ====== */
.imm-reveal {
    opacity: 0;
    transform: translateY(34px);
    transition:
        opacity 0.9s var(--imm-ease),
        transform 0.9s var(--imm-ease);
    will-change: opacity, transform;
}
.imm-reveal.imm-visible {
    opacity: 1;
    transform: translateY(0);
}
/* trễ nhau khi nhiều phần tử trong một nhóm */
.imm-reveal.imm-d1 { transition-delay: 0.08s; }
.imm-reveal.imm-d2 { transition-delay: 0.16s; }
.imm-reveal.imm-d3 { transition-delay: 0.24s; }
.imm-reveal.imm-d4 { transition-delay: 0.32s; }

/* ====== 6. THANH TIẾN TRÌNH CUỘN ====== */
#imm-progress {
    position: fixed;
    top: 0; left: 0;
    height: 2px;
    width: 0%;
    z-index: 9995;
    background: linear-gradient(90deg, var(--imm-teal), var(--imm-coral), var(--imm-crimson));
    box-shadow: 0 0 10px rgba(255,90,95,0.5);
    transition: width 0.1s linear;
    pointer-events: none;
}

/* ====== 7. CARD "THỞ" khi hover (Premium + book + bundle) ====== */
.featured-card,
.book-card,
.bundle-card {
    transition:
        transform 0.5s var(--imm-ease),
        box-shadow 0.5s var(--imm-ease),
        border-color 0.5s var(--imm-ease) !important;
    will-change: transform;
}
.featured-card:hover {
    transform: translateY(-8px) !important;
    box-shadow: 0 24px 60px rgba(0,0,0,0.6), 0 0 0 1px rgba(255,90,95,0.25), 0 0 40px rgba(200,29,37,0.12) !important;
}
.book-card:hover,
.bundle-card:hover {
    transform: translateY(-6px) !important;
    box-shadow: 0 18px 44px rgba(0,0,0,0.5), 0 0 0 1px rgba(8,126,139,0.28) !important;
}

/* ====== 8. VIGNETTE — bóng tối ăn vào rìa màn hình ====== */
#imm-vignette {
    position: fixed;
    inset: 0;
    z-index: 9980;
    pointer-events: none;
    background: radial-gradient(ellipse 90% 80% at 50% 45%, transparent 55%, rgba(0,0,0,0.45) 100%);
}

/* Khóa cuộn khi gate đang hiện */
body.imm-locked { overflow: hidden; }
