/* ==========================================================================
   HOME VARIANT — storytelling au scroll, sections épinglées, scrubbing lié
   au scroll (GSAP + ScrollTrigger, chargés uniquement ici).
   ========================================================================== */

.page-story {
    overflow-x: clip;
    position: relative;
    z-index: 1;
}

.page-story .container {
    max-width: 1280px;
}

/* "AURA DUST" — fond de particules 3D (Three.js), fixe derrière tout le
   contenu. Le canvas est transparent : le fond sombre existant (body) reste
   visible entre les particules. */
#auraParticles {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
}

/* Le header/footer ne doivent PAS recevoir de position/z-index ici : ça
   créerait un nouveau contexte d'empilement qui piège le z-index (élevé) de
   la navbar à l'intérieur, et la ferait perdre face à <main class="page-story">
   (même z-index, mais plus tard dans le DOM) dès que du contenu défile sous
   elle — c'est exactement le bug qui rendait le header non cliquable au
   scroll. La navbar (position:fixed + son propre z-index) gagne naturellement
   dans le contexte racine tant qu'on ne l'enferme pas dans un sous-contexte. */

/* INTRO */
.story-intro {
    position: relative;
    min-height: 100vh;
    /* 100vh inclut l'espace caché derrière la barre d'adresse mobile : la
       boîte est alors plus haute que la zone réellement visible, et le
       contenu centré dedans (justify-content: center) atterrit plus bas que
       le centre visuel réel. 100svh (fallback 100vh pour les anciens
       navigateurs) se cale sur la plus petite hauteur garantie. */
    min-height: 100svh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 0 2rem;
}

/* Icônes outils flottant "dans l'espace" au-dessus du fond de particules
   (#auraParticles), uniquement pendant l'intro. z-index négatif : elles
   restent derrière le titre/CTA (non positionnés, donc peints après les
   descendants z-index négatif - cf. CSS2.1 Appendix E) sans avoir besoin d'un
   z-index positif sur le texte. Le flottement "idle" (translate/rotate doux)
   est porté par .story-float-wrap en pur CSS ; l'envol au scroll (inverse du
   sens du scroll) est piloté par GSAP/ScrollTrigger sur .story-float-icon
   (deux éléments distincts pour ne pas faire écrire deux systèmes différents
   sur la même propriété transform - voir le <script> en bas de index.php).
   Cachées sous 640px (cf. media query plus bas) pour ne pas encombrer un
   titre déjà réduit. */
.story-icons-float {
    position: absolute;
    inset: 0;
    z-index: -1;
    pointer-events: none;
}

.story-float-wrap {
    position: absolute;
    animation: storyIconDriftA 9s ease-in-out infinite;
}

.story-float-wrap:nth-of-type(1) { top: 15%; left: 9%; width: clamp(34px, 4.2vw, 54px); animation-duration: 8s; animation-delay: 0s; }
.story-float-wrap:nth-of-type(2) { top: 21%; right: 10%; width: clamp(42px, 5.4vw, 70px); animation-duration: 10s; animation-delay: 1.2s; animation-name: storyIconDriftB; }
.story-float-wrap:nth-of-type(3) { top: 57%; left: 6%; width: clamp(36px, 4.6vw, 58px); animation-duration: 9s; animation-delay: 0.6s; }
.story-float-wrap:nth-of-type(4) { top: 60%; right: 7%; width: clamp(40px, 5vw, 62px); animation-duration: 11s; animation-delay: 2s; animation-name: storyIconDriftB; }
.story-float-wrap:nth-of-type(5) { bottom: 10%; left: 17%; width: clamp(32px, 4vw, 50px); animation-duration: 7.5s; animation-delay: 1.6s; }
.story-float-wrap:nth-of-type(6) { bottom: 14%; right: 19%; width: clamp(38px, 4.8vw, 60px); animation-duration: 9.5s; animation-delay: 0.4s; animation-name: storyIconDriftB; }

.story-float-icon {
    display: block;
    width: 100%;
    height: auto;
    opacity: 0.6;
    filter: drop-shadow(0 0 16px rgba(0, 216, 255, 0.28));
}

@keyframes storyIconDriftA {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    30% { transform: translate(14px, -18px) rotate(6deg); }
    60% { transform: translate(-10px, 10px) rotate(-4deg); }
}

@keyframes storyIconDriftB {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    35% { transform: translate(-16px, 14px) rotate(-5deg); }
    65% { transform: translate(12px, -12px) rotate(5deg); }
}

@media (prefers-reduced-motion: reduce) {
    .story-float-wrap {
        animation: none;
    }
}

.story-intro-title {
    font-size: 5.5rem;
    line-height: 1.05;
    font-weight: 800;
    max-width: 1000px;
    margin-bottom: 2rem;
}

.story-word {
    display: inline-block;
    opacity: 0;
    transform: translateY(30px);
    animation: storyWordIn 0.7s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

@keyframes storyWordIn {
    to { opacity: 1; transform: translateY(0); }
}

.story-intro-subtitle {
    font-size: 1.25rem;
    color: var(--text-muted);
    max-width: 560px;
    opacity: 0;
    animation: storyFadeIn 0.8s ease forwards;
    animation-delay: 1.1s;
    margin-bottom: 2.5rem;
}

@keyframes storyFadeIn {
    to { opacity: 1; }
}

.story-scrollcue {
    opacity: 0;
    animation: storyFadeIn 0.8s ease forwards, storyBounce 2s ease-in-out infinite 1.9s;
    animation-delay: 1.4s, 1.9s;
    color: var(--text-muted);
}

@keyframes storyBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(10px); }
}

/* PINNED SECTIONS (générique) */
.story-pin {
    min-height: 100vh;
    min-height: 100svh; /* voir .story-intro pour l'explication du fallback */
    display: flex;
    align-items: center;
    padding: 4rem 0;
}

.story-pin-grid {
    display: grid;
    grid-template-columns: 0.9fr 1.1fr;
    gap: 4rem;
    align-items: center;
    width: 100%;
}

.story-eyebrow {
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--primary-color);
    margin-bottom: 1rem;
    display: block;
}

/* SECTION A — 3 vidéos (une par outil), scrubées au scroll */
.story-angle-frame {
    position: relative;
    aspect-ratio: 4 / 3;
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: 28px;
    overflow: hidden;
}

.story-angle-frame video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 2rem;
    opacity: 0;
    transition: opacity 0.15s linear;
}

.story-angle-frame video.active {
    opacity: 1;
}

.story-caption-stack {
    position: relative;
    min-height: 140px;
}

.story-caption {
    position: absolute;
    top: 0;
    left: 0;
    opacity: 0;
    transform: translateY(16px);
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.story-caption.active {
    opacity: 1;
    transform: translateY(0);
}

.story-caption h2 {
    font-size: 2.6rem;
    margin-bottom: 1rem;
}

.story-caption p {
    color: var(--text-muted);
    font-size: 1.1rem;
    max-width: 480px;
}

.story-progress {
    display: flex;
    gap: 8px;
    margin-top: 2rem;
}

.story-progress span {
    width: 32px;
    height: 3px;
    border-radius: 2px;
    background: var(--glass-border);
    transition: background 0.3s ease;
}

.story-progress span.active {
    background: var(--primary-color);
}

/* SECTION B — reveal avant/après au scroll (plein cadre) */
.story-reveal-section {
    padding: 0;
    min-height: 100vh;
    min-height: 100svh; /* voir .story-intro pour l'explication du fallback */
    display: flex;
    align-items: center;
}

.story-reveal-frame {
    position: relative;
    container-type: inline-size;
    width: 100%;
    aspect-ratio: 16 / 8;
    overflow: hidden;
}

.story-reveal-frame .layer-before {
    position: absolute;
    inset: 0;
    background: url('../img/comparator/before.jpeg') bottom/cover;
}

/* .layer-after ne fait QUE masquer (overflow hidden), sa largeur est animée
   par le scroll (0 -> 100%). L'image vit dans .layer-after-inner, de taille
   FIXE (100cqw = largeur du cadre complet) pour ne jamais se redimensionner
   pendant le scrub. */
.story-reveal-frame .layer-after {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 0%;
    overflow: hidden;
    border-right: 2px solid var(--primary-color);
}

.story-reveal-frame .layer-after-inner {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 100cqw;
    background: url('../img/comparator/after.jpeg') bottom/cover;
}

.story-reveal-caption {
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
    z-index: 5;
    color: white;
}

.story-reveal-caption h2 {
    font-size: 2rem;
    margin-bottom: 0.6rem;
}

/* SECTION C — trois outils, un flux */
.story-flow-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.story-flow-item {
    padding: 1.2rem 0;
    opacity: 0.3;
    transition: opacity 0.35s ease;
}

.story-flow-item.active {
    opacity: 1;
}

.story-flow-item h3 {
    font-size: 1.8rem;
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 0.4rem;
}

.story-flow-item p {
    color: var(--text-muted);
    max-width: 420px;
}

.story-flow-stage {
    position: relative;
    aspect-ratio: 4 / 3;
}

.story-flow-stage video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* SCROLL REVEAL (fade discret, même comportement que la page classique) */
.reveal-fade {
    opacity: 0;
    transform: translateY(16px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.reveal-fade.is-visible {
    opacity: 1;
    transform: translateY(0);
}

/* SECTION D — galerie de comparaisons avant/après (plusieurs véhicules) */
.story-fleet-compare {
    padding: 140px 0;
}

.fleet-compare-header {
    text-align: center;
    max-width: 620px;
    margin: 0 auto 3.5rem;
}

.fleet-compare-header .section-title {
    font-size: 2.6rem;
    margin: 0.6rem 0 1rem;
}

.fleet-compare-header p {
    color: var(--text-muted);
    font-size: 1.05rem;
}

.fleet-compare-layout {
    display: grid;
    grid-template-columns: 1.6fr 0.9fr;
    gap: 2.5rem;
    /* "start" et non "stretch" : sinon la grille de vignettes (plus courte que
       le comparateur) est étirée sur toute sa hauteur, et comme chaque
       vignette garde sa propre hauteur (aspect-ratio 4/3), l'espace en trop
       se voit comme un énorme vide entre les deux rangées. */
    align-items: start;
    max-width: 1100px;
    margin: 0 auto;
}

.fleet-compare-stage .aura-compare-frame {
    position: relative;
    container-type: inline-size;
    width: 100%;
    height: 100%;
    aspect-ratio: 4 / 3;
    border-radius: 28px;
    overflow: hidden;
    border: 1px solid var(--glass-border);
    cursor: ew-resize;
    user-select: none;
    background: var(--bg-card);
}

.fleet-compare-stage .aura-compare-before,
.fleet-compare-stage .aura-compare-after-inner {
    transition: opacity 0.25s ease;
}

.fleet-compare-stage .aura-compare-frame.swapping .aura-compare-before,
.fleet-compare-stage .aura-compare-frame.swapping .aura-compare-after-inner {
    opacity: 0;
}

.fleet-compare-stage .aura-compare-before {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center;
}

/* .aura-compare-after ne fait QUE masquer (overflow hidden) : sa largeur est
   animée par le JS de drag. L'image "après" vit dans .aura-compare-after-inner,
   de taille FIXE (100cqw = largeur du cadre complet) pour ne jamais se
   redimensionner pendant le glisser — même contrat que sur la page classique. */
.fleet-compare-stage .aura-compare-after {
    position: absolute;
    top: 0;
    right: 0;
    height: 100%;
    width: 50%;
    overflow: hidden;
    border-left: 2px solid var(--primary-color);
}

.fleet-compare-stage .aura-compare-after-inner {
    position: absolute;
    top: 0;
    right: 0;
    height: 100%;
    width: 100cqw;
    background-size: cover;
    background-position: center;
}

.fleet-compare-stage .aura-compare-handle {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 50px;
    margin-left: -25px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5;
}

.fleet-compare-stage .aura-compare-handle-dot {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 24px rgba(139, 92, 246, 0.45);
    transition: transform 0.25s ease;
}

.fleet-compare-stage .aura-compare-frame:hover .aura-compare-handle-dot {
    transform: scale(1.08);
}

.fleet-compare-stage .aura-compare-label {
    position: absolute;
    top: 20px;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: white;
    background: rgba(13, 15, 20, 0.5);
    backdrop-filter: blur(10px);
    z-index: 4;
}

.fleet-compare-stage .aura-compare-label.before { left: 20px; }
.fleet-compare-stage .aura-compare-label.after { right: 20px; }

/* PICKER — grille de vignettes-images cliquables à côté du comparateur
   (pas de libellé : juste la photo, l'état actif suffit à se repérer). */
.fleet-compare-picker {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.fleet-compare-thumb {
    padding: 0;
    aspect-ratio: 4 / 3;
    border-radius: 14px;
    overflow: hidden;
    border: 2px solid var(--glass-border);
    background: var(--bg-stage);
    cursor: pointer;
    transition: var(--transition);
}

.fleet-compare-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.fleet-compare-thumb:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
}

.fleet-compare-thumb.active {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 1px var(--primary-color), 0 10px 24px rgba(0, 216, 255, 0.15);
}

/* SECTION E — player 360° tec3h (extérieur + intérieur), embarqué en iframe */
.story-360 {
    padding: 140px 0;
}

.story-360-header {
    text-align: center;
    max-width: 620px;
    margin: 0 auto 3.5rem;
}

.story-360-header .section-title {
    font-size: 2.6rem;
    margin: 0.6rem 0 1rem;
}

.story-360-header p {
    color: var(--text-muted);
    font-size: 1.05rem;
}

.story-360-frame {
    max-width: 1000px;
    margin: 0 auto;
    aspect-ratio: 16 / 9;
    border-radius: 28px;
    overflow: hidden;
    border: 1px solid var(--glass-border);
    /* Le player tec3h a son propre fond blanc studio (non lié au thème Aura) :
       l'arrondi + la bordure suffisent à l'intégrer proprement à la page. */
}

.story-360-iframe {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
}

/* CLOSING CTA */
.story-cta {
    min-height: 90vh;
    min-height: 90svh; /* voir .story-intro pour l'explication du fallback */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    position: relative;
    padding: 4rem 2rem;
}

.story-cta-glow {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 800px;
    height: 800px;
    transform: translate(-50%, -50%);
    background: radial-gradient(circle, rgba(139, 92, 246, 0.18), transparent 70%);
    filter: blur(20px);
    z-index: 0;
}

.story-cta h2 {
    position: relative;
    z-index: 1;
    font-size: 3.4rem;
    max-width: 700px;
    margin-bottom: 2rem;
}

.story-cta .btn {
    position: relative;
    z-index: 1;
}

@media (max-width: 1024px) {
    .story-pin-grid,
    .story-flow-list ~ .story-flow-stage {
        grid-template-columns: 1fr;
    }

    .story-pin-grid {
        grid-template-columns: 1fr;
        text-align: center;
    }

    /* min-height n'est qu'un minimum : si le contenu empilé (texte au-dessus
       de la vidéo) dépasse 100svh, la boîte grandit simplement en
       conséquence (pas de clip, pas d'overflow: hidden ici) - donc pas
       besoin de l'enlever pour éviter un débordement pendant le pin. On la
       garde pour que le contenu, quand il tient dans l'écran, reste centré
       verticalement (align-items: center) plutôt que collé en haut. */
    .story-pin {
        padding: 3rem 0;
    }

    .story-pin-grid {
        gap: 2.5rem;
    }

    .story-intro-title {
        font-size: 3rem;
    }

    .story-caption h2 {
        font-size: 1.8rem;
    }

    /* .story-progress est en display: flex (donc une boîte de bloc) : le
       text-align: center posé sur .story-pin-grid ne centre que du contenu
       inline, pas cette boîte elle-même ni son contenu. */
    .story-progress {
        justify-content: center;
    }

    .story-cta h2 {
        font-size: 2.4rem;
    }

    .fleet-compare-header .section-title,
    .story-360-header .section-title {
        font-size: 2rem;
    }

    .fleet-compare-layout {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    /* Titre déjà réduit à cette largeur : les icônes flottantes deviendraient
       gênantes autour d'un texte plus compact. */
    .story-icons-float {
        display: none;
    }

    .story-intro-title {
        font-size: 2.2rem;
    }

    .story-intro-subtitle {
        font-size: 1.05rem;
    }

    .story-caption h2 {
        font-size: 1.5rem;
    }

    .story-caption p {
        font-size: 1rem;
    }

    .story-angle-frame video {
        padding: 1rem;
    }

    .story-flow-item h3 {
        font-size: 1.4rem;
    }

    .story-reveal-caption h2 {
        font-size: 1.4rem;
    }

    .story-cta h2 {
        font-size: 1.9rem;
    }

    .fleet-compare-picker {
        gap: 0.6rem;
    }
}
