/*
 * Front-end effects. The classes are added by assets/js/effects.js,
 * so without JavaScript none of this applies.
 */

/* Reveal on scroll */

.is-reveal-pending {
	opacity: 0;
	transform: translateY(1.75rem);
	transition:
		opacity 1.1s cubic-bezier(0.25, 0.1, 0.25, 1) var(--reveal-delay, 0ms),
		transform 1.4s cubic-bezier(0.22, 1, 0.36, 1) var(--reveal-delay, 0ms);
	will-change: opacity, transform;
}

/* Items can have their own transitions (hover); while revealing, this one wins. */
.is-reveal-pending.is-reveal-item {
	transform: translateY(1.25rem);
	transition:
		opacity 1.1s cubic-bezier(0.25, 0.1, 0.25, 1) var(--reveal-delay, 0ms),
		transform 1.4s cubic-bezier(0.22, 1, 0.36, 1) var(--reveal-delay, 0ms);
}

.is-reveal-pending.is-revealed {
	opacity: 1;
	transform: none;
}

/* Smart header */

.has-smart-header .wp-site-blocks > header {
	--smart-header-top: var(--wp-admin--admin-bar--height, 0px);
	position: fixed;
	top: var(--smart-header-top);
	right: 0;
	left: 0;
	z-index: 100;
	background-color: var(--wp--preset--color--base);
	transition:
		transform 0.5s cubic-bezier(0.16, 1, 0.3, 1),
		opacity 0.45s ease;
}

/* Room for the full header; the fixed header can shrink without moving the page. */
.has-smart-header .wp-site-blocks {
	padding-top: var(--header-full-height, 0px);
}

/* Anchor links land below the header. --header-height is set by effects.js. */
html.has-smart-header {
	scroll-padding-top: calc(var(--header-height, 0px) + var(--wp-admin--admin-bar--height, 0px));
}

/* On small screens the admin bar scrolls away with the page. */
@media (max-width: 600px) {
	.has-smart-header .wp-site-blocks > header {
		--smart-header-top: 0px;
	}

	html.has-smart-header {
		scroll-padding-top: var(--header-height, 0px);
	}
}

/*
 * Only the hidden state uses a transform: a transform on the visible header
 * would break the position: fixed mobile menu overlay inside it.
 */
.has-smart-header .wp-site-blocks > header.is-hidden {
	opacity: 0;
	pointer-events: none;
	transform: translateY(-1.5rem);
}

@media (prefers-reduced-motion: reduce) {
	.has-smart-header .wp-site-blocks > header {
		transition: none;
	}
}

/* Image fade */

img[loading="lazy"] {
	transition: opacity 0.4s ease-out;
}

img.is-image-loading {
	opacity: 0;
}

@media print {
	img.is-image-loading {
		opacity: 1;
	}

	.is-reveal-pending {
		opacity: 1;
		transform: none;
	}

	.has-smart-header .wp-site-blocks > header {
		position: static;
	}

	.has-smart-header .wp-site-blocks {
		padding-top: 0;
	}
}

/* ==========================================================================
   Motion: entrances, hovers and scroll effects (front end only).
   Everything that moves sits inside prefers-reduced-motion: no-preference.
   ========================================================================== */

:root {
	--ease-out: cubic-bezier(0.16, 1, 0.3, 1);
	--ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
}

/* Colour changes are fine for everyone; only movement is opt-out. */
a,
.wp-element-button,
.wpcf7-submit,
.wp-block-navigation-item__content,
input,
textarea {
	transition:
		color 0.25s ease,
		background-color 0.25s ease,
		border-color 0.25s ease,
		text-decoration-color 0.25s ease,
		box-shadow 0.25s ease;
}

/* Form fields: a soft ring on focus. */
.wpcf7 :is(input[type="text"], input[type="email"], input[type="tel"], textarea):focus {
	border-color: var(--wp--preset--color--contrast);
	outline: none;
	box-shadow: 0 0 0 3px rgb(35 60 75 / 0.18);
}

/* Text links: the underline turns orange and thicker. */
main :is(p, li) a:not(.wp-element-button) {
	text-decoration-color: color-mix(in srgb, currentColor 45%, transparent);
	text-decoration-thickness: 1px;
}

main :is(p, li) a:not(.wp-element-button):hover {
	text-decoration-color: var(--wp--preset--color--primary);
	text-decoration-thickness: 2px;
}

@media (prefers-reduced-motion: no-preference) {

	/* Entrances on load ---------------------------------------------------- */

	@keyframes lbc-rise {
		from {
			opacity: 0;
			transform: translateY(1.75rem);
		}
	}

	@keyframes lbc-fade {
		from {
			opacity: 0;
		}
	}

	@keyframes lbc-star-in {
		from {
			opacity: 0;
			transform: rotate(-35deg) scale(0.6);
		}
	}

	@keyframes lbc-line {
		from {
			transform: scaleX(0);
		}
	}

	.hero__title,
	.hero .is-offset > *,
	.page-intro > *,
	.activity-intro > *,
	.wp-site-blocks > main > .alignfull:first-child > .wp-block-columns {
		animation: lbc-rise 0.9s var(--ease-out) both;
	}

	.hero__title { animation-delay: 0.05s; }
	.hero .is-offset > :nth-child(1) { animation-delay: 0.25s; }
	.hero .is-offset > :nth-child(2) { animation-delay: 0.4s; }
	.page-intro > :nth-child(2), .activity-intro > :nth-child(2) { animation-delay: 0.1s; }
	.page-intro > :nth-child(3), .activity-intro > :nth-child(3) { animation-delay: 0.2s; }
	.page-intro > :nth-child(n + 4), .activity-intro > :nth-child(n + 4) { animation-delay: 0.3s; }

	/* The star spins in, then floats; scrolling turns it a little further. */
	@supports (animation-timeline: scroll()) {
		/* Rotates around its centre while scrolling. */
		.hero__star {
			transform-origin: 50% 50%;
			animation: lbc-star-rotate linear both;
			animation-timeline: scroll(root);
			animation-range: 0 100vh;
		}

		@keyframes lbc-star-rotate {
			to {
				transform: rotate(-75deg);
			}
		}
	}

	.hero__star img {
		transform-origin: 55% 60%;
		animation: lbc-star-in 1.4s var(--ease-out) 0.35s backwards;
	}

	/* Header line draws in from the left. */
	.site-header__nav {
		position: relative;
	}

	.site-header__nav {
		border-bottom-color: transparent !important;
	}

	/* Smooth switch between the full and the compact header. */
	.site-header {
		transition: padding 0.5s var(--ease-out);
	}

	.site-header__nav {
		transition: padding 0.5s var(--ease-out);
	}

	.site-header__nav::after {
		content: "";
		position: absolute;
		right: 0;
		bottom: -2px;
		left: 0;
		height: 2px;
		background-color: var(--wp--preset--color--primary);
		transform-origin: left;
		transition: opacity 0.35s ease, transform 0.5s var(--ease-out);
		animation: lbc-line 1.1s var(--ease-out) 0.15s backwards;
	}

	.is-compact .site-header__nav::after {
		opacity: 0;
		transform: scaleX(0.6);
	}

	@media (max-width: 599px) {
		.site-header__nav::after {
			display: none;
		}
	}

	/* Buttons -------------------------------------------------------------- */

	.wp-element-button,
	.wpcf7-submit,
	.wp-block-navigation .is-button > .wp-block-navigation-item__content {
		background-image: linear-gradient(var(--wp--preset--color--primary-hover), var(--wp--preset--color--primary-hover));
		background-repeat: no-repeat;
		background-position: left center;
		background-size: 0% 100%;
		transition:
			background-size 0.45s var(--ease-out),
			background-color 0.25s ease,
			color 0.25s ease,
			transform 0.3s var(--ease-out),
			box-shadow 0.3s var(--ease-out);
	}

	.wp-element-button:hover,
	.wp-element-button:focus-visible,
	.wpcf7-submit:hover,
	.wpcf7-submit:focus-visible,
	.wp-block-navigation .is-button > .wp-block-navigation-item__content:hover {
		background-color: var(--wp--preset--color--primary);
		background-size: 100% 100%;
		box-shadow: 0 10px 24px -10px rgb(239 122 53 / 0.75);
		transform: translateY(-2px);
	}

	.wp-block-navigation__responsive-container.is-menu-open .is-button > .wp-block-navigation-item__content:hover {
		background: none;
		box-shadow: none;
		color: var(--wp--preset--color--primary);
		transform: none;
	}

	.wp-element-button:active,
	.wpcf7-submit:active {
		box-shadow: none;
		transform: translateY(0);
		transition-duration: 0.1s;
	}

	.is-style-outline .wp-element-button {
		background-image: linear-gradient(var(--wp--preset--color--contrast), var(--wp--preset--color--contrast));
	}

	.is-style-outline .wp-element-button:hover {
		background-color: transparent;
		box-shadow: none;
		color: var(--wp--preset--color--base);
	}

	/* Main menu: an orange line grows under the link. */
	.site-header__menu .wp-block-navigation-item:not(.is-button) > .wp-block-navigation-item__content {
		position: relative;
	}

	.site-header__menu .wp-block-navigation-item:not(.is-button) > .wp-block-navigation-item__content::after {
		content: "";
		position: absolute;
		right: 0;
		bottom: -9px;
		left: 0;
		height: 2px;
		background-color: var(--wp--preset--color--primary);
		transform: scaleX(0);
		transform-origin: right;
		transition: transform 0.4s var(--ease-out);
	}

	.site-header__menu .wp-block-navigation-item:not(.is-button) > .wp-block-navigation-item__content:hover::after {
		transform: scaleX(1);
		transform-origin: left;
	}

	.site-header .wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation-item__content::after {
		display: none;
	}

	/* Mobile menu: the overlay slides open from the top, then the links follow. */
	@keyframes lbc-menu-open {
		from {
			clip-path: inset(0 0 100% 0);
		}

		to {
			clip-path: inset(0 0 0 0);
		}
	}

	.site-header .wp-block-navigation__responsive-container.is-menu-open {
		animation: lbc-menu-open 0.55s var(--ease-out) both;
	}

	@keyframes lbc-menu-close {
		from {
			clip-path: inset(0 0 0 0);
		}

		to {
			clip-path: inset(0 0 100% 0);
		}
	}

	.site-header .wp-block-navigation__responsive-container.is-menu-open.is-menu-closing {
		animation: lbc-menu-close 0.38s var(--ease-in-out) both;
	}

	.wp-block-navigation__responsive-container.is-menu-closing .wp-block-navigation-item,
	.wp-block-navigation__responsive-container.is-menu-closing .mobile-menu-contact {
		opacity: 0;
		transition: opacity 0.2s ease;
	}

	.wp-block-navigation__responsive-container.is-menu-open .mobile-menu-contact {
		animation: lbc-rise 0.6s var(--ease-out) 0.3s both;
	}

	/* Mobile menu: links slide in one after another. */
	.wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation-item {
		animation: lbc-rise 0.6s var(--ease-out) 0.12s both;
	}

	.wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation-item:nth-child(2) { animation-delay: 0.17s; }
	.wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation-item:nth-child(3) { animation-delay: 0.22s; }
	.wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation-item:nth-child(4) { animation-delay: 0.27s; }
	.wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation-item:nth-child(5) { animation-delay: 0.32s; }
	.wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation-item:nth-child(n + 6) { animation-delay: 0.37s; }

	/* Logo: a small lift. */
	.site-header__logo img {
		transition: width 0.5s var(--ease-out), transform 0.5s var(--ease-out);
	}

	.site-footer__logo img {
		transition: transform 0.5s var(--ease-out);
	}

	.site-header__logo a:hover img,
	.site-footer__logo a:hover img {
		transform: rotate(-2deg) scale(1.03);
	}

	/* Language switcher. */
	.wp-block-loopbaancentrum-language-switcher {
		transition: border-color 0.25s ease, box-shadow 0.25s ease;
	}

	.wp-block-loopbaancentrum-language-switcher:hover {
		border-color: var(--wp--preset--color--primary);
		box-shadow: 0 0 0 3px rgb(239 122 53 / 0.15);
	}

	/* Footer: links get a line that grows, the arrow lifts. */
	.site-footer .wp-block-navigation a {
		background-image: linear-gradient(currentColor, currentColor);
		background-repeat: no-repeat;
		background-position: right bottom;
		background-size: 0% 1px;
		transition: background-size 0.4s var(--ease-out), color 0.25s ease;
	}

	.site-footer .wp-block-navigation a:hover {
		background-position: left bottom;
		background-size: 100% 1px;
	}

	.site-footer__to-top a::after {
		transition: transform 0.4s var(--ease-out);
	}

	.site-footer__to-top a:hover::after {
		transform: rotate(-45deg) translate(3px, -3px);
	}

	/* Agenda items: a soft background slides in, the arrow moves. */
	.wp-block-loopbaancentrum-agenda__item::before {
		content: "";
		position: absolute;
		inset: 0;
		z-index: -1;
		background-color: color-mix(in srgb, var(--agenda-line) 9%, transparent);
		transform: scaleX(0);
		transform-origin: left;
		transition: transform 0.5s var(--ease-out);
	}

	/* The text moves in from the edges together with the background. */
	.wp-block-loopbaancentrum-agenda__item {
		isolation: isolate;
		transition: padding 0.5s var(--ease-out);
	}

	.wp-block-loopbaancentrum-agenda__item:hover {
		padding-inline: var(--wp--preset--spacing--20);
	}

	.wp-block-loopbaancentrum-agenda__item:hover::before {
		transform: scaleX(1);
	}

	.wp-block-loopbaancentrum-agenda__item:hover .wp-block-loopbaancentrum-agenda__arrow {
		transform: translate(4px, -4px) scale(1.1);
		transition-duration: 0.4s;
	}

	.wp-block-loopbaancentrum-agenda__item:hover .wp-block-loopbaancentrum-agenda__title a {
		text-decoration: none;
	}

	/* News cards: lift, shadow, image zoom, arrow after "Read more". */
	.news-card {
		position: relative;
		transition:
			transform 0.5s var(--ease-out),
			box-shadow 0.5s var(--ease-out),
			border-color 0.3s ease;
	}

	.news-card:hover {
		border-color: var(--wp--preset--color--secondary) !important;
		box-shadow: 0 22px 40px -24px rgb(35 60 75 / 0.45);
		transform: translateY(-6px);
	}

	.news-card .wp-block-post-featured-image {
		overflow: hidden;
		border-radius: 4px;
	}

	.news-card .wp-block-post-featured-image img {
		transition: transform 0.8s var(--ease-out);
	}

	.news-card:hover .wp-block-post-featured-image img {
		transform: scale(1.08);
	}

	/* The whole card is clickable through the title link. */
	.news-card .wp-block-post-title a::after {
		content: "";
		position: absolute;
		inset: 0;
	}

	.news-card__more {
		position: relative;
		z-index: 1;
	}

	.news-card__more.wp-block-read-more {
		display: inline-flex;
		align-items: center;
		gap: 0.375rem;
	}

	.news-card__more.wp-block-read-more::after {
		content: "→";
		transition: transform 0.4s var(--ease-out);
	}

	.news-card:hover .news-card__more.wp-block-read-more::after {
		transform: translateX(5px);
	}

	/* Team: photo zooms in slightly. */
	.wp-block-loopbaancentrum-team__photo img {
		transition: transform 0.8s var(--ease-out), filter 0.5s ease;
	}

	.wp-block-loopbaancentrum-team__member:hover .wp-block-loopbaancentrum-team__photo img {
		transform: scale(1.06);
	}

	/* Arrow list: the arrow nudges on hover. */
	.wp-block-list.is-style-arrows > li::before {
		transition: transform 0.4s var(--ease-out);
	}

	.wp-block-list.is-style-arrows > li:hover::before {
		transform: translate(3px, -3px);
	}

	/* Large images: a slow zoom as they scroll through the viewport. */
	@supports (animation-timeline: view()) {
		.activity-intro + .alignfull .wp-block-post-featured-image,
		.page-intro + .alignfull .wp-block-post-featured-image {
			overflow: hidden;
		}

		.activity-intro + .alignfull .wp-block-post-featured-image img,
		.page-intro + .alignfull .wp-block-post-featured-image img {
			animation: lbc-image-zoom linear both;
			animation-timeline: view();
			animation-range: entry 0% exit 100%;
		}

		@keyframes lbc-image-zoom {
			from {
				transform: scale(1.12);
			}

			to {
				transform: scale(1);
			}
		}

		/* Section lines draw in when they scroll into view. */
		.wp-block-separator {
			transform-origin: left;
			animation: lbc-line linear both;
			animation-timeline: view();
			animation-range: entry 10% cover 35%;
		}
	}
}
