/**
 * Marginset motion.
 *
 * Quiet, editorial motion: hover and focus feedback on cards, links and
 * buttons, and content that enters once, lightly, as it scrolls into view.
 * The entrance state exists only on elements that motion.js marks below the
 * first screen, so pages without JavaScript, the first screen, the Elementor
 * editor and print always show everything at once.
 * `prefers-reduced-motion: reduce` and the Customizer's "Reduce motion"
 * option (`body.ms-motion-off`) turn all of it off.
 *
 * @package Marginset
 */

:root {
	--ms-enter: 520ms;
	--ms-enter-rise: 0.75rem;
	--ms-hover-slow: 520ms;
}

/*
 * In-page jumps (the case's "On this page", skip links) land at once.
 * Elementor's frontend.css sets `html { scroll-behavior: smooth }`; a long
 * smooth jump would also start every entrance it passes on the way.
 */
html:root {
	scroll-behavior: auto;
}

/* 1. Project cards: the photograph settles a little closer, the title underlines. */

.marginset-project-card .marginset-project-card__media img {
	transition:
		opacity var(--ms-fade) var(--ms-ease),
		transform var(--ms-hover-slow) var(--ms-ease);
}

.marginset-project-card > a:focus-visible .marginset-project-card__media img {
	opacity: 0.86;
}

.marginset-project-card > a:focus-visible .marginset-project-card__title {
	text-decoration: underline;
	text-decoration-color: var(--ms-accent);
	text-decoration-thickness: 2px;
	text-underline-offset: 0.14em;
}

.marginset-project-card__title {
	transition: text-decoration-color var(--ms-fade) var(--ms-ease);
}

@media (prefers-reduced-motion: no-preference) {
	.marginset-project-card > a:hover .marginset-project-card__media img,
	.marginset-project-card > a:focus-visible .marginset-project-card__media img {
		transform: scale(1.02);
	}
}

/* 2. "Next project" link and the closing case link. */

.marginset-project-next a span:last-child {
	text-decoration: underline;
	text-decoration-color: transparent;
	text-decoration-thickness: 2px;
	text-underline-offset: 0.18em;
	transition: text-decoration-color var(--ms-fade) var(--ms-ease);
}

.marginset-project-next a:hover span:last-child,
.marginset-project-next a:focus-visible span:last-child {
	text-decoration-color: var(--ms-accent);
}

.ms-on-dark .marginset-project-next a:hover span:last-child,
.ms-on-dark .marginset-project-next a:focus-visible span:last-child {
	text-decoration-color: currentColor;
}

/* 3. Text links: the underline colour eases in rather than snapping. */

.site-nav a,
.site-footer a,
.ms-disciplines__list a,
.ms-toc__list a,
.ms-post-row__title a,
.entry-meta a {
	transition:
		color var(--ms-fade) var(--ms-ease),
		text-decoration-color var(--ms-fade) var(--ms-ease);
}

.site-footer__menu a:focus-visible,
.ms-toc__list a:focus-visible,
.ms-post-row__title a:focus-visible {
	text-decoration: underline;
	text-decoration-color: var(--ms-accent);
	text-decoration-thickness: 2px;
}

/* 4. Buttons: colour change on hover and focus (style.css), a one-pixel press. */

button,
input[type="submit"],
input[type="button"],
input[type="reset"],
.wp-block-button__link,
.wp-element-button,
.elementor-widget-button .elementor-button,
.ms-button {
	transition:
		background-color var(--ms-fade) var(--ms-ease),
		border-color var(--ms-fade) var(--ms-ease),
		color var(--ms-fade) var(--ms-ease),
		transform 120ms var(--ms-ease);
}

.elementor-widget-button.ms-button-quiet .elementor-button:focus-visible,
.is-style-outline .wp-block-button__link:focus-visible {
	background-color: var(--ms-ink);
	border-color: var(--ms-ink);
	color: var(--ms-paper);
}

@media (prefers-reduced-motion: no-preference) {
	button:not(:disabled):active,
	input[type="submit"]:active,
	input[type="button"]:active,
	.wp-block-button__link:active,
	.wp-element-button:active,
	.elementor-widget-button .elementor-button:active,
	.ms-button:active {
		transform: translateY(1px);
	}
}

/* 5. Entrance: once, a short fade and a rise of 12 px, below the first screen only. */

@media (prefers-reduced-motion: no-preference) {
	.ms-motion body:not(.elementor-editor-active):not(.elementor-editor-preview):not(.ms-motion-off) [data-ms-reveal] {
		transition:
			opacity var(--ms-enter) var(--ms-ease),
			transform var(--ms-enter) var(--ms-ease);
		transition-delay: var(--ms-reveal-delay, 0ms);
	}

	.ms-motion body:not(.elementor-editor-active):not(.elementor-editor-preview):not(.ms-motion-off) [data-ms-reveal="instant"] {
		transition: none;
	}

	.ms-motion body:not(.elementor-editor-active):not(.elementor-editor-preview):not(.ms-motion-off) [data-ms-reveal="waiting"] {
		opacity: 0;
		transform: translateY(var(--ms-enter-rise));
	}
}

@media print {
	[data-ms-reveal] {
		opacity: 1 !important;
		transform: none !important;
	}
}

/* 6. Off switches. */

@media (prefers-reduced-motion: reduce) {
	.marginset-project-card .marginset-project-card__media img,
	.marginset-project-card__title,
	.marginset-project-next a span:last-child,
	[data-ms-reveal] {
		transition: none;
		transform: none;
	}
}

.ms-motion-off .marginset-project-card .marginset-project-card__media img,
.ms-motion-off [data-ms-reveal] {
	transform: none !important;
}
