/* Experiments Page Styles */

/* Main content offset for sidebar */
.main-content {
    min-height: 100vh;
    padding-top: 64px;
    padding-left: 280px;
    padding-right: 280px;
    max-width: calc(1200px + 280px + 280px);
    margin-left: auto;
    margin-right: auto;
    padding-bottom: 104px;
    color: #000;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow-x: hidden;
}

/* Mobile responsiveness for main content */
@media (max-width: 768px) {
    .main-content {
        margin-left: 0;
        margin-right: 0;
        padding-left: 0;
        padding-right: 0;
        padding-top: 64px;
        max-width: none;
    }
    
    /* Border-radius для gallery-item на мобильных устройствах */
    body:not(.case-study) .gallery-item,
    .gallery-container .gallery-item,
    .gallery-grid .gallery-item {
        border-radius: 16px !important;
        border: 1px solid #E9EBF0 !important;
    }
    
    /* Изображения внутри имеют border-radius: 0, контейнер обрезает */
    body:not(.case-study) .gallery-item img,
    body:not(.case-study) .gallery-item video,
    .gallery-container .gallery-item img,
    .gallery-container .gallery-item video,
    .gallery-grid .gallery-item img,
    .gallery-grid .gallery-item video {
        border-radius: 0 !important;
    }
}


/* Medium Article Styles */
.medium-article {
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    padding: 0;
    background: transparent;
    box-sizing: border-box;
}

/* Gallery Container */
.gallery-container {
    width: 100%;
    max-width: none;
    margin: 0 auto;
    min-height: 400px;
}

/* Gallery Grid */
.gallery-grid {
    display: flex;
    flex-direction: column;
    gap: 24px;
    justify-content: flex-start;
    align-items: center;
}

/* Gallery Item */
/* Используем более высокую специфичность, чтобы переопределить стили из CaseStudiesContent.css */
body:not(.case-study) .gallery-item,
.gallery-container .gallery-item,
.gallery-grid .gallery-item {
    width: 100%;
    max-width: 720px;
    height: auto;
    aspect-ratio: 720 / 488;
    border-radius: 16px;
    overflow: hidden;
    background: #F2F2F2 !important;
    border: 1px solid #E9EBF0 !important;
    border-width: 1px !important;
    border-style: solid !important;
    border-color: #E9EBF0 !important;
    transition: transform 0.3s ease;
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
    /* Восстанавливаем pointer-events для experiments.html */
    pointer-events: auto !important;
}

body:not(.case-study) .gallery-item:hover,
.gallery-container .gallery-item:hover,
.gallery-grid .gallery-item:hover {
    transform: translateY(-4px);
    border: 1px solid #E9EBF0 !important;
    border-width: 1px !important;
    border-style: solid !important;
    border-color: #E9EBF0 !important;
    outline: none !important;
    box-shadow: none !important;
    /* Обязательно сохраняем overflow: hidden при hover, чтобы изображение не выходило за границы */
    overflow: hidden !important;
}

body:not(.case-study) .gallery-item.animate,
.gallery-container .gallery-item.animate,
.gallery-grid .gallery-item.animate {
    opacity: 1;
    transform: translateY(0);
}

/* Используем более высокую специфичность для изображений в experiments.html */
body:not(.case-study) .gallery-item img,
body:not(.case-study) .gallery-item video,
.gallery-container .gallery-item img,
.gallery-container .gallery-item video,
.gallery-grid .gallery-item img,
.gallery-grid .gallery-item video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
    display: block;
    border-radius: 0 !important;
    cursor: pointer;
    border: none !important;
    outline: none !important;
    /* Восстанавливаем pointer-events для изображений */
    pointer-events: auto !important;
}

body:not(.case-study) .gallery-item:hover img,
body:not(.case-study) .gallery-item:hover video,
.gallery-container .gallery-item:hover img,
.gallery-container .gallery-item:hover video,
.gallery-grid .gallery-item:hover img,
.gallery-grid .gallery-item:hover video {
    transform: scale(1.05);
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
}

/* Mobile Version */
@media (max-width: 767px) {
    .gallery-grid {
        gap: 16px;
        justify-content: center;
    }
}

/* Image Modal Styles */
.image-modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(4px);
    padding: 40px 24px;
    overflow: auto;
}

.image-modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-modal.show.zoomed {
    align-items: flex-start;
    justify-content: flex-start;
}

.image-modal-content {
    max-width: min(90vw, 960px);
    max-height: 90vh;
    object-fit: contain;
    border-radius: 0;
    cursor: zoom-in;
    display: block;
    margin: auto;
    transition: transform 0.3s ease;
}

.video-modal-content {
    max-width: min(90vw, 960px);
    max-height: 90vh;
    width: 100%;
    height: auto;
    background: #000;
    border-radius: 0;
    display: none;
    margin: auto;
}

.image-modal.zoomed .image-modal-content,
.image-modal.show.zoomed .image-modal-content {
    max-width: none;
    max-height: none;
    cursor: zoom-out;
}

.image-modal.zoomed .video-modal-content,
.image-modal.show.zoomed .video-modal-content {
    max-width: none;
    max-height: none;
}

.image-modal-close {
    position: absolute;
    top: 20px;
    right: 30px;
    color: white;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
    z-index: 1001;
}

.image-modal-close:hover {
    opacity: 0.7;
}

/* Popup Modal Styles */
.popup-modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
}

.popup-modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

.popup-modal-overlay {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(4px);
}

.popup-modal-content {
    position: relative;
    width: 100%;
    max-width: 1440px;
    height: calc(100vh - 32px);
    max-height: calc(100vh - 32px);
    background: #FFFFFF;
    border-radius: 24px;
    overflow: visible;
    z-index: 2001;
    display: flex;
    flex-direction: column;
    margin: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.popup-modal-content::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 24px;
    background: #FFFFFF;
    z-index: -1;
    pointer-events: none;
}

.popup-modal-body {
    overflow-y: auto;
    overflow-x: visible;
    flex: 1;
    padding: 0;
    height: 100%;
    position: relative;
}

.popup-modal-body main {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: visible;
}

.popup-modal-body .main-content {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    position: relative;
    overflow: visible;
    min-height: 100vh;
}

/* Hide back button in popup or make it close popup */
.popup-modal-body .back-button {
    display: none;
}

/* Ensure SignUp content fits in popup */
.popup-modal-body .content-wrapper {
    max-width: 100%;
    margin: 0;
    padding: 20px;
    position: relative;
    overflow: visible;
    min-height: 100%;
    width: 100%;
}

/* Override SignUp.css styles for popup */
.popup-modal-body .main-content {
    min-width: auto !important;
    width: 100% !important;
    overflow: visible !important;
    overflow-x: visible !important;
}

@media (min-width: 1024px) {
    .popup-modal-body .main-content {
        min-width: auto !important;
        width: 100% !important;
        overflow: visible !important;
        overflow-x: visible !important;
    }
    
    .popup-modal-body .content-wrapper {
        max-width: 100%;
        overflow: visible;
        width: 100%;
    }
}

.popup-modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    background: rgba(0, 0, 0, 0.5);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    z-index: 2002;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    padding: 0;
}

.popup-modal-close svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
}

.popup-modal-close:hover {
    background: rgba(0, 0, 0, 0.7);
    transform: scale(1.1);
}

.popup-loading,
.popup-error {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 400px;
    font-family: 'Inter', sans-serif;
    font-size: 16px;
    color: #1A1A1A;
}

.popup-error {
    color: #dc2626;
}

/* Mobile responsiveness for popup */
@media (max-width: 767px) {
    .popup-modal-content {
        max-width: 100%;
        height: calc(100vh - 32px);
        max-height: calc(100vh - 32px);
        margin: 16px;
        border-radius: 24px;
    }

    .popup-modal-body {
        height: 100%;
    }

    .popup-modal-close {
        top: 16px;
        right: 16px;
        width: 36px;
        height: 36px;
        font-size: 24px;
    }
}

/* ========================================
   БОЛЬШИЕ ЭКРАНЫ - 1920px и больше
   ======================================== */
@media (min-width: 1920px) {
    /* Увеличение контейнера контента */
    .medium-article {
        max-width: 1000px;
    }
    
    /* Расширение меню для больших экранов - чтобы текст не переносился */
    .left-sidebar-nav {
        width: 360px !important;
    }
    
    /* Обновляем padding для main-content */
    body .main-content,
    html body .main-content {
        padding-left: 360px !important;
        padding-right: 360px !important;
        max-width: calc(1000px + 360px + 360px) !important;
    }
    
    /* Убираем перенос текста в меню */
    .left-sidebar-nav .nav-item {
        white-space: nowrap !important;
    }
    
    /* Увеличение логотипа на 8px для больших экранов - синхронизация с прелоадером */
    .left-sidebar-nav .sidebar-logo {
        font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif !important;
        font-size: 28px !important;
        font-weight: 700 !important;
    }
    
    /* Увеличение размера текста внутри логотипа на больших экранах */
    .left-sidebar-nav .sidebar-logo,
    .left-sidebar-nav .sidebar-logo * {
        font-size: 28px !important;
        font-weight: 700 !important;
        font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif !important;
        line-height: 1.2 !important;
        letter-spacing: -0.01em !important;
    }
    
    .left-sidebar-nav .sidebar-logo-icon {
        width: 28px !important;
        height: 28px !important;
    }
    
    .left-sidebar-nav .sidebar-logo img:not(.sidebar-logo-icon) {
        display: none !important;
    }
    
    .left-sidebar-nav .nav-item {
        font-size: 22px !important;
    }
    
    .left-sidebar-nav .nav-section-title {
        font-size: 21px !important;
    }
    
    /* Исправление закругления nav-badge на больших экранах */
    .nav-badge,
    .left-sidebar-nav .nav-badge {
        border-radius: 9999px !important;
    }
    
    /* Расширение галереи и изображений на больших экранах */
    body:not(.case-study) .gallery-item,
    .gallery-container .gallery-item,
    .gallery-grid .gallery-item {
        max-width: 1000px !important;
        border-radius: 16px !important;
        border: 1px solid #E9EBF0 !important;
        /* Обязательно сохраняем overflow: hidden на больших экранах */
        overflow: hidden !important;
    }
    
    body:not(.case-study) .gallery-item img,
    body:not(.case-study) .gallery-item video,
    .gallery-container .gallery-item img,
    .gallery-container .gallery-item video,
    .gallery-grid .gallery-item img,
    .gallery-grid .gallery-item video {
        max-width: 1000px !important;
        border-radius: 0 !important;
    }
    
    /* Увеличение расстояний между элементами галереи */
    .gallery-grid {
        gap: 32px !important;
    }
    
    /* Увеличение модального окна */
    .image-modal-content {
        max-width: min(90vw, 1200px) !important;
    }
    .video-modal-content {
        max-width: min(90vw, 1200px) !important;
    }
}

/* ========================================
   ОЧЕНЬ БОЛЬШИЕ ЭКРАНЫ - 2560px и больше
   ======================================== */
@media (min-width: 2560px) {
    /* Увеличение контейнера контента */
    .medium-article {
        max-width: 1200px;
    }
    
    /* Расширение меню для очень больших экранов - чтобы текст не переносился */
    .left-sidebar-nav {
        width: 400px !important;
    }
    
    /* Обновляем padding для main-content */
    body .main-content,
    html body .main-content {
        padding-left: 400px !important;
        padding-right: 400px !important;
        max-width: calc(1200px + 400px + 400px) !important;
    }
    
    /* Убираем перенос текста в меню */
    .left-sidebar-nav .nav-item {
        white-space: nowrap !important;
    }
    
    /* Увеличение логотипа на 8px для больших экранов - синхронизация с прелоадером */
    .left-sidebar-nav .sidebar-logo {
        font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif !important;
        font-size: 28px !important;
        font-weight: 700 !important;
    }
    
    /* Увеличение размера текста внутри логотипа на больших экранах */
    .left-sidebar-nav .sidebar-logo,
    .left-sidebar-nav .sidebar-logo * {
        font-size: 28px !important;
        font-weight: 700 !important;
        font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif !important;
        line-height: 1.2 !important;
        letter-spacing: -0.01em !important;
    }
    
    .left-sidebar-nav .sidebar-logo-icon {
        width: 28px !important;
        height: 28px !important;
    }
    
    .left-sidebar-nav .sidebar-logo img:not(.sidebar-logo-icon) {
        display: none !important;
    }
    
    .left-sidebar-nav .nav-item {
        font-size: 22px !important;
    }
    
    .left-sidebar-nav .nav-section-title {
        font-size: 21px !important;
    }
    
    /* Исправление закругления nav-badge на очень больших экранах */
    .nav-badge,
    .left-sidebar-nav .nav-badge {
        border-radius: 9999px !important;
    }
    
    /* Расширение галереи и изображений на очень больших экранах */
    body:not(.case-study) .gallery-item,
    .gallery-container .gallery-item,
    .gallery-grid .gallery-item {
        max-width: 1200px !important;
        border-radius: 16px !important;
        border: 1px solid #E9EBF0 !important;
    }
    
    body:not(.case-study) .gallery-item img,
    body:not(.case-study) .gallery-item video,
    .gallery-container .gallery-item img,
    .gallery-container .gallery-item video,
    .gallery-grid .gallery-item img,
    .gallery-grid .gallery-item video {
        max-width: 1200px !important;
        border-radius: 0 !important;
    }
    
    /* Увеличение расстояний между элементами галереи */
    .gallery-grid {
        gap: 40px !important;
    }
    
    /* Увеличение модального окна */
    .image-modal-content {
        max-width: min(90vw, 1440px) !important;
    }
    .video-modal-content {
        max-width: min(90vw, 1440px) !important;
    }
}

/* ========================================
   ТЕМНАЯ ТЕМА - EXPERIMENTS PAGE
   ======================================== */

/* Темная тема - обводка gallery-item с прозрачностью (как на главной) */
/* Используем более высокую специфичность для experiments.html */
[data-theme="dark"] body:not(.case-study) .gallery-item,
[data-theme="dark"] .gallery-container .gallery-item,
[data-theme="dark"] .gallery-grid .gallery-item {
    /* базовая обводка в тёмной теме — более тёмная */
    border-color: rgba(255, 255, 255, 0.10) !important;
    border-width: 1px !important;
    border-style: solid !important;
    background: #000000 !important;
}

/* Hover: не даём правилам выше ставить "почти белую" линию */
[data-theme="dark"] body:not(.case-study) .gallery-item:hover,
[data-theme="dark"] .gallery-container .gallery-item:hover,
[data-theme="dark"] .gallery-grid .gallery-item:hover {
    border-color: rgba(255, 255, 255, 0.14) !important;
}
