/* =========================================
   1. CÀI ĐẶT GỐC & TỰ ĐỘNG CO GIÃN (FLUID SIZING)
   ========================================= */
:root {
    /* Khai báo biến để dễ quản lý */
    --bg-track: #030712;
    --bg-thumb: #06b6d4;
    --bg-thumb-hover: #0891b2;
    
    /* Dùng clamp() để padding và hiệu ứng tự động thay đổi theo thiết bị */
    --glass-padding: clamp(1rem, 2.5vw, 3rem);
    --reveal-distance: clamp(20px, 4vw, 40px);
}

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body { 
    letter-spacing: 0.01em; 
    overflow-x: hidden; /* Ngăn lỗi cuộn ngang khó chịu trên điện thoại */
    font-size: clamp(14px, 1.2vw, 18px); /* Chữ tự động to nhỏ tùy màn hình */
}

/* =========================================
   2. THANH CUỘN (SCROLLBAR)
   ========================================= */
::-webkit-scrollbar { 
    width: clamp(4px, 1vw, 8px); /* Nhỏ gọn trên đt, to rõ trên PC/TV */
}
::-webkit-scrollbar-track { 
    background: var(--bg-track); 
}
::-webkit-scrollbar-thumb { 
    background: var(--bg-thumb); 
    border-radius: 10px; 
}
::-webkit-scrollbar-thumb:hover { 
    background: var(--bg-thumb-hover); 
}

/* =========================================
   3. HIỆU ỨNG KÍNH (GLASSMORPHISM)
   ========================================= */
.glass-nav { 
    background: rgba(3, 7, 18, 0.7); 
    backdrop-filter: blur(16px); 
    -webkit-backdrop-filter: blur(16px); /* Bắt buộc cho iOS/Safari */
    border: 1px solid rgba(255, 255, 255, 0.05); 
    width: 100%;
    padding: clamp(0.5rem, 2vw, 1.5rem);
}

.glass-panel { 
    background: rgba(15, 23, 42, 0.6); 
    backdrop-filter: blur(20px); 
    -webkit-backdrop-filter: blur(20px); /* Bắt buộc cho iOS/Safari */
    border: 1px solid rgba(255, 255, 255, 0.08); 
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1); 
    padding: var(--glass-padding);
    border-radius: clamp(12px, 2vw, 24px); /* Bo góc mềm mại, tự thu nhỏ trên đt */
    width: 100%;
    max-width: 100%;
}

/* =========================================
   4. HIỆU ỨNG CHỮ & HOẠT ẢNH TIẾT LỘ (REVEAL)
   ========================================= */
.text-gradient { 
    background: linear-gradient(to right, #22d3ee, #818cf8, #c084fc); 
    -webkit-background-clip: text; 
    background-clip: text;
    -webkit-text-fill-color: transparent; 
    display: inline-block; /* Tránh lỗi cắt chữ ở một số trình duyệt */
}

.reveal { 
    opacity: 0; 
    transform: translateY(var(--reveal-distance)); 
    transition: all 0.8s cubic-bezier(0.5, 0, 0, 1); 
    will-change: opacity, transform; /* Tối ưu FPS cho điện thoại đời cũ */
}
.reveal.active { 
    opacity: 1; 
    transform: translateY(0); 
}

/* =========================================
   5. PHÁO HOA & HÌNH ẢNH
   ========================================= */
#fireworks-canvas { 
    position: absolute; 
    top: 0; 
    left: 0; 
    width: 100vw; /* Đảm bảo phủ kín mọi độ rộng màn hình */
    height: 100vh; 
    z-index: 0; 
    opacity: 0.5; 
    pointer-events: none; 
}

.img-placeholder {
    background: linear-gradient(135deg, #1e293b, #0f172a);
    border: 1px solid rgba(6, 182, 212, 0.2);
    display: flex; 
    align-items: center; 
    justify-content: center;
    color: #475569; 
    font-family: 'Chakra Petch', sans-serif; 
    text-transform: uppercase;
    overflow: hidden; 
    position: relative;
    width: 100%;
    min-height: clamp(150px, 25vw, 400px); /* Linh hoạt chiều cao khối ảnh */
}
.img-placeholder::after {
    content: ''; 
    position: absolute; 
    top: 0; 
    left: -100%; 
    width: 50%; 
    height: 100%;
    background: linear-gradient(to right, transparent, rgba(255,255,255,0.1), transparent);
    transform: skewX(-20deg); 
    transition: 0.5s;
}
.img-placeholder:hover::after,
.img-placeholder:active::after { /* Thêm :active để touch trên điện thoại cũng có hiệu ứng */
    left: 150%; 
}

.img-zoomable { 
    cursor: zoom-in; 
    transition: transform 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94); 
    max-width: 100%; /* Tránh ảnh bị tràn vỡ layout */
    height: auto;
    display: block;
}
.img-zoomable:hover { 
    transform: scale(1.05); 
    filter: brightness(1.1); 
}

/* =========================================
   6. MODAL (CỬA SỔ NỔI)
   ========================================= */
#image-modal { 
    transition: opacity 0.3s ease, visibility 0.3s ease; 
    opacity: 0; 
    visibility: hidden; 
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    width: 100vw; height: 100vh;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.85);
    padding: clamp(10px, 3vw, 40px);
}
#image-modal.active { 
    opacity: 1; 
    visibility: visible; 
}

/* =========================================
   7. 3D FLIP CARD (BỐC QUẺ)
   ========================================= */
.perspective-1000 { 
    perspective: 1000px; 
    width: 100%; 
} 
.transform-style-3d { 
    transform-style: preserve-3d; 
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.8s cubic-bezier(0.4, 0.2, 0.2, 1);
}
.backface-hidden { 
    backface-visibility: hidden; 
    -webkit-backface-visibility: hidden; /* Quan trọng: Fix lỗi chớp màn hình khi xoay 3D trên iPhone/iPad */
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
}
.rotate-y-180 { 
    transform: rotateY(180deg); 
}

/* =========================================
   8. MEDIA QUERIES (TỐI ƯU CỤ THỂ THEO MÀN HÌNH)
   ========================================= */

/* Mobile (Màn hình nhỏ dưới 768px) */
@media screen and (max-width: 768px) {
    .img-zoomable:hover { 
        transform: scale(1.02); /* Giảm lực zoom trên đt để tránh bị chạm mép màn hình */
    }
}

/* TV / Ultra Wide (Màn hình siêu rộng trên 1920px) */
@media screen and (min-width: 1920px) {
    body {
        max-width: 1920px; /* Khóa khung hình tối đa, tránh giao diện bị bè ngang quá đà trên TV */
        margin: 0 auto;
    }
    #fireworks-canvas {
        left: 50%;
        transform: translateX(-50%); /* Giữ pháo hoa luôn ở trung tâm TV */
    }
}