/**
 * TP Gallery — photo grid with lightbox
 *
 * @package Technoproekt
 * @author  Kkalganov <https://kkalganov.com>
 */

/* ==========================================================================
   Section title spacing (from widget)
   ========================================================================== */

.tp-gallery__section-title {
    margin-bottom: 40px;
}

/* ==========================================================================
   Gallery Grid
   ========================================================================== */

.tp-gallery {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
}

.tp-gallery__item {
    position: relative;
    overflow: hidden;
    aspect-ratio: 4 / 3;
    cursor: pointer;
}

.tp-gallery__item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s;
}

.tp-gallery__item:hover img {
    transform: scale(1.08);
}

.tp-gallery__overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(15, 26, 14, 0.7) 0%, transparent 50%);
    opacity: 0;
    transition: opacity 0.3s;
    display: flex;
    align-items: flex-end;
    padding: 16px;
}

.tp-gallery__item:hover .tp-gallery__overlay {
    opacity: 1;
}

.tp-gallery__caption {
    font-size: 12px;
    color: var(--tp-white);
    line-height: 1.4;
}

/* ==========================================================================
   Lightbox
   ========================================================================== */

.tp-lightbox {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 3000;
    background: var(--tp-black-92);
    align-items: center;
    justify-content: center;
    padding: 40px;
    cursor: zoom-out;
}

.tp-lightbox.is-open {
    display: flex;
}

.tp-lightbox img {
    max-width: 100%;
    max-height: 90vh;
    object-fit: contain;
    border: 2px solid var(--tp-white-10);
}

.tp-lightbox__caption {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    color: var(--tp-white-80);
    font-size: 14px;
    text-align: center;
    max-width: 600px;
}

.tp-lightbox__close {
    position: absolute;
    top: 20px;
    right: 24px;
    width: 48px;
    height: 48px;
    background: none;
    border: none;
    color: var(--tp-white);
    font-size: 32px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
}

.tp-lightbox__close:hover {
    color: var(--tp-yellow);
}

.tp-lightbox__nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 48px;
    height: 48px;
    background: var(--tp-white-10);
    border: none;
    color: var(--tp-white);
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.tp-lightbox__nav:hover {
    background: var(--tp-white-20);
}

.tp-lightbox__prev {
    left: 16px;
}

.tp-lightbox__next {
    right: 16px;
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 1024px) {
    .tp-gallery {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .tp-gallery {
        grid-template-columns: 1fr 1fr;
    }
}
