/* One motion language for the whole theme: the same easings, distances and
   durations wherever something moves. Travel is zeroed rather than switched off
   under a reduced-motion preference, so a fade survives where movement does not.

   The registered properties are the ones animated on their own, outside a
   transform shorthand, so an ambient loop and a pointer offset can share one
   element without overwriting each other. */

@property --vamora-float {
	syntax: "<length>";
	inherits: false;
	initial-value: 0px;
}

@property --vamora-angle {
	syntax: "<angle>";
	inherits: false;
	initial-value: 0deg;
}

@property --vamora-sway {
	syntax: "<angle>";
	inherits: false;
	initial-value: 0deg;
}

/* How far a scene has pulled a layer against the scroll. */
@property --vamora-depth {
	syntax: "<length>";
	inherits: false;
	initial-value: 0px;
}

:root {
	--motion-rise: 1.75rem;
	--motion-shift: 3rem;
	--motion-blur: 10px;
	--motion-word-rise: 0.4em;
	--motion-word-blur: 8px;
	--motion-lift: 6px;
	--motion-zoom: 1.06;
	--motion-scale-from: 0.94;
	--motion-pop-from: 0.72;

	--motion-fast: 180ms;
	--motion-ui: 320ms;
	--motion-reveal: 720ms;
	--motion-slow: 1100ms;
	--motion-draw: 1600ms;

	--motion-stagger: 70ms;
	--motion-stagger-tight: 38ms;

	/* Smooth scroll: how long the page takes to catch up with the wheel, how
	   far behind it a scroll-linked tween trails, and the breathing room an
	   anchor leaves above its target where the page states none. */
	--motion-scroll-duration: 1.05s;
	--motion-scroll-scrub: 0.6s;
	--motion-anchor-gap: 16px;

	/* How faint a word sits before the scroll fills it in, and how far apart
	   the words are handed their turn. */
	--motion-dim: 0.35;
	--motion-scrub-stagger: 0.4s;

	--motion-out: cubic-bezier(0.16, 0.84, 0.34, 1);
	--motion-inout: cubic-bezier(0.65, 0, 0.35, 1);
	--motion-spring: cubic-bezier(0.34, 1.42, 0.64, 1);

	/* A spring that overshoots and settles, for something let go of: a control
	   the pointer has left falls back to rest instead of stopping dead. */
	--motion-elastic: linear(0, 0.34 8%, 0.78 17%, 1.09 29%, 1.05 40%, 0.98 52%, 1.01 66%, 1);

	--motion-float-travel: 0.75rem;
	--motion-float-cycle: 7s;
	--motion-pulse-cycle: 2.8s;
	--motion-drift-cycle: 19s;
	--motion-gradient-cycle: 9s;
	--motion-spin-cycle: 70s;
	--motion-sheen-cycle: 5.5s;
	--motion-ring-cycle: 4s;
	--motion-ripple-cycle: 1.1s;

	--motion-tilt: 6deg;
	--motion-perspective: 56rem;
	--motion-spot: 0.16;
	--motion-magnet: 0.22;

	/* The header button's hover: how far its ripple spreads (across, then down,
	   so the pill grows evenly all round) and how bright its fill pulses. */
	--motion-ripple: 1.14 1.5;
	--motion-glow: 1.12;

	/* Layered art: how far a layer of depth 1 leans toward the pointer and
	   travels against the scroll, and how far it rocks while it floats. */
	--motion-parallax: 18px;
	--motion-depth: 5rem;
	--motion-sway: 2.5deg;
	--motion-roll: 9deg;
	--motion-settle: 0.94;

	--motion-count: 1300ms;
	--motion-sway-cycle: 9s;
	--motion-twinkle-cycle: 3.4s;
	--motion-border-cycle: 5s;
	--motion-sweep-cycle: 6s;
	--motion-status-cycle: 7.5s;
	--motion-screen-cycle: 6s;
	--motion-flicker-cycle: 1.4s;
}

@media (prefers-reduced-motion: reduce) {
	:root {
		--motion-rise: 0px;
		--motion-shift: 0px;
		--motion-blur: 0px;
		--motion-word-rise: 0px;
		--motion-word-blur: 0px;
		--motion-lift: 0px;
		--motion-zoom: 1;
		--motion-scale-from: 1;
		--motion-pop-from: 1;
		--motion-float-travel: 0px;
		--motion-tilt: 0deg;
		--motion-magnet: 0;
		--motion-parallax: 0px;
		--motion-depth: 0px;
		--motion-sway: 0deg;
		--motion-roll: 0deg;
		--motion-settle: 1;
	}
}

/* The loops every page draws on: the light streak, the drift, the slow turn,
   the pulse, the rock and the twinkle. */
@keyframes vamora-sheen {
	0% {
		transform: translateX(-180%) skewX(-18deg);
	}

	45%,
	100% {
		transform: translateX(320%) skewX(-18deg);
	}
}

@keyframes vamora-turn {
	to {
		--vamora-angle: 360deg;
	}
}

@keyframes vamora-float {
	from {
		--vamora-float: calc(-1 * var(--motion-float-travel) / 2);
	}

	to {
		--vamora-float: calc(var(--motion-float-travel) / 2);
	}
}

@keyframes vamora-float-up {
	from {
		--vamora-float: 0px;
	}

	to {
		--vamora-float: calc(-1 * var(--motion-float-travel));
	}
}

@keyframes vamora-gradient {
	from {
		background-position: 0% 50%;
	}

	to {
		background-position: 100% 50%;
	}
}

@keyframes vamora-glow {
	from {
		transform: translate3d(0, 0, 0) scale(1);
	}

	to {
		transform: translate3d(-6%, 8%, 0) scale(1.12);
	}
}

@keyframes vamora-pulse {
	0%,
	100% {
		box-shadow: 0 0 0 0 rgb(var(--rgb-primary) / 0.35);
	}

	70% {
		box-shadow: 0 0 0 0.75rem rgb(var(--rgb-primary) / 0);
	}
}

@keyframes vamora-sway {
	from {
		--vamora-sway: calc(-1 * var(--motion-sway));
	}

	to {
		--vamora-sway: var(--motion-sway);
	}
}

@keyframes vamora-twinkle {
	0%,
	100% {
		opacity: 0.45;
		scale: 0.72;
		rotate: 0deg;
	}

	50% {
		opacity: 1;
		scale: 1.06;
		rotate: 20deg;
	}
}
