/* Фотогалерея */
.gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1rem;
    margin-top: 1.5rem;
}

.gallery-item {
    position: relative;
    overflow: hidden;
    border-radius: 5px;
    height: 200px;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    transition: transform 0.3s;
}

.gallery-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s;
}

.gallery-item:hover img {
    transform: scale(1.05);
}

/* Модальное окно для галереи */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.95);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    padding: 2rem;
}

.modal-image-container {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    max-height: 95vh;
}

.modal-content {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    transition: all 0.3s ease;
}

/* Стили для портретных изображений */
.image-portrait .modal-content {
    max-width: auto;
    max-height: 95vh;
    height: 95vh;
    width: auto;
}

/* Стили для ландшафтных изображений */
.image-landscape .modal-content {
    max-width: 95vw;
    max-height: 95vh;
    width: auto;
    height: auto;
}

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

.close:hover {
    background: rgba(0,0,0,0.8);
    transform: scale(1.1);
}

.modal-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0,0,0,0.5);
    color: white;
    border: none;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 1001;
}

.modal-nav:hover {
    background: rgba(0,0,0,0.8);
    transform: translateY(-50%) scale(1.1);
}

.modal-prev {
    left: 20px;
}

.modal-next {
    right: 20px;
}

.modal-counter {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.7);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.9rem;
    z-index: 1001;
}

/* Адаптивность для галереи */
@media (max-width: 768px) {
    .gallery {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 0.8rem;
    }
    
    .gallery-item {
        height: 150px;
    }
    
    .modal {
        padding: 1rem;
    }
    
    .modal-image-container {
        max-height: 90vh;
    }
    
    .image-portrait .modal-content {
        max-height: 90vh;
        height: 90vh;
    }
    
    .image-landscape .modal-content {
        max-width: 95vw;
        max-height: 90vh;
    }
    
    .close {
        top: 15px;
        right: 20px;
        width: 45px;
        height: 45px;
        font-size: 35px;
    }
    
    .modal-nav {
        width: 45px;
        height: 45px;
        font-size: 1.3rem;
    }
    
    .modal-prev {
        left: 15px;
    }
    
    .modal-next {
        right: 15px;
    }
    
    .modal-counter {
        bottom: 15px;
        font-size: 0.85rem;
    }
}

@media (max-width: 480px) {
    .gallery {
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
        gap: 0.6rem;
    }
    
    .gallery-item {
        height: 130px;
    }
    
    .modal {
        padding: 0.5rem;
    }
    
    .modal-image-container {
        max-height: 85vh;
    }
    
    .image-portrait .modal-content {
        max-height: 85vh;
        height: 85vh;
    }
    
    .image-landscape .modal-content {
        max-width: 98vw;
        max-height: 85vh;
    }
    
    .close {
        top: 10px;
        right: 15px;
        width: 40px;
        height: 40px;
        font-size: 30px;
    }
    
    .modal-nav {
        width: 40px;
        height: 40px;
        font-size: 1.1rem;
    }
    
    .modal-prev {
        left: 10px;
    }
    
    .modal-next {
        right: 10px;
    }
    
    .modal-counter {
        bottom: 10px;
        font-size: 0.8rem;
        padding: 0.4rem 0.8rem;
    }
}

/* Ландшафтный режим на мобильных */
@media (max-width: 768px) and (orientation: landscape) {
    .modal-image-container {
        max-height: 80vh;
    }
    
    .image-portrait .modal-content {
        max-height: 80vh;
        height: 80vh;
    }
    
    .image-landscape .modal-content {
        max-height: 80vh;
    }
}