/* ========================================
   BODY
======================================== */

body {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* ========================================
   SHARED CONTENT WIDTH
======================================== */

:root {
    --content-width: 90%;
    --content-max-width: 82rem;
}

/* ========================================
   PROJECT LIBRARY
======================================== */

.projects {
    width: 100%;
    margin: 0;
    padding: 0 0 2rem;
    box-sizing: border-box;
    margin-top: 10rem; /*TOP SPACING*/
}

.projects__container {
    width: var(--content-width);
    max-width: var(--content-max-width);
    margin-inline: auto;
    box-sizing: border-box;
}


/* ========================================
   HEADER
======================================== */

.projects__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
}

.projects__title {
    margin: 0;
    color: #FFFFFF;
}

/* ========================================
   FILTER BUTTON
======================================== */

.projects__filter {
    position: relative;
    z-index: 1;
    flex-shrink: 0;
}

.projects__filter-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    font-size: 1rem !important;
    padding: 0.45rem 0.65rem;
    color: #FFFFFF;
    background: #151515;
    border: 1px solid #303030;
    border-radius: 0.35rem;

    cursor: pointer;

    transition:
        background 180ms ease,
        border-color 180ms ease;
}

.projects__filter-button:hover,
.projects__filter-button[aria-expanded="true"] {
    background: #202020;
    border-color: #505050;
}

.projects__filter-icon {
    display: block;
    width: 1.25rem;
    height: 1.25rem;
    flex: 0 0 auto;
    color: #FF5900;
}

.projects__filter-button .label-card {
    font-size: 1rem;
    line-height: 1.2;
}


/* ========================================
   FILTER DROPDOWN
======================================== */

.projects__filter-menu {
    position: absolute;
    top: calc(100% + 0.45rem);
    right: 0;

    display: flex;
    flex-direction: column;
    gap: 0.15rem;

    width: max-content;
    min-width: 10.5rem;
    max-width: min(15rem, 80vw);

    padding: 0.45rem;

    background: rgba(19, 19, 19, 0.96);
    border: 1px solid #292929;
    border-radius: 0.4rem;

    box-shadow: 0 0.75rem 2rem rgba(0, 0, 0, 0.45);

    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
}

.projects__filter-menu[hidden] {
    display: none;
}

.projects__filter-option {
    width: 100%;
    padding: 0.55rem 0.65rem;
    font-size: .90rem !important;
    color: #D8D8D8;
    text-align: left;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 0.25rem;
    cursor: pointer;
    transition:
        color 180ms ease,
        background 180ms ease,
        border-color 180ms ease;
}

.projects__filter-option.body-text {
    font-size: 0.8rem;
    line-height: 1.35;
}

.projects__filter-option:hover,
.projects__filter-option:focus-visible {
    color: #FFFFFF;
    background: #262626;
    outline: none;
}

.projects__filter-option.is-selected {
    color: #FFFFFF;
    background: #252525;
    border-color: #414141;
}

/* ========================================
   FILTER STATUS
======================================== */

.projects__filter-status {
    margin: 0.75rem 0 0;
    color: #A8A8A8;
    font-size: 1.15rem;
}

.projects__filter-status:empty {
    display: none;
}

/* ========================================
   PROJECT LIST
======================================== */

.projects__list {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;

    width: 100%;
    margin: 1.5rem auto 0;

    box-sizing: border-box;
}

/* ========================================
   PROJECT CARD
======================================== */

.project-card {
    position: relative;
    isolation: isolate;
    overflow: hidden;
    display: block;
    width: 100%;
    aspect-ratio: 810 / 285;
    min-height: 12rem;
    color: #FFFFFF;
    text-decoration: none;
    background: #151515;
    border: 2px solid transparent;
    border-radius: 2rem;
    box-sizing: border-box;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.project-card[hidden] {
    display: none;
}

.project-card__image {
    position: absolute;
    inset: 0;
    z-index: -2;

    display: block;
    width: 100%;
    height: 100%;

    object-fit: cover;
    object-position: center;

    transition: transform 450ms ease;
}

/* ========================================
   BOTTOM GRADIENT
======================================== */

.project-card::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;

    background: linear-gradient(
        to bottom,
        rgba(0, 0, 0, 0) 55%,
        rgba(0, 0, 0, 0.65) 85%,
        rgba(0, 0, 0, .8) 100%
    );

    pointer-events: none;
}

/* ========================================
   CARD CONTENT
======================================== */

.project-card__content {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;

    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1.25rem;
    padding: 1.75rem 2rem;
    box-sizing: border-box;
}

.project-card__text {
    display: flex;
    flex-direction: column;
    align-items: flex-start;

    flex: 0 1 auto;
    min-width: 0;
}

.project-card__title {
    max-width: 100%;
    margin: 0;
    color: #FFFFFF;
    margin-bottom: 0 !important;
}

.project-card__description {
    margin: -.25rem 0 0 0 !important;
    color: rgba(255, 255, 255, 0.9);
    font-size: 1.15rem;
    font-weight: 400;
}

/* ========================================
   TAG RAIL
======================================== */

.project-card__tags {
    margin-top: 0;
    position: relative;
    flex: 0 1 auto;
    min-width: 0;
    max-width: fit-content;
    display: flex;
    align-items: center;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(0.35rem);
    transition:
        opacity 220ms ease,
        transform 220ms ease,
        visibility 220ms ease;
}

/* ========================================
   TAG ICON
======================================== */

.project-card__tag-icon {
    display: block;
    width: 0.85rem;
    height: 0.85rem;
    flex: 0 0 auto;
    object-fit: contain;
}

.projects__filter-icon {
    transform: translateY(0.1rem);
}

@media (min-width: 768px) {
    .project-card__tags {
        flex: 0 1 auto;
        width: fit-content;
        max-width: 55%;
    }

    .project-card__tags-track {
        width: 100%;
    }
}

.project-card__tags-track {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    width: 100%;
    min-width: 0;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 0.15rem 0 0.35rem;
    scrollbar-width: none;
    -ms-overflow-style: none;
    overscroll-behavior-inline: contain;
}

.project-card__tags-track::-webkit-scrollbar {
    display: none;
}

.project-card__tag-set {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    flex: 0 0 auto;
}

.project-card__tag-position {
    flex: 0 0 auto;
    font-size: .95rem;
}


/* ========================================
   DESKTOP AND TABLET TAG SCROLLING
======================================== */

@media (hover: hover) and (min-width: 768px) {
    .project-card__tags-track {
        cursor: grab;
        touch-action: pan-y;
        user-select: none;
        -webkit-user-select: none;
    }

    .project-card__tags-track:active {
        cursor: grabbing;
    }

    .project-card__tags-track .project-card__tag-set {
        pointer-events: none;
    }
}

/* ========================================
   SOFT TRANSPARENT GRADIENT MASK
======================================== */

/* Default: no mask when tags first appear */
.project-card__tags-track {
    -webkit-mask-image: none;
    mask-image: none;
}

/* Fade the left edge only after tags have scrolled */
.project-card__tags.has-scrolled-left .project-card__tags-track {
    -webkit-mask-image: linear-gradient(
        to right,
        transparent 0,
        rgba(0, 0, 0, 0.12) 0.5rem,
        rgba(0, 0, 0, 0.45) 1rem,
        rgba(0, 0, 0, 0.8) 1.5rem,
        #000 2rem,
        #000 100%
    );

    mask-image: linear-gradient(
        to right,
        transparent 0,
        rgba(0, 0, 0, 0.12) 0.5rem,
        rgba(0, 0, 0, 0.45) 1rem,
        rgba(0, 0, 0, 0.8) 1.5rem,
        #000 2rem,
        #000 100%
    );
}

/* Fade the right edge while more tags remain */
.project-card__tags.has-overflow:not(.at-end) .project-card__tags-track {
    -webkit-mask-image: linear-gradient(
        to right,
        #000 0,
        #000 calc(100% - 2rem),
        rgba(0, 0, 0, 0.8) calc(100% - 1.5rem),
        rgba(0, 0, 0, 0.45) calc(100% - 1rem),
        rgba(0, 0, 0, 0.12) calc(100% - 0.5rem),
        transparent 100%
    );

    mask-image: linear-gradient(
        to right,
        #000 0,
        #000 calc(100% - 2rem),
        rgba(0, 0, 0, 0.8) calc(100% - 1.5rem),
        rgba(0, 0, 0, 0.45) calc(100% - 1rem),
        rgba(0, 0, 0, 0.12) calc(100% - 0.5rem),
        transparent 100%
    );
}

/* Fade both edges after scrolling */
.project-card__tags.has-scrolled-left.has-overflow:not(.at-end)
.project-card__tags-track {
    -webkit-mask-image: linear-gradient(
        to right,
        transparent 0,
        rgba(0, 0, 0, 0.12) 0.5rem,
        rgba(0, 0, 0, 0.45) 1rem,
        rgba(0, 0, 0, 0.8) 1.5rem,
        #000 2rem,
        #000 calc(100% - 2rem),
        rgba(0, 0, 0, 0.8) calc(100% - 1.5rem),
        rgba(0, 0, 0, 0.45) calc(100% - 1rem),
        rgba(0, 0, 0, 0.12) calc(100% - 0.5rem),
        transparent 100%
    );

    mask-image: linear-gradient(
        to right,
        transparent 0,
        rgba(0, 0, 0, 0.12) 0.5rem,
        rgba(0, 0, 0, 0.45) 1rem,
        rgba(0, 0, 0, 0.8) 1.5rem,
        #000 2rem,
        #000 calc(100% - 2rem),
        rgba(0, 0, 0, 0.8) calc(100% - 1.5rem),
        rgba(0, 0, 0, 0.45) calc(100% - 1rem),
        rgba(0, 0, 0, 0.12) calc(100% - 0.5rem),
        transparent 100%
    );
}

/* ========================================
   DESKTOP AND TABLET HOVER
======================================== */

@media (hover: hover) and (min-width: 768px) {
    .project-card:hover .project-card__tags,
    .project-card:focus-visible .project-card__tags {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
        transform: translateY(0);
    }

    .project-card:hover {
        border: 2px solid white;
    }

    .project-card:hover .project-card__image {
        transform: scale(1.025);
    }

    .project-card:hover .project-card__content,
    .project-card:focus-visible .project-card__content {
        gap: 1.5rem;
    }

    .project-card__tags-track {
        overflow-x: auto;
        overflow-y: hidden;
        touch-action: pan-x;
        overscroll-behavior-x: contain;
        cursor: grab;
        pointer-events: auto;
    }

    .project-card__tags-track:active {
        cursor: grabbing;
    }
}

/* ========================================
   EMPTY STATE
======================================== */

.projects__empty {
    margin: 2rem 0 0;
    padding: 2rem 1rem;

    color: #B8B8B8;
    text-align: center;

    border: 1px solid #292929;
    border-radius: 0.6rem;
}

.projects__empty[hidden] {
    display: none;
}


/* ========================================
   TABLET
======================================== */

@media (min-width: 768px) and (max-width: 1023px) {
    .projects {
        padding-top: 0;
        padding-bottom: 5rem;
    }

    .project-card__title {
        font-size: 1.4rem;
    }

    .project-card__description {
        font-size: .95rem;
    }

    .project-card__tag-position {
        font-size: .90rem;
    }

    .projects__list {
        gap: 1rem;
        margin-top: 1.35rem;
    }

    .project-card {
        min-height: 11rem;
        border-radius: 1rem;
    }

    .project-card__content {
        padding: 1rem;
        gap: 1rem;
    }

    .project-card__tags {
        flex-basis: 48%;
        max-width: 48%;
    }
}

/* ========================================
   MOBILE
======================================== */

@media (max-width: 767px) {
    .projects {
        margin-top: 8rem;
        padding-top: 0;
        padding-bottom: 4rem;
    }

    .projects__filter-status {
        font-size: 1rem;
    }

    .projects__header {
        align-items: flex-start;
        flex-direction: column;
        gap: 0;
    }

    .project-card__title {
        font-size: 1.15rem;
    }

    .project-card__description {
        font-size: .90rem;
        font-weight: 450;
    }

    .project-card__tag-position {
        font-size: 0.85rem;  
    }

    .projects__filter {
        margin-top: .75rem;
        margin-bottom: 2rem;
        align-self: flex-start;
    }

    .projects__filter-button {
        gap: 0.4rem;
        padding: 0.45rem 0.6rem;
    }

    .projects__filter-button .label-card {
        font-size: .95rem;
    }

    .projects__filter-menu {
        left: 0;
        right: auto;
        min-width: 9.5rem;
    }

    .projects__list {
        gap: 1rem;
        margin-top: 1.25rem;
    }

    .project-card {
        aspect-ratio: 380 / 175;
        min-height: 9rem;
        border-radius: 0.75rem;

        transition: min-height 220ms ease;
    }

    .project-card__content {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        justify-content: flex-end;
        gap: 0;
        padding: 0.35rem .9rem;
    }

    .project-card__text {
        width: 100%;
        flex: 0 0 auto;
    }

    /* Inactive cards remain compact. */
    .project-card__tags {
        margin-top: 0.25rem !important;
        display: flex;
        width: 100%;
        max-width: 100%;
        flex: 0 0 auto;
        margin-top: 0;
        max-height: 0;
        overflow: hidden;
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
        transform: translateY(0.25rem);
        transition:
            max-height 220ms ease,
            margin-top 220ms ease,
            opacity 220ms ease,
            transform 220ms ease,
            visibility 220ms ease;
    }

        .projects__filter-icon {
        width: 1.2rem;
        height: 1.2rem;
        margin-right: .15rem;
    }

    .projects__filter-icon {
        transform: translateY(0.05rem);
    }

    .project-card__tags-track {
        padding-block: 0.15rem 0.3rem;
    }

    /* ========================================
    MOBILE ACTIVE PROJECT CARD
    Preserve the original card dimensions
    ======================================== */

    .project-card.is-active {
        aspect-ratio: 380 / 175;
        min-height: 9rem;
    }

    .project-card.is-active .project-card__content {
        position: absolute;
        right: 0;
        bottom: 0;
        left: 0;

        inset: auto 0 0;

        min-height: 0;
    }

    /* Reveal tags without changing the card height */
    .project-card.is-active .project-card__tags {
        flex-basis: auto;
        max-height: 4rem;

        margin-top: 0.85rem;

        opacity: 1;
        visibility: visible;
        pointer-events: auto;

        transform: translateY(0);
    }

}


/* ========================================
   REDUCED MOTION
======================================== */

@media (prefers-reduced-motion: reduce) {
    .project-card__image,
    .project-card__tags,
    .projects__filter-button,
    .projects__filter-option {
        transition: none;
    }
}