/* ==========================================================
   KDM BAT — Page Réalisations : chantier phare (Canopia)
   À charger APRÈS css/styles.css
   ========================================================== */

.chantier-phare {
    display: grid;
    grid-template-columns: 1fr;
    background: var(--navy);
    box-shadow: 0 10px 30px rgba(27, 42, 59, 0.18);
    margin-bottom: 3rem;
    overflow: hidden;
}

@media (min-width: 768px) {
    .chantier-phare {
        margin-bottom: 4rem;
    }
}

/* ---------- Panneau texte ---------- */
.cp-info {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 1.5rem;
    padding: 1.5rem 1.25rem 1.25rem;
    color: #FFFFFF;
    border-top: 4px solid var(--red);
}

@media (min-width: 768px) {
    .cp-info {
        padding: 2rem;
    }
}

.cp-status {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.3rem 0.7rem;
    background: rgba(192, 57, 43, 0.15);
    border: 1px solid rgba(192, 57, 43, 0.6);
    font-family: 'Oswald', sans-serif;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #FFFFFF;
    margin-bottom: 1rem;
}

.cp-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #E74C3C;
    animation: cpPulse 2s ease-out infinite;
}

@keyframes cpPulse {
    0%   { box-shadow: 0 0 0 0 rgba(231, 76, 60, 0.6); }
    70%  { box-shadow: 0 0 0 8px rgba(231, 76, 60, 0); }
    100% { box-shadow: 0 0 0 0 rgba(231, 76, 60, 0); }
}

.cp-info h3 {
    font-family: 'Oswald', sans-serif;
    font-size: 2.5rem;
    font-weight: 700;
    line-height: 1;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: #FFFFFF;
    margin-bottom: 0.4rem;
}

@media (min-width: 768px) {
    .cp-info h3 {
        font-size: 3.25rem;
    }
}

.cp-city {
    font-family: 'Oswald', sans-serif;
    font-size: 0.85rem;
    font-weight: 500;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #E74C3C;
    margin-bottom: 1rem;
}

.cp-desc {
    font-size: 0.95rem;
    line-height: 1.65;
    color: var(--text-light);
}

.cp-facts {
    display: grid;
    grid-template-columns: 1fr 1fr;
    margin: 0 0 1.25rem;
    border-top: 1px solid rgba(255, 255, 255, 0.14);
}

.cp-facts div {
    padding: 0.8rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.14);
}

.cp-facts div:nth-child(odd) {
    padding-right: 0.75rem;
}

.cp-facts dt {
    font-family: 'Oswald', sans-serif;
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 0.15rem;
}

.cp-facts dd {
    margin: 0;
    font-size: 0.9rem;
    font-weight: 600;
    color: #FFFFFF;
    line-height: 1.35;
}

.cp-cta {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    width: 100%;
    padding: 0.9rem 1.25rem;
    background: var(--red);
    color: #FFFFFF;
    border: none;
    font-family: 'Oswald', sans-serif;
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    cursor: pointer;
    transition: background-color 0.18s ease;
}

.cp-cta span {
    transition: transform 0.18s ease;
}

.cp-cta:hover {
    background: #A93226;
}

.cp-cta:hover span {
    transform: translateX(4px);
}

.cp-cta:focus-visible {
    outline: 3px solid #FFFFFF;
    outline-offset: 3px;
}

/* ---------- Photos ---------- */
.chantier-photo {
    position: relative;
    margin: 0;
    overflow: hidden;
    background: #0F1A26;
}

.chantier-photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.35s ease;
}

.chantier-photo:hover img {
    transform: scale(1.05);
}

.chantier-photo::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(15, 26, 38, 0.75) 0%, rgba(15, 26, 38, 0) 40%);
    pointer-events: none;
}

.chantier-photo figcaption {
    position: absolute;
    left: 0.75rem;
    right: 0.75rem;
    bottom: 0.7rem;
    z-index: 1;
    font-family: 'Oswald', sans-serif;
    font-size: 0.8rem;
    font-weight: 500;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #FFFFFF;
    pointer-events: none;
}

.chantier-photo figcaption::before {
    content: "";
    display: block;
    width: 1.5rem;
    height: 3px;
    background: var(--red);
    margin-bottom: 0.35rem;
}

.cp-main figcaption {
    font-size: 0.95rem;
}

.chantier-photo.is-zoomable {
    cursor: zoom-in;
}

.chantier-photo.is-zoomable:focus-visible {
    outline: 3px solid var(--red);
    outline-offset: -3px;
}

/* Téléphone : photos qui défilent au doigt */
.cp-gallery {
    display: flex;
    gap: 0.6rem;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-padding: 0 1.25rem;
    padding: 0 1.25rem;
    margin-top: 0.25rem;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}

.cp-gallery::-webkit-scrollbar {
    display: none;
}

.cp-gallery .chantier-photo {
    flex: 0 0 82%;
    aspect-ratio: 4 / 5;
    scroll-snap-align: start;
}

.cp-dots {
    display: flex;
    justify-content: center;
    gap: 0.4rem;
    padding: 1rem 0 1.25rem;
}

.cp-dots span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transition: background-color 0.2s ease, width 0.2s ease;
}

.cp-dots span.is-active {
    width: 22px;
    border-radius: 4px;
    background: var(--red);
}

/* Tablette : mosaïque sous le texte */
@media (min-width: 640px) {
    .cp-gallery {
        display: grid;
        grid-template-columns: 2fr 1fr 1fr;
        grid-template-rows: 1fr 1fr;
        height: 460px;
        gap: 4px;
        overflow: visible;
        padding: 0;
        margin: 0;
    }

    .cp-gallery .chantier-photo {
        aspect-ratio: auto;
    }

    .cp-main {
        grid-row: 1 / 3;
    }

    .cp-dots {
        display: none;
    }
}

/* Ordinateur : texte à gauche, mosaïque à droite */
@media (min-width: 1024px) {
    .chantier-phare {
        grid-template-columns: minmax(340px, 5fr) 8fr;
    }

    .cp-info {
        border-top: none;
        border-left: 4px solid var(--red);
        padding: 2.5rem 2.25rem;
    }

    .cp-gallery {
        height: 100%;
        min-height: 540px;
    }
}

/* ---------- Sous-titre « Autres réalisations » ---------- */
.section-subhead {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.section-subhead h3 {
    font-family: 'Oswald', sans-serif;
    font-size: 1.25rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--navy);
}

@media (min-width: 768px) {
    .section-subhead {
        margin-bottom: 1.75rem;
    }
    .section-subhead h3 {
        font-size: 1.5rem;
    }
}

/* ==========================================================
   Chantiers CREPS de Poitiers & Groupe scolaire des Bénédictins
   ========================================================== */

/* Badge « Chantier terminé » */
.cp-status--done {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.45);
}

.cp-check {
    display: inline-grid;
    place-items: center;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #FFFFFF;
    color: var(--navy);
    font-size: 0.6rem;
    line-height: 1;
}

/* Titres sur plusieurs lignes : place pour les accents (É) */
.cp-info h3 { line-height: 1.1; }

@media (min-width: 1024px) {
    .cp-info h3.cp-title-long { font-size: 2.75rem; }
}

@media (max-width: 639px) {
    .ba-tag small { display: none; }
    .ba-note { font-size: 0.7rem; padding-top: 1.2rem; }
}

.cp-facts dd.cp-done { color: #FFFFFF; }
.cp-facts dd.cp-todo { color: #E74C3C; }

/* Galerie à 2 photos (CREPS) */
@media (min-width: 640px) {
    .cp-gallery--duo {
        grid-template-columns: 1fr 1fr;
        grid-template-rows: 1fr;
    }
}

/* Colonne photos du chantier Bénédictins : avant/après + 3 photos */
.cp-media {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.cp-gallery--row {
    margin-top: 0.6rem;
}

@media (min-width: 640px) {
    .cp-gallery--row {
        grid-template-columns: repeat(3, 1fr);
        grid-template-rows: 1fr;
        height: 240px;
        margin-top: 4px;
    }
}

@media (min-width: 1024px) {
    .cp-gallery--row {
        flex: 1 1 auto;
        height: auto;
        min-height: 220px;
    }
}

/* Une seule photo sous l'avant/après (vue intérieure) */
.cp-gallery.cp-gallery--single {
    display: block;
    height: auto;
    min-height: 0;
    padding: 0;
    margin: 4px 0 0;
    overflow: hidden;
}

.cp-gallery--single .chantier-photo {
    width: 100%;
    aspect-ratio: 16 / 9;
}

/* ---------- Avant / Après ---------- */
.ba {
    --pos: 50%;
    position: relative;
    margin: 0;
    aspect-ratio: 3 / 2;
    overflow: hidden;
    background: #0F1A26;
    user-select: none;
    -webkit-user-select: none;
    touch-action: pan-y;
    cursor: ew-resize;
}

@media (min-width: 640px) {
    .ba { aspect-ratio: 16 / 7; }
}

@media (min-width: 1024px) {
    .ba { aspect-ratio: 1600 / 680; }
}

.ba-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    pointer-events: none;
    -webkit-user-drag: none;
}

.ba-before {
    position: absolute;
    inset: 0;
    clip-path: inset(0 calc(100% - var(--pos)) 0 0);
}

/* Étiquettes */
.ba-tag {
    position: absolute;
    top: 0.75rem;
    z-index: 2;
    display: flex;
    flex-direction: column;
    padding: 0.35rem 0.6rem;
    font-family: 'Oswald', sans-serif;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    line-height: 1.2;
    color: #FFFFFF;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.ba-tag small {
    font-family: 'Open Sans', sans-serif;
    font-size: 0.62rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    text-transform: none;
    opacity: 0.85;
}

.ba-tag--before {
    left: 0.75rem;
    background: rgba(15, 26, 38, 0.82);
}

.ba-tag--after {
    right: 0.75rem;
    text-align: right;
    background: var(--red);
}

.ba.hide-before .ba-tag--before,
.ba.hide-after .ba-tag--after {
    opacity: 0;
}

/* Barre + poignée */
.ba-handle {
    position: absolute;
    top: 0;
    bottom: 0;
    left: var(--pos);
    z-index: 3;
    width: 3px;
    margin-left: -1.5px;
    background: #FFFFFF;
    box-shadow: 0 0 12px rgba(0, 0, 0, 0.35);
    pointer-events: none;
}

.ba-knob {
    position: absolute;
    top: 50%;
    left: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    width: 46px;
    height: 46px;
    margin: -23px 0 0 -23px;
    border-radius: 50%;
    background: var(--red);
    border: 3px solid #FFFFFF;
    color: #FFFFFF;
    font-size: 1.15rem;
    font-weight: 700;
    line-height: 1;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
    transition: transform 0.18s ease;
}

.ba.is-hint .ba-knob {
    animation: baPulse 1.8s ease-out infinite;
}

.ba.is-dragging .ba-knob {
    transform: scale(1.1);
}

@keyframes baPulse {
    0%   { box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.7), 0 4px 14px rgba(0, 0, 0, 0.35); }
    70%  { box-shadow: 0 0 0 14px rgba(255, 255, 255, 0), 0 4px 14px rgba(0, 0, 0, 0.35); }
    100% { box-shadow: 0 0 0 0 rgba(255, 255, 255, 0), 0 4px 14px rgba(0, 0, 0, 0.35); }
}

/* Curseur invisible : sert au clavier et aux lecteurs d'écran */
.ba-range {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.ba:has(.ba-range:focus-visible) {
    outline: 3px solid #FFFFFF;
    outline-offset: -3px;
}

.ba-note {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2;
    padding: 1.6rem 0.9rem 0.65rem;
    background: linear-gradient(to top, rgba(15, 26, 38, 0.85), rgba(15, 26, 38, 0));
    font-size: 0.75rem;
    line-height: 1.45;
    color: #FFFFFF;
    pointer-events: none;
}

@media (min-width: 768px) {
    .ba-tag { top: 1rem; font-size: 0.9rem; }
    .ba-tag--before { left: 1rem; }
    .ba-tag--after { right: 1rem; }
    .ba-tag small { font-size: 0.68rem; }
    .ba-note { font-size: 0.8rem; padding: 2rem 1.1rem 0.8rem; }
}

@media (prefers-reduced-motion: reduce) {
    .cp-dot { animation: none; }
    .chantier-photo img,
    .cp-cta span { transition: none; }
    .ba.is-hint .ba-knob { animation: none; }
}
