/*
 * Charis scroll motion (T-SCROLL-B).
 *
 * The theme adds `.charis-scroll-motion` to <body> only when the scroll-motion
 * option is enabled. The JS tags targets with
 * data-charis-reveal="section|card|media|headline|button|text" and moves
 * data-charis-reveal-state from pending → revealing → revealed.
 *
 * Every type uses the same entrance effect: opacity 0 → 1. There is no
 * translate, scale, clip-path or blur, so content never moves sideways or
 * "floats" into place. Types only decide which element is tagged; cards keep
 * their stagger delay.
 *
 * With the body class absent — or with JS disabled — no selector matches, so
 * nothing is hidden. Transitions are scoped to the pending/revealing states:
 * once an element is revealed the theme's own hover transitions take over.
 */

.charis-scroll-motion {
	overflow-x: clip;
}

.charis-scroll-motion [data-charis-reveal] {
	--charis-reveal-duration: 600ms;
	--charis-reveal-easing: cubic-bezier(0.16, 1, 0.3, 1);
	--charis-reveal-delay: 0ms;
}

/* ---- Transition: only while pending or animating ------------------------- */

.charis-scroll-motion [data-charis-reveal][data-charis-reveal-state="pending"],
.charis-scroll-motion [data-charis-reveal][data-charis-reveal-state="revealing"] {
	will-change: opacity;
	transition: opacity var(--charis-reveal-duration) var(--charis-reveal-easing) var(--charis-reveal-delay);
}

/* ---- Hidden / revealed states -------------------------------------------- */

.charis-scroll-motion [data-charis-reveal][data-charis-reveal-state="pending"] {
	opacity: 0;
}

.charis-scroll-motion [data-charis-reveal][data-charis-reveal-state="revealing"] {
	opacity: 1;
}

/* Keyboard focus must never wait for the reveal animation. */
.charis-scroll-motion [data-charis-reveal][data-charis-reveal-state="pending"]:focus-within,
.charis-scroll-motion [data-charis-reveal][data-charis-reveal-state="revealing"]:focus-within {
	opacity: 1;
	transition: none;
}

/* ---- Reduced motion kill switch -----------------------------------------
 * JS never tags anything when reduce is active at load. This also covers a
 * user toggling the OS preference after the page has been initialised: any
 * pending element is forced visible and all reveal transitions are dropped.
 * The state attribute is part of the selector so this block wins by source
 * order over the pending/revealing rules without !important. */

@media (prefers-reduced-motion: reduce) {

	.charis-scroll-motion [data-charis-reveal][data-charis-reveal-state] {
		opacity: 1;
		transition: none;
		will-change: auto;
	}
}
