/* --- Галерея превью --- */
.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: 75vh;
    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;
    }
}

/* =========================
   Стабильные стрелки (всегда по центру)
========================= */

.prev, .next {
    position: fixed;   /* ключевой момент */
    top: 50%;
    transform: translateY(-50%);
    z-index: 1100;
}

.prev {
    left: 15px;
}

.next {
    right: 15px;
}

/* Мобильная версия */
@media (max-width: 768px) {

    .prev, .next {
        width: 55px;
        height: 55px;
        line-height: 52px;
        font-size: 36px;
        background: rgba(0,0,0,0.5);
        border: 2px solid rgba(255,255,255,0.6);
    }

}

/* --- Заголовки секций --- */
.gallery-section {
    padding: 0px 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;
    }
}


/* ===== Категории ===== */

/* ===== Категории ===== */

.category-nav {
    display: flex;
    justify-content: center;
    gap: 14px;
    margin: 30px 0 10px 0;
    flex-wrap: wrap;
}

.category-btn {
    display: flex;
    align-items: center;
    gap: 10px;

    padding: 8px 16px;

    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.25);

    background: rgba(255,255,255,0.04);

    color: white;
    font-size: 15px;
    font-weight: 600;

    cursor: pointer;

    transition:
        transform 0.2s ease,
        background 0.2s ease,
        border-color 0.2s ease,
        box-shadow 0.2s ease;
}

/* иконка */
.category-icon {
    width: 64px;
    height: 64px;

    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;

    flex-shrink: 0;
}

/* hover */
.category-btn:hover {
    transform: translateY(-1px);

    background: rgba(255,255,255,0.12);

    border-color: rgba(255,255,255,0.45);
}

/* активная категория */
.category-btn.active {

    background: linear-gradient(
        135deg,
        rgba(120,160,255,0.35),
        rgba(70,110,230,0.35)
    );

    border-color: rgba(120,160,255,0.8);

    box-shadow:
        0 0 0 1px rgba(120,160,255,0.5),
        0 0 12px rgba(120,160,255,0.35);
}

.modal-image-wrapper{
    position:relative;
    display:flex;
    justify-content:center;
    align-items:center;
}

.modal-content{
    max-width:90%;
    max-height:75vh;
    border-radius:10px;
    transition:opacity .2s ease;
}

/* размытие превью */

.modal-content.loading{
    filter: blur(25px);
    transform: scale(1.05);
}

/* loader */

.image-loader{
    position:absolute;
    width:60px;
    height:60px;
    border-radius:50%;
    border:4px solid rgba(255,255,255,.2);
    border-top:4px solid white;
    animation:spin 1s linear infinite;
    display:none;
}

.image-loader.show{
    display:block;
}

@keyframes spin{
    from{transform:rotate(0)}
    to{transform:rotate(360deg)}
}