/* ==========================================================================
   Animations
   --------------------------------------------------------------------------
   Entrée de la page d'accueil, apparition des blocs au défilement,
   bandeau des technologies, fenêtres, notifications et changement de thème.
   Toutes sont neutralisées si le système demande de réduire les animations.
   ========================================================================== */

@keyframes fade-in {
    from { opacity: 0; }
}

@keyframes fade-out {
    to { opacity: 0; }
}

@keyframes rise {
    from {
        opacity: 0;
        transform: translateY(18px);
    }
}

@media (prefers-reduced-motion: no-preference) {

    /* Accueil : les lettres du nom montent une à une, puis le reste suit */
    .hero__char {
        animation: char-in 0.9s var(--ease-out) both;
        animation-delay: calc(var(--word-delay, 0ms) + var(--char-delay, 0ms) + 120ms);
    }

    .hero__word:nth-child(2) { --word-delay: 160ms; }
    .hero__word:nth-child(3) { --word-delay: 320ms; }
    .hero__word:nth-child(n + 4) { --word-delay: 480ms; }

    .hero__char:nth-child(2) { --char-delay: 35ms; }
    .hero__char:nth-child(3) { --char-delay: 70ms; }
    .hero__char:nth-child(4) { --char-delay: 105ms; }
    .hero__char:nth-child(5) { --char-delay: 140ms; }
    .hero__char:nth-child(6) { --char-delay: 175ms; }
    .hero__char:nth-child(7) { --char-delay: 210ms; }
    .hero__char:nth-child(8) { --char-delay: 245ms; }
    .hero__char:nth-child(9) { --char-delay: 280ms; }
    .hero__char:nth-child(n + 10) { --char-delay: 315ms; }

    .hero__meta {
        animation: rise 0.7s var(--ease-out) both;
    }

    .hero__role {
        animation: rise 0.8s var(--ease-out) 0.55s both;
    }

    .hero__role::before {
        animation: line-in 0.9s var(--ease-out) 0.7s both;
    }

    .hero__body {
        animation: rise 0.9s var(--ease-out) 0.7s both;
    }

    .marquee {
        animation: fade-in 1.2s var(--ease) 0.9s both;
    }

    /* Bandeau des technologies : défilement continu, en pause au survol */
    .marquee__viewport {
        animation: marquee 38s linear infinite;
    }

    .marquee:hover .marquee__viewport {
        animation-play-state: paused;
    }

    /* Blocs qui apparaissent en entrant dans l'écran (classe ajoutée par animations.js) */
    .has-reveal [data-reveal] {
        transition: opacity 0.75s var(--ease-out), transform 0.75s var(--ease-out);
        transition-delay: var(--reveal-delay, 0ms);
    }

    .has-reveal [data-reveal]:not(.is-revealed) {
        opacity: 0;
        transform: translateY(28px);
    }

    /* Titres de section : légère montée plus marquée */
    .has-reveal .section-header[data-reveal]:not(.is-revealed) {
        transform: translateY(40px);
    }

    /* Menu mobile : les liens arrivent l'un après l'autre */
    .is-menu-open .site-nav__list li {
        animation: rise 0.5s var(--ease-out) both;
    }

    .is-menu-open .site-nav__list li:nth-child(2) { animation-delay: 40ms; }
    .is-menu-open .site-nav__list li:nth-child(3) { animation-delay: 80ms; }
    .is-menu-open .site-nav__list li:nth-child(4) { animation-delay: 120ms; }
    .is-menu-open .site-nav__list li:nth-child(5) { animation-delay: 160ms; }
    .is-menu-open .site-nav__list li:nth-child(6) { animation-delay: 200ms; }

    /* Méthode : contenu de l'étape choisie */
    .stepper__panel.is-entering .stepper__intro,
    .stepper__panel.is-entering .stepper__points li {
        animation: rise 0.55s var(--ease-out) both;
    }

    .stepper__panel.is-entering .stepper__points li:nth-child(1) { animation-delay: 80ms; }
    .stepper__panel.is-entering .stepper__points li:nth-child(2) { animation-delay: 140ms; }
    .stepper__panel.is-entering .stepper__points li:nth-child(3) { animation-delay: 200ms; }
    .stepper__panel.is-entering .stepper__points li:nth-child(n + 4) { animation-delay: 260ms; }

    .stepper__panel.is-entering .stepper__big {
        animation: big-in 0.8s var(--ease-out) both;
    }

    /* Confirmation d'envoi du formulaire */
    .form-success:not([hidden]) .form-success__icon {
        animation: pop 0.6s var(--ease-spring) both;
    }
}

@keyframes char-in {
    from {
        opacity: 0;
        transform: translateY(0.45em) rotate(6deg);
    }
}

@keyframes line-in {
    from { transform: scaleX(0); }
}

.hero__role::before {
    transform-origin: left;
}

@keyframes marquee {
    to { transform: translateX(-50%); }
}

@keyframes big-in {
    from {
        opacity: 0;
        transform: translateY(30%);
    }
}

@keyframes pop {
    from {
        opacity: 0;
        transform: scale(0.4);
    }
}

@keyframes modal-switch {
    from {
        opacity: 0;
        transform: translateX(var(--switch-from, 24px));
    }
}

/* Éléments réaffichés par un filtre */
.is-entering {
    animation: rise 0.45s var(--ease-out) both;
}

/* Fenêtre de détail */
.modal[open] {
    animation: modal-in 0.4s var(--ease-out);
}

.modal[open]::backdrop {
    animation: fade-in 0.25s var(--ease);
}

.modal.is-closing {
    animation: modal-out 0.2s var(--ease) forwards;
}

.modal.is-closing::backdrop {
    animation: fade-out 0.2s var(--ease) forwards;
}

@keyframes modal-in {
    from {
        opacity: 0;
        transform: translateY(24px) scale(0.98);
    }
}

@keyframes modal-out {
    to {
        opacity: 0;
        transform: translateY(12px) scale(0.98);
    }
}

/* Recherche rapide */
.palette[open] {
    animation: palette-in 0.25s var(--ease-out);
}

.palette[open]::backdrop {
    animation: fade-in 0.2s var(--ease);
}

@keyframes palette-in {
    from {
        opacity: 0;
        transform: translateY(-10px) scale(0.98);
    }
}

/* Notifications */
.toast {
    animation: toast-in 0.35s var(--ease-spring);
}

.toast.is-leaving {
    animation: fade-out 0.15s var(--ease) forwards;
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.96);
    }
}

/* Chargement */
.btn__spinner {
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Filtres : les cartes glissent vers leur nouvelle place (filters.js) */
::view-transition-group(*) {
    animation-duration: 0.45s;
    animation-timing-function: var(--ease-out);
}

/* Préférence système : animations réduites */
@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        transition-delay: 0s !important;
    }

    /* Bandeau : affiché à l'arrêt, sur plusieurs lignes si nécessaire */
    .marquee {
        -webkit-mask-image: none;
        mask-image: none;
    }

    .marquee__viewport {
        flex-wrap: wrap;
        width: auto;
    }

    .marquee__track + .marquee__track {
        display: none;
    }

    .marquee__track {
        flex-wrap: wrap;
    }
}
