/* --- Галерея превью --- */
.gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
    padding: 25px;
}

.gallery-item {
    width: 100%;
    height: 210px;
    object-fit: cover;
    border-radius: 12px;
    cursor: pointer;
    transition: transform 0.3s, box-shadow 0.3s;
}

.gallery-item:hover {
    transform: scale(1.06);
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.3);
}

/* --- Модальное окно --- */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.85);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    text-align: center;
}

.modal-content {
    max-width: 90%;
    max-height: 85vh;
    border-radius: 10px;
    box-shadow: 0 0 30px rgba(0,0,0,0.6);
    transition: opacity 0.3s ease-in-out;
}

/* --- Кнопка закрытия --- */
.close {
    position: absolute;
    top: 25px;
    right: 35px;
    color: #fff;
    font-size: 55px; /* увеличено */
    font-weight: bold;
    cursor: pointer;
    transition: color 0.3s, transform 0.2s;
}

.close:hover {
    color: #ff4444; /* краснеет при наведении */
    transform: scale(1.15);
}

/* --- Кнопка скачать --- */
.download {
    position: absolute;
    top: 32px;
    right: 120px;
    background: rgba(255, 255, 255, 0.25);
    color: white;
    padding: 12px 24px; /* увеличено */
    border-radius: 10px;
    text-decoration: none;
    font-size: 18px; /* увеличено */
    font-weight: bold;
    transition: background 0.3s, transform 0.2s;
}

.download:hover {
    background: rgba(0, 255, 0, 0.35); /* зеленеет при наведении */
    transform: scale(1.1);
}

/* --- Кнопки листания --- */
.prev, .next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    color: white;
    font-size: 60px;
    font-weight: bold;
    cursor: pointer;
    user-select: none;
    width: 75px;
    height: 75px;
    line-height: 70px;
    text-align: center;
    background: rgba(0, 0, 0, 0.35);
    border: 3px solid rgba(255, 255, 255, 0.6);
    border-radius: 15px; /* квадрат с плавными углами */
    transition: background 0.3s, transform 0.2s, border-color 0.3s;
}

.prev:hover, .next:hover {
    background: rgba(255, 255, 255, 0.25);
    border-color: white;
    transform: translateY(-50%) scale(1.1);
}

.prev { left: 40px; }
.next { right: 40px; }

/* --- Мобильная адаптация --- */
@media (max-width: 768px) {
    .gallery {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
        gap: 15px;
        padding: 15px;
    }

    .gallery-item {
        height: 160px;
    }

    .modal-content {
        max-width: 95%;
        max-height: 70vh;
    }

    .close {
        top: 15px;
        right: 25px;
        font-size: 50px;
    }

    .download {
        top: 15px;
        right: 90px;
        font-size: 17px;
        padding: 10px 18px;
    }
}

/* --- Маленькие экраны (телефоны) --- */
@media (max-width: 480px) {
    .gallery {
        grid-template-columns: 1fr;
        gap: 12px;
        padding: 12px;
    }

    .gallery-item {
        max-height: 240px;
        width: 100%;
    }

    .prev, .next {
        font-size: 40px;
        width: 60px;
        height: 60px;
        line-height: 58px;
        border-radius: 12px;
    }

    .close {
        font-size: 48px;
        right: 20px;
        top: 15px;
    }

    .download {
        right: 90px;
        top: 18px;
        font-size: 18px;
        padding: 10px 18px;
    }
}

/* --- Адаптация стрелок под планшеты и меньше --- */
@media (max-width: 1024px) {
    .modal {
        flex-direction: column;
    }

    .modal-content {
        max-width: 95%;
        max-height: 70vh;
        margin-bottom: 20px; /* отступ под стрелки */
    }

    /* стрелки становятся под фото */
    .prev, .next {
        position: static;          /* убираем абсолютное позиционирование */
        transform: none;           /* убираем смещение по Y */
        display: inline-flex;
        justify-content: center;
        align-items: center;
        margin: 0 10px;
        width: 65px;
        height: 65px;
        line-height: 60px;
        font-size: 45px;
        background: rgba(0, 0, 0, 0.4);
        border: 3px solid rgba(255, 255, 255, 0.6);
        border-radius: 15px;       /* квадрат с мягкими углами */
        transition: background 0.3s, transform 0.2s;
    }

    /* стрелки по центру в ряд */
    .modal-controls {
        display: flex;
        justify-content: center;
        align-items: center;
        margin-bottom: 25px;
        gap: 25px;
    }

    .prev:hover, .next:hover {
        background: rgba(255, 255, 255, 0.25);
        transform: scale(1.1);
    }
}

/* --- Заголовки секций --- */
.gallery-section {
    padding: 30px 20px;
    text-align: center;
}

.gallery-title {
    font-size: 26px;
    margin-bottom: 20px;
    color: #fff;
    text-shadow: 0 0 10px rgba(255,255,255,0.2);
}

/* --- Галерея для квадратных изображений (1:1) --- */
.square-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    padding: 0 25px;
}

.square-gallery .gallery-item {
    aspect-ratio: 1 / 1; /* делаем квадраты */
    width: 100%;
    object-fit: cover;
    border-radius: 12px;
    cursor: pointer;
    transition: transform 0.3s, box-shadow 0.3s;
}

.square-gallery .gallery-item:hover {
    transform: scale(1.06);
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.3);
}

/* --- Мобильная адаптация квадратных --- */
@media (max-width: 480px) {
    .square-gallery {
        grid-template-columns: 1fr;
        gap: 12px;
        padding: 10px;
    }

    .square-gallery .gallery-item {
        aspect-ratio: 1 / 1;
        height: auto;
    }
}