/*
 * Tsuki Éclipse — animations au scroll, CSS pur (démos #11a/#11b du prototype).
 * Chrome/Edge : animation-timeline scroll()/view(). Firefox/Safari : rien ne
 * s'applique (tout vit DANS @supports) → rendu statique propre, aucun contenu
 * masqué. Le header sticky, lui, est géré en JS (.is-scrolled) partout.
 * prefers-reduced-motion : aucune animation.
 */

@media (prefers-reduced-motion: no-preference) {
	@supports (animation-timeline: scroll()) {

		/* --- Hero : parallax du fond, halos qui s'estompent, contenu qui file --- */
		@keyframes tkh-bg {
			to { transform: translateY(150px) scale(1.12); }
		}
		@keyframes tkh-dim {
			to { opacity: 0.3; }
		}
		@keyframes tkh-content {
			to { opacity: 0; transform: translateY(-80px); }
		}
		@keyframes tkh-cue {
			to { opacity: 0; }
		}
		@keyframes tkh-rise {
			from { opacity: 0; transform: translateY(36px); }
		}

		.tk-hero__video {
			animation: tkh-bg linear both;
			animation-timeline: scroll(root block);
			animation-range: 0 800px;
		}
		/* Les halos gardent leur dérive : la timeline scroll s'ajoute en 2ᵉ animation. */
		.tk-hero__halo--bleu {
			animation: tk-drift1 16s ease-in-out infinite alternate, tkh-dim linear both;
			animation-timeline: auto, scroll(root block);
			animation-range: normal, 0 700px;
		}
		.tk-hero__halo--violet {
			animation: tk-drift2 22s ease-in-out infinite alternate, tkh-dim linear both;
			animation-timeline: auto, scroll(root block);
			animation-range: normal, 0 700px;
		}
		.tk-hero__in {
			animation: tkh-content linear both;
			animation-timeline: scroll(root block);
			animation-range: 0 620px;
		}
		.tk-hero__cue {
			animation: tkh-cue linear both;
			animation-timeline: scroll(root block);
			animation-range: 0 140px;
		}

		/* --- Révélation des blocs à l'entrée dans le viewport --- */
		.tk-sechead,
		.tk-line,
		.tk-card,
		.tk-phase,
		.tk-review,
		.tk-quote,
		.tk-faq__item,
		/* .tk-stats__cell : retiré — le compteur (main.js) est leur entrée, et
		   une cellule semi-révélée dans le viewport initial échoue au contraste axe. */
		.tk-infos__cell,
		.tk-featured,
		.tk-postcard,
		.tk-founder__photo,
		.tk-founder__bio,
		.tk-statement,
		.tk-list__item,
		.tk-stack,
		.tk-localo,
		.tk-moonfinal > * {
			animation: tkh-rise linear both;
			animation-timeline: view();
			animation-range: entry 0% entry 60%;
		}

		/* --- Stagger : les frères d'une même rangée entrent en cascade --- */
		.tk-card:nth-child(3n+2),
		.tk-review:nth-child(3n+2),
		.tk-postcard:nth-child(3n+2),
		.tk-infos__cell:nth-child(3n+2),
		.tk-phase:nth-child(3n+2),
		.tk-line:nth-child(even),
		.tk-list__item:nth-child(even),
		.tk-faq__item:nth-child(even) { animation-range: entry 8% entry 68%; }
		.tk-card:nth-child(3n),
		.tk-review:nth-child(3n),
		.tk-postcard:nth-child(3n),
		.tk-infos__cell:nth-child(3n),
		.tk-phase:nth-child(3n) { animation-range: entry 16% entry 76%; }

		/* --- Phases : remplissage CONTINU, de la première à la dernière
		   étape (retour client) — tous les liserés partagent la timeline
		   de la grille, avec des fenêtres séquentielles qui se chevauchent
		   légèrement. L'ordre 01→05 tient sur tous les layouts. --- */
		@keyframes tkm-trace {
			to { transform: scaleX(1); }
		}
		.tk-phases { view-timeline-name: --tk-phases; }
		.tk-phase::after {
			animation: tkm-trace linear both;
			animation-timeline: --tk-phases;
		}
		.tk-phase:nth-child(1)::after { animation-range: cover 5% cover 30%; }
		.tk-phase:nth-child(2)::after { animation-range: cover 22% cover 47%; }
		.tk-phase:nth-child(3)::after { animation-range: cover 40% cover 65%; }
		.tk-phase:nth-child(4)::after { animation-range: cover 58% cover 83%; }
		.tk-phase:nth-child(5)::after { animation-range: cover 75% cover 100%; }

		/* --- Barre de lecture des articles : progression du scroll --- */
		@keyframes tkm-lecture {
			to { transform: scaleX(1); }
		}
		.tk-lecture {
			animation: tkm-lecture linear both;
			animation-timeline: scroll(root block);
		}

		/* Mobile : plages réduites (600/520/460/160/110). */
		@media (max-width: 768px) {
			.tk-hero__video { animation-range: 0 600px; }
			.tk-hero__halo--bleu,
			.tk-hero__halo--violet { animation-range: normal, 0 520px; }
			.tk-hero__in { animation-range: 0 460px; }
			.tk-hero__cue { animation-range: 0 110px; }
		}
	}
}
