/*
 * MJ2 Kit base styles. Loaded wherever an MJ2 Kit block is used, in the
 * editor and on the frontend.
 *
 * The engine's internal custom properties must not inherit: a child reading
 * --mj2-pgap needs its own parent's gap, never a grandparent's.
 */
@property --mj2-pgap {
	syntax: "*";
	inherits: false;
}

@property --mj2-ovl {
	syntax: "*";
	inherits: false;
}

@property --mj2-bgi {
	syntax: "*";
	inherits: false;
}

.mj2 {
	box-sizing: border-box;
}

/* Pause/Play button on moving content (zero specificity: style it from the block). */
:where(.mj2-pause) {
	box-sizing: border-box;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 2rem;
	height: 2rem;
	padding: 0;
	border: 1px solid currentcolor;
	border-radius: 999px;
	background: transparent;
	color: inherit;
	cursor: pointer;
}

.mj2-pause[hidden] {
	display: none;
}

:where(.mj2-pause) svg {
	width: 1rem;
	height: 1rem;
	fill: currentcolor;
}

.mj2-pause.is-paused .mj2-pause__pause,
.mj2-pause:not(.is-paused) .mj2-pause__play {
	display: none;
}

/*
 * Motion (`reveal` and `drift` keys). The engine only sets variables; these
 * rules use them. The reveal script marks blocks below the fold
 * `mj2-rv-pending` (shown in their start state, nothing animating yet) and
 * adds `mj2-rv-in` as each scrolls into view. Without the script, with
 * reduced motion, in print and in the editor, nothing is hidden or moved.
 */
@media screen and (prefers-reduced-motion: no-preference) {

	.mj2-rv-pending:not(.mj2-rv-in) {
		opacity: var(--mj2-rv-po, var(--mj2-rv-oo, var(--mj2-rv-o, 1)));
		translate: var(--mj2-rv-t, none);
		scale: var(--mj2-rv-s, none);
	}

	.mj2-rv-in {
		animation: var(--mj2-rv-k, none) var(--mj2-rv-dur, var(--mj2-rv-d0, 1.1s)) cubic-bezier(0.25, 0.46, 0.45, 0.94) calc(var(--mj2-rv-delay, 0s) + var(--mj2-rv-i, 0) * 120ms) backwards;
	}

	/* "Italic words": accent words settle in after their block. */
	.mj2-rv-in em {
		animation: var(--mj2-em-k, none) var(--mj2-em-dur, 1.1s) cubic-bezier(0.25, 0.46, 0.45, 0.94) calc(var(--mj2-rv-delay, 0s) + var(--mj2-em-delay, 0.5s) + var(--mj2-rv-i, 0) * 120ms) backwards;
	}

	@keyframes mj2-reveal {

		from {
			opacity: var(--mj2-rv-oo, var(--mj2-rv-o, 1));
			translate: var(--mj2-rv-t, none);
			scale: var(--mj2-rv-s, none);
		}
	}

	@keyframes mj2-clip {

		from {
			opacity: var(--mj2-rv-oo, var(--mj2-rv-o, 1));
			clip-path: var(--mj2-rv-c, none);
		}

		to {
			clip-path: var(--mj2-rv-ce, none);
		}
	}

	@keyframes mj2-em {

		from {
			opacity: var(--mj2-em-o, 0.2);
		}
	}

	/* Scroll drift: settles into place as the block comes fully into view. */
	@supports (animation-timeline: view()) {

		.mj2-drift {
			animation: mj2-drift linear both;
			animation-timeline: view();
			animation-range: entry 0% entry 100%;
		}

		@keyframes mj2-drift {

			from {
				translate: var(--mj2-dx, none);
			}
		}
	}
}
