/*
 * Kestrel Ridge motion. Slow, smooth, nothing overshoots.
 * Everything animated sits inside prefers-reduced-motion: no-preference, so
 * reduced-motion visitors get the finished page. Only transform, opacity and
 * clip-path are animated.
 *
 * Reveal states reuse the base runtime (data-reveal, data-count, data-marquee).
 * Extra reveal values defined here: wipe, rule, bars, draw.
 */

@media (prefers-reduced-motion: no-preference) {
	/* ---- Hero entrance (CSS only; the image is never hidden) ---- */
	.kr-hero--home .kr-hero__media img,
	.kr-hero--page .kr-hero__media img { animation: kr-settle 1.6s var(--kr-ease-out) both; }
	@keyframes kr-settle { from { transform: scale(1.08); } to { transform: scale(1); } }

	.kr-rise { animation: kr-rise .95s var(--kr-ease-out) both; }
	.kr-rise--2 { animation-delay: .14s; }
	.kr-rise--3 { animation-delay: .28s; }
	.kr-rise--4 { animation-delay: .42s; }
	@keyframes kr-rise { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: none; } }

	/* ---- Extra reveal types, driven by the base IntersectionObserver ---- */
	.tf-js [data-reveal] { transition-timing-function: var(--kr-ease-out); }
	.tf-js [data-reveal="wipe"] { transition: clip-path 1.1s var(--kr-ease-in-out); }
	.tf-js [data-reveal="wipe"]:not(.is-in) { clip-path: inset(0 100% 0 0); }
	.tf-js [data-reveal="wipe"] img { transition: transform 1.3s var(--kr-ease-out); }
	.tf-js [data-reveal="wipe"]:not(.is-in) img { transform: scale(1.12); }

	.tf-js [data-reveal="rule"] { transition: transform .9s var(--kr-ease-in-out); }
	.tf-js [data-reveal="rule"]:not(.is-in) { transform: scaleX(0); }

	.tf-js [data-reveal="bars"] .kr-bars__track i { transition: transform .9s var(--kr-ease-out); transition-delay: calc(var(--kr-bi, 0) * 90ms); }
	.tf-js [data-reveal="bars"]:not(.is-in) .kr-bars__track i { transform: scaleX(0); }

	.tf-js [data-reveal="draw"] path { stroke-dasharray: 1; stroke-dashoffset: 0; transition: stroke-dashoffset 1.6s var(--kr-ease-in-out); }
	.tf-js [data-reveal="draw"] path:nth-of-type(2) { transition-delay: .15s; }
	.tf-js [data-reveal="draw"] path:nth-of-type(3) { transition-delay: .3s; }
	.tf-js [data-reveal="draw"]:not(.is-in) path { stroke-dashoffset: 1; }

	/* ---- Hover and focus ---- */
	.kr-option:hover, .kr-option:focus-within { transform: translateY(-6px); }
	.kr-wine__panel, .kr-bottle { will-change: transform; }

	/* ---- Status chip pulse ---- */
	.kr-status.is-open .kr-status__dot { animation: kr-pulse 2.6s ease-in-out infinite; }
	@keyframes kr-pulse { 0%, 100% { box-shadow: 0 0 0 0 rgb(157 179 122 / 55%); } 60% { box-shadow: 0 0 0 .5rem rgb(157 179 122 / 0%); } }

	/* ---- Header hide and show ---- */
	.site-header.is-hidden { transition-duration: .45s; }

	/* ---- Age notice ---- */
	.kr-age[open] { animation: kr-fade .6s var(--kr-ease-out); }
	.kr-age[open]::backdrop { animation: kr-fade .6s var(--kr-ease-out); }
	@keyframes kr-fade { from { opacity: 0; } to { opacity: 1; } }

	/* ---- FAQ: smooth height where supported ---- */
	@supports (interpolate-size: allow-keywords) {
		:root { interpolate-size: allow-keywords; }
		.wp-block-details::details-content { block-size: 0; overflow: clip; transition: block-size .45s var(--kr-ease-out), content-visibility .45s allow-discrete; }
		.wp-block-details[open]::details-content { block-size: auto; }
	}
}

/* ---- Scroll-driven animations (progressive enhancement) ---- */
@supports (animation-timeline: view()) {
	@media (prefers-reduced-motion: no-preference) {
		/* Footer wordmark slides up as the footer enters. */
		.kr-footer__mega { animation: kr-footer-rise linear both; animation-timeline: view(); animation-range: entry 0% entry 100%; }
		@keyframes kr-footer-rise { from { transform: translateY(40px); opacity: .2; } to { transform: none; opacity: 1; } }

		/* Vertical line draws as the steps scroll through. */
		.kr-steps::after { animation: kr-line linear both; animation-timeline: view(); animation-range: entry 25% cover 62%; }
		@keyframes kr-line { from { transform: scaleY(0); } to { transform: scaleY(1); } }

		/* Reading bar on journal posts. */
		.kr-read-bar { display: block; position: fixed; inset: 0 0 auto 0; z-index: 100001; height: 3px; background: var(--kr-shiraz); transform: scaleX(0); transform-origin: 0 50%; animation: kr-read linear both; animation-timeline: scroll(root block); }
		@keyframes kr-read { to { transform: scaleX(1); } }

		/* Band text drifts up over the sticky image. */
		.kr-band__line { animation: kr-drift linear both; animation-timeline: view(); animation-range: entry 10% cover 50%; }
		@keyframes kr-drift { from { opacity: 0; transform: translateY(60px); } to { opacity: 1; transform: none; } }

		/* Pinned horizontal seasons: wide screens only. */
		@media (min-width: 1024px) {
			.kr-seasons { view-timeline: --kr-seasons block; height: 420vh; position: relative; }
			.kr-seasons__pin { position: sticky; top: 0; height: 100svh; display: flex; flex-direction: column; padding-top: var(--tf-header-height); overflow: clip; background: var(--kr-bone); }
			.admin-bar .kr-seasons__pin { top: 32px; height: calc(100svh - 32px); }
			.kr-seasons__head { padding-block: var(--kr-space-4) var(--kr-space-3); }
			.kr-seasons__head .kr-h2 { margin-bottom: var(--kr-space-3); font-size: var(--kr-step-4); }
			.kr-seasons__rail { display: block; height: 1px; background: var(--kr-hair); position: relative; }
			.kr-seasons__rail i { position: absolute; inset: 0; background: var(--kr-shiraz); height: 3px; top: -1px; transform-origin: left; animation: kr-rail linear both; animation-timeline: --kr-seasons; animation-range: contain 0% contain 100%; }
			.kr-seasons__viewport { flex: 1; min-height: 0; overflow: clip; }
			.kr-seasons__track { display: flex; gap: 0; width: 400%; height: 100%; animation: kr-slide linear both; animation-timeline: --kr-seasons; animation-range: contain 0% contain 100%; }
			.kr-season { flex: 0 0 25%; grid-template-columns: 1fr 1fr; height: 100%; padding: var(--kr-space-4) var(--kr-gutter) var(--kr-space-5); align-items: center; gap: var(--kr-space-6); box-sizing: border-box; }
			.kr-season:nth-child(even) .kr-season__img { order: 0; }
			.kr-season__img { height: min(100%, 34rem); aspect-ratio: auto; }
			.kr-season__text { max-width: 30rem; }
			@keyframes kr-slide { to { transform: translateX(-75%); } }
			@keyframes kr-rail { from { transform: scaleX(.02); } to { transform: scaleX(1); } }
		}
	}
}

/* Cross-document view transitions: 300 ms fade, named shared images. */
@media (prefers-reduced-motion: no-preference) {
	::view-transition-group(*) { animation-duration: .6s; animation-timing-function: var(--kr-ease-in-out); }
}
@media (prefers-reduced-motion: reduce) {
	[style*="view-transition-name"] { view-transition-name: none !important; }
	.kr-status.is-open .kr-status__dot { animation: none; }
	.kr-band__text { min-height: 100svh; }
}
