/* --- ОСНОВНАЯ СЕКЦИЯ --- */
.photo-gallery {
    background: #0a0a0a;
    padding: 100px 50px;
    color: #fff;
}

.gallery-wrapper {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    gap: 60px;
    align-items: flex-start;
}

.gallery-info {
    flex: 0 0 400px;
    position: sticky;
    top: 100px;
}

a {
    text-decoration: none;
}

/* --- ПОРТРЕТ (ЛЕВАЯ ЧАСТЬ) --- */
.gallery-portrait {
    width: 100%;
    margin-bottom: 30px;
    border-radius: 20px;
    overflow: hidden;
    border: 2px solid transparent;
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    cursor: pointer;
}

.gallery-portrait img {
    width: 100%;
    height: 550px;
    object-fit: cover;
    display: block;
    transition: transform 0.5s ease;
}

.gallery-portrait:hover {
    border-color: #D4FC1E;
    box-shadow: 0 0 40px rgba(212, 252, 30, 0.4);
    transform: translateY(-5px);
}

/* --- ТЕКСТ И КНОПКИ --- */
.gallery-title {
    font-size: 38px;
    font-weight: 900;
    line-height: 1.1;
    margin-bottom: 35px;
    text-transform: uppercase;
}

.gallery-actions {
    display: flex;
    align-items: center;
    gap: 20px;
}

.btn-primary {
    display: inline-block;
    text-decoration: none;
    background-color: #D4FC1E; 
    color: #000;
    padding: 15px 30px;
    border-radius: 5px;
    font-weight: bold;
    transition: all 0.3s ease;
    border: none;
    cursor: pointer;
}

.btn-arrow-circle {
    width: 64px; height: 64px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    background: transparent;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-arrow-circle:hover { border-color: #D4FC1E; }

.arrow-icon {
    font-size: 24px; color: #fff;
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.btn-arrow-circle:hover .arrow-icon {
    color: #D4FC1E;
    transform: rotate(-75deg); /* Поворот на 75 градусов */
}

/* --- СЕТКА ФОТОГРАФИЙ (ПРАВАЯ ЧАСТЬ) --- */
.gallery-grid {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-auto-rows: 240px;
    gap: 20px;
}

.grid-item {
    background-size: cover;
    background-position: center;
    border-radius: 12px;
    border: 2px solid transparent;
    filter: grayscale(100%) brightness(0.8);
    transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
}

.grid-item:hover {
    filter: grayscale(0%) brightness(1.1);
    transform: translateY(-5px) scale(1.02);
    border-color: #D4FC1E;
}

.grid-item.tall { grid-row: span 2; }
.grid-item.wide { grid-column: span 2; }

/* --- МОДАЛЬНОЕ ОКНО --- */
.modal {
    display: none;
    position: fixed;
    z-index: 4000;
    left: 0; top: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0);
    backdrop-filter: blur(0px);
    justify-content: center; align-items: center;
    transition: background 0.4s ease, backdrop-filter 0.4s ease;
}

.modal.active {
    display: flex;
    background: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(15px);
}

.modal-content {
    position: relative;
    width: 90%;
    height: 90%;
    display: flex;
    justify-content: center;
    align-items: center;
}

#modalImage {
    opacity: 0;
    transform: scale(0.9) translateY(20px);
    transition: opacity 0.5s cubic-bezier(0.4, 0, 0.2, 1), 
                transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    max-width: 100%;
    max-height: 80vh;
    object-fit: contain;
    border-radius: 10px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
    border: 2px solid rgba(211, 252, 30, 0.8);
}

#modalImage.visible {
    opacity: 1;
    transform: scale(1) translateY(0);
}

/* Кнопки навигации в модалке */
.modal-close, .modal-prev, .modal-next {
    position: absolute; color: #fff; font-size: 40px;
    background: none; border: none; cursor: pointer;
    transition: color 0.3s, opacity 0.3s;
    z-index: 4001;
}

.modal-close { top: 20px; right: 20px; font-size: 50px; }
.modal-prev { left: 20px; }
.modal-next { right: 20px; }

/* --- РАСПРАВЛЕННАЯ ГАЛЕРЕЯ ДЛЯ МОБИЛЬНЫХ --- */

/* Адаптация для планшетов */
@media (max-width: 1100px) {
    .photo-gallery {
        padding: 60px 20px;
    }
    .gallery-wrapper {
        flex-direction: column;
        align-items: center;
        gap: 40px;
    }
    .gallery-info {
        position: static;
        flex: none;
        width: 100%;
        text-align: center;
    }
    .gallery-actions {
        justify-content: center;
    }
}

/* Полная мобильная адаптивность */
@media (max-width: 768px) {
    .photo-gallery {
        padding: 40px 15px;
    }

    .gallery-info {
        padding: 0;
        margin-bottom: 30px;
    }

    .gallery-title {
        font-size: 28px;
    }

    /* --- ГЛАВНЫЙ ПОРТРЕТ (ЦВЕТНОЙ) --- */
    .gallery-portrait {
        width: 100%;
        border-radius: 15px;
        margin-bottom: 25px;
        overflow: hidden;
        /* Отключаем ЧБ эффект только для профиля */
        filter: grayscale(0%) !important; 
        border: 1px solid rgba(255, 255, 255, 0.1);
        box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
    }

    .gallery-portrait img {
        width: 100%;
        height: 450px;
        object-fit: cover;
        display: block;
    }

    /* --- СЕТКА: 3 в ряд + 3 в ряд + 1 внизу (ЧЕРНО-БЕЛАЯ) --- */
    .gallery-grid {
        display: grid;
        grid-template-columns: repeat(3, 1fr); 
        grid-auto-rows: minmax(100px, auto); 
        gap: 10px; 
        width: 100%;
    }

    .grid-item {
        width: 100%;
        aspect-ratio: 1 / 1; 
        height: auto !important; 
        border-radius: 8px;
        
        /* Черно-белый эффект для всех карточек */
        filter: grayscale(100%) contrast(1.1);
        transition: all 0.4s ease;
        
        grid-column: auto !important;
        grid-row: auto !important;
        -webkit-tap-highlight-color: transparent; /* Убирает блик при нажатии на мобильных */
    }

    /* Возврат цвета при нажатии пальцем */
    .grid-item:active {
        filter: grayscale(0%);
        transform: scale(0.98);
    }

    /* Последний элемент (7-й) на всю ширину */
    .grid-item:last-child {
        grid-column: 1 / span 3 !important; 
        aspect-ratio: 16 / 9; 
    }

    /* --- МОДАЛЬНОЕ ОКНО --- */
    .modal-content {
        width: 95%;
    }

    #modalImage {
        max-height: 70vh;
        border-width: 1px;
        filter: grayscale(0%); /* В модалке фото всегда цветное */
    }

    .modal-close {
        top: 10px;
        right: 15px;
        font-size: 35px;
    }

    .modal-prev, .modal-next {
        bottom: 20px;
    }
    .modal-prev { left: 20%; }
    .modal-next { right: 20%; }

    /* Компактные кнопки управления под текстом */
    .btn-arrow-circle {
        width: 50px;
        height: 50px;
    }
    .btn-primary {
        padding: 12px 24px;
        font-size: 14px;
    }
}

/* Маленькие экраны */
@media (max-width: 480px) {
    .gallery-grid {
        gap: 8px;
    }
    
    .gallery-title {
        font-size: 24px;
    }

    .gallery-portrait img {
        height: 380px;
    }
}