/* Сетка галереи */
.clg-gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
    margin: 20px 0;
}

.clg-gallery-item {
    cursor: pointer;
    overflow: hidden;
    border-radius: 8px;
    aspect-ratio: 1 / 1;
    background-color: #f0f0f0;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.clg-gallery-item:hover {
    transform: scale(1.03);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

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

/* Модальное окно / Flashbox */
.clg-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 999999;
    align-items: center;
    justify-content: center;
}

.clg-modal.active {
    display: flex;
}

.clg-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(5px);
}

/* ФИКСИРОВАННЫЙ размер контейнера */
.clg-modal-container {
    position: relative;
    z-index: 2;
    width: 85vw;
    height: 80vh;
    max-width: 1000px;
    max-height: 700px;
    background: #111;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

.clg-image-wrapper {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Фотография вписывается в контейнер */
.clg-image-wrapper img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    display: block;
    user-select: none;
}

/* ФИКСИРОВАННЫЕ элементы управления (стрелки) */
.clg-nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    border: none;
    font-size: 24px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
    z-index: 10;
}

.clg-nav-btn:hover {
    background: rgba(255, 255, 255, 0.4);
}

.clg-prev-btn {
    left: 15px;
}

.clg-next-btn {
    right: 15px;
}

/* Кнопка закрытия */
.clg-close-btn {
    position: absolute;
    top: 10px;
    right: 15px;
    background: transparent;
    color: #fff;
    border: none;
    font-size: 32px;
    cursor: pointer;
    line-height: 1;
    z-index: 10;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    transition: background 0.2s ease;
}

.clg-close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* БЛОКИРОВКА СКТРОЛЛА СТРАНИЦЫ */
body.clg-no-scroll {
    overflow: hidden !important;
    touch-action: none;
}

/* Мобильная адаптивность контейнера */
@media (max-width: 600px) {
    .clg-modal-container {
        width: 95vw;
        height: 75vh;
        padding: 10px;
    }
    
    .clg-nav-btn {
        width: 38px;
        height: 38px;
        font-size: 18px;
    }
    
    .clg-prev-btn { left: 5px; }
    .clg-next-btn { right: 5px; }
}
