

/*Галерея*/

/* Сетка галереи */
.gallery-container {
    display: grid;
    /* Автоматически заполняет строку, минимальная ширина фото 200px */
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); 
    gap: 10px; /* Отступы между картинками */
    padding: 10px;
}

.gallery-item {
    width: 100%;
    height: 200px; /* Фиксированная высота для ровности */
    object-fit: cover; /* Обрезает лишнее, сохраняя пропорции */
    cursor: pointer;
    border-radius: 4px;
    transition: transform 0.2s;
}

.gallery-item:hover {
    transform: scale(1.02); /* Легкое увеличение при наведении */
}

/* Стили для модального окна (Fullscreen) */
.modal {
    display: none; /* Скрыто по умолчанию */
    position: fixed; 
    z-index: 1000; 
    left: 0;
    top: 0;
    width: 100%; 
    height: 100%; 
    background-color: rgba(0,0,0,0.9); /* Черный фон с прозрачностью */
    align-items: center;
    justify-content: center;
}

.modal-content {
    max-width: 90%;
    max-height: 90%;
    border-radius: 5px;
    box-shadow: 0 0 20px rgba(255,255,255,0.2);
}

/* Кнопка закрытия */
.close {
    position: absolute;
    top: 20px;
    left: 35px;
    color: red;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
}

/* Кнопки переключения */
.prev-btn, .next-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background-color: rgba(0, 0, 0, 0.5);
    color: white;
    border: none;
    padding: 20px 15px;
    font-size: 30px;
    cursor: pointer;
    user-select: none;
    transition: 0.3s;
    z-index: 1001;
}

.prev-btn { left: 10px; }
.next-btn { right: 10px; }

.prev-btn:hover, .next-btn:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

/* На мобилках делаем стрелки чуть меньше */
@media screen and (max-width: 600px) {
    .prev-btn, .next-btn {
        padding: 10px 10px;
        font-size: 20px;
        background-color: rgba(0, 0, 0, 0.3);
    }
}


.modal-content {
    /* ... ваши старые стили ... */
    transition: opacity 0.2s ease-in-out;
}

/* Класс для эффекта мерцания при переключении */
.fade {
    animation: fadeIn 0.3s;
}

@keyframes fadeIn {
    from { opacity: 0.3; }
    to { opacity: 1; }
}


/* Мобильная оптимизация */
@media only screen and (max-width: 600px) {
    .gallery-container {
        /* Создаем ровно 4 колонки на узких экранах */
        grid-template-columns: repeat(4, 1fr); 
        /* Уменьшаем отступы до минимума, чтобы сэкономить место */
        gap: 4px; 
        padding: 4px;
    }

    .gallery-item {
        /* Автоматическая высота, чтобы картинки были квадратными в сетке */
        height: 80px; 
        border-radius: 2px; /* Чуть менее скругленные углы для мелких превью */
    }

    .close {
        top: 15px;
        right: 20px;
        font-size: 35px;
    }
}

/* Дополнительно для совсем маленьких экранов (если нужно 4 колонки) */
@media only screen and (max-width: 400px) {
    .gallery-container {
        grid-template-columns: repeat(4, 1fr);
    }
    .gallery-item {
        height: 70px;
    }
}

/* Если хочешь именно 5 колонок на экранах пошире (например, iPhone Pro Max) */
@media only screen and (min-width: 450px) and (max-width: 600px) {
    .gallery-container {
        grid-template-columns: repeat(5, 1fr);
    }
}