/* ===== GALLERY STYLES ===== */

/* Breadcrumb */
.breadcrumb {
    margin-bottom: 20px;
    color: rgba(255, 255, 255, 0.8);
    font-size: var(--text-sm);
}

.breadcrumb a {
    color: rgba(255, 255, 255, 0.9);
    transition: var(--transition);
}

.breadcrumb a:hover {
    color: var(--white);
}

/* Hero для страницы светотехники */
.page-hero-lighting {
    background: linear-gradient(135deg, #f59e0b 0%, #fbbf24 100%);
}

/* Filter Section */
.filter-section {
    background: var(--white);
    padding: 30px 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    position: sticky;
    top: 80px;
    z-index: 100;
}

.filter-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
}

.filter-header h2 {
    font-size: var(--text-lg);
    color: var(--dark);
    margin: 0;
}

.filter-counter {
    font-size: var(--text-sm);
    color: var(--gray);
    background: var(--gray-light);
    padding: 8px 16px;
    border-radius: 20px;
}

.filter-counter span {
    font-weight: 700;
    color: var(--primary);
}

.filter-controls {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
}

.filter-btn {
    padding: 10px 16px;
    background: var(--gray-light);
    border: 2px solid transparent;
    border-radius: 50px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    display: flex;
    align-items: center;
    gap: 0;
    font-size: var(--text-sm);
}

.filter-btn:hover {
    background: var(--primary);
    color: var(--white);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(30, 64, 175, 0.3);
}

.filter-btn.active {
    background: var(--primary);
    color: var(--white);
    border-color: var(--primary-dark);
    box-shadow: 0 4px 12px rgba(30, 64, 175, 0.4);
}

.filter-btn .count {
    display: inline-block;
    padding: 2px 8px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    font-size: var(--text-xs);
    margin-left: 5px;
}

/* Gallery Grid */
.gallery-section {
    padding: 60px 0;
    background: var(--gray-light);
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 30px;
    margin-bottom: 50px;
}

.gallery-item {
    position: relative;
    overflow: hidden;
    border-radius: 12px;
    cursor: pointer;
    aspect-ratio: 4/3;
    background: var(--white);
    /* ТЕНИ для фото */
    box-shadow:
        0 4px 6px rgba(0, 0, 0, 0.07),
        0 10px 20px rgba(0, 0, 0, 0.1);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.gallery-item:hover {
    /* Усиленная тень при наведении */
    box-shadow:
        0 10px 20px rgba(0, 0, 0, 0.12),
        0 20px 40px rgba(0, 0, 0, 0.15);
    transform: translateY(-8px) scale(1.02);
}

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

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

/* Скрытие отфильтрованных элементов */
.gallery-item.filtered-out {
    display: none !important;
}

/* Улучшенная анимация пагинации */
.gallery-item.fade-in {
    animation: fadeInScale 0.4s ease forwards;
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.gallery-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(
        to top,
        rgba(0, 0, 0, 0.9) 0%,
        rgba(0, 0, 0, 0.7) 50%,
        transparent 100%
    );
    color: var(--white);
    padding: 30px 20px 20px;
    transform: translateY(20px);
    opacity: 0;
    transition: all 0.4s ease;
}

.gallery-item:hover .gallery-overlay {
    transform: translateY(0);
    opacity: 1;
}

.gallery-overlay h3 {
    font-size: var(--text-md);
    margin-bottom: 8px;
    font-weight: 700;
}

.gallery-overlay p {
    font-size: var(--text-sm);
    margin-bottom: 8px;
    opacity: 0.9;
}

.gallery-location {
    display: inline-block;
    font-size: var(--text-xs);
    opacity: 0.8;
}

/* Load More Button */
.load-more-container {
    text-align: center;
}

#loadMoreBtn {
    padding: 15px 40px;
    font-size: var(--text-base);
}

.load-more-hint {
    margin-top: 12px;
    color: var(--gray);
    font-size: var(--text-sm);
}

/* Modal for Zoomed Image */
.gallery-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    z-index: 10000;
    animation: fadeIn 0.3s ease;
}

.gallery-modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.modal-content {
    max-width: 45%;
    max-height: 90vh;
    position: relative;
    animation: zoomIn 0.3s ease;
}

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

.modal-content img {
    max-width: 100%;
    max-height: 80vh;
    display: block;
    border-radius: 8px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.modal-info {
    background: rgba(0, 0, 0, 0.8);
    color: var(--white);
    padding: 20px;
    border-radius: 0 0 8px 8px;
    margin-top: -5px;
}

.modal-info h3 {
    font-size: var(--text-xl);
    margin-bottom: 10px;
}

.modal-info p {
    font-size: var(--text-base);
    margin-bottom: 10px;
    opacity: 0.9;
}

.modal-info span {
    font-size: var(--text-sm);
    opacity: 0.8;
}

/* Modal Controls */
.modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    border: none;
    color: var(--white);
    font-size: var(--text-hero);
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    transition: var(--transition);
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10001;
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

.modal-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    border: none;
    color: var(--white);
    font-size: var(--text-2xl);
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10001;
}

.modal-nav:hover {
    background: rgba(255, 255, 255, 0.3);
}

.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);
    backdrop-filter: blur(10px);
    color: var(--white);
    padding: 10px 20px;
    border-radius: 20px;
    font-size: var(--text-sm);
    font-weight: 600;
}

/* Keyboard hint */
.modal-content::after {
    content: 'Используйте ← → для навигации, ESC для закрытия';
    position: absolute;
    top: -40px;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255, 255, 255, 0.6);
    font-size: var(--text-xs);
    white-space: nowrap;
}

/* Animation for filtered items */
.gallery-item {
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.gallery-item.hidden {
  opacity: 0;
  transform: scale(0.8);
  pointer-events: none;
  /* Уберите height: 0 и margin: 0 */
  visibility: hidden;
  position: absolute;
  left: -9999px; /* Скрываем, но не удаляем из верстки */
}

.gallery-item.visible {
    opacity: 1;
    transform: scale(1);
    pointer-events: auto;
}

/* Плавное появление после фильтрации */
@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.gallery-item.fade-in {
    animation: fadeInScale 0.4s ease forwards;
}

/* Responsive */
@media (max-width: 768px) {
    .gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
        gap: 20px;
    }

    .modal-content {
        max-width: 95%;
    }

    .modal-nav {
        width: 40px;
        height: 40px;
        font-size: var(--text-xl);
    }

    .modal-close {
        width: 40px;
        height: 40px;
        font-size: var(--text-3xl);
        top: 10px;
        right: 10px;
    }

    .modal-prev {
        left: 10px;
    }

    .modal-next {
        right: 10px;
    }

    .modal-content::after {
        display: none;
    }

    .filter-section {
        padding: 18px 0;
        top: 74px;
    }

    .filter-btn {
        width: auto;
        white-space: nowrap;
        flex: 0 0 auto;
    }

    .filter-header {
        margin-bottom: 14px;
    }

    .filter-header h2 {
        font-size: var(--text-md);
    }

    .filter-controls {
        flex-wrap: nowrap;
        overflow-x: auto;
        padding-bottom: 6px;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .filter-controls::-webkit-scrollbar {
        display: none;
    }

    .gallery-overlay {
        transform: none;
        opacity: 1;
        padding: 16px 14px 14px;
        background: linear-gradient(to top, rgba(15, 23, 42, 0.92) 0%, rgba(15, 23, 42, 0.72) 58%, rgba(15, 23, 42, 0.2) 100%);
    }

    .gallery-overlay h3 {
        font-size: var(--text-base);
        line-height: 1.35;
    }

    .gallery-overlay p {
        font-size: var(--text-sm);
        line-height: 1.45;
        margin-bottom: 6px;
    }
}

@media (max-width: 480px) {
    .gallery-grid {
        grid-template-columns: 1fr;
    }

    .modal-info h3 {
        font-size: var(--text-md);
    }

    .modal-info p {
        font-size: var(--text-sm);
    }
}
