/*
 * Reapit Base motion system. Tokens: settings.custom.motion.{duration.fast|base|slow, easing, revealDistance, stagger}.
 * Only transform, opacity and box-shadow animate (zero layout shift). Everything is off under prefers-reduced-motion
 * and when motion.js has not run (the `reapit-motion` class on <html> is the gate, so content is never hidden without JS).
 */
@layer reapit.base, reapit.blocks, reapit.variation;

/* ---- scroll reveal ---- */
html.reapit-motion .reapit-reveal {
	opacity: 0;
	transform: translateY(var(--wp--custom--motion--reveal-distance));
	transition:
		opacity var(--wp--custom--motion--duration--slow) var(--wp--custom--motion--easing),
		transform var(--wp--custom--motion--duration--slow) var(--wp--custom--motion--easing);
	transition-delay: calc(var(--reveal-index, 0) * var(--wp--custom--motion--stagger));
	will-change: opacity, transform;
}
html.reapit-motion .reapit-reveal.is-inview {
	opacity: 1;
	transform: none;
	will-change: auto;
}

/* ---- hero photo: slow Ken Burns (not on the Stone hero, which has its own scroll-linked scale) ---- */
html.reapit-motion .reapit-hero:not(.reapit-stone-hero) > .wp-block-cover__image-background,
html.reapit-motion .reapit-hero:not(.reapit-stone-hero) > .wp-block-cover__video-background {
	animation: reapit-kenburns 28s var(--wp--custom--motion--easing) both alternate infinite;
	transform-origin: 60% 40%;
}
@keyframes reapit-kenburns {
	from { transform: scale(1); }
	to { transform: scale(var(--wp--custom--hero--ken-burns-scale)); }
}

/* ---- hover micro-interactions ---- */
.reapit-card,
.wp-block-reapit-cta-item,
.reapit-agent,
.wp-block-post-template > li,
.is-style-shadow-card {
	transition:
		transform var(--wp--custom--motion--duration--base) var(--wp--custom--motion--easing),
		box-shadow var(--wp--custom--motion--duration--base) var(--wp--custom--motion--easing);
}
.reapit-card__media img,
.reapit-cta__media img,
.reapit-agent__photo img,
.wp-block-post-featured-image img {
	transition: transform var(--wp--custom--motion--duration--slow) var(--wp--custom--motion--easing);
}
.reapit-card:hover,
.reapit-card:focus-within,
.wp-block-reapit-cta-item:where(a):hover,
.wp-block-reapit-cta-item:where(a):focus-visible {
	transform: translateY(-4px);
}
.reapit-card:hover .reapit-card__media img,
.reapit-card:focus-within .reapit-card__media img,
.wp-block-reapit-cta-item:where(a):hover .reapit-cta__media img,
.wp-block-reapit-cta-item:where(a):focus-visible .reapit-cta__media img,
.reapit-agent:hover .reapit-agent__photo img,
.wp-block-post-template > li:hover .wp-block-post-featured-image img {
	transform: scale(1.03);
}
.wp-block-post-featured-image {
	overflow: hidden;
}

/* Buttons press, links underline from the left. */
.wp-block-button__link,
.reapit-button {
	transition:
		transform var(--wp--custom--motion--duration--fast) var(--wp--custom--motion--easing),
		background-color var(--wp--custom--motion--duration--fast) var(--wp--custom--motion--easing),
		color var(--wp--custom--motion--duration--fast) var(--wp--custom--motion--easing),
		border-color var(--wp--custom--motion--duration--fast) var(--wp--custom--motion--easing),
		box-shadow var(--wp--custom--motion--duration--fast) var(--wp--custom--motion--easing);
}
.wp-block-button__link:active,
.reapit-button:active {
	transform: scale(0.97);
}
.wp-block-navigation-item__content,
.reapit-nav-footer a,
.reapit-nav-legal a,
.wp-block-post-title a {
	background-image: linear-gradient(currentColor, currentColor);
	background-repeat: no-repeat;
	background-position: 0 100%;
	background-size: 0% 1px;
	text-decoration: none;
	transition: background-size var(--wp--custom--motion--duration--base) var(--wp--custom--motion--easing);
}
.wp-block-navigation-item__content:hover,
.wp-block-navigation-item__content:focus-visible,
.reapit-nav-footer a:hover,
.reapit-nav-legal a:hover,
.wp-block-post-title a:hover {
	background-size: 100% 1px;
	text-decoration: none;
}
.wp-block-navigation .wp-block-navigation-item__content:hover {
	text-decoration: none;
}

/* Details and slider dots ease consistently. */
.wp-block-details > summary::after,
.reapit-slider__dot,
.reapit-slider__track {
	transition-timing-function: var(--wp--custom--motion--easing);
}
.reapit-slider__dot {
	transition: opacity var(--wp--custom--motion--duration--base) var(--wp--custom--motion--easing), transform var(--wp--custom--motion--duration--base) var(--wp--custom--motion--easing);
}
.reapit-slider__dot.is-active {
	transform: scale(1.25);
}

/* ---- header on scroll ---- */
.wp-site-blocks > header > .wp-block-group {
	transition: box-shadow var(--wp--custom--motion--duration--base) var(--wp--custom--motion--easing), background-color var(--wp--custom--motion--duration--base) var(--wp--custom--motion--easing);
}
.wp-site-blocks > header.is-scrolled > .wp-block-group {
	box-shadow: 0 1px 0 var(--wp--preset--color--border), 0 0.75rem 2rem -1.25rem color-mix(in srgb, var(--wp--preset--color--contrast) 45%, transparent);
}
.wp-site-blocks > header .wp-block-site-logo img,
.wp-site-blocks > header .wp-block-site-title {
	transition: transform var(--wp--custom--motion--duration--base) var(--wp--custom--motion--easing);
	transform-origin: left center;
}

/* ---- dialogs (share, agent contact, gallery lightbox, video): fade and rise on open; CSS only ---- */
html.reapit-motion dialog.reapit-dialog {
	transition:
		opacity var(--wp--custom--motion--duration--base) var(--wp--custom--motion--easing),
		translate var(--wp--custom--motion--duration--base) var(--wp--custom--motion--easing),
		overlay var(--wp--custom--motion--duration--base) allow-discrete,
		display var(--wp--custom--motion--duration--base) allow-discrete;
	opacity: 0;
	translate: 0 0.5rem;
}
html.reapit-motion dialog.reapit-dialog[open] {
	opacity: 1;
	translate: 0 0;
}
@starting-style {
	html.reapit-motion dialog.reapit-dialog[open] {
		opacity: 0;
		translate: 0 0.5rem;
	}
}
html.reapit-motion dialog.reapit-dialog::backdrop {
	transition:
		opacity var(--wp--custom--motion--duration--base) var(--wp--custom--motion--easing),
		overlay var(--wp--custom--motion--duration--base) allow-discrete,
		display var(--wp--custom--motion--duration--base) allow-discrete;
	opacity: 0;
}
html.reapit-motion dialog.reapit-dialog[open]::backdrop {
	opacity: 1;
}
@starting-style {
	html.reapit-motion dialog.reapit-dialog[open]::backdrop {
		opacity: 0;
	}
}

/* ---- details marked .reapit-details-animate: the content eases open (height + fade) ---- */
html.reapit-motion .reapit-details-animate {
	interpolate-size: allow-keywords;
}
html.reapit-motion .reapit-details-animate::details-content {
	block-size: 0;
	opacity: 0;
	overflow-y: clip;
	transition:
		block-size var(--wp--custom--motion--duration--base) var(--wp--custom--motion--easing),
		opacity var(--wp--custom--motion--duration--base) var(--wp--custom--motion--easing),
		content-visibility var(--wp--custom--motion--duration--base) allow-discrete;
}
html.reapit-motion .reapit-details-animate[open]::details-content {
	block-size: auto;
	opacity: 1;
}
/* Browsers without ::details-content: fade the content in on open. */
@supports not selector(::details-content) {
	html.reapit-motion .reapit-details-animate[open] > :not(summary) {
		animation: reapit-fade-in var(--wp--custom--motion--duration--base) var(--wp--custom--motion--easing) both;
	}
}
@keyframes reapit-fade-in {
	from { opacity: 0; transform: translateY(0.5rem); }
	to { opacity: 1; transform: none; }
}

/* ---- keyboard focus ---- */
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
	outline: 2px solid var(--wp--preset--color--accent);
	outline-offset: 3px;
}
/* Soften the ring on text links only: controls keep their brand radius (Swell pills, Promontory squares). */
:where(a:not(.wp-block-button__link, .reapit-button), summary):focus-visible {
	border-radius: 2px;
}
.wp-block-button__link:focus-visible {
	outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
	html.reapit-motion .reapit-reveal {
		opacity: 1;
		transform: none;
		transition: none;
	}
	html.reapit-motion .reapit-hero > .wp-block-cover__image-background,
	html.reapit-motion .reapit-hero > .wp-block-cover__video-background,
	html.reapit-motion .reapit-details-animate[open] > :not(summary) {
		animation: none;
	}
	html.reapit-motion dialog.reapit-dialog,
	html.reapit-motion dialog.reapit-dialog::backdrop,
	html.reapit-motion .reapit-details-animate::details-content {
		transition: none;
	}
	.reapit-card, .wp-block-reapit-cta-item, .reapit-agent, .wp-block-post-template > li, .is-style-shadow-card,
	.reapit-card__media img, .reapit-cta__media img, .reapit-agent__photo img, .wp-block-post-featured-image img,
	.wp-block-button__link, .reapit-button, .wp-block-navigation-item__content, .reapit-nav-footer a, .reapit-nav-legal a,
	.wp-block-post-title a, .reapit-slider__dot, .wp-site-blocks > header > .wp-block-group,
	.wp-site-blocks > header .wp-block-site-logo img, .wp-site-blocks > header .wp-block-site-title {
		transition: none;
	}
	.reapit-card:hover, .wp-block-reapit-cta-item:where(a):hover,
	.reapit-card:hover .reapit-card__media img, .wp-block-reapit-cta-item:where(a):hover .reapit-cta__media img,
	.reapit-agent:hover .reapit-agent__photo img, .wp-block-post-template > li:hover .wp-block-post-featured-image img {
		transform: none;
	}
}
