/* =====================================================================
   Projets avant / après — page publique + comparateur à curseur.
   Style NEUTRE et SURCHARGEABLE (variables --pj-*). Le comparateur
   (.ba-compare) est autonome et réutilisable n'importe où.
   ===================================================================== */

.projs,
.proj-detail {
    --pj-accent: #111827;
    --pj-text: #1f2433;
    --pj-muted: #6b7280;
    --pj-card-bg: #ffffff;
    --pj-shadow: 0 10px 30px rgba(20, 28, 55, .10);
    --pj-radius: 16px;
    --pj-gap: 24px;
    color: var(--pj-text);
    max-width: 1120px;
    margin: 0 auto;
    padding: 0 16px;
}

/* En-tete */
.projs-head,
.proj-detail-head {
    text-align: center;
    margin: 0 0 28px;
}

.projs-title,
.proj-detail-title {
    margin: 0 0 8px;
    font-size: clamp(26px, 4vw, 40px);
    line-height: 1.15;
}

.projs-desc {
    margin: 0;
    color: var(--pj-muted);
    font-size: 17px;
}

/* Filtres par categorie */
.projs-filters {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin: 0 0 28px;
}

.projs-filter {
    border: 0;
    cursor: pointer;
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    color: var(--pj-muted);
    background: rgba(17, 24, 39, .06);
    padding: 9px 18px;
    border-radius: 999px;
    transition: background .18s ease, color .18s ease;
}

.projs-filter:hover {
    color: var(--pj-text);
}

.projs-filter.is-active {
    background: var(--pj-accent);
    color: #fff;
}

/* Grille de projets */
.projs-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
    gap: var(--pj-gap);
}

.proj-card {
    background: var(--pj-card-bg);
    border-radius: var(--pj-radius);
    overflow: hidden;
    box-shadow: var(--pj-shadow);
    display: flex;
    flex-direction: column;
}

.proj-body {
    padding: 16px 18px 18px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.proj-cat {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--pj-accent);
}

.proj-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--pj-text);
    text-decoration: none;
}

.proj-title:hover {
    text-decoration: none;
}

.projs-empty,
.projs-empty-filter {
    text-align: center;
    color: var(--pj-muted);
    padding: 40px 0;
}

/* Page detail */
.proj-detail-media {
    margin: 0 auto 28px;
    max-width: 900px;
}

.proj-detail-body {
    max-width: 760px;
    margin: 0 auto;
    font-size: 17px;
    line-height: 1.7;
}

.proj-detail-body img {
    max-width: 100%;
    height: auto;
    border-radius: 10px;
}

.proj-back {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 32px auto 0;
    color: var(--pj-accent);
    font-weight: 600;
    text-decoration: none;
    justify-content: center;
}

.proj-back svg {
    width: 18px;
    height: 18px;
}

.proj-back:hover {
    text-decoration: none;
}

/* neutralise le soulignement global au survol */
.proj-detail {
    text-align: center;
}

.proj-detail-body {
    text-align: left;
}

/* =========================== Comparateur avant/après =================== */
.ba-compare {
    --ba: 50%;
    position: relative;
    overflow: hidden;
    border-radius: var(--pj-radius, 14px);
    background: #e9ecf2;
    touch-action: none;
    /* le drag ne fait pas defiler la page */
    user-select: none;
    line-height: 0;
}

.ba-compare--card {
    border-radius: 0;
}

/* dans une carte : coins gérés par la carte */
/* Le moteur peut envelopper les <img> dans un <picture> (WebP responsive) :
   display:contents fait disparaitre ce wrapper de la mise en page, les images
   se comportent alors comme des enfants directs de .ba-compare. */
.ba-compare picture,
.ba-single picture {
    display: contents;
}

.ba-after {
    display: block;
    width: 100%;
    height: auto;
}

.ba-before {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    /* on masque la partie droite : ne reste visible que --ba depuis la gauche */
    clip-path: inset(0 calc(100% - var(--ba)) 0 0);
    -webkit-clip-path: inset(0 calc(100% - var(--ba)) 0 0);
}

/* Etiquettes Avant / Après */
.ba-label {
    position: absolute;
    top: 12px;
    z-index: 3;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .03em;
    color: #fff;
    background: rgba(17, 24, 39, .62);
    padding: 5px 11px;
    border-radius: 999px;
    line-height: 1;
    pointer-events: none;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.ba-label-before {
    left: 12px;
}

.ba-label-after {
    right: 12px;
}

/* Poignee + ligne de separation */
.ba-handle {
    position: absolute;
    top: 0;
    bottom: 0;
    left: var(--ba);
    z-index: 4;
    width: 2px;
    background: rgba(255, 255, 255, .9);
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.ba-handle svg {
    width: 18px;
    height: 18px;
    color: #1f2433;
    background: #fff;
    border-radius: 999px;
    padding: 7px;
    box-sizing: content-box;
    box-shadow: 0 2px 10px rgba(0, 0, 0, .25);
}

/* Le range reste pour le CLAVIER (focus + fleches). Au pointeur (souris/tactile),
   c'est le JS qui pilote le glissement sur tout le cadre : on neutralise donc le
   range au pointeur (pointer-events:none) pour ne pas lui voler le geste tactile. */
.ba-range {
    position: absolute;
    inset: 0;
    z-index: 5;
    width: 100%;
    height: 100%;
    margin: 0;
    opacity: 0;
    pointer-events: none;
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
}

.ba-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 44px;
    height: 100%;
}

.ba-range::-moz-range-thumb {
    width: 44px;
    height: 100%;
    border: 0;
    background: transparent;
}

.ba-range:focus-visible {
    outline: none;
}

.ba-compare {
    cursor: ew-resize;
}

.ba-compare:focus-within .ba-handle svg {
    box-shadow: 0 0 0 3px rgba(17, 24, 39, .35);
}

/* Image seule (un seul visuel fourni) */
.ba-single img {
    display: block;
    width: 100%;
    height: auto;
    border-radius: var(--pj-radius, 14px);
}

/* =========================== Apparition au défilement ================== */
[data-reveal] {
    opacity: 0;
    transform: translateY(14px);
    transition: opacity .5s ease, transform .5s cubic-bezier(.16, 1, .3, 1);
}

[data-reveal].is-in {
    opacity: 1;
    transform: none;
}

.proj-card[data-reveal] {
    transition-delay: calc(var(--i, 0) * 60ms);
}

@media (prefers-reduced-motion: reduce) {
    [data-reveal] {
        opacity: 1;
        transform: none;
        transition: none;
    }
}

/* =========================== Mobile ==================================== */
@media (max-width: 600px) {

    /* main fournit deja le padding lateral : on retire celui du conteneur pour eviter le double. */
    .projs,
    .proj-detail {
        padding-left: 0;
        padding-right: 0;
    }

    .projs-grid {
        grid-template-columns: 1fr;
        --pj-gap: 18px;
    }

    .projs-desc {
        font-size: 15px;
    }

    .ba-label {
        top: 8px;
        font-size: 11px;
        padding: 4px 9px;
    }
}