/* Базовые стили */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: #0a0a0a;
    color: #e0e0e0;
    line-height: 1.5;
    font-weight: 300;
    overflow-x: hidden;
}

/* Галерея */
.gallery-container {
    width: 100%;
    margin: 0;
    padding: 0;
}

.gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 0;
    grid-auto-flow: dense;
    width: 100%;
}

.photo-item {
    overflow: hidden;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    aspect-ratio: 4/3;
    background: #111;
    position: relative;
}

.photo-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, transparent 70%, rgba(0, 0, 0, 0.1));
    z-index: 1;
    opacity: 0;
    transition: opacity 0.3s;
}

.photo-item:hover {
    transform: scale(1.02);
    z-index: 10;
}

.photo-item:hover::before {
    opacity: 1;
}

.photo-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.photo-item:hover img {
    transform: scale(1.08);
}

/* Лайтбокс */
.lightbox {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.98);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    padding: 0;
    backdrop-filter: blur(8px);
}

.lightbox.active {
    display: flex;
    animation: fadeIn 0.2s ease-out;
}

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

.lightbox-content {
    position: relative;
    width: 100%;
    max-width: 95vw;
    height: 95vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* Кнопка закрытия */
.lightbox-close {
    position: fixed;
    top: 24px;
    right: 24px;
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.8);
    font-size: 1.5rem;
    width: 40px;
    height: 40px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    z-index: 1002;
    opacity: 0.7;
}

.lightbox-close:hover {
    color: #fff;
    opacity: 1;
    transform: rotate(90deg);
}

.lightbox-close svg {
    width: 20px;
    height: 20px;
}

/* Контейнер изображения */
.image-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

#lightbox-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    display: block;
    animation: imageFadeIn 0.3s ease-out;
}

@keyframes imageFadeIn {
    from { opacity: 0.5; }
    to { opacity: 1; }
}

/* Стрелки навигации */
.nav-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    opacity: 0;
    z-index: 1001;
    width: 60px;
    height: 100%;
    padding: 0 20px;
}

.lightbox-content:hover .nav-arrow {
    opacity: 0.7;
}

.nav-arrow:hover {
    color: #fff;
    opacity: 1;
}

.nav-arrow svg {
    width: 24px;
    height: 24px;
    transition: transform 0.2s;
}

.arrow-left {
    left: 0;
}

.arrow-right {
    right: 0;
}

.nav-arrow:hover svg {
    transform: scale(1.2);
}

/* Панель управления */
.controls-panel {
    position: absolute;
    bottom: 24px;
    right: 24px;
    display: flex;
    gap: 16px;
    z-index: 1001;
    opacity: 0;
    transition: opacity 0.3s;
}

.lightbox-content:hover .controls-panel {
    opacity: 0.7;
}

.controls-panel:hover {
    opacity: 1 !important;
}

.control-btn {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    padding: 8px;
    text-decoration: none;
}

.control-btn:hover {
    color: #fff;
    transform: scale(1.1);
}

.control-btn svg {
    width: 20px;
    height: 20px;
}

.download-btn:hover svg {
    animation: downloadPulse 0.5s ease;
}

@keyframes downloadPulse {
    0% { transform: translateY(0); }
    50% { transform: translateY(-2px); }
    100% { transform: translateY(0); }
}

/* Полноэкранный режим */
.fullscreen-btn {
    position: relative;
}

.exit-fullscreen-icon {
    display: none;
}

body.fullscreen-active .fullscreen-icon {
    display: none;
}

body.fullscreen-active .exit-fullscreen-icon {
    display: block;
}

.fullscreen-btn:hover svg {
    animation: fullscreenRotate 0.5s ease;
}

@keyframes fullscreenRotate {
    0% { transform: rotate(0); }
    100% { transform: rotate(90deg); }
}

/* Счетчик */
.image-counter {
    position: fixed;
    bottom: 24px;
    left: 24px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.85rem;
    font-weight: 400;
    letter-spacing: 0.5px;
    background: rgba(0, 0, 0, 0.3);
    padding: 6px 12px;
    border-radius: 4px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.05);
    opacity: 0;
    transition: opacity 0.3s;
}

.lightbox-content:hover .image-counter {
    opacity: 1;
}

/* Подвал */
footer {
    padding: 20px;
    background: #050505;
    border-top: 1px solid #1a1a1a;
}

.footer-content {
    max-width: 100%;
    margin: 0;
}

footer p {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.4);
    font-weight: 400;
    letter-spacing: 0.5px;
}

/* Адаптивность */
@media (max-width: 1024px) {
    .gallery {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    }
}

@media (max-width: 768px) {
    .gallery {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    }
    
    .nav-arrow {
        width: 50px;
        padding: 0 15px;
        opacity: 0.5;
    }
    
    .controls-panel {
        opacity: 0.7;
        bottom: 20px;
        right: 20px;
    }
    
    .image-counter {
        opacity: 0.7;
        bottom: 20px;
        left: 20px;
        font-size: 0.8rem;
    }
    
    .lightbox-close {
        top: 20px;
        right: 20px;
        opacity: 0.7;
    }
}

@media (max-width: 480px) {
    .gallery {
        grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    }
    
    .nav-arrow {
        width: 40px;
        padding: 0 10px;
    }
    
    .nav-arrow svg {
        width: 20px;
        height: 20px;
    }
    
    .controls-panel {
        gap: 12px;
        bottom: 16px;
        right: 16px;
    }
    
    .control-btn svg {
        width: 18px;
        height: 18px;
    }
    
    footer {
        padding: 16px;
    }
    
    footer p {
        font-size: 0.85rem;
    }
}

/* Тонкий скроллбар */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: #111;
}

::-webkit-scrollbar-thumb {
    background: #333;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #444;
}

/* Анимация загрузки */
@keyframes pulse {
    0% { opacity: 0.4; }
    50% { opacity: 0.7; }
    100% { opacity: 0.4; }
}

.loading {
    animation: pulse 1.5s infinite;
}