/* Основные стили галереи */
.gallery5 {
    max-width: 1800px;
    margin: 0 auto;
    padding: 15px;
    box-sizing: border-box;
}

.gallery5__grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 15px;
}

.gallery5__item {
    overflow: hidden;
    aspect-ratio: 1 / 1;
    width: 100%;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease;
}

.gallery5__item:hover {
    transform: scale(1.02);
}

.gallery5__item--hidden {
    display: none;
}

.gallery5__image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    cursor: pointer;
    display: block;
}

/* Кнопка "Загрузить еще" */
.gallery5__load-more {
    display: block;
    margin: 25px auto;
    padding: 10px 25px;
    background: #0073aa;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    transition: background 0.3s ease;
}

.gallery5__load-more:hover {
    background: #005177;
}

/* Лайтбокс */
.gallery5__lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease;
}

.gallery5__lightbox--hidden {
    opacity: 0;
    visibility: hidden;
}

.gallery5__lightbox:not(.gallery5__lightbox--hidden) {
    opacity: 1;
    visibility: visible;
}

.gallery5__lightbox-image {
    max-width: 95%;
    max-height: 95%;
    border-radius: 3px;
    box-shadow: 0 0 0 10px rgba(0,0,0,0.3);
    position: relative;
    z-index: 2;
}

/* Затемнение краев для лучшей видимости кнопок */
.gallery5__lightbox::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(ellipse at center, 
                              rgba(0,0,0,0) 0%, 
                              rgba(0,0,0,0.3) 40%, 
                              rgba(0,0,0,0.6) 100%);
    pointer-events: none;
    z-index: 1;
}

/* Элементы управления лайтбоксом */
.gallery5__close {
    position: absolute;
    cursor: pointer;
    width: 44px;
    height: 44px;
    background: rgba(0, 0, 0, 0.7);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    border: 2px solid rgba(255, 255, 255, 0.8);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    z-index: 10001;
}

.gallery5__prev,
.gallery5__next {
    position: absolute;
    cursor: pointer;
    width: 44px;
    height: 44px;
    background: rgba(0, 0, 0, 0.7);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid rgba(255, 255, 255, 0.8);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    z-index: 10001;
}

.gallery5__close:hover {
    background: rgba(0, 0, 0, 0.9);
    transform: scale(1.1);
}

.gallery5__prev:hover,
.gallery5__next:hover {
    background: rgba(0, 0, 0, 0.9);
}

/* Позиционирование кнопок */
.gallery5__close {
    top: 25px;
    right: 25px;
}

.gallery5__prev,
.gallery5__next {
    top: 50%;
    transform: translateY(-50%);
}

.gallery5__prev {
    left: 25px;
}

.gallery5__next {
    right: 25px;
}

/* Иконки */
.gallery5__close::before,
.gallery5__close::after {
    content: '';
    position: absolute;
    width: 22px;
    height: 3px;
    background: white;
    border-radius: 2px;
}

.gallery5__close::before {
    transform: rotate(45deg);
}

.gallery5__close::after {
    transform: rotate(-45deg);
}

.gallery5__prev::before,
.gallery5__next::before {
    content: '';
    width: 14px;
    height: 14px;
    border-left: 3px solid white;
    border-top: 3px solid white;
    margin-top: -2px;
}

.gallery5__prev::before {
    transform: rotate(-45deg);
    margin-left: 4px;
    filter: drop-shadow(1px 1px 1px rgba(0,0,0,0.5));
}

.gallery5__next::before {
    transform: rotate(135deg);
    margin-right: 4px;
    filter: drop-shadow(1px 1px 1px rgba(0,0,0,0.5));
}

/* Адаптивность */
@media (max-width: 1200px) {
    .gallery5__grid {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    }
}

@media (max-width: 992px) {
    .gallery5__grid {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    }
}

@media (max-width: 768px) {
    .gallery5__grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    
    .gallery5 {
        padding: 10px;
    }
    
    .gallery5__close,
    .gallery5__prev,
    .gallery5__next {
        width: 40px;
        height: 40px;
    }
    
    .gallery5__close {
        top: 15px;
        right: 15px;
    }
    
    .gallery5__prev {
        left: 10px;
    }
    
    .gallery5__next {
        right: 10px;
    }
    
    .gallery5__close::before,
    .gallery5__close::after {
        width: 18px;
        height: 2px;
    }
    
    .gallery5__prev::before,
    .gallery5__next::before {
        width: 12px;
        height: 12px;
        border-width: 2px;
    }
}

@media (max-width: 576px) {
    .gallery5__grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
    
    .gallery5__item {
        border-radius: 5px;
    }
    
    .gallery5__close,
    .gallery5__prev,
    .gallery5__next {
        width: 36px;
        height: 36px;
        background: rgba(0, 0, 0, 0.8);
    }
    
    .gallery5__close {
        top: 10px;
        right: 10px;
    }
    
    .gallery5__prev {
        left: 5px;
    }
    
    .gallery5__next {
        right: 5px;
    }
    
    .gallery5__close::before,
    .gallery5__close::after {
        width: 16px;
    }
    
    .gallery5__prev::before,
    .gallery5__next::before {
        width: 10px;
        height: 10px;
    }
}

@media (max-width: 400px) {
    .gallery5__grid {
        gap: 6px;
    }
    
    .gallery5__load-more {
        padding: 8px 20px;
        font-size: 14px;
    }
    
    .gallery5__close,
    .gallery5__prev,
    .gallery5__next {
        width: 32px;
        height: 32px;
    }
}