@layer pages {
    /* PORTFOLIO STYLING */
    .portfolio-grid {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(400px, 1fr)); /* Adjust grid item size */
        gap: 10px; /* Spacing between grid items */
        padding: 0px;
        margin-top: 20px; /* sits below filters */
    }

    /* When filters are collapsed, ensure grid clears the fixed header/logo */
    .portfolio-filters:not(.is-open) + .portfolio-grid {
        margin-top: 120px; /* header (100px) + buffer */
    }

    /* Filters section */
    .portfolio-filters {
        width: 100%;
        max-width: 1400px;
        margin: 0 auto; /* collapsed state has no extra spacing */
        padding: 0 20px; /* horizontal padding retained */
        max-height: 0;
        opacity: 0;
        overflow: hidden;
        pointer-events: none;
        transition: max-height 300ms ease, opacity 250ms ease, margin 200ms ease, padding 200ms ease;
    }

    .portfolio-filters {
        position: sticky;
        top: 120px;
        z-index: 50; /* stays above project cards */
        background: var(--color-bg, #fff);
        transition: box-shadow 0.2s ease;
    }

    /* Add subtle shadow when scrolled */
    .portfolio-filters.is-stuck {
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
        padding: 20px 20px !important;
        border-radius: 20px;
    }

    /* If you’re using the toggle panel layout on mobile */
    @media (max-width: 768px) {
        .portfolio-filters.is-open {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            height: 100vh;
            overflow-y: auto;
            z-index: 100;
        }
    }

    .portfolio-filters.is-open {
        margin: 120px auto 10px auto; /* sits under fixed header */
        padding: 0 20px 10px 20px;
        max-height: 1000px; /* sufficiently large to show content */
        opacity: 1;
        pointer-events: auto;
    }

    .filters-inner {
        display: flex;
        align-items: center;
        gap: 14px;
        flex-wrap: wrap;
    }

    .filters-group {
        display: flex;
        align-items: center;
        gap: 10px;
        flex-wrap: wrap;
    }

    .filters-title {
        text-transform: uppercase;
        font-size: 14px;
        letter-spacing: 0.06em;
        opacity: 0.8;
    }

    .filters-list {
        display: flex;
        flex-wrap: wrap;
        gap: 8px 10px;
    }

    .filter-pill {
        position: relative;
        display: inline-flex;
        align-items: center;
        gap: 8px;
        background: rgba(255, 255, 255, 0.06);
        border: 1px solid rgba(255, 255, 255, 0.15);
        border-radius: 999px;
        padding: 6px 12px;
        cursor: pointer;
        user-select: none;
    }

    .filter-pill:hover {
        background: rgba(255, 255, 255, 0.1);
        border-color: rgba(255, 255, 255, 0.3);
    }

    .filter-pill input[type="checkbox"] {
        position: absolute;
        opacity: 0;
        width: 0;
        height: 0;
        pointer-events: none;
    }

    .filter-pill .filter-label {
        font-size: 13px;
        display: inline-flex;
        align-items: center;
        gap: 8px;
    }

    .filter-pill .filter-label::before {
        content: "";
        width: 14px;
        height: 14px;
        border-radius: 3px;
        border: 1px solid rgba(255, 255, 255, 0.6);
        background: transparent;
    }

    .filter-pill.is-checked {
        background: rgba(241, 96, 86, 0.15);
        border-color: #F16056;
    }

    .filter-pill.is-checked .filter-label::before {
        background: #F16056;
        border-color: #F16056;
    }

    .filters-clear {
        margin-left: auto;
        background: transparent;
        color: #fff;
        border: 1px solid rgba(255, 255, 255, 0.25);
        border-radius: 6px;
        padding: 6px 10px;
        cursor: pointer;
    }

    .filters-clear:hover {
        border-color: rgba(255, 255, 255, 0.5);
    }

    .filters-divider {
        height: 1px;
        background: rgba(255, 255, 255, 0.15);
        margin-top: 10px;
    }

    /* Toggle button (top-right near header) */
    .portfolio-filter-toggle {
        position: fixed;
        top: 28px; /* align roughly with header menu */
        right: 20px;
        width: 38px;
        height: 38px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        border-radius: 8px;
        background: rgba(255, 255, 255, 0.06);
        color: #fff; /* icon color */
        border: 1px solid rgba(255, 255, 255, 0.18);
        cursor: pointer;
        z-index: 1100; /* above header */
        transition: background 0.2s ease, border-color 0.2s ease;
    }

    .portfolio-filter-toggle:hover {
        background: rgba(255, 255, 255, 0.12);
    }

    .portfolio-filter-toggle.is-active {
        background: var(--color-accent, #F16056);
        border-color: var(--color-accent, #F16056);
    }

    /* Search */
    .filters-group--search {
        width: 100%;
        flex: 1 0 100%;
        display: flex;
        justify-content: center;
        margin-bottom: 10px;
    }

    .filter-search {
        width: 100%;
        max-width: 100%;
        justify-content: flex-start;
        padding: 10px 16px;
    }

    .filter-search:hover {
        background: rgba(255, 255, 255, 0.1);
        border-color: rgba(255, 255, 255, 0.3);
    }

    .filter-search:focus-within .filter-search__icon {
        color: #F16056;
    }

    .filter-search:focus-within {
        background: rgba(241, 96, 86, 0.15);
        border-color: #F16056;
    }

    .filter-search__icon {
        opacity: 0.6;
        flex-shrink: 0;
    }

    .portfolio-search {
        width: 100%;
        font-size: 15px;
        color: #fff;
        border: none;
        background: transparent;
        outline: none;
    }

    .portfolio-search::placeholder {
        color: rgba(255, 255, 255, 0.6);
        font-style: italic;
    }

    .portfolio-item {
        width: 100%;
        aspect-ratio: 1.3;
        position: relative;
        overflow: hidden;
        border-radius: 10px; /* subtle rounded corners */
        border: 0px solid #ddd;
        text-align: center;
        background: repeating-linear-gradient(
                -45deg, /* Angle of the stripes */ rgba(255, 255, 255, 0.05) 0px, /* opacity white */ rgba(255, 255, 255, 0.1) 2px, /* End of white stripe */ transparent 5px, /* Start of transparent stripe */ transparent 4px /* End of transparent stripe */
        );
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        align-items: center; /* Center the title container horizontally */
    }

    .portfolio-image-wrapper {
        width: 100%;
        flex-grow: 1;
        position: relative;
        z-index: 1;
    }

    .portfolio-item img {
        width: 100%;
        height: 100%;
        object-fit: cover;
        display: block;
        transition: transform 0.3s, filter 0.3s;
        transform-origin: top center; /* pivot from middle top */
        z-index: 1;
    }

    .portfolio-item img.highlight {
        transform: scale(1.5);
        filter: brightness(0.5);
        transform-origin: top center;
    }

    .portfolio-title-container {
        text-align: left;
        width: 90%;
        height: 100%;
        border: 0px solid #ddd;
        align-content: center;
        z-index: 2;
        transition: text-align 0.3s
    }

    /* Style for the portfolio type */
    .portfolio-type {
        color: #F16056;
        font-size: 15px;
        text-transform: uppercase;
    }

    /* Style for the portfolio title */
    .portfolio-title {
        color: white;
        font-size: 18px;
    }

    /* Hover and highlight zoom (no reveal dependency) */
    .portfolio-item-link .portfolio-image-wrapper img.highlight {
        transform: scale(1.4);
        filter: brightness(0.5);
        transform-origin: top center;
    }

    .portfolio-item-link:hover .portfolio-image-wrapper img {
        transform: scale(1.4);
        transform-origin: top center;
        will-change: transform;
    }


    /* Pagination */
    .portfolio-pagination {
        display: flex;
        justify-content: center;
        align-items: center;
        flex-wrap: wrap;
        gap: 6px;
        padding: 24px 0;
    }

    .page-btn {
        background: none;
        border: 1px solid rgba(255,255,255,0.15);
        color: #fff;
        padding: 6px 12px;
        border-radius: 4px;
        cursor: pointer;
        transition: all 0.2s ease;
        font-weight: 500;
    }

    .page-btn:hover {
        background: rgba(255, 255, 255, 0.1);
        border-color: rgba(255, 255, 255, 0.3);
    }

    .page-btn.is-active {
        background: rgba(241, 96, 86, 0.15);
        border-color: #F16056;
        font-weight: 600;
    }

    .pagination-dots {
        color: rgba(255,255,255,0.5);
        padding: 0 8px;
        user-select: none;
    }
}
