/* ========== ПОРТФОЛИО - ФИЛЬТРЫ И ПАГИНАЦИЯ ========== */

/* Скрытие карточек при фильтрации */
.project-card.hidden {
    display: none !important;
}

.project-card .box {
    position: relative;
}

/* Активная кнопка фильтра */
.filter-btn.active {
    background: var(--color-primary) !important;
    color: white !important;
    border-color: var(--color-primary) !important;
}

/* Пагинация */
.pagination {
    display: flex;
    justify-content: center;
    list-style: none;
    padding: 2rem 0;
    gap: 0.5rem;
    margin: 0;
}

.pagination li {
    margin: 0;
}

.pagination a,
.pagination span {
    display: inline-block;
    padding: 0.5rem 1rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    text-decoration: none;
    color: white;
    background: rgba(0, 0, 0, 0.4);
    transition: all 0.3s ease;
    font-weight: 500;
}

.pagination a:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: var(--color-primary);
    transform: translateY(-2px);
}

.pagination .active span {
    background: var(--color-primary);
    color: white;
    border-color: var(--color-primary);
    box-shadow: 0 0 15px rgba(13, 110, 253, 0.3);
}

/* Кнопки фильтрации в общем стиле */
.filter-buttons {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
    margin: 0;
    padding: 0;
}

.filter-buttons > li {
    display: flex;
}

.filter-btn {
    min-width: 120px;
    text-align: center;
}

.filter-scroll {
    display: none;
}

/* Адаптация для мобильных */
@media screen and (max-width: 736px) {
    section#header.page-hero {
        /* The strip adds 4px above and below its visible buttons. */
        row-gap: calc(var(--hero-edge-space) - 0.25rem);
        padding-bottom: calc(var(--hero-edge-space) - 0.25rem);
    }

    .pagination {
        gap: 0.25rem;
        padding: 1.5rem 0;
    }
    
    .pagination a,
    .pagination span {
        padding: 0.4rem 0.8rem;
        font-size: 0.9rem;
    }
    
    .filter-btn {
        min-width: 100px;
        font-size: 0.9rem;
        padding: 0.6rem 1rem;
    }

    #filter-buttons {
        flex-direction: row;
        flex-wrap: nowrap;
        align-items: stretch;
        justify-content: flex-start;
        max-width: 100%;
        overflow-x: auto;
        overflow-y: hidden;
        padding: 0.25rem;
        scroll-padding-inline: 0.25rem;
        scroll-snap-type: x proximity;
        overscroll-behavior-x: contain;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
    }

    #filter-buttons::-webkit-scrollbar {
        display: none;
    }

    #filter-buttons > li {
        flex: 0 0 auto;
        width: auto;
        max-width: none;
        scroll-snap-align: start;
    }

    #filter-buttons .filter-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        width: auto;
        min-height: 44px;
        white-space: nowrap;
    }
}

/* Mouse controls supplement the compact strip without changing the wide layout. */
@media screen and (max-width: 736px) and (hover: hover) and (pointer: fine) {
    .portfolio-filters.has-overflow {
        display: grid;
        grid-template-columns: 44px minmax(0, 1fr) 44px;
        align-items: center;
        gap: 0.25rem;
    }

    .portfolio-filters.has-overflow .filter-scroll {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 44px;
        height: 44px;
        padding: 0;
        border: 0;
        border-radius: 6px;
        background: rgba(255, 255, 255, 0.2);
        color: var(--color-text);
        font-size: 1rem;
        cursor: pointer;
    }

    .filter-scroll:not(:disabled):hover {
        background: rgba(255, 255, 255, 0.3);
    }

    .filter-scroll:not(:disabled):active {
        background: rgba(255, 255, 255, 0.4);
    }

    .filter-scroll:focus-visible {
        outline: 2px solid var(--color-primary);
        outline-offset: 2px;
    }

    .filter-scroll:disabled {
        opacity: 0.35;
        cursor: default;
    }
}

#portfolio-results {
    transition: opacity 180ms ease;
    scroll-margin-top: 1rem;
}

#portfolio-results.is-loading {
    opacity: 0.45;
    pointer-events: none;
}

#intro {
    scroll-margin-top: 1rem;
}
