/*
 * Animations légères de deft-2027 (décision de Julien, 20/11/2026).
 * CSS seul, sans script ni extension. Tout est désactivé si le visiteur demande
 * moins d'animations dans son système (prefers-reduced-motion), et un navigateur
 * qui ne connaît pas une technique affiche simplement la page sans l'effet.
 *
 *   1. Fondu entre les pages (transitions de vue entre documents).
 *   2. Images qui apparaissent au défilement (animations liées au défilement).
 *   3. Accroche de l'accueil : titre mot par mot, image dévoilée en diagonale puis zoom lent.
 *
 * Les anciennes classes d'apparition du contenu (« animated fadeIn »…) restent
 * gérées par animations.css ; ce fichier ne les anime pas une seconde fois.
 */

/* À l'impression, tout est affiché à son état final, sans animation. */
@media print {
	*,
	*::before,
	*::after {
		animation: none !important;
	}
}

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

	/* ------------------------------------------------------------------
	 * 1. Fondu entre les pages
	 * L'en-tête reste en place pendant que le contenu change.
	 * ---------------------------------------------------------------- */
	@view-transition {
		navigation: auto;
	}

	.deft-site-header {
		view-transition-name: deft-entete;
	}

	::view-transition-old(root) {
		animation: deft-vt-sortie 0.18s ease-in both;
	}

	::view-transition-new(root) {
		animation: deft-vt-entree 0.32s ease-out both;
	}

	@keyframes deft-vt-sortie {
		to { opacity: 0; }
	}

	@keyframes deft-vt-entree {
		from { opacity: 0; transform: translateY(8px); }
	}

	/* ------------------------------------------------------------------
	 * 2. Images qui apparaissent au défilement
	 * Seulement si le navigateur sait lier une animation au défilement.
	 * Une image déjà à l'écran au chargement est affichée tout de suite.
	 * ---------------------------------------------------------------- */
	@supports (animation-timeline: view()) {
		:is(
			.deft-archive .wp-block-post,
			.deft-products .wc-block-product,
			.deft-fil-flux .wp-block-post,
			.wp-block-post-content :is(.wp-block-image, .wp-block-gallery, .wp-block-video, .wp-block-media-text, .wp-block-table, .lfg-panorama-section, .wp-block-w0-panorama-gallery__container)
		):not(.animated, .animated *) {
			animation: deft-apparition linear both;
			animation-timeline: view();
			animation-range: entry 0% entry 35%;
		}

		/* Les images d'une galerie apparaissent ensemble, avec leur galerie. */
		.wp-block-post-content .wp-block-gallery .wp-block-image {
			animation: none;
		}
	}

	@keyframes deft-apparition {
		from {
			opacity: 0;
			transform: translateY(24px);
		}
		to {
			opacity: 1;
			transform: none;
		}
	}

	/* ------------------------------------------------------------------
	 * 3. Accroche de l'accueil (0.14.0, demandée par Julien : plus d'impact)
	 * A. Le titre arrive mot par mot.
	 * B. L'image se dévoile par un balayage en diagonale (coup de rouleau),
	 *    puis vit d'un zoom très lent, en continu.
	 * Le tout dure environ 1,4 s à l'arrivée ; seul le zoom lent continue ensuite.
	 * ---------------------------------------------------------------- */

	/* Surtitre, phrase et boutons : montée douce, après le titre. */
	.deft-home-hero-text > :not(.deft-home-title) {
		animation: deft-devoile 0.7s cubic-bezier(0.2, 0.7, 0.2, 1) both;
	}

	.deft-home-hero-text > :nth-child(3) { animation-delay: 0.55s; }
	.deft-home-hero-text > :nth-child(4) { animation-delay: 0.7s; }

	/* A. Mots du titre, l'un après l'autre (--deft-i posé par home-hero.php). */
	.deft-home-title .deft-mot {
		animation: deft-mot 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) both;
		animation-delay: calc(0.1s + var(--deft-i, 0) * 0.08s);
	}

	/* B. L'image : balayage en diagonale, puis zoom très lent qui va et vient. */
	.deft-home-hero-media .wp-block-post-featured-image {
		overflow: hidden;
		border-radius: 2px;
		animation: deft-balayage 0.95s cubic-bezier(0.7, 0, 0.2, 1) 0.15s both;
	}

	.deft-home-hero-media .wp-block-post-featured-image img {
		animation: deft-zoom-lent 24s ease-in-out 1.1s infinite alternate both;
	}

	.deft-home-hero-caption {
		animation: deft-devoile 0.7s cubic-bezier(0.2, 0.7, 0.2, 1) 0.9s both;
	}

	@keyframes deft-devoile {
		from {
			opacity: 0;
			transform: translateY(18px);
		}
	}

	@keyframes deft-mot {
		from {
			opacity: 0;
			transform: translateY(0.45em);
		}
	}

	@keyframes deft-balayage {
		from {
			clip-path: polygon(0 0, 0 0, -25% 100%, 0 100%);
		}
		to {
			clip-path: polygon(0 0, 125% 0, 100% 100%, 0 100%);
		}
	}

	@keyframes deft-zoom-lent {
		from {
			transform: scale(1);
		}
		to {
			transform: scale(1.06);
		}
	}
}
