/* --- IMG SEO LIGHTBOX STYLES v.7 (Smooth Animations) --- */

/* Курсор */
.thumb { cursor: zoom-in; transition: opacity 0.2s; width: 100%; height: auto;}
.thumb:hover { opacity: 0.8; }

/* Оверлей */
.image-zoom-overlay {
    /* Используем visibility вместо display для анимации */
    visibility: hidden;
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0); /* Старт с прозрачного */
    z-index: 99999;
    opacity: 0;
    /* Плавное появление фона */
    transition: background-color 0.3s ease, opacity 0.3s ease, visibility 0s 0.3s;
    /* Хардварное ускорение */
    will-change: opacity, background-color;
}

.image-zoom-overlay.active {
    visibility: visible;
    opacity: 1;
    background: rgba(0, 0, 0, 1); /* Финиш черный */
    transition: background-color 0.3s ease, opacity 0.3s ease, visibility 0s 0s;
}

/* Контейнер для центрирования */
.image-zoom-container {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transform: scale(0.9);
    transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.2, 0, 0.2, 1);
}

.image-zoom-overlay.active .image-zoom-container {
    opacity: 1;
    transform: scale(1);
}

/* Основная картинка */
.image-zoom-full-image {
    max-width: 100%;
    max-height: calc(100vh - 110px); 
    width: auto; height: auto;
    object-fit: contain;
    user-select: none;
    margin-bottom: 0;
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
}

/* Навигация */
.image-zoom-nav {
    position: absolute; top: 50%; transform: translateY(-60%);
    background: transparent; color: rgba(255,255,255,0.3);
    border: none; width: 80px; height: 120px;
    font-size: 40px; font-family: monospace;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; transition: all 0.2s;
    z-index: 100002;
}
.image-zoom-nav:hover { color: #fff; background: rgba(255,255,255,0.1); transform: translateY(-60%) scale(1.05); }
.image-zoom-prev { left: 0; }
.image-zoom-next { right: 0; }

/* Закрыть */
.image-zoom-close {
    position: absolute; top: 10px; right: 15px;
    background: transparent; color: #888;
    border: none; font-size: 30px; line-height: 1;
    cursor: pointer; transition: color 0.2s, transform 0.2s;
    z-index: 100005; padding: 10px;
}
.image-zoom-close:hover { color: #fff; transform: rotate(90deg); }

/* Кнопка Сетки */
.image-zoom-grid-toggle {
    position: absolute; top: 18px; right: 70px;
    background: transparent; color: #888;
    border: none; width: 34px; height: 34px;
    cursor: pointer; display: flex; flex-wrap: wrap; gap: 4px; padding: 4px;
    z-index: 100005; transition: color 0.2s;
}
.image-zoom-grid-toggle span {
    display: block; width: 11px; height: 11px;
    background-color: currentColor; border-radius: 1px;
}
.image-zoom-grid-toggle:hover { color: #fff; }

/* Инфо */
.image-zoom-info {
    position: absolute; bottom: 110px; left: 0; width: 100%;
    text-align: center; z-index: 100002; pointer-events: none;
    background: transparent;
    text-shadow: 0 0 3px rgba(0,0,0,0.9);
    padding-bottom: 10px;
    /* Анимация появления снизу */
    transform: translateY(20px); opacity: 0;
    transition: all 0.3s 0.1s;
}
.image-zoom-overlay.active .image-zoom-info {
    transform: translateY(0); opacity: 1;
}

.image-zoom-description { display: block; font-size: 16px; color: #fff; font-weight: 500; margin-bottom: 4px; }
.image-zoom-counter { font-size: 13px; font-family: monospace; color: #ddd; }

/* Лоадер */
.image-zoom-loading {
    position: absolute; top: 50%; left: 50%;
    transform: translate(-50%, -60%);
    display: none; z-index: 100001;
}
.image-zoom-loading.active { display: block; }
.spinner {
    width: 40px; height: 40px;
    border: 3px solid rgba(255,255,255,0.2);
    border-radius: 50%; border-top-color: #fff;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }


/* --- ПАНЕЛЬ МИНИАТЮР (DESKTOP) --- */
@media (min-width: 1025px) {
    .image-zoom-thumbnails-wrapper {
        position: absolute; bottom: 0; left: 0;
        width: 100%; height: 100px;
        background: #111; border-top: 1px solid #222;
        padding: 10px 0; box-sizing: border-box;
        z-index: 100003;
        overflow-x: auto; overflow-y: hidden; white-space: nowrap;
        scrollbar-width: none; -ms-overflow-style: none;
        
        /* Анимация выезда снизу */
        transform: translateY(100%);
        transition: transform 0.3s cubic-bezier(0.2, 0, 0.2, 1);
    }
    
    .image-zoom-overlay.active .image-zoom-thumbnails-wrapper {
        transform: translateY(0);
    }

    .image-zoom-thumbnails-wrapper::-webkit-scrollbar { display: none; }

    .image-zoom-thumbnails {
        display: inline-flex; gap: 8px; padding: 0 20px;
        min-width: 100%; justify-content: center;
    }

    .image-zoom-thumbnails img {
        width: 80px; height: 80px; object-fit: cover;
        cursor: pointer; border-radius: 2px; opacity: 1;
        border: 2px solid transparent; flex-shrink: 0;
        transition: border-color 0.1s;
    }

    .image-zoom-thumbnails img.active { border-color: #edd274; }
    .image-zoom-thumbnails img:hover { border-color: #666; }
    .image-zoom-thumbnails img.active:hover { border-color: #edd274; }

    /* --- GRID VIEW (Optimized) --- */
    .image-zoom-thumbnails-wrapper.is-grid {
        height: 100%; /* На весь экран */
        background: #000; padding-top: 80px; padding-bottom: 40px;
        overflow-y: scroll; overflow-x: hidden; white-space: normal;
        transform: translateY(0) !important; /* Всегда показан в режиме сетки */
    }

    .image-zoom-thumbnails-wrapper.is-grid .image-zoom-thumbnails {
        display: flex; flex-wrap: wrap; justify-content: center;
        align-content: flex-start; gap: 10px; padding: 0;
    }

    .image-zoom-thumbnails-wrapper.is-grid img {
        width: 120px; height: 120px;
    }
    .image-zoom-thumbnails-wrapper.is-grid img.active {
        border-color: #edd274; box-shadow: 0 0 0 2px rgba(237, 210, 116, 0.2);
    }
}

@media (max-width: 1024px) {
    .image-zoom-thumbnails-wrapper, .image-zoom-grid-toggle { display: none !important; }
}

@media (max-width: 768px) {
    .image-zoom-nav { display: none; }
    .image-zoom-close { top: 15px; right: 15px; background: rgba(255,255,255,0.1); border-radius: 50%; }
    .image-zoom-info { bottom: 20px; width: 90%; padding: 0 20px; }
}