/* =================================
   Gallery Wrapper (Centered Flex Layout)
   ================================= */

.page-gallery {
    max-width: 900px;
    margin: 60px auto;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;   /* KEY: centers new rows */
    gap: 30px;
}

/* =================================
   Gallery Items
   ================================= */

.gallery-item {
    width: 250px;              /* Fixed thumbnail width */
    cursor: pointer;
    border: 1px solid #000;
    background: #000;
    box-shadow: 0 10px 10px rgba(0, 0, 0, 0.25);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    overflow: hidden;
}

/* 16:9 Ratio Thumbnail */
.gallery-item img {
    width: 100%;
    height: 140px;             /* 250px wide → 16:9 height ≈ 140px */
    object-fit: cover;
    display: block;
    transition: transform 0.4s ease;
}

/* Hover Effects */

.gallery-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 14px 18px rgba(0, 0, 0, 0.35);
}

.gallery-item:hover img {
    transform: scale(1.05);
}

/* =================================
   Lightbox
   ================================= */

#lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.94);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 5000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

#lightbox.active {
    opacity: 1;
}

.lightbox-inner {
    position: relative;
    text-align: center;
    animation: zoomIn 0.3s ease;
}

.lightbox-content {
    max-width: 90vw;
    max-height: 80vh;
    border: 10px solid #fff;
    box-sizing: border-box;
}

.lightbox-caption {
    color: #fff;
    margin-top: 15px;
    font-size: 16px;
}

/* Controls */

.lightbox-close {
    position: absolute;
    top: -40px;
    right: 0;
    font-size: 36px;
    color: #fff;
    cursor: pointer;
}

.lightbox-prev,
.lightbox-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    font-size: 45px;
    color: #fff;
    cursor: pointer;
    padding: 10px;
    user-select: none;
    transition: color 0.3s ease;
}

.lightbox-prev { left: -60px; }
.lightbox-next { right: -60px; }

.lightbox-prev:hover,
.lightbox-next:hover,
.lightbox-close:hover {
    color: #535353;
}

/* =================================
   Responsive
   ================================= */

@media (max-width: 768px) {

    .page-gallery {
        gap: 20px;
        padding: 0 15px;
    }

    .gallery-item {
        width: 200px;
    }

    .gallery-item img {
        height: 112px;   /* 16:9 ratio */
    }

    .lightbox-prev { left: 10px; }
    .lightbox-next { right: 10px; }
}

@media (max-width: 480px) {

    .gallery-item {
        width: 100%;
        max-width: 320px;
    }

    .gallery-item img {
        height: auto;
        aspect-ratio: 16 / 9;
    }
}

/* =================================
   Animation
   ================================= */

@keyframes zoomIn {
    from { transform: scale(0.95); opacity: 0; }
    to   { transform: scale(1); opacity: 1; }
}