/*
Theme Name: ESP32Code Liquid Glass Theme
Theme URI: https://example.com/esp32-liquid-glass
Author: Admin
Description: Giao diện Kính Lỏng bóng bẩy dành cho tín đồ ESP32 và IoT, hỗ trợ Dark/Light mode và Customizer toàn diện. (Cập nhật đăng nhập bằng Google)
Version: 1.0.2
Text Domain: esp32-liquid-glass
*/

:root {
    --bg-color: #000000;
    --text-color: #ffffff;
    --text-muted: #86868b;
    --glass-bg: rgba(255, 255, 255, 0.08);
    --glass-border: rgba(255, 255, 255, 0.15);
    --glass-shadow: rgba(0, 0, 0, 0.3);
    --cta-bg: #ffffff;
    --cta-text: #000000;
    --heading-grad: linear-gradient(180deg, #ffffff 0%, #a1a1a1 100%);
    --mockup-border: rgba(255, 255, 255, 0.3);
    --mockup-glow: rgba(255, 255, 255, 0.2);
    /* Bổ sung màu nền đục hơn cho Sub-menu ở Dark Mode */
    --submenu-bg: rgba(15, 15, 15, 0.85); 
}

/* Light Mode Configuration */
[data-theme="light"] {
    --bg-color: #f5f5f7;
    --text-color: #1d1d1f;
    --text-muted: #6e6e73;
    --glass-bg: rgba(255, 255, 255, 0.45);
    --glass-border: rgba(0, 0, 0, 0.08);
    --glass-shadow: rgba(0, 0, 0, 0.05);
    --cta-bg: #1d1d1f;
    --cta-text: #ffffff;
    --heading-grad: linear-gradient(180deg, #1d1d1f 0%, #515154 100%);
    --mockup-border: rgba(0, 0, 0, 0.15);
    --mockup-glow: rgba(0, 0, 0, 0.05);
    /* Bổ sung màu nền đục hơn cho Sub-menu ở Light Mode */
    --submenu-bg: rgba(255, 255, 255, 0.92); 
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body {
    background: var(--bg-color);
    color: var(--text-color);
    overflow-x: hidden;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: background 0.5s ease, color 0.5s ease;
}

/* Khối chất lỏng nền sinh động */
.liquid-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 1;
    overflow: hidden;
    filter: blur(80px);
    pointer-events: none;
}

.blob {
    position: absolute;
    border-radius: 50%;
    opacity: 0.45;
}

@keyframes float {
    0% { transform: translate(0, 0) scale(1) rotate(0deg); border-radius: 50% 50% 30% 70% / 50% 60% 40% 60%; }
    100% { transform: translate(120px, 60px) scale(1.25) rotate(360deg); border-radius: 30% 70% 70% 30% / 60% 40% 60% 40%; }
}

.container {
    position: relative;
    z-index: 2;
    width: 100%;
    max-width: 1200px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* --- MENU LIQUID GLASS --- */
nav {
    position: relative; 
    z-index: 999;       
    width: 100%;
    max-width: 950px;
    margin-top: 20px;
    padding: 5px 25px;
    border-radius: 40px;
    background: var(--glass-bg);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border: 1px solid var(--glass-border);
    box-shadow: 0 8px 32px 0 var(--glass-shadow);
    transition: all 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.4);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

nav:hover {
    transform: scale(1.01);
    box-shadow: 0 15px 40px rgba(0, 242, 254, 0.1);
}

/* Khớp cấu trúc ul li của WP Nav Menu */
nav ul {
    display: flex;
    align-items: center;
    list-style: none;
    flex-grow: 1;
    justify-content: flex-start;
}

nav ul li a {
    color: var(--text-color);
    opacity: 0.75;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    display: inline-block;
    padding: 8px 16px;
    border-radius: 20px;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.5);
}

nav ul li a:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px) scale(1.05);
}

/* --- CẤU HÌNH MENU XỔ XUỐNG (DROPDOWN) --- */
nav ul li {
    position: relative; 
}

nav ul li .sub-menu {
    position: absolute;
    top: 100%;
    left: 0;
    min-width: max-content; 
    padding: 10px 0;
    /* Cập nhật màu nền và độ mờ để dễ nhìn hơn, tránh nhiễu với nền */
    background: var(--submenu-bg);
    backdrop-filter: blur(40px);
    -webkit-backdrop-filter: blur(40px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    box-shadow: 0 15px 35px var(--glass-shadow);
    visibility: hidden;
    opacity: 0;
    transform: translateY(15px);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.2);
    z-index: 1000;
    display: flex; 
    flex-direction: column; 
}

nav ul li:hover > .sub-menu {
    visibility: visible;
    opacity: 1;
    transform: translateY(10px);
}

nav ul li .sub-menu li {
    display: block;
    width: 100%;
}

nav ul li .sub-menu li a {
    display: block;
    padding: 10px 16px;
    border-radius: 12px; 
    margin: 4px 8px;     
    font-size: 14px;
    opacity: 0.8;
    transition: all 0.3s ease; 
    white-space: nowrap; 
}

nav ul li .sub-menu li a:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.08);
    transform: translateX(8px);
}

/* Nút Shortcut Chuyên mục tùy chỉnh trên Header */
.header-featured-cat-link {
    margin-left: 10px;
    margin-right: 15px;
    font-size: 13px;
    font-weight: 600;
    padding: 6px 14px;
    border-radius: 14px;
    background: rgba(0, 242, 254, 0.12);
    border: 1px solid rgba(0, 242, 254, 0.25);
    color: #00f2fe;
    text-decoration: none;
    white-space: nowrap;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.header-featured-cat-link:hover {
    background: #00f2fe;
    color: #ffffff;
    box-shadow: 0 0 15px rgba(0, 242, 254, 0.45);
    transform: translateY(-1px);
}

/* Cụm công cụ bên phải (Search + Dark/Light mode toggle) */
.nav-tools {
    display: flex;
    align-items: center;
    gap: 15px;
}

.theme-toggle-btn, .search-toggle-btn {
    background: none;
    border: none;
    color: var(--text-color);
    cursor: pointer;
    font-size: 16px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.3);
    background: rgba(255, 255, 255, 0.05);
}

.theme-toggle-btn:hover, .search-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

/* Hộp tìm kiếm ẩn/hiện mượt mà */
.search-overlay-container {
    max-height: 0;
    overflow: hidden;
    width: 100%;
    max-width: 950px;
    transition: max-height 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.1);
}

.search-overlay-container.active {
    max-height: 100px;
    margin-top: 15px;
}

/* --- HERO SECTION --- */
.hero {
    margin-top: 60px;
    width: 100%;
    max-width: 900px;
    padding: 60px 40px;
    border-radius: 40px;
    text-align: center;
    background: var(--glass-bg);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    border: 1px solid var(--glass-border);
    box-shadow: 0 20px 50px var(--glass-shadow);
    transition: transform 0.7s cubic-bezier(0.175, 0.885, 0.32, 1.275), 
                border-radius 0.7s ease, 
                box-shadow 0.7s ease;
}

.hero:hover {
    transform: translateY(-8px) scale(1.005);
    border-radius: 60px 30px 60px 30px;
    box-shadow: 0 30px 60px rgba(0, 242, 254, 0.15);
}

.hero h1 {
    font-size: 58px;
    font-weight: 700;
    background: var(--heading-grad);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 12px;
    letter-spacing: -1px;
}

.hero p {
    font-size: 20px;
    color: var(--text-muted);
    margin-bottom: 35px;
}

.cta-btn {
    display: inline-block;
    background: var(--cta-bg);
    color: var(--cta-text);
    padding: 14px 36px;
    border-radius: 30px;
    font-weight: 600;
    text-decoration: none;
    box-shadow: 0 4px 15px rgba(255,255,255,0.1);
    transition: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.6);
}

.cta-btn:hover {
    transform: scale(1.1);
    background: #00f2fe;
    color: #fff;
    box-shadow: 0 10px 25px rgba(0, 242, 254, 0.4);
}

/* --- ESP32 MOCKUP CHIP DESIGN --- */
.product-mockup {
    margin-top: 50px;
    width: 280px;
    height: 280px;
    border-radius: 35px;
    margin-left: auto;
    margin-right: auto;
    background: rgba(255, 255, 255, 0.03);
    border: 2px solid var(--mockup-border);
    box-shadow: inset 0 0 25px var(--mockup-glow);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: relative;
    transition: all 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.3);
}

.product-mockup::before {
    content: '';
    position: absolute;
    width: 104%;
    height: 80%;
    border-left: 6px dashed #ffb703;
    border-right: 6px dashed #ffb703;
    opacity: 0.6;
    transition: opacity 0.4s;
}

.hero:hover .product-mockup {
    transform: scale(1.06) rotate(5deg);
    border-color: #00f2fe;
    box-shadow: inset 0 0 35px rgba(0, 242, 254, 0.25), 0 15px 30px rgba(0,0,0,0.4);
}

.product-mockup span {
    font-size: 16px;
    font-weight: 600;
    letter-spacing: 2px;
    color: var(--text-color);
    z-index: 2;
    background: rgba(0,0,0,0.2);
    padding: 6px 12px;
    border-radius: 8px;
}

.core-crystal {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #00f2fe, #4facfe);
    border-radius: 12px;
    margin-bottom: 15px;
    z-index: 2;
    box-shadow: 0 0 20px rgba(0,242,254,0.5);
}

/* --- POSTS SECTION & APPLE-STYLE CARDS --- */
.posts-section {
    width: 100%;
    max-width: 1100px;
    margin-top: 80px;
    padding-bottom: 50px;
    z-index: 2;
}

.posts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 30px;
}

.post-card {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    overflow: hidden;
    box-shadow: 0 10px 30px var(--glass-shadow);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    transition: transform 0.4s ease, box-shadow 0.4s ease;
    display: flex;
    flex-direction: column;
}

.post-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
}

.post-thumb {
    width: 100%;
    height: 200px;
    overflow: hidden;
    background: rgba(0,0,0,0.1);
}

.post-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.post-card:hover .post-thumb img {
    transform: scale(1.05);
}

.no-thumb {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-weight: 600;
    letter-spacing: 1px;
    font-size: 14px;
}

.post-content {
    padding: 24px;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.post-title {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 10px;
    line-height: 1.3;
}

.post-title a {
    color: var(--text-color);
    text-decoration: none;
}

.post-desc {
    font-size: 14px;
    color: var(--text-muted);
    line-height: 1.5;
    margin-bottom: 20px;
    flex-grow: 1;
}

.esp-selector {
    margin-top: auto;
    padding-top: 15px;
    border-top: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.esp-selector label {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.model-dropdown {
    width: 100%;
    padding: 10px 14px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--glass-border);
    color: var(--text-color);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    outline: none;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='gray' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 16px;
    transition: background 0.3s ease;
}

.model-dropdown:hover {
    background-color: rgba(255, 255, 255, 0.15);
}

[data-theme="light"] .model-dropdown {
    background-color: rgba(0, 0, 0, 0.05);
}

.model-dropdown option {
    background: #222;
    color: #fff;
}

[data-theme="light"] .model-dropdown option {
    background: #fff;
    color: #000;
}

/* Style cho liên kết bọc toàn bộ thẻ card */
.post-card-link {
    transition: transform 0.3s cubic-bezier(0.25, 1, 0.5, 1);
    display: block;
}
.post-card-link:hover {
    transform: scale(1.02);
}

/* Khu vực chứa tag phần cứng */
.esp-hardware-tags {
    margin-top: auto;
    padding-top: 15px;
    border-top: 1px solid var(--glass-border);
}
.hardware-label {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
    margin-bottom: 8px;
}
.tags-container {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.board-badge {
    font-size: 12px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--glass-border);
    color: var(--text-color);
}
.board-badge.default {
    opacity: 0.5;
}

/* Cấu trúc trang chi tiết */
.post-detailed-content {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 20px;
}
.entry-content p {
    margin-bottom: 25px;
}

/* --- PRICE BADGE STYLING --- */
.price-badge {
    position: absolute;
    top: 15px;
    right: 15px;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
    z-index: 10;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.2);
}

.price-badge.free {
    background: rgba(46, 213, 115, 0.85);
    color: #ffffff;
    border-color: rgba(46, 213, 115, 0.5);
}

.price-badge.paid {
    background: rgba(255, 71, 87, 0.85);
    color: #ffffff;
    border-color: rgba(255, 71, 87, 0.5);
}
/* =========================================
   RESPONSIVE & MOBILE/TABLET OPTIMIZATION
   ========================================= */

/* --- Tablet (Dưới 992px) --- */
@media (max-width: 992px) {
    .hero {
        padding: 40px 20px;
        width: 90%;
    }
    .hero h1 {
        font-size: 42px;
    }
    nav {
        max-width: 100%;
        padding: 10px 20px;
    }
}

/* --- Mobile (Dưới 768px) --- */
@media (max-width: 768px) {
    /* Nút Hamburger */
    .mobile-menu-toggle {
        display: flex !important;
        align-items: center;
        justify-content: center;
        background: rgba(255, 255, 255, 0.05);
        border: 1px solid var(--glass-border);
        color: var(--text-color);
        font-size: 20px;
        width: 36px;
        height: 36px;
        border-radius: 50%;
        cursor: pointer;
        margin-left: auto;
        margin-right: 15px;
        transition: all 0.3s ease;
    }
    
    .mobile-menu-toggle:hover {
        background: rgba(255, 255, 255, 0.15);
    }

    /* Thu gọn Menu ngang thành dọc */
    nav {
        flex-wrap: wrap;
        border-radius: 24px;
    }
    
    nav ul {
        display: none; /* Ẩn menu mặc định */
        width: 100%;
        flex-direction: column;
        padding-top: 15px;
        margin-top: 15px;
        border-top: 1px solid var(--glass-border);
        animation: fadeIn 0.3s ease forwards;
    }
    
    nav ul.active {
        display: flex; /* Hiện menu khi bấm nút */
    }
    
    nav ul li {
        width: 100%;
        text-align: left;
    }
    
    nav ul li a {
        display: block;
        padding: 12px 16px;
        border-radius: 12px;
        margin-bottom: 5px;
    }

    /* Reset Sub-menu cho Mobile */
    nav ul li .sub-menu {
        position: static;
        visibility: visible;
        opacity: 1;
        transform: none;
        box-shadow: none;
        border: none;
        background: rgba(0, 0, 0, 0.05); /* Tối nhẹ để phân biệt cấp bậc */
        border-radius: 12px;
        margin-top: 0;
        margin-bottom: 10px;
        display: none; /* Ẩn sub-menu, dùng JS để mở */
        padding: 5px 0;
    }

    [data-theme="dark"] nav ul li .sub-menu {
        background: rgba(255, 255, 255, 0.05);
    }
    
    nav ul li.active-sub > .sub-menu {
        display: flex;
    }

    /* Thu nhỏ Hero Section & Fonts */
    .hero {
        margin-top: 30px;
        padding: 30px 15px;
        border-radius: 30px;
    }
    .hero h1 {
        font-size: 32px;
    }
    .hero p {
        font-size: 16px;
        margin-bottom: 25px;
    }

    /* Thu nhỏ Mockup Chip ESP32 */
    .product-mockup {
        width: 200px;
        height: 200px;
        margin-top: 30px;
    }
    .core-crystal {
        width: 45px;
        height: 45px;
    }

    /* Tối ưu Grid bài viết cho màn hình cực nhỏ (như iPhone SE) */
    .posts-grid {
        grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
        gap: 20px;
    }

    /* Tối ưu thanh công cụ & Nút đăng nhập */
    .header-featured-cat-link {
        display: none; /* Ẩn shortcut để tiết kiệm diện tích Header */
    }
    
    .nav-tools {
        gap: 10px;
    }
    
    .login-trigger-btn {
        padding: 6px 14px;
        font-size: 12px;
    }
    
    /* Tránh việc Box đăng nhập bị tràn màn hình */
    #loginPolicyDropdown {
        right: -20px;
        width: 260px;
    }

    @keyframes fadeIn {
        from { opacity: 0; transform: translateY(-10px); }
        to { opacity: 1; transform: translateY(0); }
    }
}