/* Specific styles for the BD (Illustrations) page */

/* Empêcher le débordement horizontal sur toute la page */
body {
    overflow-x: hidden;
}

.bd-project-container {
    max-width: 1434px;
    margin: 10px auto 100px;
    padding: 0 20px;
    display: flex;
    flex-direction: column;
    gap: 45px; /* Réduit pour remonter les sections */
    box-sizing: border-box;
    width: 100%;
}

/* ═══════════════════════════════════════════════════════════
   SECTION 1 — HERO ILLUSTRATIONS
   Logique responsive naturelle (même principe que .bd-selection-section) :
   full-bleed avec -50vw, dimensions en % + aspect-ratio
   Base Figma DESKTOP : 1510 × 893 px
   ═══════════════════════════════════════════════════════════ */

/* Full-bleed : même logique que .bd-selection-section */
.illustration-header {
    width: 100vw;
    position: relative;
    left: 50%;
    margin-left: -50vw;
    margin-right: -50vw;
    height: auto;
    overflow: visible;
    margin-bottom: 25px; /* Réduit pour remonter la sélection */
}

.illustration {
    width: 100%;
    position: relative;
}

/* hero-Illustration : occupe 100% de la largeur, hauteur proportionnelle (1510:893) */
.hover-illustration {
    position: relative;
    width: 100%;
    aspect-ratio: 1510 / 893;
    background: #FFFFFF;
    overflow: visible;
}

.illustrations-wrapper {
    position: absolute;
    width: 100%;
    height: 100%;
    left: 0;
    top: 0;
    overflow: hidden;
}

/* .illustrations : calque de référence aligné sur hover-illustration */
.illustrations {
    position: absolute;
    width: 100%;
    height: 100%;
    left: 0;
    top: 0;
}

/* ─── BD panels : positions en % calculées depuis Figma ─────────────────────
   Formules :
   left   = (illustrations.left + bd.left) / 1510  × 100
   top    = (illustrations.top  + bd.top)  / 893   × 100
   width  = bd.width / 1510 × 100
   aspect-ratio = bd.width / bd.height  (préserve les proportions sans px)
   ──────────────────────────────────────────────────────────────────────── */

/* BD1-1 : (80.09+51.5)/1510=8.72% — (-10-7)/893=-1.90% — w:669/1510=44.30% */
.bd1-1 {
    position: absolute;
    left: 8.72%;
    top: -1.90%;
    width: 44.30%;
    aspect-ratio: 669 / 485;
    background-image: url('../01-Illustrations/header/BD1.webp');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-color: #ffffff;
    border-radius: 6px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.04);
    transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.5s ease;
    overflow: hidden;
}

/* BD1-2 : (80.09-34.5)/1510=3.02% — (-10+467)/893=51.18% — w:617/1510=40.86% */
.bd1-2 {
    position: absolute;
    left: 3.02%;
    top: 51.18%;
    width: 40.86%;
    aspect-ratio: 617 / 442;
    background-image: url('../01-Illustrations/header/BD2.webp');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-color: #ffffff;
    border-radius: 6px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.04);
    transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.5s ease;
    overflow: hidden;
}

/* BD2-1 : (80.09+720.5)/1510=53.02% — (-10+0)/893=-1.12% — w:637/1510=42.18% */
.bd2-1 {
    position: absolute;
    left: 53.02%;
    top: -1.12%;
    width: 42.18%;
    aspect-ratio: 637 / 588;
    background-image: url('../01-Illustrations/header/BD3.webp');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-color: #ffffff;
    border-radius: 6px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.04);
    transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.5s ease;
    overflow: hidden;
}

/* BD2-2 : (80.09+775.5)/1510=56.66% — (-10+588)/893=64.73% — w:636/1510=42.12% */
.bd2-2 {
    position: absolute;
    left: 56.66%;
    top: 64.73%;
    width: 42.12%;
    aspect-ratio: 636 / 324;
    background-image: url('../01-Illustrations/header/BD4.webp');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-color: #ffffff;
    border-radius: 6px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.04);
    transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.5s ease;
    overflow: hidden;
}

.bd1-1:hover, .bd1-2:hover, .bd2-1:hover, .bd2-2:hover {
    transform: translateY(-8px);
    box-shadow: 0 20px 40px rgba(16, 16, 16, 0.12);
    z-index: 10;
}

/* Descriptif : left=547/1510=36.22% — top remonté à 50% — w=430/1510=28.48% → élargi à 34% */
.descriptif {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 25px 20px;
    gap: 10px;
    position: absolute;
    left: 36.22%;
    top: 50%;
    width: 34%;
    min-width: 280px;
    height: auto;
    z-index: 20;
    background: #FFFFFF;
    border: 1px solid #000000;
    box-sizing: border-box;
    cursor: pointer;
}

/* Texte : var(--font-body) = 16px desktop (override 14px mobile dans @media) */
.descriptif-text {
    width: 100%;
    height: auto;
    font-family: 'Source Code Pro', monospace;
    font-style: normal;
    font-weight: 400;
    font-size: 0.875rem; /* 14px */
    line-height: 1.4em;
    color: #000000;
    text-align: left;
}

.descriptif-text strong {
    font-size: 0.875rem; /* 14px */
    font-weight: 600;
}

/* Bouton flèche — flex child en bas du descriptif */
.bouton-tout-voir {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 22px;
    height: 13px;
    margin: 4px auto 0;
}

.fluent-ios-arrow-24-regular {
    width: 22px;
    height: 13px;
    transform: rotate(0deg);
    transition: transform 0.3s ease, filter 0.3s ease;
}

.fluent-ios-arrow-24-regular img {
    width: 22px;
    height: 13px;
    display: block;
}

.descriptif:hover .fluent-ios-arrow-24-regular {
    transform: translateY(4px);
    filter: invert(40%) sepia(0%) saturate(0%) brightness(80%);
}

.bd-selection-section {
    display: flex;
    flex-direction: column;
    gap: 15px; /* Reduced gap from 35px */
    width: 100vw;
    position: relative;
    left: 50%;
    right: 50%;
    margin-left: -50vw;
    margin-right: -50vw;
    background-image: url('../01-Illustrations/fond-sélection.webp'); /* Set background image */
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    padding: 60px 0 20px; /* Reduced bottom padding from 70px to 20px to offset the increased carousel bottom padding */
    overflow: hidden;
}

.bd-selection-section .bd-section-title {
    max-width: 1430px;
    margin: 0 auto;
    width: 100%;
    padding: 0 40px;
    color: #101010;
}

.bd-selection-carousel {
    display: flex;
    width: 100%;
    overflow-x: auto;
    position: relative;
    padding: 95px 0 110px; /* Increased bottom padding to 110px to accommodate hovered card shadow without vertical clipping */
    margin-top: -85px; /* Pull the carousel up to sit right under the title */
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}

.bd-selection-carousel::-webkit-scrollbar {
    display: none;
}

.bd-selection-track {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    width: max-content;
    margin: 0 auto;
    padding: 20px 250px; /* Increased left/right padding to 250px for more spacing at the ends of the selection */
}

.bd-selection-card {
    width: auto; /* Dynamically sizes to fit the image's aspect ratio */
    height: 550px; /* Enlarged from 450px */
    flex-shrink: 0;
    position: relative;
    border-radius: 0;
    background: transparent;
    border: none;
    box-shadow: none;
    padding: 0; /* Perfectly uniform white border frame on all sides */
    box-sizing: border-box; /* Explicit border-box layout */
    margin-left: -260px; /* Increased overlap for tighter cards */
    display: flex; /* Flex layout to reliably center the illustration inside the padding */
    justify-content: center;
    align-items: center;
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    cursor: pointer;
    z-index: 1;
}

.bd-selection-card:first-child {
    margin-left: 0;
}

.bd-selection-card img {
    height: 100%; /* Take up exact inner vertical height inside the padding */
    width: auto;  /* Width auto-adjusts based on aspect-ratio */
    object-fit: contain; /* Guarantee no cropping of any pixel */
    border: none; /* Inset outline for the art print */
    border-radius: 0;
    display: block;
    filter: drop-shadow(0 6px 15px rgba(16, 16, 16, 0.08));
    transition: filter 0.4s ease;
}

/* Sibling shift animation when hovering a card (spreads open the deck) */
.bd-selection-track:has(.bd-selection-card:hover) .bd-selection-card {
    transform: translateX(-300px); /* Shift wider to accommodate tighter cards */
}

.bd-selection-track:has(.bd-selection-card:hover) .bd-selection-card:hover {
    z-index: 10;
    transform: scale(1.2) translateY(-30px) translateX(0); /* Zoom and lift */
}

.bd-selection-track:has(.bd-selection-card:hover) .bd-selection-card:hover img {
    filter: drop-shadow(0 15px 30px rgba(16, 16, 16, 0.16));
}

.bd-selection-track:has(.bd-selection-card:hover) .bd-selection-card:hover ~ .bd-selection-card {
    transform: translateX(300px); /* Shift wider to accommodate tighter cards */
}

.bd-selection-caption {
    display: none !important;
}

/* SECTION 3 : LES AUTRES ILLUSTRATIONS */
.bd-others-section {
    display: flex;
    flex-direction: column;
    gap: 20px;
    width: 100%;
}

.bd-others-title {
    font-family: 'Source Code Pro', monospace;
    font-weight: 400;
    font-size: 16px;
    line-height: 20px;
    text-align: center;
    color: #101010;
    margin-bottom: 10px;
}

.bd-others-grid {
    display: flex;
    flex-direction: row;
    align-items: center;
    padding: 0;
    width: 100%;
    height: 650px;
    border-radius: 8px;
    overflow: hidden;
    gap: 0;
}

/* Cards for secondary illustrations */
.bd-other-card {
    position: relative;
    flex: 1;
    height: 650px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    cursor: pointer;
}

.bd-card-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    transition: transform 0.7s cubic-bezier(0.16, 1, 0.3, 1), filter 0.4s ease;
    z-index: 1;
}

.bd-other-card:hover .bd-card-bg {
    transform: scale(1.04);
    filter: brightness(0.9);
}

.bd-card-caption {
    position: absolute;
    top: 23px;
    right: 27px;
    font-family: 'Source Code Pro', monospace;
    font-weight: 400;
    font-size: 16px;
    line-height: 20px;
    color: #101010;
    z-index: 2;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid #101010;
    padding: 4px 10px;
    border-radius: 2px;
    transition: background 0.3s ease, color 0.3s ease;
}

.bd-other-card:hover .bd-card-caption {
    background: #101010;
    color: #FFFFFF;
}

/* Zoomer et remonter l'image Anatomie sur tous les formats pour masquer
   le texte "Anatomie" dessiné directement sur l'image de fond */
.bd-other-card[href="anatomie.html"] .bd-card-bg {
    transform: scale(1.48) translate(-10%, 6%);
    background-position: center top;
}
.bd-other-card[href="anatomie.html"]:hover .bd-card-bg {
    transform: scale(1.53) translate(-10%, 6%);
    filter: brightness(0.9);
}

/* RESPONSIVE DESIGN & ADAPTATIONS */
/* @media 1440px — supprimé : plus nécessaire avec le layout full-bleed % */

@media (max-width: 1280px) {
    .bd-others-grid {
        height: 550px;
    }
    .bd-other-card {
        height: 550px;
    }
}

@media (max-width: 1600px) {
    /* ── Section 2 : LA SÉLECTION — carrousel swipeable ──── */
    .bd-selection-section {
        width: 100vw !important;
        left: auto !important;
        right: auto !important;
        margin-left: -20px !important;
        margin-right: -20px !important;
        position: relative !important;
    }

    .bd-section-title {
        font-size: clamp(22px, 8.14vw, 36px) !important;
        line-height: clamp(28px, 10.18vw, 44px) !important;
        margin-bottom: 0 !important;
        text-align: center !important;
        width: 100% !important;
    }

    /* Carrousel : swipe horizontal fluide avec snap au centre */
    .bd-selection-carousel {
        overflow-x: scroll !important;
        overflow-y: hidden !important;
        -webkit-overflow-scrolling: touch !important;  /* momentum iOS */
        scroll-snap-type: x mandatory !important;
        padding: 5vw 0 8vw !important;
        margin-top: 0 !important;
        cursor: grab;
    }

    .bd-selection-carousel:active {
        cursor: grabbing;
    }

    /* Track : rangée linéaire avec padding suffisant pour snap center */
    .bd-selection-track {
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        justify-content: flex-start !important;
        width: max-content !important;
        padding: 2vw 50vw !important; /* Permet le snap center des éléments d'extrémité */
        gap: 3vw !important;          /* espacement entre les images */
        margin: 0 !important;
    }

    /* Cartes : taille fixe, scroll-snap sur chaque image au centre */
    .bd-selection-card {
        width: auto !important;
        height: clamp(280px, 75vw, 600px) !important;       /* Agrandies sur mobile pour être plus visibles */
        margin-left: 0 !important;     /* plus d'overlap */
        padding: 0 !important;
        flex-shrink: 0 !important;
        scroll-snap-align: center !important;
        background: transparent !important;
        border: none !important;
        box-shadow: none !important;
        transition: transform 0.3s ease !important;
    }

    /* Désactiver l'animation de "spread" desktop sur tactile */
    .bd-selection-track:has(.bd-selection-card:hover) .bd-selection-card {
        transform: none !important;
    }
    .bd-selection-track:has(.bd-selection-card:hover) .bd-selection-card:hover {
        transform: scale(1.04) !important;
    }
    .bd-selection-track:has(.bd-selection-card:hover) .bd-selection-card:hover img {
        filter: drop-shadow(0 10px 20px rgba(16, 16, 16, 0.12)) !important;
    }
    .bd-selection-track:has(.bd-selection-card:hover) .bd-selection-card:hover ~ .bd-selection-card {
        transform: none !important;
    }
}

@media (max-width: 992px) {
    /* ── Conteneur principal ── */
    .bd-project-container {
        padding: 0 20px;
        gap: 20px; /* Réduit pour remonter les sections sur mobile */
        margin: 0 auto 60px auto;
        overflow: visible; /* pas de clip ici : chaque section gère son overflow */
        align-items: center;
        width: 100%;
        box-sizing: border-box;
    }

    /* illustration-header : hauteur min pour que le descriptif soit visible en entier, avec marge en haut pour descendre l'image */
    .illustration-header {
        left: auto !important;
        width: calc(100% + 40px) !important;
        margin-left: -20px !important;
        margin-right: -20px !important;
        align-self: stretch !important;
        margin-top: 20px !important; /* Remonte l'image de fond du hero */
        margin-bottom: 90px !important; /* Espacement avec le bloc La Sélection */
        overflow: visible !important;   /* laisse le descriptif sortir en bas */
        padding-bottom: 210px !important; /* espace augmenté pour le descriptif pour éviter les chevauchements */
    }
    .hover-illustration {
        aspect-ratio: 1510 / 1116 !important; /* Agrandit la zone hero de 25% */
        overflow: visible !important;   /* ne coupe plus le descriptif */
    }
    .illustrations-wrapper {
        overflow: visible !important;
    }
    .illustrations {
        transform: scale(1.25) !important; /* Zoom de 25% de l'image de fond */
        transform-origin: center top !important;
    }
    /* Descriptif : z-index élevé pour passer au-dessus du fond sélection */
    .descriptif {
        z-index: 200 !important;
        background: #FFFFFF !important; /* s'assurer que le fond blanc couvre tout */
    }

    /* Descriptif : sur l'image de fond de la hero, centré, texte 12px, descendu encore plus */
    .descriptif {
        left: 50% !important;
        top: 82% !important; /* Descend le descriptif sur l'image de fond encore plus bas */
        transform: translateX(-50%) !important;
        width: calc(100% - 40px) !important;
        min-width: unset !important;
        max-width: 420px !important;
        padding: 20px 18px !important;
    }
    .descriptif-text {
        font-size: clamp(9px, 3.05vw, 13px) !important; /* = taille "les autres illustrations" */
        line-height: 1.45em !important;
    }


    /* ── Section 3 : LES AUTRES ILLUSTRATIONS ───────────── */
    .bd-others-section {
        align-items: center !important;
        width: 100% !important;
    }

    .bd-others-title {
        font-size: clamp(9px, 3.05vw, 13px) !important;
        line-height: clamp(12px, 3.82vw, 16px) !important;
        margin-bottom: 0 !important;
        text-align: center !important;
        width: 100% !important;
    }

    /* Ligne horizontale — 2 cartes côte à côte, centrées */
    .bd-others-grid {
        display: flex !important;
        flex-direction: row !important;
        justify-content: center !important;
        align-items: center !important;
        height: 81.13vw !important;   /* 318.79 / 393 × 100 */
        width: 100% !important;
        max-width: 100% !important;
        border-radius: 0 !important;
        overflow: hidden !important;
        gap: 0 !important;
        margin: 0 auto !important;
    }

    .bd-other-card {
        flex: 1 !important;
        width: auto !important;
        height: 81.13vw !important;
        flex-shrink: 1 !important;
        border-bottom: none !important;
    }

    /* Vice Versa x Unbottled caché sur mobile (1ère carte dans le HTML) */
    .bd-other-card:nth-child(1) {
        display: none !important;
    }

    .bd-card-caption {
        font-size: clamp(6px, 1.63vw, 8px) !important;
        top: 2.29vw !important;
        right: 2.8vw !important;
        padding: 0.51vw 1.27vw !important;
    }

    /* Zoomer et remonter l'image de fond pour masquer le texte "Anatomie" dessiné dessus au format mobile */
    .bd-other-card[href="anatomie.html"] .bd-card-bg {
        transform: scale(1.48) translate(-10%, 6%) !important;
    }
    .bd-other-card[href="anatomie.html"]:hover .bd-card-bg {
        transform: scale(1.53) translate(-10%, 6%) !important;
        filter: brightness(0.9) !important;
    }
    .nav-arrow {
        display: none !important;
    }
}

/* Navigation Control Arrows */
.nav-arrow {
    position: absolute;
    width: 64px;
    height: 64px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 15;
    cursor: pointer;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.55) 0%, rgba(245, 245, 245, 0.25) 100%);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 50%;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04), inset 0 1px 0 rgba(255, 255, 255, 0.45);
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), background-color 0.3s ease, box-shadow 0.3s ease, opacity 0.3s ease;
}

.nav-arrow img {
    width: 26px;
    height: 26px;
    object-fit: contain;
    filter: brightness(0) invert(1);
    transition: transform 0.2s ease;
}

.arrow-left {
    left: 40px;
}

.arrow-right {
    right: 40px;
    transform: translateY(-50%) rotate(180deg);
}

.nav-arrow:hover {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.75) 0%, rgba(245, 245, 245, 0.45) 100%);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.04), inset 0 1px 0 rgba(255, 255, 255, 0.55);
}

.arrow-left:hover {
    transform: translateY(-50%) scale(1.08);
}

.arrow-right:hover {
    transform: translateY(-50%) rotate(180deg) scale(1.08);
}

.nav-arrow:hover img {
    transform: translateX(-2px);
}

@media (min-width: 1601px) {
    .nav-arrow {
        display: none !important;
    }
}

/* Phone format: move down the descriptif and adjust spacing */
@media (max-width: 767px) {
    .descriptif {
        top: 92% !important;
    }
    .illustration-header {
        padding-bottom: 240px !important; /* Espace sous la hero pour le descriptif */
        margin-bottom: 60px !important;   /* Espace entre la hero et la sélection */
    }
}

/* ═══════════════════════════════════════════════════════════════
   LIGHTBOX MOBILE/TABLETTE — tap sur image pour agrandir
   Actif uniquement sur écrans tactiles (max-width: 1024px)
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 1024px) {

    /* Overlay sombre qui apparaît derrière l'image agrandie */
    .bd-lightbox-overlay {
        position: fixed;
        inset: 0;
        background: rgba(10, 10, 10, 0.85);
        z-index: 9000;
        display: flex;
        align-items: center;
        justify-content: center;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.28s ease;
        backdrop-filter: blur(6px);
        -webkit-backdrop-filter: blur(6px);
    }

    .bd-lightbox-overlay.is-open {
        opacity: 1;
        pointer-events: all;
    }

    /* Image agrandie à l'intérieur de l'overlay */
    .bd-lightbox-overlay img {
        max-width: 92vw;
        max-height: 88vh;
        object-fit: contain;
        border-radius: 4px;
        box-shadow: 0 24px 80px rgba(0, 0, 0, 0.55);
        transform: scale(0.88);
        transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
        display: block;
    }

    .bd-lightbox-overlay.is-open img {
        transform: scale(1);
    }

    /* Bouton de fermeture discret en haut à droite */
    .bd-lightbox-close {
        position: absolute;
        top: 18px;
        right: 20px;
        width: 38px;
        height: 38px;
        background: rgba(255, 255, 255, 0.15);
        border: 1px solid rgba(255, 255, 255, 0.25);
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        color: #ffffff;
        font-size: 20px;
        line-height: 1;
        backdrop-filter: blur(8px);
        -webkit-backdrop-filter: blur(8px);
    }
}
