/* =========================================
   RESET & BASE TYPOGRAPHY
========================================= */
:root {
    --primary-color: #000;
    --text-color: #333;
    --bg-color: #fff;
    --gap: 15px;
    /* Giảm gap để sát hơn một chút */
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    color: var(--text-color);
    background-color: var(--bg-color);
    line-height: 1.6;
    overflow-x: hidden;
}

/* Scrollbar mượt cho Chrome/Edge */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #999;
}

a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color 0.3s;
}

a:hover {
    color: #666;
}

/* =========================================
   HEADER
========================================= */
.site-header {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 60px 20px 40px;
    background: #fff;
    gap: 30px;
}

.logo a {
    display: inline-block;
}

.logo img {
    height: 130px;

    width: auto;
}

.nav-links {
    display: flex;
    gap: 40px;
}

.nav-links a {
    text-transform: lowercase;
    font-size: 15px;
    font-weight: 500;
    color: #555;
    letter-spacing: 1px;
}

.nav-links a:hover {
    color: var(--primary-color);
}

/* =========================================
   MOBILE MENU / HAMBURGER 
========================================= */
.menu-toggle {
    display: none;
    flex-direction: column;
    gap: 8px;
    cursor: pointer;
    z-index: 100000;
    /* Luôn nổi trên menu overlay */
    position: relative;
    width: 30px;
    height: 24px;
    justify-content: center;
}

.menu-toggle span {
    display: block;
    height: 2px;
    background-color: #000;
    transition: all 0.3s ease-in-out;
    position: absolute;
    width: 30px;
}

.menu-toggle span:first-child {
    top: 0;
}

.menu-toggle span:last-child {
    width: 20px;
    bottom: 0;
    right: 0;
}

/* Hiệu ứng biến thành dấu X khi Menu mở */
.menu-toggle.active {
    position: fixed;
    top: 30px;
    right: 40px;
}

.menu-toggle.active span:first-child {
    transform: rotate(45deg);
    top: 11px;
}

.menu-toggle.active span:last-child {
    width: 30px;
    /* Nhả full chiều dài */
    transform: rotate(-45deg);
    bottom: 11px;
}

.close-menu {
    display: none;
    /* Không dùng nút X riêng nữa */
}

/* =========================================
   GRID GALLERY (HOME)
========================================= */
.gallery-container {
    padding: 0 15px 50px 15px;
    max-width: 1200px;
    margin: 0 auto;
}

.grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--gap);
}

.grid-item {
    cursor: pointer;
    overflow: hidden;
}

.image-wrapper {
    position: relative;
    padding-bottom: 100%;
    /* Hình vuông (1:1) */
    background: #f4f4f4;
    overflow: hidden;
}

.image-wrapper img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.6s cubic-bezier(0.25, 1, 0.5, 1);
}

.overlay-title {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.4);
    /* Nền mờ đi cho dễ đọc chữ */
    color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    padding: 20px;
    text-align: center;
}

.overlay-title h3 {
    font-size: 18px;
    font-weight: 400;
    letter-spacing: 1px;
    text-transform: uppercase;
    transform: translateY(15px);
    transition: transform 0.3s ease;
}

/* Hover Effects */
.grid-item:hover .image-wrapper img {
    transform: scale(1.05);
}

.grid-item:hover .overlay-title {
    opacity: 1;
}

.grid-item:hover .overlay-title h3 {
    transform: translateY(0);
}

/* =========================================
   MODAL - SPLIT SCREEN (HIỆU ỨNG SPA SLIDER)
========================================= */
.project-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #fff;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s ease, visibility 0.4s;
    overflow: hidden;
    /* Chống cuộn body */
}

.project-modal.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    display: flex;
    width: 100%;
    height: 100%;
}

/* Cột trái: Slider Ảnh */
.modal-images {
    width: 70%;
    height: 100%;
    background: #fafafa;
    position: relative;
    display: flex;
    flex-direction: column;
    padding: 20px;
}

/* Nút điều hướng Slider */
.slider-nav {
    position: absolute;
    top: 45%;
    transform: translateY(-50%);
    background: none;
    border: none;
    font-size: 40px;
    color: #666;
    cursor: pointer;
    z-index: 10;
    padding: 20px;
    transition: color 0.3s;
}

.slider-nav:hover {
    color: #000;
}

.slider-nav.prev {
    left: 20px;
}

.slider-nav.next {
    right: 20px;
}

/* Ảnh lớn */
.main-image-wrapper {
    flex-grow: 1;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    padding-bottom: 20px;
    /* Nhường chỗ cho thumbnail */
}

#main-slider-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    /* Đảm bảo thấy toàn bộ ảnh mà không bị cắt */
    opacity: 1;
    transition: opacity 0.3s ease;
}

/* Ảnh nhỏ (Thumbnails) */
.thumbnails-container {
    height: 100px;
    min-height: 100px;
    width: 100%;
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding: 10px 0;
    justify-content: center;
    /* Ra giữa */
}

/* Ẩn scrollbar của thumbnail nếu có thể */
.thumbnails-container::-webkit-scrollbar {
    height: 4px;
}

.thumbnails-container::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 4px;
}

.thumb-img {
    height: 100%;
    width: auto;
    aspect-ratio: 4/3;
    /* Có thể để cố định khung hình cho đều */
    object-fit: cover;
    cursor: pointer;
    opacity: 0.5;
    transition: opacity 0.3s, border 0.3s;
    border: 2px solid transparent;
}

.thumb-img:hover {
    opacity: 0.8;
}

.thumb-img.active {
    opacity: 1;
    border-color: #000;
}

/* Cột phải: Thông tin (sticky) */
.modal-info {
    width: 30%;
    height: 100%;
    position: relative;
    padding: 60px 50px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    border-left: 1px solid #eee;
}

.close-btn {
    position: absolute;
    top: 30px;
    right: 40px;
    background: none;
    border: none;
    font-size: 40px;
    font-weight: 300;
    color: #aaa;
    cursor: pointer;
    line-height: 1;
    transition: color 0.3s, transform 0.3s;
    z-index: 1000;
}

.close-btn:hover {
    color: #000;
    transform: rotate(90deg);
}

/* Nút phóng to / thu nhỏ ảnh */
.expand-btn {
    position: absolute;
    top: 35px;
    left: 40px;
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 4px;
    width: 40px;
    height: 40px;
    cursor: pointer;
    z-index: 1000;
    transition: all 0.3s;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #666;
}
.expand-btn:hover {
    border-color: #0d6efd;
    color: #0d6efd;
}
.expand-btn svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
}
.icon-compress { display: none; }

/* Chế độ Fullscreen Ảnh */
.project-modal.expanded .modal-images {
    width: 100%;
}
.project-modal.expanded .modal-info,
.project-modal.expanded .thumbnails-container {
    display: none;
}
.project-modal.expanded .main-image-wrapper {
    padding-bottom: 0;
}
.project-modal.expanded .expand-btn {
    border-color: #0d6efd;
    color: #0d6efd;
}
.project-modal.expanded .icon-expand { display: none; }
.project-modal.expanded .icon-compress { display: block; }

.info-content h2 {
    font-size: 32px;
    font-weight: 600;
    margin-bottom: 20px;
    line-height: 1.2;
}

.meta {
    margin-bottom: 30px;
    font-size: 14px;
    color: #666;
    letter-spacing: 0.5px;
}

.meta p {
    margin-bottom: 5px;
}

.desc {
    font-size: 15px;
    line-height: 1.7;
    color: #444;
}

/* =========================================
   FOOTER
========================================= */
.site-footer {
    text-align: center;
    padding: 20px 20px 60px 20px;
    font-size: 13px;
    color: #888;
}

.site-footer .footer-socials {
    margin-top: 15px;
    display: flex;
    justify-content: center;
    gap: 15px;
    font-size: 16px;
}

.site-footer .footer-socials a {
    color: #333;
    text-decoration: none;
    transition: color 0.3s;
}

.site-footer .footer-socials a:hover {
    color: var(--primary-color);
}

/* =========================================
   DESKTOP SPECIFIC RULES
========================================= */
@media (min-width: 993px) {
    /* Đảm bảo tuyệt đối nút menu điện thoại không bao giờ hiện trên máy tính, kể cả khi dùng JS ghi đè inline */
    .menu-toggle {
        display: none !important;
    }
}

/* RESPONSIVE */
@media (max-width: 992px) {

    /* Header & Mobile Menu */
    .site-header {
        flex-direction: row;
        justify-content: space-between;
        padding: 30px 40px;
    }

    .logo img {
        height: 60px;
    }

    .menu-toggle {
        display: flex;
    }

    .nav-links {
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        background: #fff;
        flex-direction: column;
        justify-content: flex-start;
        align-items: center;
        gap: 20px;
        padding-top: 15vh;
        z-index: 99999;
        /* Hiệu ứng trượt từ phải sang */
        transform: translateX(100%);
        transition: transform 0.4s cubic-bezier(0.25, 1, 0.5, 1);
    }

    .nav-links.active {
        transform: translateX(0);
    }

    .nav-links a {
        font-size: 20px;
    }

    .close-menu {
        display: none;
        /* Đã ẩn chung ở trên */
    }

    /* Grid */
    .grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .grid-item:nth-child(5n+1) {
        grid-column: span 1;
        grid-row: span 1;
    }

    .grid-item:nth-child(5n+1) .image-wrapper {
        padding-bottom: 100%;
    }

    /* Modal Split Screen */
    .modal-content {
        flex-direction: column;
        overflow-y: auto;
        /* Cho phép vuốt khi nội dung dài */
        display: block;
        /* Hủy flex để tự nhiên đẩy màn hình xuống */
    }

    .modal-images {
        width: 100%;
        height: 60vh;
        /* Ảnh chiếm 60% màn hình khi mới mở ra */
        padding: 10px;
    }

    .expand-btn {
        display: none !important;
    }

    .modal-info {
        width: 100%;
        height: auto;
        padding: 30px 20px 50px 20px;
        border-left: none;
        border-bottom: none;
        display: block;
        /* Text nội dung sẽ bung tự do */
    }

    .close-btn {
        position: fixed;
        /* Bám chặt góc trên bên phải để người dùng luôn tắt được */
        top: 15px;
        right: 15px;
        font-size: 35px;
        z-index: 9999;
        background: rgba(255, 255, 255, 0.9);
        width: 44px;
        height: 44px;
        border-radius: 50%;
        display: flex;
        justify-content: center;
        align-items: center;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
        color: #000;
    }
}

@media (max-width: 600px) {
    .site-header {
        padding: 20px;
    }

    .menu-toggle.active {
        top: 70px;
        /* Điều chỉnh vị trí nút X trên đt nhỏ */
        right: 20px;
    }

    .close-menu {
        right: 20px;
        top: 20px;
    }

    .logo img {
        height: 125px;
    }

    .gallery-container {
        padding: 0 20px 20px 20px;
    }

    .grid {
        grid-template-columns: 1fr;
    }
}