/**
 * FOCUS Media Viewer
 * Модальное окно для просмотра изображений и видео.
 * Автономный модуль — не зависит от стилей сайта.
 */

/* ===== Переменные (fallback, если переменные сайта не заданы) ===== */
:root {
    --mv-neon-purple: var(--neon-purple, #8a2be2);
    --mv-neon-purple-light: var(--neon-purple-light, #9d4edd);
    --mv-black: var(--black, #000000);
    --mv-dark-gray: var(--dark-gray, #1a1a1a);
    --mv-medium-gray: var(--medium-gray, #333333);
    --mv-light-gray: var(--light-gray, #666666);
    --mv-white: var(--white, #ffffff);
}

/* ===== Корневой контейнер ===== */
.mv-root {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 100002; /* Выше чата (99999) и контекстного меню (100001) */
    background: rgba(0, 0, 0, 0.92);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    transition: opacity 0.3s ease;
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    color: var(--mv-white);
    user-select: none;
    -webkit-user-select: none;
}

.mv-root.mv-active {
    display: flex;
    opacity: 1;
}

/* ===== Контент (изображение или видео) ===== */
.mv-content {
    max-width: 90vw;
    max-height: 85vh;
    position: relative;
    border-radius: 12px;
    border: 2px solid rgba(138, 43, 226, 0.3);
    box-shadow: 0 0 60px rgba(138, 43, 226, 0.2);
    overflow: hidden;
    animation: mvZoomIn 0.4s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
}

@keyframes mvZoomIn {
    from {
        transform: scale(0.85);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.mv-content img,
.mv-content video {
    display: block;
    max-width: 100%;
    max-height: 85vh;
    width: auto;
    height: auto;
    object-fit: contain;
}

.mv-content video {
    min-width: 480px;
    min-height: 270px;
    background: #000;
}

/* ===== Подпись ===== */
.mv-caption {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 20px 30px;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.85));
    color: var(--mv-white);
    font-size: 0.95rem;
    line-height: 1.4;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.mv-content:hover .mv-caption,
.mv-caption.mv-caption-visible {
    opacity: 1;
}

/* ===== Кнопка закрытия ===== */
.mv-close {
    position: fixed;
    top: 30px;
    right: 40px;
    background: none;
    border: none;
    color: var(--mv-white);
    font-size: 2.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 100003;
    opacity: 0.7;
    line-height: 1;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mv-close:hover {
    opacity: 1;
    transform: rotate(90deg) scale(1.1);
    color: var(--mv-neon-purple);
}

/* ===== Навигация ===== */
.mv-nav {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    border: 2px solid var(--mv-neon-purple);
    color: var(--mv-white);
    cursor: pointer;
    z-index: 100003;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.mv-nav:hover:not(:disabled) {
    background: var(--mv-neon-purple);
    box-shadow: 0 0 20px var(--mv-neon-purple);
    transform: translateY(-50%) scale(1.05);
}

.mv-nav:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.mv-nav-prev {
    left: 24px;
}

.mv-nav-next {
    right: 24px;
}

/* ===== Счётчик ===== */
.mv-counter {
    position: fixed;
    top: 30px;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255, 255, 255, 0.85);
    font-size: 0.9rem;
    z-index: 100003;
    background: rgba(0, 0, 0, 0.5);
    padding: 6px 18px;
    border-radius: 20px;
    backdrop-filter: blur(10px);
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.5px;
}

/* ===== Мобильные устройства ===== */
@media (max-width: 768px) {
    .mv-content {
        max-width: 100vw;
        max-height: 80vh;
        border-radius: 8px;
    }

    .mv-content img,
    .mv-content video {
        max-height: 80vh;
    }

    .mv-content video {
        min-width: 0;
        min-height: 0;
    }

    .mv-close {
        top: 15px;
        right: 15px;
        font-size: 2rem;
    }

    .mv-nav {
        width: 44px;
        height: 44px;
        font-size: 1.1rem;
    }

    .mv-nav-prev { left: 10px; }
    .mv-nav-next { right: 10px; }

    .mv-counter {
        top: 15px;
        font-size: 0.8rem;
        padding: 5px 14px;
    }

    .mv-caption {
        font-size: 0.85rem;
        padding: 15px 20px;
    }
}

@media (max-width: 480px) {
    .mv-root {
        padding: 0;
    }

    .mv-content {
        border-radius: 0;
        border: none;
        box-shadow: none;
    }

    .mv-content img,
    .mv-content video {
        max-height: 100vh;
    }

    .mv-content video {
        width: 100%;
        height: auto;
    }
}

/* ===== Уменьшение анимаций ===== */
@media (prefers-reduced-motion: reduce) {
    .mv-root,
    .mv-content,
    .mv-close,
    .mv-nav,
    .mv-caption {
        transition: none;
        animation: none;
    }
}