/* =========================================
   CORE SYSTEM VARIABLES (CSS VARS)
   ========================================= */
:root {
    /* Colors */
    --bg-color: #050505;
    --terminal-bg: rgba(13, 17, 23, 0.95);
    --card-bg: rgba(22, 27, 34, 0.75);
    
    /* Neon Palette */
    --neon-cyan: #00f3ff;
    --neon-pink: #bc13fe;
    --neon-green: #0aff0a;
    --neon-red: #ff003c;
    --neon-yellow: #ffee00;
    
    /* Text */
    --text-main: #e6edf3;
    --text-dim: #8b949e;
    
    /* Effects */
    --glass-border: 1px solid rgba(255, 255, 255, 0.1);
    --shadow-glow: 0 0 15px rgba(0, 243, 255, 0.25);
    --scanline: rgba(0, 0, 0, 0.5);
}

/* =========================================
   GLOBAL RESET & TYPOGRAPHY
   ========================================= */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    outline: none;
    -webkit-tap-highlight-color: transparent; /* Remove blue highlight on mobile tap */
    scrollbar-width: thin;
    scrollbar-color: var(--neon-cyan) var(--bg-color);
}

html {
    font-size: 16px; /* Base font size */
    scroll-behavior: smooth;
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    font-family: 'Fira Code', monospace; /* Font cho dân IT */
    overflow-x: hidden; /* Ngăn cuộn ngang gây vỡ layout */
    min-height: 100vh;
    position: relative;
    line-height: 1.6;
}

/* Custom Scrollbar (Webkit based) */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg-color); }
::-webkit-scrollbar-thumb { background: var(--neon-cyan); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--neon-pink); }

/* Selection Color */
::selection { background: var(--neon-pink); color: #fff; }

/* =========================================
   BACKGROUND FX: CANVAS & SCANLINES
   ========================================= */
#matrix-canvas {
    position: fixed;
    top: 0; left: 0;
    width: 100vw; height: 100vh;
    z-index: 0;
    opacity: 0.12;
    pointer-events: none;
}

.scanlines {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: linear-gradient(to bottom, rgba(255,255,255,0), rgba(255,255,255,0) 50%, rgba(0,0,0,0.2) 50%, rgba(0,0,0,0.2));
    background-size: 100% 4px;
    z-index: 999;
    pointer-events: none;
    opacity: 0.4;
}

/* =========================================
   LOADER: SYSTEM BOOT SEQUENCE
   ========================================= */
#system-boot {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: #000;
    z-index: 99999; /* Highest priority */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.boot-text {
    color: var(--neon-green);
    font-size: 1rem;
    margin-bottom: 15px;
    text-align: center;
}

.progress-bar {
    width: 100%;
    max-width: 300px;
    height: 4px;
    background: #333;
    position: relative;
    overflow: hidden;
    border-radius: 2px;
}

.progress-fill {
    height: 100%;
    background: var(--neon-green);
    width: 0%;
    transition: width 0.5s ease;
    box-shadow: 0 0 10px var(--neon-green);
}

/* =========================================
   HEADER: HUD INTERFACE
   ========================================= */
header {
    position: sticky;
    top: 0;
    z-index: 100;
    padding: 15px 5%; /* Sử dụng % để linh hoạt */
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(0, 243, 255, 0.2);
    background: rgba(5, 5, 5, 0.9);
    backdrop-filter: blur(15px); /* Hiệu ứng kính mờ */
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 15px;
}

.system-status {
    width: 12px; height: 12px;
    background-color: var(--neon-green);
    border-radius: 50%;
    box-shadow: 0 0 10px var(--neon-green);
    animation: blink 2s infinite;
    flex-shrink: 0; /* Không bị co lại trên màn hình nhỏ */
}

h1 {
    font-family: 'Orbitron', sans-serif;
    font-size: clamp(1.2rem, 2.5vw, 1.8rem); /* Tự động scale font chữ */
    letter-spacing: 1px;
    color: #fff;
    text-shadow: 0 0 5px var(--neon-cyan);
    white-space: nowrap;
}

.subtitle {
    font-size: 0.75rem;
    color: var(--neon-cyan);
    opacity: 0.8;
    display: block;
}

.controls {
    display: flex;
    gap: 15px;
}

.hud-btn {
    background: transparent;
    border: 1px solid var(--neon-cyan);
    color: var(--neon-cyan);
    padding: 8px 16px;
    font-family: 'Fira Code', monospace;
    cursor: pointer;
    transition: all 0.3s;
    text-transform: uppercase;
    font-size: 0.8rem;
    position: relative;
    overflow: hidden;
    white-space: nowrap;
}

.hud-btn:hover {
    background: rgba(0, 243, 255, 0.15);
    box-shadow: 0 0 15px rgba(0, 243, 255, 0.4);
    text-shadow: 0 0 8px var(--neon-cyan);
}

/* =========================================
   MAIN CONTAINER
   ========================================= */
.container {
    width: 100%;
    max-width: 1440px; /* Giới hạn chiều rộng trên màn hình siêu lớn */
    margin: 0 auto;
    padding: 30px 20px;
    position: relative;
    z-index: 10;
}

/* TERMINAL SECTION */
.terminal-window {
    background: var(--terminal-bg);
    border: 1px solid var(--text-dim);
    border-radius: 6px;
    margin-bottom: 40px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.6);
    overflow: hidden;
}

.terminal-header {
    background: #161b22;
    padding: 10px 15px;
    display: flex;
    align-items: center;
    gap: 8px;
    border-bottom: 1px solid #30363d;
}

.dot { width: 12px; height: 12px; border-radius: 50%; }
.red { background: #ff5f56; }
.yellow { background: #ffbd2e; }
.green { background: #27c93f; }

.terminal-body {
    padding: 20px;
    min-height: 120px;
    max-height: 300px;
    overflow-y: auto;
}

.command-line { color: var(--neon-green); margin-bottom: 8px; font-weight: 600; }
.command-output { color: var(--text-main); margin-bottom: 12px; line-height: 1.5; }

/* TABS SYSTEM */
.tech-tabs {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 30px;
    flex-wrap: wrap; /* Tự động xuống dòng trên mobile */
}

.tech-tab {
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.1);
    color: var(--text-dim);
    padding: 10px 20px;
    cursor: pointer;
    font-family: 'Orbitron', sans-serif;
    clip-path: polygon(12px 0, 100% 0, 100% calc(100% - 12px), calc(100% - 12px) 100%, 0 100%, 0 12px); /* Shape góc cạnh */
    transition: all 0.3s ease;
    font-size: 0.9rem;
    user-select: none;
}

.tech-tab:hover, .tech-tab.active {
    background: rgba(0, 243, 255, 0.1);
    border-color: var(--neon-cyan);
    color: var(--neon-cyan);
    box-shadow: var(--shadow-glow);
}

/* GALLERY GRID SYSTEM */
.grid-system {
    display: grid;
    /* Responsive Grid logic: Tự động tính toán số cột dựa trên độ rộng */
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 30px;
}

.data-card {
    background: var(--card-bg);
    border: var(--glass-border);
    border-radius: 6px;
    overflow: hidden;
    position: relative;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    backdrop-filter: blur(10px);
    opacity: 0;
    animation: fadeInCard 0.8s forwards;
    display: flex;
    flex-direction: column;
}

.data-card:hover {
    transform: translateY(-8px) scale(1.01);
    border-color: var(--neon-pink);
    box-shadow: 0 0 25px rgba(188, 19, 254, 0.25);
    z-index: 5;
}

.card-visual {
    height: 180px;
    width: 100%;
    overflow: hidden;
    position: relative;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.card-visual img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.6s ease;
    filter: grayscale(40%) contrast(1.1);
}

.data-card:hover .card-visual img {
    transform: scale(1.1);
    filter: grayscale(0%) contrast(1.1);
}

.card-overlay {
    position: absolute;
    top: 10px; right: 10px;
    background: rgba(0,0,0,0.8);
    padding: 4px 8px;
    font-size: 0.7rem;
    color: var(--neon-green);
    border: 1px solid var(--neon-green);
    border-radius: 2px;
    backdrop-filter: blur(4px);
}

.card-content {
    padding: 20px;
    flex-grow: 1; /* Đẩy footer của card xuống dưới cùng */
}

.card-content h3 {
    color: var(--neon-cyan);
    font-family: 'Orbitron', sans-serif;
    margin-bottom: 10px;
    font-size: 1.25rem;
    line-height: 1.3;
}

.card-content p {
    color: var(--text-dim);
    font-size: 0.9rem;
    line-height: 1.6;
    margin-bottom: 15px;
}

.tech-tags {
    margin-top: auto; /* Đẩy tag xuống dưới */
}

.tech-tags span {
    display: inline-block;
    font-size: 0.7rem;
    color: var(--neon-pink);
    border: 1px solid var(--neon-pink);
    padding: 3px 8px;
    margin-right: 6px;
    margin-bottom: 6px;
    border-radius: 3px;
    background: rgba(188, 19, 254, 0.05);
}

.action-bar {
    padding: 15px 20px;
    border-top: 1px solid rgba(255,255,255,0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(0,0,0,0.2);
}

.btn-access {
    background: transparent;
    color: #fff;
    border: none;
    font-family: 'Fira Code', monospace;
    font-size: 0.85rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: color 0.3s;
}

.btn-access:hover { color: var(--neon-green); text-shadow: 0 0 5px var(--neon-green); }

/* =========================================
   FOOTER
   ========================================= */
footer {
    margin-top: 60px;
    border-top: 1px solid var(--glass-border);
    padding: 40px 20px;
    background: rgba(5, 5, 5, 0.95);
    text-align: center;
}

.footer-code {
    color: var(--text-dim);
    font-size: 0.9rem;
    max-width: 600px;
    margin: 0 auto;
}

/* =========================================
   KEYFRAME ANIMATIONS
   ========================================= */
@keyframes blink { 
    0%, 100% { opacity: 1; box-shadow: 0 0 10px var(--neon-green); } 
    50% { opacity: 0.3; box-shadow: none; } 
}

@keyframes fadeInCard {
    to { opacity: 1; transform: translateY(0); }
}

.glitch-hover:hover {
    animation: glitch-anim 0.3s cubic-bezier(.25, .46, .45, .94) both infinite;
    color: var(--neon-red);
}

@keyframes glitch-anim {
    0% { transform: translate(0) }
    20% { transform: translate(-2px, 2px) }
    40% { transform: translate(-2px, -2px) }
    60% { transform: translate(2px, 2px) }
    80% { transform: translate(2px, -2px) }
    100% { transform: translate(0) }
}

/* =========================================
   RESPONSIVE MEDIA QUERIES (CRITICAL)
   ========================================= */

/* 1. Large Screens / TV (4K & Above) */
@media (min-width: 1921px) {
    html { font-size: 20px; } /* Tăng size chữ cho màn hình TV lớn */
    .container { max-width: 1800px; }
    .grid-system { grid-template-columns: repeat(4, 1fr); } /* 4 Cột cố định */
}

/* 2. Laptops / Desktops (Standard) */
@media (max-width: 1200px) {
    .container { padding: 30px; }
}

/* 3. Tablets / iPads (Portrait & Landscape) */
@media (max-width: 992px) {
    header { padding: 15px 30px; }
    .grid-system { grid-template-columns: repeat(2, 1fr); } /* 2 Cột */
    .post-title { font-size: 2rem; }
}

/* 4. Mobile Devices (Large Phones) */
@media (max-width: 768px) {
    header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }
    
    .controls {
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
    }

    .tech-tabs { gap: 10px; }
    
    .tech-tab {
        flex: 1 1 40%; /* Chia tab thành 2 cột trên mobile */
        text-align: center;
        padding: 10px;
        font-size: 0.85rem;
    }
    
    .grid-system { grid-template-columns: 1fr; } /* 1 Cột duy nhất */
    
    .data-card { margin: 0 10px; } /* Thêm margin để không sát lề */
}

/* 5. Small Mobile Devices (iPhone SE, Mini) */
@media (max-width: 480px) {
    html { font-size: 14px; } /* Giảm size chữ cơ sở */
    
    .container { padding: 20px 10px; }
    
    h1 { font-size: 1.5rem; }
    
    .hud-btn {
        padding: 8px 12px;
        font-size: 0.75rem;
        flex: 1; /* Nút bấm giãn đều */
    }
    
    .tech-tab { flex: 1 1 100%; } /* Tab xếp chồng dọc */
    
    .card-visual { height: 160px; }
}

/* =========================================
   UTILITIES FOR TOUCH DEVICES
   ========================================= */
@media (hover: none) {
    /* Tối ưu cho thiết bị cảm ứng không có chuột hover */
    .data-card:hover { transform: none; } /* Tắt hiệu ứng bay lên để tránh lag */
    .hud-btn { padding: 12px 20px; } /* Nút bấm to hơn cho ngón tay */
    .tech-tab { padding: 12px; }
}