/* ==========================================================
   PROJETS
========================================================== */

.projects-section {
    overflow: visible;
}


/* ==========================================================
   FILTRES
========================================================== */

.projects-filters {
    max-width: 920px;
    margin: 0 auto 40px;

    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
}

.filter-button {
    min-height: 46px;
    padding: 8px 16px;

    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;

    color: var(--color-text);
    background: var(--color-surface);

    border: 1px solid var(--color-white);
    border-radius: var(--radius-pill);

    cursor: pointer;

    font-family: var(--font-title);
    font-size: 0.84rem;
    font-weight: 700;

    box-shadow: 0 12px 30px rgba(31, 31, 31, 0.07);

    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);

    transition:
        transform 0.2s ease,
        background-color 0.2s ease,
        color 0.2s ease,
        box-shadow 0.2s ease;
}

.filter-button:hover,
.filter-button.active {
    color: var(--color-white);
    background: var(--color-primary);

    box-shadow: 0 16px 34px rgba(59, 167, 166, 0.26);

    transform: translateY(-2px);
}

.filter-button img {
    width: 24px;
    height: 24px;

    object-fit: contain;
}

.filter-button:hover img,
.filter-button.active img {
    filter: brightness(0) invert(1);
}


/* ==========================================================
   CARROUSEL
========================================================== */

.projects-carousel {
    width: 100%;
    max-width: 1440px;
    margin: 0 auto;
}

.projects-viewport {
    width: 100%;
    padding-bottom: 12px;

    overflow-x: auto;
    overflow-y: hidden;

    scroll-behavior: smooth;
    scroll-snap-type: x mandatory;
    scroll-padding-inline: 0;

    overscroll-behavior-x: contain;
    overscroll-behavior-y: auto;

    touch-action: pan-x pan-y;

    -webkit-overflow-scrolling: touch;

    scrollbar-width: thin;
    scrollbar-color:
        var(--color-primary)
        rgba(255, 255, 255, 0.45);
}

.projects-viewport::-webkit-scrollbar {
    height: 7px;
}

.projects-viewport::-webkit-scrollbar-track {
    margin-inline: 12px;

    background: rgba(255, 255, 255, 0.45);
    border-radius: var(--radius-pill);
}

.projects-viewport::-webkit-scrollbar-thumb {
    background: var(--color-primary);
    border-radius: var(--radius-pill);
}

.projects-track {
    width: 100%;
}


/*
 * Affichage de secours si JavaScript est désactivé.
 */

.projects-track:not(.is-ready) {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 18px;
}


/*
 * Le JavaScript construit des pages contenant
 * 8, 4 ou 1 projet.
 */

.projects-track.is-ready {
    width: 100%;

    display: flex;
    align-items: stretch;
    gap: 0;
}

.projects-page {
    flex: 0 0 100%;

    width: 100%;
    min-width: 100%;
    min-height: 698px;

    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    grid-auto-rows: minmax(340px, auto);
    align-content: start;
    gap: 18px;

    scroll-snap-align: start;
    scroll-snap-stop: always;
}


/* ==========================================================
   CONTRÔLES DU CARROUSEL
========================================================== */

.projects-carousel-controls {
    margin-top: 22px;

    display: flex;
    align-items: center;
    justify-content: center;
    gap: 18px;
}

.projects-carousel-controls[hidden] {
    display: none;
}

.projects-carousel-button {
    width: 48px;
    height: 48px;
    padding: 0;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    color: var(--color-text);
    background: rgba(255, 255, 255, 0.8);

    border: 1px solid rgba(255, 255, 255, 0.95);
    border-radius: 50%;

    cursor: pointer;

    box-shadow: 0 14px 32px rgba(31, 31, 31, 0.1);

    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);

    transition:
        color 0.2s ease,
        background-color 0.2s ease,
        opacity 0.2s ease,
        transform 0.2s ease;
}

.projects-carousel-button:hover:not(:disabled) {
    color: var(--color-white);
    background: var(--color-primary);

    transform: translateY(-2px);
}

.projects-carousel-button:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.projects-carousel-button svg {
    width: 22px;
    height: 22px;

    fill: none;
    stroke: currentColor;
    stroke-width: 2.4;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.projects-carousel-dots {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
}

.projects-carousel-dot {
    width: 10px;
    height: 10px;
    padding: 0;

    background: rgba(31, 31, 31, 0.2);

    border: none;
    border-radius: var(--radius-pill);

    cursor: pointer;

    transition:
        width 0.25s ease,
        background-color 0.25s ease,
        transform 0.25s ease;
}

.projects-carousel-dot:hover {
    background: var(--color-primary-light);

    transform: scale(1.15);
}

.projects-carousel-dot.active {
    width: 28px;

    background: var(--color-primary);
}

.projects-carousel-status {
    margin-top: 12px;

    color: var(--color-text-soft);

    font-size: 0.78rem;
    text-align: center;
}

.projects-empty {
    padding: 40px 20px;

    color: var(--color-text-soft);

    font-size: 1rem;
    text-align: center;
}


/* ==========================================================
   CARTE PROJET
========================================================== */

.project-card {
    position: relative;

    width: 100%;
    height: 100%;
    min-height: 340px;

    overflow: hidden;

    background: var(--color-surface);

    border: 1px solid var(--color-white);
    border-radius: 24px;

    box-shadow: var(--shadow-soft);

    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);

    isolation: isolate;

    touch-action: pan-x pan-y;

    transition:
        transform 0.25s ease,
        box-shadow 0.25s ease;
}

.project-card:hover {
    box-shadow: var(--shadow-medium);

    transform: translateY(-5px);
}

.project-image-wrapper {
    position: absolute;
    inset: 0;
    z-index: 1;
}

.project-img {
    display: block;

    width: 100%;
    height: 100%;

    object-fit: cover;

    transition:
        transform 0.45s ease,
        filter 0.45s ease;
}

.project-card:hover .project-img {
    filter: saturate(1.04) contrast(0.96);

    transform: scale(1.06);
}


/* ==========================================================
   ZONE DE ZOOM
========================================================== */

.project-zoom-area {
    position: absolute;
    inset: 0;
    z-index: 3;

    width: 100%;
    height: 100%;

    background: transparent;

    border: none;

    cursor: zoom-in;

    touch-action: pan-x pan-y;
}


/* ==========================================================
   LIEN DU PROJET
========================================================== */

.project-open-link {
    position: absolute;
    top: 14px;
    right: 14px;
    z-index: 6;

    width: 40px;
    height: 40px;

    display: flex;
    align-items: center;
    justify-content: center;

    color: var(--color-primary-dark);
    background: var(--color-white);

    border: 1px solid var(--color-white);
    border-radius: var(--radius-pill);

    box-shadow: 0 12px 28px rgba(31, 31, 31, 0.12);

    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);

    transition:
        transform 0.2s ease,
        color 0.2s ease,
        background-color 0.2s ease;
}

.project-open-link:hover {
    color: var(--color-white);
    background: var(--color-primary);

    transform: translateY(-2px);
}

.project-open-link.is-disabled {
    opacity: 0.45;

    cursor: not-allowed;
}

.project-open-link.is-disabled:hover {
    color: var(--color-primary-dark);
    background: var(--color-white);

    transform: none;
}

.project-open-link svg {
    width: 20px;
    height: 20px;

    fill: none;
    stroke: currentColor;
    stroke-width: 2.4;
    stroke-linecap: round;
    stroke-linejoin: round;
}


/* ==========================================================
   OVERLAY
========================================================== */

.project-overlay {
    position: absolute;
    left: 14px;
    right: 14px;
    bottom: 14px;
    z-index: 4;

    max-height: calc(100% - 28px);
    padding: 16px;

    display: flex;
    flex-direction: column;

    color: var(--color-text);
    background: rgba(255, 255, 255, 0.88);

    border: 1px solid var(--color-white);
    border-radius: 18px;

    box-shadow: 0 14px 34px rgba(31, 31, 31, 0.12);

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

    overflow: hidden;

    pointer-events: auto;

    touch-action: pan-x pan-y;
}

.project-heading {
    flex: 0 0 auto;

    transform: translateY(0);

    transition:
        transform 0.3s ease;
}

.project-card:hover .project-heading,
.project-card:focus-within .project-heading {
    transform: translateY(-4px);
}


/* ==========================================================
   TYPE DU PROJET
========================================================== */

.project-type {
    width: fit-content;
    margin-bottom: 8px;
    padding: 5px 9px;

    display: inline-flex;

    color: var(--color-white);
    background: var(--color-primary);

    border-radius: var(--radius-pill);

    font-size: 0.66rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.project-overlay h3 {
    color: var(--color-text);

    font-size: clamp(1.05rem, 1.4vw, 1.25rem);
    line-height: 1.15;
    letter-spacing: -0.03em;
}


/* ==========================================================
   DÉTAILS SCROLLABLES
========================================================== */

.project-details {
    min-height: 0;
    max-height: 0;

    opacity: 0;

    overflow: hidden;

    transform: translateY(12px);

    transition:
        max-height 0.4s ease,
        opacity 0.25s ease,
        transform 0.35s ease;
}

.project-card:hover .project-details,
.project-card:focus-within .project-details {
    max-height: 220px;

    opacity: 1;

    overflow-x: hidden;
    overflow-y: auto;

    overscroll-behavior-x: auto;
    overscroll-behavior-y: auto;

    touch-action: pan-x pan-y;

    transform: translateY(0);

    scrollbar-width: thin;
    scrollbar-color:
        var(--color-primary)
        rgba(255, 255, 255, 0.45);
}

.project-details::-webkit-scrollbar {
    width: 5px;
}

.project-details::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.45);

    border-radius: var(--radius-pill);
}

.project-details::-webkit-scrollbar-thumb {
    background: var(--color-primary);

    border-radius: var(--radius-pill);
}

.project-details p {
    margin: 12px 0 14px;

    color: var(--color-text-soft);

    font-size: 0.86rem;
    line-height: 1.55;
}


/* ==========================================================
   TECHNOLOGIES
========================================================== */

.technologies-list {
    margin: 0;
    padding: 0;

    display: flex;
    flex-wrap: wrap;
    gap: 7px;

    list-style: none;
}

.technologies-list li {
    padding: 6px 9px;

    display: inline-flex;
    align-items: center;
    gap: 6px;

    color: var(--color-primary-dark);
    background: rgba(155, 216, 198, 0.22);

    border: 1px solid rgba(155, 216, 198, 0.34);
    border-radius: var(--radius-pill);

    font-size: 0.68rem;
    font-weight: 700;
}

.techno-img {
    width: 16px;
    height: 16px;

    object-fit: contain;
}


/* ==========================================================
   LIGHTBOX
========================================================== */

.project-lightbox {
    position: fixed;
    inset: 0;

    width: min(1100px, calc(100vw - 32px));
    max-width: calc(100vw - 32px);
    max-height: calc(100vh - 32px);

    margin: auto;
    padding: 0;

    overflow: visible;

    background: transparent;

    border: none;
}

.project-lightbox[open] {
    display: flex;
    align-items: center;
    justify-content: center;
}

.project-lightbox::backdrop {
    background: rgba(31, 31, 31, 0.78);

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

.project-lightbox img {
    display: block;

    width: auto;
    max-width: 100%;
    max-height: calc(100vh - 32px);

    object-fit: contain;

    border-radius: 24px;

    box-shadow: 0 30px 90px rgba(0, 0, 0, 0.35);
}

.project-lightbox-close {
    position: absolute;
    top: -18px;
    right: -18px;
    z-index: 2;

    width: 44px;
    height: 44px;

    display: flex;
    align-items: center;
    justify-content: center;

    color: var(--color-text);
    background: var(--color-white);

    border: none;
    border-radius: var(--radius-pill);

    cursor: pointer;

    font-size: 2rem;
    line-height: 1;

    box-shadow: 0 14px 34px rgba(31, 31, 31, 0.25);
}


/* ==========================================================
   TABLETTE — 4 PROJETS PAR PAGE
========================================================== */

@media screen and (max-width: 1024px) {

    .projects-track:not(.is-ready) {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 14px;
    }

    .projects-page {
        min-height: 614px;

        grid-template-columns: repeat(2, minmax(0, 1fr));
        grid-auto-rows: minmax(300px, auto);
        gap: 14px;
    }

    .project-card {
        min-height: 300px;

        border-radius: 22px;
    }

    .project-overlay {
        left: 10px;
        right: 10px;
        bottom: 10px;

        max-height: calc(100% - 20px);
        padding: 13px;

        border-radius: 16px;
    }

    .project-type {
        font-size: 0.6rem;
    }

    .project-overlay h3 {
        font-size: 1rem;
    }

    .project-details p {
        font-size: 0.78rem;
    }

    .technologies-list li {
        padding: 5px 8px;

        font-size: 0.64rem;
    }

    .techno-img {
        width: 14px;
        height: 14px;
    }

    .project-open-link {
        top: 10px;
        right: 10px;

        width: 36px;
        height: 36px;
    }

    .project-open-link svg {
        width: 18px;
        height: 18px;
    }
}


/* ==========================================================
   MOBILE — 1 PROJET PAR PAGE
========================================================== */

@media screen and (max-width: 768px) {

    .projects-filters {
        margin-bottom: 32px;
        padding-bottom: 8px;

        flex-wrap: nowrap;
        justify-content: center;

        overflow-x: visible;
    }

    .filter-button {
        width: 52px;
        min-width: 52px;
        height: 52px;
        min-height: 52px;
        padding: 0;

        flex: 0 0 52px;

        gap: 0;

        border-radius: 50%;

        font-size: 0;
        line-height: 0;
    }

    .projects-filters .filter-button > span {
        display: none;
    }

    .filter-button img {
        width: 24px;
        height: 24px;
        margin: 0;
    }

    .projects-carousel {
        width: 100%;
    }

    .projects-track:not(.is-ready) {
        grid-template-columns: 1fr;
        gap: 0;
    }

    .projects-page {
        min-height: 430px;

        grid-template-columns: 1fr;
        grid-auto-rows: minmax(430px, auto);
        gap: 0;
    }

    .project-card {
        width: min(100%, 390px);
        min-height: 430px;
        margin: 0 auto;

        border-radius: 22px;

        transform: none;
    }

    .project-card:hover {
        transform: none;
    }

    .projects-carousel-controls {
        margin-top: 18px;
        gap: 14px;
    }

    .projects-carousel-button {
        width: 44px;
        height: 44px;
    }

    .project-overlay {
        left: 12px;
        right: 12px;
        bottom: 12px;

        max-height: calc(100% - 24px);
        padding: 16px;

        border-radius: 18px;
    }

    .project-heading,
    .project-card:hover .project-heading,
    .project-card:focus-within .project-heading {
        transform: none;
    }

    .project-details,
    .project-card:hover .project-details,
    .project-card:focus-within .project-details {
        min-height: 0;
        max-height: 220px;

        opacity: 1;

        overflow-x: hidden;
        overflow-y: auto;

        pointer-events: auto;

        overscroll-behavior-x: auto;
        overscroll-behavior-y: auto;

        touch-action: pan-x pan-y;

        transform: none;

        -webkit-overflow-scrolling: touch;

        scrollbar-width: thin;
        scrollbar-color:
            var(--color-primary)
            rgba(255, 255, 255, 0.45);
    }

    .project-details p {
        font-size: 0.9rem;
    }

    .project-open-link {
        top: 14px;
        right: 14px;

        width: 42px;
        height: 42px;
    }

    .project-lightbox-close {
        top: 10px;
        right: 10px;
    }

    .project-lightbox img {
        border-radius: 18px;
    }
}