/* ============================================================
   ANIMATIONS SUPPLÉMENTAIRES (le site « vivant »)
   ============================================================ */

/* ---------- Couleurs des lueurs, selon le thème ---------- */
:root,
[data-theme="sombre"] {
    --orbe-1: rgba(90, 120, 255, .16);
    --orbe-2: rgba(255, 90, 140, .10);
    --orbe-3: rgba(61, 220, 132, .08);
}

[data-theme="clair"] {
    --orbe-1: rgba(90, 120, 255, .18);
    --orbe-2: rgba(255, 150, 90, .18);
    --orbe-3: rgba(61, 220, 132, .14);
}

[data-theme="amoled"] {
    --orbe-1: rgba(90, 120, 255, .10);
    --orbe-2: rgba(255, 90, 140, .06);
    --orbe-3: rgba(61, 220, 132, .05);
}

/* ---------- 1. Fond vivant ---------- */
.fond-vivant {
    position: fixed;
    inset: 0;
    z-index: -2;
    overflow: hidden;
    pointer-events: none;
}

.fond-vivant span {
    position: absolute;
    width: 55vmax;
    height: 55vmax;
    border-radius: 50%;
    background: radial-gradient(circle, var(--orbe) 0%, transparent 65%);
    animation: derive 28s ease-in-out infinite alternate;
    will-change: transform;
}

.fond-vivant span:nth-child(1) {
    top: -20%;
    left: -10%;
    --orbe: var(--orbe-1);
}

.fond-vivant span:nth-child(2) {
    bottom: -25%;
    right: -15%;
    --orbe: var(--orbe-2);
    animation-duration: 34s;
    animation-direction: alternate-reverse;
}

.fond-vivant span:nth-child(3) {
    top: 30%;
    left: 40%;
    width: 40vmax;
    height: 40vmax;
    --orbe: var(--orbe-3);
    animation-duration: 40s;
}

@keyframes derive {
    from {
        transform: translate3d(0, 0, 0) scale(1);
    }

    to {
        transform: translate3d(8vw, 6vh, 0) scale(1.15);
    }
}

/* ---------- 2. Barre de progression du scroll ---------- */
.barre-scroll {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    z-index: 200;
    pointer-events: none;
    background: linear-gradient(90deg, #3ddc84, #5a78ff);
    transform-origin: left;
    transform: scaleX(var(--p, 0));
}

/* ---------- 3. Lumière qui suit la souris sur les cartes ---------- */
.showcase {
    position: relative;
}

.showcase::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    opacity: 0;
    transition: opacity .4s ease;
    background: radial-gradient(420px circle at var(--mx, 50%) var(--my, 50%), rgba(255, 255, 255, .14), transparent 60%);
}

.showcase:hover::after {
    opacity: 1;
}

/* ---------- 4 + 5. Boutons magnétiques et ondulation au clic ---------- */
.btn,
.chip {
    position: relative;
    overflow: hidden;
}

.btn {
    transition: opacity .2s ease, transform .2s ease, translate .25s ease-out;
}

.ondulation {
    position: absolute;
    border-radius: 50%;
    background: currentColor;
    opacity: .25;
    transform: scale(0);
    pointer-events: none;
    animation: onde .6s ease-out forwards;
}

@keyframes onde {
    to {
        transform: scale(1);
        opacity: 0;
    }
}

/* ---------- 6. Mots tournants dans le sous-titre ---------- */
.mot-tournant {
    display: inline-block;
    color: var(--couleur-texte);
    font-weight: 500;
}

.mot-tournant.entre {
    animation: mot-entre .5s cubic-bezier(.2, .8, .2, 1);
}

@keyframes mot-entre {
    from {
        opacity: 0;
        transform: translateY(.5em);
        filter: blur(4px);
    }

    to {
        opacity: 1;
        transform: none;
        filter: blur(0);
    }
}

/* ---------- 7. Transition entre les pages ---------- */
body {
    animation: entree .6s ease backwards;
    transition: opacity .25s ease, color .4s ease;
}

body.sortie {
    opacity: 0;
}

@keyframes entree {
    from {
        opacity: 0;
    }
}

/* ---------- 8. Apparition au scroll (page d'un mod) ---------- */
.reveal {
    opacity: 0;
    translate: 0 36px;
    transition: opacity .8s ease, translate .8s cubic-bezier(.2, .8, .2, 1);
}

.reveal.visible {
    opacity: 1;
    translate: 0 0;
}

.mini.reveal {
    transition: opacity .8s ease, translate .8s cubic-bezier(.2, .8, .2, 1), transform .3s ease;
}

/* ---------- 9. Filtres en cascade quand la pilule s'ouvre ---------- */
.island.ouvert .chip,
.island.ouvert .island-recherche {
    animation: pop .5s cubic-bezier(.2, .9, .3, 1.3) backwards;
    animation-delay: var(--d, .1s);
}

.chip:nth-child(2) {
    --d: .14s;
}

.chip:nth-child(3) {
    --d: .18s;
}

.chip:nth-child(4) {
    --d: .22s;
}

.chip:nth-child(5) {
    --d: .26s;
}

.chip:nth-child(6) {
    --d: .30s;
}

.chip:nth-child(7) {
    --d: .34s;
}

.chip:nth-child(8) {
    --d: .38s;
}

@keyframes pop {
    from {
        opacity: 0;
        transform: translateY(8px) scale(.9);
    }
}

/* ---------- 10. L'image principale d'un mod « respire » ---------- */
.mod-hero .showcase-image>img {
    animation: souffle 16s ease-in-out infinite alternate;
}

@keyframes souffle {
    from {
        transform: scale(1);
    }

    to {
        transform: scale(1.07);
    }
}

/* ---------- 11. Halo sur le bouton Télécharger ---------- */
.btn-gros {
    animation: halo 2.6s ease-out infinite;
}

@keyframes halo {
    0% {
        box-shadow: 0 0 0 0 rgba(128, 128, 128, .45);
    }

    70% {
        box-shadow: 0 0 0 14px rgba(128, 128, 128, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(128, 128, 128, 0);
    }
}

/* ---------- Pour les personnes qui désactivent les animations ---------- */
@media (prefers-reduced-motion: reduce) {

    .fond-vivant span,
    .mod-hero .showcase-image>img,
    .btn-gros,
    .mot-tournant.entre {
        animation: none;
    }

    body {
        animation: none;
    }

    .reveal {
        opacity: 1;
        translate: none;
        transition: none;
    }
}