/* gallery.css */

/* Модальное окно */
.modal {
    display: none; /* Скрыт по умолчанию */
    position: fixed;
    z-index: 1000;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9); /* Темный фон */
    overflow: auto; /* Добавляем прокрутку, если контент выходит за пределы экрана */
}

.modal-content {
    opacity: 0; /* Начальная невидимость */
    display: block;
    max-width: 100%; /* Максимальная ширина */
    max-height: 80vh; /* Максимальная высота (80% от высоты экрана) */
    margin: auto; /* Центрирование по горизонтали */
    position: absolute;
    top: 50%; /* Позиционирование по вертикали */
    left: 50%; /* Позиционирование по горизонтали */
    transform: translate(-50%, -50%); /* Корректировка позиции */
    object-fit: contain; /* Сохранение пропорций */
    animation: fadeIn 0.3s ease-out forwards; /* Плавное появление */
    user-select: none; /* Запрещаем выделение текста */
    touch-action: manipulation; /* Улучшаем взаимодействие с тачскрином */
    cursor: pointer; /* Курсор указывает на возможность клика */
    -webkit-user-drag: none; /* Отключаем перетаскивание изображения */
    -webkit-tap-highlight-color: transparent; /* Убираем подсветку при клике на мобильных устройствах */
}

@keyframes fadeIn {
    from { opacity: 0; transform: translate(-50%, -50%) scale(1); }
    to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

/* Кнопка закрытия */
.close {
    position: absolute;
    background: url("/uploads/icons/gallery-close.svg") center/50px no-repeat;
    top: 25px;
    right: 25px;
    width: 50px;
    height: 50px;
    transition: 0.3s;
    cursor: pointer;
}

.close:hover,
.close:focus {
    -webkit-tap-highlight-color: transparent;
}

/* Иконка для открытия галереи */
.gallery-icon {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.8) url("/uploads/icons/gallery-icon.svg") center/40px no-repeat;
    border-radius: 50%; /* Круглая форма */
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.3s ease;
    -webkit-tap-highlight-color: transparent;
    tap-highlight-color: transparent;
}

.gallery-icon:hover {
    cursor: zoom-in;
    background-color: rgba(255, 255, 255, 1); /* Темнее при наведении */
}

/* Вьюпорт - ограничивает видимую область */
.gallery-viewport {
    width: 100%;
    height: 80vh; /* Высота области просмотра */
    position: absolute;
    top: 50%;
    left: 0;
    transform: translateY(-50%);
    overflow: hidden;
}

/* Трек - лента с картинками */
.gallery-track {
    display: flex;
    height: 100%;
    transition: transform 0.3s ease-out; /* Плавность для кнопок, JS будет переопределять это при свайпе */
    cursor: grab;
}

.gallery-track:active {
    cursor: grabbing;
}

/* Отдельный слайд */
.gallery-slide {
    min-width: 100%; /* Каждый слайд занимает всю ширину */
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

/* Изображение внутри слайда */
.gallery-slide img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    user-select: none;
    pointer-events: none; /* Чтобы картинка не перетаскивалась сама по себе */
    -webkit-user-drag: none;
}

/* Лоадер для слайда (опционально) */
.slide-loader {
    position: absolute;
    color: #fff;
    font-size: 1.2rem;
}

/* Кнопки "Назад" и "Вперед" */
.gallery-btn {
    position: absolute;
    top: 50%;
    border: none;
    width: 70px;
    height: 100px;
    cursor: pointer;
    transform: translateY(-50%);
    -webkit-tap-highlight-color: transparent;
}

.prev {
    background: url("/uploads/icons/gallery-prev.svg") center/30px no-repeat;
    left: 0px;
}

.next {
    background: url("/uploads/icons/gallery-next.svg") center/30px no-repeat;
    right: 0px;
}

#gallery-modal #modal-image[src=""] {
    display: none; /* Hide image when src is empty */
}

#gallery-modal #caption {
    display: none;
    margin: auto;
    width: 80%;
    max-width: 700px;
    text-align: center;
    color: #ccc;
    padding: 40px 0;
    font-size: 1.2rem;
}

@media (max-width: 767px) {
    .prev, .next {
        background: none;
    }
}