/* ===== Gallery Section (Main Page) ===== */

.gallery-section h2 {
    margin-bottom: 24px;
}

/* ===== Masonry Grid ===== */
.gallery-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 24px;
    justify-content: center;
}

.gallery-item {
    height: 250px;
    border-radius: 16px;
    overflow: hidden;
    position: relative;
    cursor: pointer;
    transition: opacity var(--transition-time);
}

.gallery-item:hover {
    opacity: 0.85;
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Row pattern: 4-3-4 items repeating (11 per cycle) */
.gallery-item:nth-child(11n+1)  { flex: 350 1 250px; }
.gallery-item:nth-child(11n+2)  { flex: 250 1 180px; }
.gallery-item:nth-child(11n+3)  { flex: 300 1 220px; }
.gallery-item:nth-child(11n+4)  { flex: 246 1 180px; }
.gallery-item:nth-child(11n+5)  { flex: 500 1 350px; }
.gallery-item:nth-child(11n+6)  { flex: 350 1 250px; }
.gallery-item:nth-child(11n+7)  { flex: 320 1 230px; }
.gallery-item:nth-child(11n+8)  { flex: 250 1 180px; }
.gallery-item:nth-child(11n+9)  { flex: 350 1 250px; }
.gallery-item:nth-child(11n+10) { flex: 246 1 180px; }
.gallery-item:nth-child(11n+11) { flex: 300 1 220px; }

/* ===== Video Play Icon ===== */
.gallery-item .video-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80px;
    height: 80px;
    background-color: rgba(0, 0, 0, 0.8);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.video-icon .video-icon-play {
    width: 0;
    height: 0;
    border-top: 13px solid transparent;
    border-bottom: 13px solid transparent;
    border-left: 26px solid #fff;
    margin-left: 5px;
}

/* ===== "See all" Button ===== */
.gallery-section .btn-see-all {
    width: fit-content;
    display: block;
    margin: 40px auto 0;
    padding: 30px 76px;
    background-color: var(--color-dark);
    color: var(--color-light);
    border: none;
    border-radius: 24px;
    font-family: var(--font-family-base);
    font-size: 20px;
    font-weight: 500;
    cursor: pointer;
    transition: box-shadow var(--transition-time);
    text-decoration: none;
    line-height: 1.38;
}


/* ===== Lightbox ===== */
.gallery-lightbox {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}

.gallery-lightbox.open {
    opacity: 1;
    visibility: visible;
}

.lightbox-overlay {
    position: absolute;
    inset: 0;
    background: rgba(31, 31, 41, 0.92);
    cursor: pointer;
}

.lightbox-content {
    position: relative;
    width: 75vw;
    max-width: 1440px;
    max-height: 85vh;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox-slide {
    display: none;
    width: 100%;
    height: 100%;
    align-items: center;
    justify-content: center;
}

.lightbox-slide.active {
    display: flex;
}

.lightbox-slide img {
    max-width: 100%;
    max-height: 85vh;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 16px;
    display: block;
    margin: auto;
}

.lightbox-slide video {
    max-width: 100%;
    max-height: 85vh;
    border-radius: 16px;
}

/* Lightbox buttons */
.lightbox-close,
.lightbox-prev,
.lightbox-next {
    position: absolute;
    z-index: 2;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 1.5px solid rgba(255, 255, 255, 0.25);
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    font-family: var(--font-family-base);
    font-size: 20px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition-time);
    padding: 0;
    line-height: 1;
}

.lightbox-close:hover,
.lightbox-prev:hover,
.lightbox-next:hover {
    background: rgba(255, 255, 255, 0.22);
}

.lightbox-close {
    top: 32px;
    right: 160px;
}

.lightbox-prev {
    left: 40px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 24px;
}

.lightbox-next {
    right: 40px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 24px;
}

.lightbox-counter {
    position: absolute;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2;
    color: rgba(255, 255, 255, 0.7);
    font-family: var(--font-family-base);
    font-size: 16px;
    font-weight: 500;
}

/* ===== Gallery Page ===== */
.gallery-page {
    padding-top: 120px;
    padding-bottom: 80px;
    min-height: 100vh;
}

.gallery-page h1 {
    font-size: 56px;
    font-weight: 700;
    margin-bottom: 24px;
}

/* ===== Responsive — Tablet ===== */
@media (max-width: 1023px) {
    }

    .gallery-grid {
        gap: 16px;
    }

    .gallery-item {
        height: 200px;
    }

    .gallery-section .btn-see-all {
        padding: 20px 40px;
        font-size: 16px;
    }

    .lightbox-close {
        top: 16px;
        right: 16px;
    }

    .lightbox-prev {
        left: 16px;
    }

    .lightbox-next {
        right: 16px;
    }

    .lightbox-content {
        width: 90vw;
    }

    .gallery-page {
        padding-top: 90px;
        padding-bottom: 60px;
    }

    .gallery-page h1 {
        font-size: 36px;
    }
}

/* ===== Responsive — Mobile ===== */
@media (max-width: 767px) {
    .gallery-grid {
        gap: 12px;
    }

    .gallery-item {
        height: 200px;
        flex: 1 1 calc(50% - 6px) !important;
        max-width: calc(50% - 6px);
        min-width: 0;
    }

    .gallery-item .video-icon {
        width: 50px;
        height: 50px;
    }

    .video-icon .video-icon-play {
        border-top: 8px solid transparent;
        border-bottom: 8px solid transparent;
        border-left: 16px solid #fff;
        margin-left: 3px;
    }

    .gallery-section .btn-see-all {
        padding: 16px 32px;
        font-size: 14px;
        border-radius: 16px;
    }

    .lightbox-content {
        width: 95vw;
    }

    .lightbox-close,
    .lightbox-prev,
    .lightbox-next {
        width: 36px;
        height: 36px;
        font-size: 16px;
    }

    .lightbox-close {
        top: 12px;
        right: 12px;
    }

    .gallery-page {
        padding-top: 80px;
        padding-bottom: 40px;
    }

    .gallery-page h1 {
        font-size: 28px;
    }

}

/* ===== YouTube in Lightbox ===== */
.lightbox-slide .yt-embed {
    width: 100%;
    aspect-ratio: 16/9;
    max-height: 85vh;
    border-radius: 16px;
    border: none;
}

.lightbox-slide .youtube-placeholder {
    width: 100%;
    aspect-ratio: 16/9;
    max-height: 85vh;
    border-radius: 16px;
    background: #000;
}

/* webp <picture> fallback wrappers — keep layout identical to a bare <img> */
.gallery-item picture { display: block; width: 100%; height: 100%; }
.lightbox-slide picture { display: contents; }
