/* ==========================================================================
   Motion layer for v2 pages (body.ahan-v2): scroll reveal, hover lifts, press feedback, smooth
   anchors, reading-progress bar. One place for the site's motion so components stay plain.
   Everything is inside prefers-reduced-motion: no-preference. Selectors are prefixed with
   `.ahan-v2` to win over the components' own (later printed) single-class rules.
   ========================================================================== */

@media (prefers-reduced-motion: no-preference) {

	/* Anchors (table of contents, "quick access") glide instead of jumping. */
	html:has(body.ahan-v2) {
		scroll-behavior: smooth;
	}

	/* ---------- Scroll reveal (reveal.js adds .ahan-reveal only to items below the fold) ---------- */

	.ahan-v2 .ahan-reveal {
		opacity: 0;
		translate: 0 18px;
		transition: opacity .55s ease, translate .55s cubic-bezier(.2, .7, .2, 1);
		transition-delay: calc(var(--ahan-i, 0) * 70ms);
	}

	.ahan-v2 .ahan-reveal.is-in {
		opacity: 1;
		translate: none;
	}

	/* Cards added by "load more". */
	@keyframes ahan-appear {
		from {
			opacity: 0;
			translate: 0 14px;
		}

		to {
			opacity: 1;
			translate: none;
		}
	}

	.ahan-v2 .ahan-appear {
		animation: ahan-appear .45s ease both;
		animation-delay: calc(var(--ahan-i, 0) * 60ms);
	}

	/* ---------- Hover / focus lifts ---------- */

	.ahan-v2 .ahan-post-card--grid {
		transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
	}

	.ahan-v2 .ahan-post-card--grid:hover,
	.ahan-v2 .ahan-post-card--grid:focus-visible {
		transform: translateY(-4px);
		box-shadow: 0 10px 26px rgba(0, 0, 0, 0.16);
	}

	.ahan-v2 .ahan-post-card--tile .ahan-post-card__img,
	.ahan-v2 .ahan-service-card__img,
	.ahan-v2 .ahan-blog-cats__img {
		transition: transform .6s ease;
	}

	.ahan-v2 .ahan-post-card--tile:hover .ahan-post-card__img,
	.ahan-v2 .ahan-service-card:hover .ahan-service-card__img,
	.ahan-v2 .ahan-service-card:focus-visible .ahan-service-card__img,
	.ahan-v2 .ahan-blog-cats__link:hover .ahan-blog-cats__img,
	.ahan-v2 .ahan-blog-cats__link:focus-visible .ahan-blog-cats__img {
		transform: scale(1.06);
	}

	.ahan-v2 .ahan-share__btn {
		transition: color var(--dur) var(--ease), border-color var(--dur) var(--ease), background-color var(--dur) var(--ease), transform var(--dur) var(--ease);
	}

	.ahan-v2 .ahan-share__btn:hover,
	.ahan-v2 .ahan-share__btn:focus-visible {
		transform: translateY(-3px);
	}

	.ahan-v2 .ahan-call-cta {
		transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
	}

	.ahan-v2 .ahan-call-cta:hover,
	.ahan-v2 .ahan-call-cta:focus-visible {
		transform: translateY(-3px);
		box-shadow: 0 12px 28px rgba(94, 5, 32, 0.35);
	}

	.ahan-v2 .ahan-post-list__link,
	.ahan-v2 .ahan-toc__link,
	.ahan-v2 .ahan-subcats__link {
		transition: color var(--dur-fast) var(--ease), translate var(--dur-fast) var(--ease);
	}

	.ahan-v2 .ahan-post-list__link:hover,
	.ahan-v2 .ahan-post-list__link:focus-visible {
		translate: -6px 0; /* leans away from the start edge, like the old padding did, without relayout */
	}

	/* An open FAQ question is highlighted. */
	.ahan-v2 .ahan-faq__item .ahan-accordion__trigger {
		transition: color var(--dur) var(--ease);
	}

	.ahan-v2 .ahan-faq__item.is-open .ahan-accordion__trigger {
		color: var(--c-primary);
	}

	/* Form fields: the focus ring fades in. */
	.ahan-v2 .ahan-request__input,
	.ahan-v2 .ahan-sale-alert__input {
		transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
	}

	.ahan-v2 .ahan-request__input:focus-visible {
		border-color: var(--c-primary);
		box-shadow: 0 0 0 3px rgba(94, 5, 32, 0.15);
		outline: none;
	}

	/* ---------- Press feedback ---------- */

	.ahan-v2 :is(.ahan-blog-more__btn, .ahan-blog-section__all, .ahan-request__btn, .ahan-sale-alert__btn, .ahan-post-list__toggle, .ahan-share__btn):active {
		transform: scale(0.97);
	}

	/* ---------- Reading progress (article) ---------- */

	.ahan-progress {
		position: fixed;
		inset-block-start: var(--wp-admin--admin-bar--height, 0px);
		inset-inline: 0;
		z-index: 60;
		height: 3px;
		background: transparent;
		pointer-events: none;
	}

	.ahan-progress__bar {
		display: block;
		width: 100%;
		height: 100%;
		background: var(--c-primary);
		transform: scaleX(var(--ahan-progress, 0));
		transform-origin: right; /* RTL: it grows from the reading start. */
	}
}

/* Not animated, so it is outside the media query: the bar simply hides for reduced motion. */
@media (prefers-reduced-motion: reduce) {
	.ahan-progress {
		display: none;
	}
}

/* ==========================================================================
   Home page motion (phase 5.3). Subtle on purpose: short fades, small lifts.
   ========================================================================== */
@media (prefers-reduced-motion: no-preference) {

	/* The line after a section title grows from the reading start when the title row scrolls in. */
	.ahan-v2 .ahan-home-section__head--line::after {
		transition: transform .9s cubic-bezier(.2, .7, .2, 1) .15s;
		transform-origin: right; /* RTL: the reading start */
	}

	.ahan-v2 .ahan-home-section__head--line.ahan-reveal:not(.is-in)::after {
		transform: scaleX(0);
	}

	/* The dotted wave of the purchase steps is drawn from the first step towards the last
	   (the wave is mirrored for RTL, so the local left edge is the visual right). */
	.ahan-v2 .ahan-steps__wave.ahan-reveal {
		opacity: 1;
		translate: none;
		clip-path: inset(0 100% 0 0);
		transition: clip-path 1.4s cubic-bezier(.4, 0, .2, 1);
		transition-delay: 0s;
	}

	.ahan-v2 .ahan-steps__wave.ahan-reveal.is-in {
		clip-path: inset(0);
	}

	/* Steps: the icon grows a little on hover. */
	.ahan-v2 .ahan-step__icon img {
		transition: transform var(--dur-slow) var(--ease);
	}

	.ahan-v2 .ahan-step:hover .ahan-step__icon img {
		transform: scale(1.07);
	}

	/* Banners and logos lift. */
	.ahan-v2 .ahan-home-banners .ahan-consult-banner {
		transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
	}

	.ahan-v2 .ahan-home-banners .ahan-consult-banner:hover,
	.ahan-v2 .ahan-home-banners .ahan-consult-banner:focus-visible {
		transform: translateY(-3px);
		box-shadow: 0 10px 24px rgba(0, 0, 0, 0.14);
	}

	.ahan-v2 .ahan-logo {
		transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
	}

	.ahan-v2 .ahan-logo:hover,
	.ahan-v2 .ahan-logo:focus-within {
		transform: translateY(-3px) scale(1.03);
		box-shadow: 0 8px 18px rgba(0, 0, 0, 0.14);
	}

	/* Form fields of the home page: the focus ring fades in (primary on light, gold on the dark band). */
	.ahan-v2 .ahan-hero__input,
	.ahan-v2 .ahan-home-sale__input,
	.ahan-v2 .ahan-inquiry__input,
	.ahan-v2 .ahan-ms__trigger {
		transition: box-shadow var(--dur) var(--ease);
	}

	.ahan-v2 .ahan-hero__input:focus-visible,
	.ahan-v2 .ahan-home-sale__input:focus-visible {
		box-shadow: 0 0 0 3px rgba(94, 5, 32, 0.25);
		outline: none;
	}

	.ahan-v2 .ahan-inquiry__input:focus-visible,
	.ahan-v2 .ahan-ms__trigger:focus-visible {
		box-shadow: 0 0 0 3px rgba(238, 198, 79, 0.55);
		outline: none;
	}

	/* The multi-select panel opens with a short fade and rise. */
	@keyframes ahan-pop {
		from {
			opacity: 0;
			translate: 0 -6px;
		}

		to {
			opacity: 1;
			translate: none;
		}
	}

	.ahan-v2 .ahan-ms.is-open .ahan-ms__panel {
		animation: ahan-pop .18s ease both;
	}

	/* The attachment button and the submit buttons share the press feedback and hover shade. */
	.ahan-v2 :is(.ahan-hero__btn, .ahan-home-sale__btn, .ahan-inquiry__btn, .ahan-ms__apply, .ahan-ms__clear, .ahan-upload__btn):active {
		transform: scale(0.97);
	}

	.ahan-v2 .ahan-hero__btn,
	.ahan-v2 .ahan-ms__apply,
	.ahan-v2 .ahan-ms__clear,
	.ahan-v2 .ahan-upload__btn {
		transition: filter var(--dur) var(--ease), transform var(--dur-fast) var(--ease), background-color var(--dur) var(--ease), color var(--dur) var(--ease);
	}

	.ahan-v2 .ahan-hero__btn:hover,
	.ahan-v2 .ahan-ms__apply:hover,
	.ahan-v2 .ahan-ms__clear:hover {
		filter: brightness(1.12);
	}

	.ahan-v2 .ahan-upload__btn:hover {
		background-color: rgba(238, 198, 79, 0.12);
	}
}

/* ==========================================================================
   Special and plain pages motion (phase 5.4). Subtle: the header and the first block fade in on
   load (below-the-fold blocks are revealed by reveal.js); the About page's joining line is drawn
   downwards when it scrolls in.
   ========================================================================== */
@media (prefers-reduced-motion: no-preference) {

	.ahan-v2 .ahan-page__inner > :nth-child(-n + 2):not(.ahan-about__block--intro) {
		animation: ahan-appear .5s ease both;
	}

	.ahan-v2 .ahan-page__inner > :nth-child(2):not(.ahan-about__block--intro) {
		animation-delay: 80ms;
	}

	.ahan-v2 .ahan-about__line.ahan-reveal {
		opacity: 1;
		translate: none;
		transform-origin: top;
		transform: scaleY(0);
		transition: transform .8s cubic-bezier(.4, 0, .2, 1);
		transition-delay: 0s;
	}

	.ahan-v2 .ahan-about__line.ahan-reveal.is-in {
		transform: none;
	}
}

/* Directional entrances (data-ahan-anim="right|left|down|fade" + --ahan-delay), used by the About
   page's first section. Short and small on purpose. */
@media (prefers-reduced-motion: no-preference) {

	.ahan-v2 [data-ahan-anim].ahan-reveal {
		transition-duration: .5s;
		transition-delay: var(--ahan-delay, 0ms);
	}

	.ahan-v2 [data-ahan-anim="right"].ahan-reveal {
		translate: 36px 0;
	}

	.ahan-v2 [data-ahan-anim="left"].ahan-reveal {
		translate: -36px 0;
	}

	.ahan-v2 [data-ahan-anim="down"].ahan-reveal {
		translate: 0 -24px;
	}

	.ahan-v2 [data-ahan-anim="fade"].ahan-reveal {
		translate: none;
	}

	.ahan-v2 [data-ahan-anim].ahan-reveal.is-in {
		translate: none;
	}

	/* ---------- Back-to-top button: hover lift, press, and «show after N px» ---------- */

	.ahan-v2 .ahan-totop,
	.ahan-v2 .ahan-totop__text {
		transition: background-color var(--dur) var(--ease), scale var(--dur) var(--ease);
	}

	.ahan-v2 .ahan-totop:hover {
		scale: 1.05;
	}

	.ahan-v2 .ahan-totop:active {
		scale: 0.95;
	}

	/* Show after N px of scrolling (--after modifier; N = --totop-after): pure CSS scroll-driven animation. Without support the
	   button simply stays visible. Inside the floating column the height and gap collapse too, so no empty slot is left above it. */
	@keyframes ahan-totop-in {
		from {
			opacity: 0;
			visibility: hidden;
		}

		to {
			opacity: 1;
			visibility: visible;
		}
	}

	@keyframes ahan-totop-in-fab {
		from {
			height: 0;
			margin-block-end: calc(var(--totop-fab-gap) * -1);
			overflow: hidden;
			opacity: 0;
			visibility: hidden;
		}

		to {
			height: var(--totop-size);
			margin-block-end: 0;
			overflow: visible;
			opacity: 1;
			visibility: visible;
		}
	}

	@supports (animation-timeline: scroll()) {
		.ahan-v2 .ahan-totop--after {
			animation: ahan-totop-in 1ms linear both; /* the 1ms duration is for Firefox; scroll timelines ignore it */
			animation-timeline: scroll(root block);
			animation-range: var(--totop-after) calc(var(--totop-after) + var(--totop-reveal));
		}

		.ahan-v2 .ahan-fab .ahan-totop--after {
			animation-name: ahan-totop-in-fab;
		}
	}
}