/* article-modal.css - Стили для модальных окон изображений статей */

.single-image-modal-wrapper img {
    cursor: zoom-in;
    transition: transform 0.2s;
}

.single-image-modal-wrapper img:hover {
    transform: scale(1.02);
}

.image-modal-overlay {
    display: none;
    position: fixed;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    background: rgba(0, 0, 0, 0.95) !important;
    z-index: 2147483647 !important; /* Максимальный z-index */
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(5px);
    padding: 20px;
    box-sizing: border-box;
    outline: none !important; /* Убираем outline при фокусе */
}

.image-modal-overlay:focus {
    outline: none !important;
}

.image-modal-overlay.active {
    display: flex !important;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-open {
    overflow: hidden !important;
}

/* Принудительно сбрасываем z-index для всех элементов кроме модального окна */
.modal-open * {
    z-index: auto !important;
}

.modal-close {
    position: absolute;
    top: 30px;
    right: 30px;
    background: #fff;
    border: none;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2147483646 !important; /* Почти максимальный z-index */
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    transition: background 0.2s, transform 0.2s;
    outline: none;
}

.modal-close:hover,
.modal-close:focus {
    background: #e0e0e0;
    transform: scale(1.1);
    outline: 2px solid #007cba !important;
    outline-offset: 2px !important;
}

.modal-content {
    position: relative;
    max-width: calc(100vw - 40px);
    max-height: calc(100vh - 40px);
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2147483645 !important;
    animation: scaleIn 0.3s ease;
    margin: auto;
}

@keyframes scaleIn {
    from { 
        transform: scale(0.8);
        opacity: 0;
    }
    to { 
        transform: scale(1);
        opacity: 1;
    }
}

.modal-image {
    max-width: 100%;
    max-height: 100%;
    display: block;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    object-fit: contain;
    width: auto;
    height: auto;
}

/* Адаптивность для мобильных устройств */
@media (max-width: 768px) {
    .image-modal-overlay {
        padding: 10px;
    }
    
    .modal-close {
        top: 15px;
        right: 15px;
        width: 40px;
        height: 40px;
        font-size: 20px;
    }
    
    .modal-content {
        max-width: calc(100vw - 20px);
        max-height: calc(100vh - 20px);
    }
}

/* Гарантируем что overlay всегда поверх всего */
.image-modal-overlay {
    position: fixed !important;
    z-index: 2147483647 !important;
}