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

.card--project {
    position: relative;
    z-index: 10;
    transition: all 0.3s ease;
    overflow: visible;
    cursor: pointer;
}

/* Allow layers to overflow the image container */
.card--project .card__image {
    overflow: visible;
    background: transparent;
}

.project-media-track {
    position: relative;
    width: 100%;
    overflow: visible;
}

.card--project .project-media-track > .project-main-media {
    position: relative;
    z-index: 2;
    border-radius: var(--card-image-radius);
    width: 100%;
    aspect-ratio: 1 / 1.2;
    object-fit: cover;
    background: var(--bg-card-image);
    overflow: hidden;
    will-change: transform;
}

.card--wide .project-media-track > .project-main-media {
    aspect-ratio: 16 / 9;
}

.project-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    border-radius: var(--radius-lg);
    z-index: 1;
    opacity: 1;
    transform: none;
    pointer-events: none;
    overflow: hidden;
    background: var(--bg-card-image);
    aspect-ratio: 1 / 1.2;
    will-change: transform;
}

.card--wide .project-layer {
    aspect-ratio: 16 / 9;
}

.project-layer img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}


body.is-project-expanded {
    background-color: var(--bg-page);
}

body.is-project-expanded .card-grid > .card:not(.is-active),
body.is-project-expanded .sidebar,
body.is-project-expanded .theme-toggle {
    opacity: 0 !important;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.3s ease, visibility 0s 0.3s;
}

.card--project.is-active {
    z-index: 1000 !important;
    cursor: default;
    overflow: visible !important;
}

.card--project.is-active .card__content {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

body.is-project-expanded .card--project.is-active .project-layer {
    opacity: 1;
    left: calc(var(--layer-offset-index) * (100% + var(--project-layer-gap, 40px)));
    transform: translate(0, 0) scale(1);
    width: calc(var(--layer-width-mult) * 100% + (var(--layer-width-mult) - 1) * var(--project-layer-gap, 40px));
    z-index: 1;
}

body.is-project-expanded .card--project.is-active .project-main-media {
    transform: translate(0, 0) rotate(0deg) scale(1);
}

.card--project.is-closing .project-layer {
    transition: transform 0.8s cubic-bezier(0.16, 1, 0.3, 1),
        left 0.8s cubic-bezier(0.16, 1, 0.3, 1),
        opacity 0s 0.8s;
}

.close-button {
    position: fixed;
    top: 12px;
    right: 12px;
    z-index: 200;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    background: transparent;
    border: none;
    border-radius: 0;
    padding: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-primary);
    width: 40px;
    height: 40px;
}

body.is-project-expanded .close-button {
    opacity: 1;
    pointer-events: auto;
    transition: opacity 0.3s ease 0.3s;
}

@media (max-width: 768px) {
    .card--project {
        --project-layer-gap: 16px;
    }

    .project-layer {
        display: none;
    }

    .card--project .project-media-track {
        display: flex;
        overflow-x: auto;
        scroll-snap-type: x mandatory;
        gap: var(--project-layer-gap, 16px);
        padding-right: 0;
        margin: 0;
        padding-left: 0;
        width: 100%;
        scrollbar-width: none;
        align-items: center;
        background: transparent !important;
        aspect-ratio: auto !important;
        height: auto !important;
        z-index: 20;
    }

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

    .card--project .project-media-track > * {
        flex-shrink: 0;
        width: 100% !important;
        height: auto !important;
        position: relative !important;
        top: auto !important;
        left: auto !important;
        scroll-snap-align: center;
        border-radius: var(--radius-lg);
        opacity: 1 !important;
        object-fit: cover;
        transform: none !important;
        z-index: auto !important;
    }

    .card--project:not(.card--wide) .project-media-track > * {
        aspect-ratio: 1 / 1.236 !important;
        max-height: 450px;
    }

    .card--project.card--wide .project-media-track > * {
        aspect-ratio: 16 / 9 !important;
    }
}
