/* Модальное окно для просмотра изображений */
.image-modal {
    display: flex;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999;
    background: rgba(0, 0, 0, 0.92);
    backdrop-filter: blur(8px);
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--motion-base, 280ms) var(--motion-ease, cubic-bezier(.22,.8,.25,1)), visibility 0s linear var(--motion-base, 280ms);
}

.image-modal.is-open {
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
    transition-delay: 0s;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.image-modal-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    opacity: 0;
    transform: translateY(10px) scale(.97);
    transition: opacity var(--motion-base, 280ms) var(--motion-ease, cubic-bezier(.22,.8,.25,1)), transform var(--motion-base, 280ms) var(--motion-ease, cubic-bezier(.22,.8,.25,1));
}
.image-modal.is-open .image-modal-content { opacity: 1; transform: translateY(0) scale(1); }

.image-modal-content img {
    display: block;
    max-width: 100%;
    max-height: 90vh;
    width: auto;
    height: auto;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.image-modal-media { width: min(860px, 90vw); color: #fff; }
.image-modal-media audio, .image-modal-media video { display: block; width: 100%; max-height: 78vh; border-radius: 12px; background: #111; box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.image-modal-download { display: inline-flex; align-items: center; min-height: 48px; padding: 12px 18px; border: 1px solid rgba(255,255,255,.35); border-radius: 8px; color: #fff; background: rgba(255,255,255,.12); font-weight: 700; }

.image-modal-close {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 48px;
    height: 48px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    color: #fff;
    font-size: 28px;
    font-weight: 300;
    line-height: 1;
    cursor: pointer;
    transition: background var(--motion-fast, 180ms) ease, border-color var(--motion-fast, 180ms) ease, transform var(--motion-base, 280ms) var(--motion-ease, cubic-bezier(.22,.8,.25,1));
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-modal-close:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.5);
    transform: rotate(90deg);
}

.image-modal-info {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    padding: 12px 20px;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    border-radius: 999px;
    color: rgba(255, 255, 255, 0.9);
    font-size: 14px;
    font-weight: 600;
    max-width: 80vw;
    text-align: center;
}

/* Стрелки и счётчик навигации в модальном окне */
.image-modal-nav {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    z-index: 3;
    width: 52px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid rgba(255, 255, 255, 0.32);
    border-radius: 50%;
    background: rgba(20, 20, 20, 0.35);
    backdrop-filter: blur(10px);
    color: #fff;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    transition: background var(--motion-fast, 180ms) ease, border-color var(--motion-fast, 180ms) ease, transform var(--motion-fast, 180ms) ease;
}
.image-modal-nav:hover { background: rgba(255, 255, 255, 0.22); border-color: rgba(255, 255, 255, 0.65); }
.image-modal-prev { left: 20px; }
.image-modal-next { right: 20px; }
.image-modal-nav[hidden] { display: none; }
.image-modal-counter {
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 3;
    padding: 7px 14px;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(8px);
    color: rgba(255, 255, 255, 0.88);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.06em;
}
.image-modal-counter[hidden] { display: none; }

@media (max-width: 600px) {
    .image-modal-nav { width: 42px; height: 42px; font-size: 20px; }
    .image-modal-prev { left: 10px; }
    .image-modal-next { right: 10px; }
    .image-modal-counter { right: 12px; bottom: 14px; }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes zoomIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@media (max-width: 600px) {
    .image-modal.is-open { padding: 14px; }
    .image-modal-media { width: 100%; }
    .image-modal-media video { max-height: 62vh; }
    .image-modal-close {
        width: 40px;
        height: 40px;
        font-size: 24px;
        top: 15px;
        right: 15px;
    }
    
    .image-modal-info {
        font-size: 13px;
        padding: 10px 16px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .image-modal, .image-modal-content { transition: none; }
}
