/*
 * Bhatko motion: scroll reveals, image wipes, hero entrance and hover polish.
 *
 * Reveals run only when <html> has .bhatko-motion, which is set in <head>
 * when the visitor allows motion. Individual transform properties
 * (translate, scale, rotate) are used so they never fight a block's own
 * transform.
 */

:root {
	--bhatko-ease: cubic-bezier(0.16, 1, 0.3, 1);
	--bhatko-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ---------- Scroll reveals ---------- */

.bhatko-motion [data-reveal] {
	opacity: 0;
	transition:
		opacity 0.8s var(--bhatko-ease),
		translate 0.95s var(--bhatko-ease),
		rotate 0.95s var(--bhatko-ease),
		clip-path 1.2s var(--bhatko-ease);
	transition-delay: var(--reveal-delay, 0ms);
}

.bhatko-motion [data-reveal="rise"] {
	translate: 0 2.25rem;
}

.bhatko-motion [data-reveal="slide"] {
	translate: -1.25rem 0;
}

.bhatko-motion [data-reveal="drop"] {
	translate: 0 -1.5rem;
	rotate: -5deg;
	transition-timing-function: var(--bhatko-ease), var(--bhatko-spring), var(--bhatko-spring), linear;
	transition-duration: 0.6s, 0.85s, 0.85s, 0s;
}

.bhatko-motion [data-reveal="wordmark"] {
	opacity: 1;
	translate: 0 30%;
	clip-path: inset(0 0 100% 0);
}

.bhatko-motion [data-reveal].is-revealed {
	opacity: 1;
	translate: none;
	rotate: none;
	clip-path: inset(0 0 0 0);
}

/* ---------- Image wipe: unveils downward, top edge first, while settling from a zoom ---------- */

.bhatko-motion [data-wipe] {
	clip-path: inset(0 0 100% 0);
	transition: clip-path 1.15s var(--bhatko-ease) var(--reveal-delay, 0ms);
}

.bhatko-motion [data-wipe] img {
	scale: 1.18;
	transition: scale 1.7s var(--bhatko-ease) var(--reveal-delay, 0ms), transform 0.9s var(--bhatko-ease);
}

.bhatko-motion [data-wipe].is-revealed {
	clip-path: inset(0 0 0 0);
}

.bhatko-motion [data-wipe].is-revealed img {
	scale: 1;
}

/* ---------- Difficulty: the peaks rise, smallest first, then the snow settles ---------- */

.bhatko-motion [data-reveal="peaks"] {
	opacity: 1;
}

.bhatko-motion [data-reveal="peaks"] .bhatko-difficulty__peaks polygon {
	transform-box: fill-box;
	transform-origin: 50% 100%;
	scale: 1 0;
	transition: scale 0.7s var(--bhatko-spring);
	transition-delay: calc(var(--reveal-delay, 0ms) + 0.25s + (var(--i, 1) - 1) * 0.16s);
}

.bhatko-motion [data-reveal="peaks"] .bhatko-difficulty__snow {
	transform-origin: 50% 0;
	scale: 1;
	opacity: 0;
	translate: 0 -3px;
	transition: opacity 0.4s ease, translate 0.5s var(--bhatko-ease);
	transition-delay: calc(var(--reveal-delay, 0ms) + 0.75s + (var(--i, 1) - 1) * 0.16s);
}

.bhatko-motion [data-reveal="peaks"] .bhatko-difficulty__label {
	opacity: 0;
	transition: opacity 0.5s ease calc(var(--reveal-delay, 0ms) + 0.5s);
}

.bhatko-motion [data-reveal="peaks"].is-revealed .bhatko-difficulty__peaks polygon {
	scale: 1 1;
}

.bhatko-motion [data-reveal="peaks"].is-revealed .bhatko-difficulty__snow {
	opacity: 1;
	translate: 0 0;
}

.bhatko-motion [data-reveal="peaks"].is-revealed .bhatko-difficulty__label {
	opacity: 1;
}

/* On hover the filled peaks give a small hop, one after another. */
@media (hover: hover) and (prefers-reduced-motion: no-preference) {
	:is(.bhatko-card, .bhatko-trip):hover .wp-block-bhatko-difficulty .is-on {
		animation: bhatko-peak-hop 0.55s var(--bhatko-ease) calc((var(--i, 1) - 1) * 0.08s);
	}
}

@keyframes bhatko-peak-hop {
	40% { translate: 0 -2.5px; }
}

/* ---------- Hero entrance ---------- */

.bhatko-motion :is(.bhatko-hero, .bhatko-place-hero) .wp-block-cover__image-background {
	scale: 1.12;
	transition: scale 2.8s var(--bhatko-ease);
}

.bhatko-motion :is(.bhatko-hero, .bhatko-place-hero) :is(.wp-block-column:first-child, .wp-block-group.alignwide) > *,
.bhatko-motion .bhatko-hero .wp-block-bhatko-image-credit {
	opacity: 0;
	translate: 0 1.6rem;
	transition: opacity 0.9s var(--bhatko-ease), translate 1.1s var(--bhatko-ease);
}

.bhatko-motion .bhatko-hero__panel {
	opacity: 0;
	translate: 2.5rem 0;
	transition: opacity 0.9s var(--bhatko-ease) 0.55s, translate 1.1s var(--bhatko-ease) 0.55s;
}

.bhatko-motion .bhatko-hero .bhatko-board__row {
	opacity: 0;
	translate: 1rem 0;
	transition: opacity 0.6s var(--bhatko-ease), translate 0.8s var(--bhatko-ease);
}

.bhatko-motion :is(.bhatko-hero, .bhatko-place-hero) :is(.wp-block-column:first-child, .wp-block-group.alignwide) > :nth-child(1) { transition-delay: 0.1s; }
.bhatko-motion :is(.bhatko-hero, .bhatko-place-hero) :is(.wp-block-column:first-child, .wp-block-group.alignwide) > :nth-child(2) { transition-delay: 0.22s; }
.bhatko-motion :is(.bhatko-hero, .bhatko-place-hero) :is(.wp-block-column:first-child, .wp-block-group.alignwide) > :nth-child(3) { transition-delay: 0.36s; }
.bhatko-motion :is(.bhatko-hero, .bhatko-place-hero) :is(.wp-block-column:first-child, .wp-block-group.alignwide) > :nth-child(4) { transition-delay: 0.5s; }
.bhatko-motion .bhatko-hero .wp-block-bhatko-image-credit { transition-delay: 0.9s; }
.bhatko-motion .bhatko-hero .bhatko-board__row:nth-child(1) { transition-delay: 0.75s; }
.bhatko-motion .bhatko-hero .bhatko-board__row:nth-child(2) { transition-delay: 0.83s; }
.bhatko-motion .bhatko-hero .bhatko-board__row:nth-child(3) { transition-delay: 0.91s; }
.bhatko-motion .bhatko-hero .bhatko-board__row:nth-child(4) { transition-delay: 0.99s; }
.bhatko-motion .bhatko-hero .bhatko-board__row:nth-child(n+5) { transition-delay: 1.07s; }

.bhatko-hero-in :is(.bhatko-hero, .bhatko-place-hero) .wp-block-cover__image-background {
	scale: 1;
}

.bhatko-hero-in :is(.bhatko-hero, .bhatko-place-hero) :is(.wp-block-column:first-child, .wp-block-group.alignwide) > *,
.bhatko-hero-in .bhatko-hero :is(.wp-block-bhatko-image-credit, .bhatko-hero__panel, .bhatko-board__row) {
	opacity: 1;
	translate: none;
}

/* ---------- Header: tightens on scroll, with a reading-progress line ---------- */

.bhatko-mainbar {
	position: relative;
	transition: padding 0.35s var(--bhatko-ease), box-shadow 0.35s ease;
}

.bhatko-wordmark-logo img {
	transition: width 0.35s var(--bhatko-ease);
}

.bhatko-header.is-scrolled .bhatko-wordmark-logo img {
	width: 124px !important;
}

.bhatko-header.is-scrolled .bhatko-mainbar {
	padding-top: 0.5rem !important;
	padding-bottom: 0.5rem !important;
	box-shadow: 0 14px 30px -22px rgb(18 20 23 / 0.55);
}

@supports (animation-timeline: scroll()) {
	@media (prefers-reduced-motion: no-preference) {
		.bhatko-mainbar::after {
			content: "";
			position: absolute;
			left: 0;
			bottom: -2px;
			width: 100%;
			height: 3px;
			background: var(--wp--preset--color--accent-1);
			transform-origin: left;
			animation: bhatko-progress linear both;
			animation-timeline: scroll(root);
		}
	}
}

@keyframes bhatko-progress {
	from { scale: 0 1; }
	to { scale: 1 1; }
}

/* ---------- Hover: buttons ---------- */

.wp-block-button__link,
.bhatko-form__submit {
	position: relative;
	overflow: hidden;
	transition:
		background-color 0.3s ease,
		color 0.3s ease,
		border-color 0.3s ease,
		translate 0.35s var(--bhatko-ease),
		box-shadow 0.35s var(--bhatko-ease);
}

/* A glint sweeps across, like sun on a road sign. */
.wp-block-button__link::before,
.bhatko-form__submit::before {
	content: "";
	position: absolute;
	inset: 0 auto 0 -60%;
	width: 45%;
	background: linear-gradient(100deg, transparent, rgb(255 255 255 / 0.38), transparent);
	transform: skewX(-20deg);
	pointer-events: none;
}

.bhatko-arrow .wp-block-button__link::after,
.bhatko-form__submit span,
.wp-block-read-more.bhatko-arrow::after {
	display: inline-block;
	transition: translate 0.35s var(--bhatko-ease);
}

@media (hover: hover) and (prefers-reduced-motion: no-preference) {
	.wp-block-button__link:hover,
	.bhatko-form__submit:hover {
		translate: 0 -3px;
		box-shadow: 0 4px 0 0 var(--wp--preset--color--accent-1);
	}

	.is-style-bhatko-signal .wp-block-button__link:hover {
		box-shadow: 0 4px 0 0 var(--wp--preset--color--contrast);
	}

	.wp-block-button__link:hover::before,
	.bhatko-form__submit:hover::before {
		translate: 420% 0;
		transition: translate 0.75s var(--bhatko-ease);
	}

	.bhatko-arrow .wp-block-button__link:hover::after,
	.bhatko-form__submit:hover span,
	.wp-block-read-more.bhatko-arrow:hover::after {
		translate: 0.3rem 0;
	}

	.wp-block-button__link:active,
	.bhatko-form__submit:active {
		translate: 0 0;
		box-shadow: 0 1px 0 0 var(--wp--preset--color--accent-1);
	}
}

/* ---------- Hover: menus, an underline that draws in from the left ---------- */

.wp-block-navigation .wp-block-navigation-item__content {
	text-decoration: none !important;
	background: linear-gradient(currentColor, currentColor) 0 100% / 0 2px no-repeat;
	transition: background-size 0.35s var(--bhatko-ease), color 0.2s ease;
	padding-bottom: 2px;
}

.wp-block-navigation .wp-block-navigation-item__content:hover,
.wp-block-navigation .wp-block-navigation-item__content:focus-visible,
.wp-block-navigation .current-menu-item > .wp-block-navigation-item__content {
	background-size: 100% 2px;
}

.bhatko-footer-nav .wp-block-navigation-item__content:hover {
	color: var(--wp--preset--color--accent-1);
}

/* ---------- Hover: cards ---------- */

/* Titles get a signal-yellow marker stroke. */
.bhatko-card .wp-block-post-title a,
.bhatko-trip .wp-block-post-title a,
.bhatko-region__name a {
	background: linear-gradient(var(--wp--preset--color--accent-1), var(--wp--preset--color--accent-1)) 0 92% / 0 0.22em no-repeat;
	transition: background-size 0.5s var(--bhatko-ease);
}

.bhatko-region__name a {
	background-position: 0 96%;
}

.bhatko-card:hover .wp-block-post-title a,
.bhatko-card:focus-within .wp-block-post-title a,
.bhatko-trip:hover .wp-block-post-title a,
.bhatko-region:hover .bhatko-region__name a,
.bhatko-region:focus-within .bhatko-region__name a {
	background-size: 100% 0.22em;
}

.bhatko-card .wp-block-bhatko-milestone {
	transition: translate 0.45s var(--bhatko-spring), rotate 0.45s var(--bhatko-spring), opacity 0.6s ease;
}

.bhatko-trip .wp-block-post-featured-image {
	overflow: hidden;
}

.bhatko-trip .wp-block-post-featured-image img,
.bhatko-region {
	transition: transform 0.9s var(--bhatko-ease), translate 0.5s var(--bhatko-ease), box-shadow 0.5s ease, opacity 0.8s var(--bhatko-ease);
}

.bhatko-region-filter .children a {
	transition: background-color 0.25s ease, color 0.25s ease, border-color 0.25s ease, translate 0.3s var(--bhatko-ease);
}

@media (hover: hover) and (prefers-reduced-motion: no-preference) {
	.bhatko-card:hover .wp-block-bhatko-milestone {
		translate: 0 -8px;
		rotate: -3deg;
	}

	.bhatko-trip:hover .wp-block-post-featured-image img {
		transform: scale(1.045);
	}

	.bhatko-region:hover {
		translate: 0 -6px;
		box-shadow: 0 24px 40px -26px rgb(18 20 23 / 0.7);
	}

	/* Status board rows: a soft highlight and a nudge. */
	.wp-block-bhatko-status-board .bhatko-board__row {
		transition: background-color 0.25s ease, padding 0.35s var(--bhatko-ease), opacity 0.8s var(--bhatko-ease), translate 0.95s var(--bhatko-ease);
	}

	.wp-block-bhatko-status-board .bhatko-board__row:hover {
		background-color: color-mix(in srgb, currentColor 6%, transparent);
		padding-left: 0.6rem;
		padding-right: 0.6rem;
	}

	.bhatko-region-filter .children a:hover {
		translate: 0 -2px;
	}
}

/* ---------- Footprints: someone walks along behind the mouse ---------- */

.bhatko-step {
	position: fixed;
	top: 0;
	left: 0;
	z-index: 9999;
	width: 11px;
	height: 21px;
	margin: -10.5px 0 0 -5.5px;
	background: url(../images/footprint.svg) center / contain no-repeat;
	pointer-events: none;
	opacity: 0;
}

.bhatko-step.is-down {
	animation: bhatko-step 1s ease-out forwards;
}

@keyframes bhatko-step {
	0% { opacity: 0; scale: 0.85; }
	8% { opacity: 0.9; scale: 1; }
	45% { opacity: 0.7; }
	100% { opacity: 0; scale: 1; }
}

/* Anyone who asks for less motion gets none. */
@media (prefers-reduced-motion: reduce) {
	*,
	*::before,
	*::after {
		transition-duration: 0.01ms !important;
		animation-duration: 0.01ms !important;
		scroll-behavior: auto !important;
	}
}
