/* ==========================================================================
   3D EFFECTS & BIDIRECTIONAL SCROLL ENGINE (DoiTuongTac.Com)
   ========================================================================== */

/* ---- 3D Scroll Progress Depth Bar ---- */
#scroll-depth-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 0%;
    height: 4px;
    background: linear-gradient(90deg, #00f2fe 0%, #4facfe 50%, #6366f1 100%);
    box-shadow: 0 0 10px rgba(0, 242, 254, 0.8), 0 0 20px rgba(99, 102, 241, 0.6);
    z-index: 999999;
    pointer-events: none;
    transition: width 0.08s linear;
    border-radius: 0 4px 4px 0;
}

/* ---- Ambient 3D Neon Orbs (Background Depth) ---- */
.ambient-scene-bg {
    position: fixed;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
    z-index: 0;
}

.ambient-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(90px);
    opacity: 0.16;
    pointer-events: none;
    will-change: transform;
    transition: transform 0.4s ease-out;
}

.ambient-orb-1 {
    width: 520px;
    height: 520px;
    top: 5%;
    left: -100px;
    background: radial-gradient(circle, #38bdf8, #2563eb);
    animation: orbFloat1 18s ease-in-out infinite alternate;
}

.ambient-orb-2 {
    width: 600px;
    height: 600px;
    top: 45%;
    right: -120px;
    background: radial-gradient(circle, #818cf8, #4f46e5);
    animation: orbFloat2 22s ease-in-out infinite alternate;
}

.ambient-orb-3 {
    width: 480px;
    height: 480px;
    bottom: 5%;
    left: 20%;
    background: radial-gradient(circle, #06b6d4, #0284c7);
    animation: orbFloat3 20s ease-in-out infinite alternate;
}

@keyframes orbFloat1 {
    0% { transform: translate3d(0, 0, 0) scale(1); }
    100% { transform: translate3d(80px, 120px, 0) scale(1.15); }
}
@keyframes orbFloat2 {
    0% { transform: translate3d(0, 0, 0) scale(1); }
    100% { transform: translate3d(-100px, -80px, 0) scale(1.2); }
}
@keyframes orbFloat3 {
    0% { transform: translate3d(0, 0, 0) scale(1.1); }
    100% { transform: translate3d(60px, -90px, 0) scale(0.9); }
}

/* ---- 3D Perspective Scenes ---- */
.perspective-scene {
    perspective: 1200px;
    perspective-origin: center center;
    transform-style: preserve-3d;
}

/* Sections Perspective Setup */
#hero, #why_chose_us, #service_home, #payment_methods, #api-section {
    perspective: 1200px;
    position: relative;
    z-index: 1;
}

#get-start, footer {
    position: relative;
    z-index: 1;
    overflow: hidden !important;
}

/* ---- 3D Scroll Reveal Elements (Bidirectional Up & Down) ---- */
.reveal-3d {
    opacity: 0;
    filter: blur(4px);
    will-change: transform, opacity, filter;
    transition: transform 0.85s cubic-bezier(0.16, 1, 0.3, 1),
                opacity 0.85s cubic-bezier(0.16, 1, 0.3, 1),
                filter 0.85s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Khi người dùng cuộn XUỐNG: Phần tử xuất hiện từ dưới lên, nghiêng về sau */
.reveal-3d.from-bottom {
    transform: perspective(1200px) rotateX(15deg) translateY(65px) translateZ(-50px) scale(0.94);
}

/* Khi người dùng cuộn LÊN: Phần tử xuất hiện từ trên xuống, nghiêng về trước */
.reveal-3d.from-top {
    transform: perspective(1200px) rotateX(-15deg) translateY(-60px) translateZ(-50px) scale(0.94);
}

/* Cột trái lượn từ góc trái vào */
.reveal-3d.from-left {
    transform: perspective(1200px) rotateY(18deg) rotateX(6deg) translateX(-60px) translateZ(-50px) scale(0.94);
}

/* Cột phải lượn từ góc phải vào */
.reveal-3d.from-right {
    transform: perspective(1200px) rotateY(-18deg) rotateX(6deg) translateX(60px) translateZ(-50px) scale(0.94);
}

/* Khi phần tử nằm trong khung nhìn (In-View) */
.reveal-3d.in-view-3d {
    opacity: 1;
    filter: blur(0);
    transform: perspective(1200px) rotateX(0deg) rotateY(0deg) translateX(0) translateY(0) translateZ(0) scale(1) !important;
}

/* Độ trễ phân tầng tự nhiên (Stagger delays) */
.reveal-delay-1 { transition-delay: 0.1s; }
.reveal-delay-2 { transition-delay: 0.2s; }
.reveal-delay-3 { transition-delay: 0.3s; }
.reveal-delay-4 { transition-delay: 0.4s; }

/* ---- Dynamic Scroll Velocity Inertia (Quán tính cuộn trang) ---- */
.inertia-scroll-layer {
    will-change: transform;
    transform-style: preserve-3d;
    transition: transform 0.12s ease-out;
}

/* ---- Interactive 3D Card Tilt with Specular Glare ---- */
.card-3d-tilt {
    transform-style: preserve-3d;
    perspective: 1000px;
    will-change: transform, box-shadow;
    position: relative;
    transition: transform 0.12s ease-out, box-shadow 0.3s ease;
}

.card-3d-tilt:hover {
    box-shadow: 0 25px 50px -12px rgba(26, 70, 153, 0.25), 0 0 25px rgba(67, 185, 254, 0.18) !important;
}

/* Tầng chiều sâu bên trong card (Parallax Z-Depth) */
.card-3d-tilt .depth-layer-1 {
    transform: translateZ(20px);
    transform-style: preserve-3d;
}

.card-3d-tilt .depth-layer-2 {
    transform: translateZ(40px);
    transform-style: preserve-3d;
}

.card-3d-tilt .depth-layer-3 {
    transform: translateZ(60px);
    transform-style: preserve-3d;
}

/* Lớp vệt sáng phản chiếu (Specular Glare Reflection) */
.glare-effect-layer {
    position: absolute;
    inset: 0;
    border-radius: inherit;
    pointer-events: none;
    overflow: hidden;
    z-index: 20;
    opacity: 0;
    mix-blend-mode: overlay;
    transition: opacity 0.35s ease;
}

.glare-effect-layer .glare-highlight {
    position: absolute;
    width: 200%;
    height: 200%;
    top: -50%;
    left: -50%;
    background: radial-gradient(circle at center, rgba(255, 255, 255, 0.6) 0%, rgba(255, 255, 255, 0.1) 35%, transparent 70%);
    pointer-events: none;
    transform: translate(-50%, -50%);
}

.card-3d-tilt:hover .glare-effect-layer {
    opacity: 1;
}

/* ---- Floating 3D Parallax Badges & Icons ---- */
.float-3d-item {
    will-change: transform;
    transform-style: preserve-3d;
    animation: float3D 6s ease-in-out infinite alternate;
}

@keyframes float3D {
    0% {
        transform: perspective(800px) translateY(0px) translateZ(20px) rotateX(0deg) rotateY(0deg);
    }
    50% {
        transform: perspective(800px) translateY(-14px) translateZ(45px) rotateX(6deg) rotateY(-8deg);
    }
    100% {
        transform: perspective(800px) translateY(8px) translateZ(25px) rotateX(-5deg) rotateY(6deg);
    }
}

.float-delay-1 { animation-delay: 0.5s; animation-duration: 5.5s; }
.float-delay-2 { animation-delay: 1.2s; animation-duration: 6.8s; }
.float-delay-3 { animation-delay: 1.9s; animation-duration: 7.2s; }
.float-delay-4 { animation-delay: 2.6s; animation-duration: 6.2s; }

/* ---- Card Services Glass 3D Elevation ---- */
.card_services {
    border-radius: 24px !important;
    overflow: hidden;
    box-shadow: 0 20px 45px rgba(26, 70, 153, 0.12) !important;
    border: 1px solid rgba(67, 185, 254, 0.25) !important;
    background: rgba(255, 255, 255, 0.96) !important;
    backdrop-filter: blur(10px);
}

.card_services:hover {
    box-shadow: 0 30px 60px rgba(26, 70, 153, 0.2), 0 0 30px rgba(67, 185, 254, 0.2) !important;
}

/* Feature Item 3D Hover */
.feature_item {
    border-radius: 20px !important;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1) !important;
    border: 1px solid rgba(67, 185, 254, 0.15);
    background: #ffffff;
    box-shadow: 0 10px 25px rgba(26, 70, 153, 0.06);
}

.feature_item:hover {
    transform: translateY(-8px) translateZ(30px) scale(1.02);
    box-shadow: 0 20px 40px rgba(26, 70, 153, 0.16), 0 0 20px rgba(67, 185, 254, 0.2) !important;
    border-color: rgba(67, 185, 254, 0.5);
}

.feature_item .icon {
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.feature_item:hover .icon {
    transform: scale(1.15) rotate(4deg) translateZ(25px);
}

/* API Code Box 3D Isometric View */
#api-section .bg-dark {
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.12) !important;
    box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.6), 0 0 35px rgba(56, 189, 248, 0.15) !important;
    transition: all 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

#api-section .bg-dark:hover {
    transform: perspective(1000px) rotateX(4deg) rotateY(-4deg) translateY(-8px) translateZ(30px);
    box-shadow: 0 35px 75px -15px rgba(0, 0, 0, 0.7), 0 0 50px rgba(56, 189, 248, 0.3) !important;
}

/* Get Started Banner 3D */
.get_start_container {
    position: relative;
    border-radius: 30px !important;
    box-shadow: 0 25px 65px rgba(26, 70, 153, 0.28) !important;
    transition: box-shadow 0.3s ease;
}

.get_start_container:hover {
    box-shadow: 0 35px 80px rgba(26, 70, 153, 0.35) !important;
}

/* Mobile & Tablet Performance Optimizations (Smooth 60fps & Zero Hidden Content) */
@media (max-width: 991px) {
    /* 1. Tắt đèn nền ambient orb nặng GPU trên điện thoại */
    .ambient-scene-bg {
        display: none !important;
    }

    /* 2. Hiển thị 100% nội dung ngay lập tức, không để bất kỳ khối nào bị ẩn hay mờ */
    .reveal-3d,
    .reveal-3d.from-bottom,
    .reveal-3d.from-top,
    .reveal-3d.from-left,
    .reveal-3d.from-right {
        opacity: 1 !important;
        filter: none !important;
        transform: none !important;
        transition: none !important;
        visibility: visible !important;
    }

    /* 3. Tắt 3D tilt và vệt sáng phản chiếu khi chạm tay */
    .card-3d-tilt,
    .card-3d-tilt:hover,
    .feature_item:hover,
    #api-section .bg-dark:hover {
        transform: none !important;
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.06) !important;
    }

    .glare-effect-layer {
        display: none !important;
    }
}
