/**
 * Motion.
 *
 * Two rules govern everything in this file:
 *
 *   1. Nothing here may hide content. Every animated element is fully visible
 *      before JavaScript runs and stays visible if JavaScript never arrives —
 *      the .js class gates the starting state, so a no-JS visitor sees the
 *      finished layout rather than a page of invisible blocks.
 *
 *   2. prefers-reduced-motion wins. Not "reduced motion", not "a gentler
 *      version" — off. Vestibular disorders are not a design preference.
 *
 * Motion can also be switched off site-wide in the Customizer, in which case
 * this stylesheet is never loaded at all.
 */

/* ==========================================================================
   Scroll-triggered reveals
   ========================================================================== */

:root {
	--stoess-reveal-distance: 1.5rem;
	--stoess-reveal-duration: 620ms;
	--stoess-reveal-delay: 0ms;
	--stoess-reveal-ease: cubic-bezier(.22, .68, .28, 1);
}

.motion-subtle {
	--stoess-reveal-distance: .875rem;
	--stoess-reveal-duration: 480ms;
}

.motion-lively {
	--stoess-reveal-distance: 2.25rem;
	--stoess-reveal-duration: 760ms;
}

/*
 * The starting state only applies once JavaScript has confirmed it can put the
 * elements back. .is-observed is added by motion.js the moment it takes charge
 * of an element.
 */
.js.has-motion [data-animate].is-observed {
	opacity: 0;
	transition:
		opacity var(--stoess-reveal-duration) var(--stoess-reveal-ease) var(--stoess-reveal-delay),
		transform var(--stoess-reveal-duration) var(--stoess-reveal-ease) var(--stoess-reveal-delay);
	will-change: opacity, transform;
}

.js.has-motion [data-animate="fade-up"].is-observed {
	transform: translateY(var(--stoess-reveal-distance));
}

.js.has-motion [data-animate="slide-left"].is-observed {
	transform: translateX(calc(var(--stoess-reveal-distance) * -1.5));
}

.js.has-motion [data-animate="slide-right"].is-observed {
	transform: translateX(calc(var(--stoess-reveal-distance) * 1.5));
}

.js.has-motion [data-animate="zoom-in"].is-observed {
	transform: scale(.965);
}

.js.has-motion [data-animate].is-revealed {
	opacity: 1;
	transform: none;
	will-change: auto;
}

/* Draw a rule -------------------------------------------------------------- */

.js.has-motion [data-animate="rule-draw"].is-observed {
	opacity: 1;
	transform: scaleX(0);
	transform-origin: left center;
	transition: transform var(--stoess-reveal-duration) var(--stoess-reveal-ease) var(--stoess-reveal-delay);
}

.js.has-motion [data-animate="rule-draw"].is-revealed {
	transform: scaleX(1);
}

/* Stagger children --------------------------------------------------------- */

.js.has-motion [data-animate="stagger"].is-observed {
	opacity: 1;
	transform: none;
}

.js.has-motion [data-animate="stagger"].is-observed > * {
	opacity: 0;
	transform: translateY(var(--stoess-reveal-distance));
	transition:
		opacity var(--stoess-reveal-duration) var(--stoess-reveal-ease),
		transform var(--stoess-reveal-duration) var(--stoess-reveal-ease);
}

.js.has-motion [data-animate="stagger"].is-revealed > * {
	opacity: 1;
	transform: none;
}

/* Six steps is plenty; anything beyond simply arrives with the sixth. */
.js.has-motion [data-animate="stagger"].is-revealed > *:nth-child(1) { transition-delay: calc(var(--stoess-reveal-delay) + 0ms); }
.js.has-motion [data-animate="stagger"].is-revealed > *:nth-child(2) { transition-delay: calc(var(--stoess-reveal-delay) + 70ms); }
.js.has-motion [data-animate="stagger"].is-revealed > *:nth-child(3) { transition-delay: calc(var(--stoess-reveal-delay) + 140ms); }
.js.has-motion [data-animate="stagger"].is-revealed > *:nth-child(4) { transition-delay: calc(var(--stoess-reveal-delay) + 210ms); }
.js.has-motion [data-animate="stagger"].is-revealed > *:nth-child(5) { transition-delay: calc(var(--stoess-reveal-delay) + 280ms); }
.js.has-motion [data-animate="stagger"].is-revealed > *:nth-child(n+6) { transition-delay: calc(var(--stoess-reveal-delay) + 350ms); }

/* ==========================================================================
   The practice grid arrives card by card
   ========================================================================== */

.js.has-motion .c-practice-grid.is-observed > * {
	opacity: 0;
	transform: translateY(1.25rem);
	transition:
		opacity 560ms var(--stoess-reveal-ease),
		transform 560ms var(--stoess-reveal-ease);
}

.js.has-motion .c-practice-grid.is-revealed > * {
	opacity: 1;
	transform: none;
}

.js.has-motion .c-practice-grid.is-revealed > *:nth-child(1) { transition-delay: 0ms; }
.js.has-motion .c-practice-grid.is-revealed > *:nth-child(2) { transition-delay: 60ms; }
.js.has-motion .c-practice-grid.is-revealed > *:nth-child(3) { transition-delay: 120ms; }
.js.has-motion .c-practice-grid.is-revealed > *:nth-child(4) { transition-delay: 180ms; }
.js.has-motion .c-practice-grid.is-revealed > *:nth-child(5) { transition-delay: 240ms; }
.js.has-motion .c-practice-grid.is-revealed > *:nth-child(6) { transition-delay: 300ms; }
.js.has-motion .c-practice-grid.is-revealed > *:nth-child(7) { transition-delay: 360ms; }
.js.has-motion .c-practice-grid.is-revealed > *:nth-child(n+8) { transition-delay: 420ms; }

/* ==========================================================================
   Hero
   ========================================================================== */

/*
 * The hero is above the fold, so it animates on load rather than on scroll —
 * and it animates its contents, never its own box, so the layout never shifts
 * (which would show up as Cumulative Layout Shift).
 */
.js.has-motion .c-hero__inner > * {
	opacity: 0;
	transform: translateY(1rem);
	animation: stoess-hero-in 760ms var(--stoess-reveal-ease) forwards;
}

.js.has-motion .c-hero__inner > *:nth-child(1) { animation-delay: 90ms; }
.js.has-motion .c-hero__inner > *:nth-child(2) { animation-delay: 190ms; }
.js.has-motion .c-hero__inner > *:nth-child(3) { animation-delay: 290ms; }
.js.has-motion .c-hero__inner > *:nth-child(4) { animation-delay: 390ms; }
.js.has-motion .c-hero__inner > *:nth-child(n+5) { animation-delay: 470ms; }

@keyframes stoess-hero-in {
	to {
		opacity: 1;
		transform: none;
	}
}

/* The image is scaled slightly so parallax has somewhere to travel. */
.js.has-motion .c-hero__media[data-parallax] .c-hero__image {
	transform: scale(1.08) translate3d(0, var(--stoess-parallax-y, 0), 0);
	transition: transform 60ms linear;
}

/* The gold rule under a section heading draws itself in. */
.js.has-motion .c-section-heading.is-revealed .c-rule,
.js.has-motion .c-page-header.is-revealed .c-rule {
	animation: stoess-rule-draw 620ms var(--stoess-reveal-ease) 180ms both;
}

@keyframes stoess-rule-draw {
	from { transform: scaleX(0); }
	to   { transform: scaleX(1); }
}

.c-section-heading .c-rule,
.c-page-header .c-rule {
	transform-origin: center;
}

.c-section-heading.is-align-left .c-rule {
	transform-origin: left center;
}

/* ==========================================================================
   Hover and interaction polish
   ========================================================================== */

.has-motion .c-card,
.has-motion .c-practice-card,
.has-motion .c-link-card {
	transition:
		transform 260ms var(--stoess-reveal-ease),
		box-shadow 260ms var(--stoess-reveal-ease),
		border-color 260ms var(--stoess-reveal-ease);
}

.has-motion .wp-block-image.is-style-soft img,
.has-motion .c-card__media img {
	transition: transform 620ms var(--stoess-reveal-ease);
}

.has-motion .wp-block-image.is-style-soft:hover img,
.has-motion .c-card:hover .c-card__media img {
	transform: scale(1.035);
}

.has-motion .wp-block-image.is-style-soft {
	overflow: hidden;
	border-radius: var(--s-radius-lg, 10px);
}

.has-motion .c-hours-status.is-open .c-hours-status__dot {
	animation: stoess-pulse 2.4s ease-in-out infinite;
}

@keyframes stoess-pulse {
	0%, 100% { opacity: 1; transform: scale(1); }
	50%      { opacity: .55; transform: scale(.82); }
}

/* ==========================================================================
   The override that matters
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
	*,
	*::before,
	*::after {
		animation-duration: .01ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: .01ms !important;
		scroll-behavior: auto !important;
	}

	/*
	 * Belt and braces: force every animated element to its finished state so a
	 * near-zero transition duration can never leave content invisible.
	 */
	.js.has-motion [data-animate],
	.js.has-motion [data-animate] > *,
	.js.has-motion .c-practice-grid > *,
	.js.has-motion .c-hero__inner > * {
		opacity: 1 !important;
		transform: none !important;
		animation: none !important;
	}

	.js.has-motion .c-hero__media[data-parallax] .c-hero__image {
		transform: none !important;
	}
}
