/**
 * Bricksify: Text Roll - "Mask rise" effect.
 *
 * Loads only with the companion plugin, together with text-mask.js. Slot
 * geometry comes from the panel (custom properties, per breakpoint); the
 * element's own typed settings still win, because these rules sit inside
 * :where() and carry no specificity.
 */

/* Photo slots: direct children holding an image. Also styled without JS. */
:where(.bxc-text-mask) > :where(:not(img, .bxtm-line-mask):has(img)) {
	position: relative;
	display: inline-block;
	width: calc(var(--bxtm-slot-w, 1.7) * 1em);
	height: calc(var(--bxtm-slot-h, 0.72) * 1em);
	border-radius: calc(var(--bxtm-slot-r, 0.36) * 1em);
	overflow: hidden;
	isolation: isolate;
	vertical-align: baseline;
}

.bxc-text-mask > :where(:not(img, .bxtm-line-mask):has(img)) img {
	position: absolute;
	top: -20%;
	left: 50%;
	display: block;
	width: calc(var(--bxtm-slot-w, 1.7) * 1em);
	max-width: none;
	height: 140%;
	margin-left: calc(var(--bxtm-slot-w, 1.7) * -0.5em);
	object-fit: cover;
}

/* Room for descenders under each line mask, without moving the layout. */
.bxc-text-mask .bxtm-line {
	padding-bottom: 0.18em;
}

.bxc-text-mask .bxtm-line-mask {
	margin-bottom: -0.18em;
}

.bxc-text-mask .bxtm-word,
.bxc-text-mask .bxtm-char {
	will-change: transform;
}

/*
 * Hidden until the script has split it, so it cannot flash and then drop out
 * of sight. `bx-js` is printed in <head> by the companion only on pages that
 * use the effect, so a visitor without JavaScript always sees the text. If the
 * script never arrives, the failsafe shows it after 3 seconds.
 */
html.bx-js body.bricks-is-frontend .bxc-text-mask:not(.is-ready) {
	visibility: hidden;
	animation: bxtm-failsafe 0s 3s forwards;
}

@keyframes bxtm-failsafe {
	to {
		visibility: visible;
	}
}

@media (prefers-reduced-motion: reduce) {
	html.bx-js body.bricks-is-frontend .bxc-text-mask:not(.is-ready) {
		visibility: visible;
		animation: none;
	}
}
