/* Beurre Scroll Text (Bricks element), shipped with Beurre 0.9.1
 * Every animated piece (word, character or word-in-a-line) carries --p, a number
 * from 0 (not revealed) to 1 (revealed). JS writes --p, the rules below turn it
 * into the visual effect. */

.btr-st {
	--btr-st-o: .15;
	--btr-st-dist: 40px;
	--btr-st-blur: 12px;
	--btr-st-scale: .6;
	--btr-st-rot: 80deg;
	--btr-st-dim: rgba(128, 128, 128, .35);
	--btr-st-hl: #ffe14d;
	position: relative;
}

.btr-st__text {
	position: relative;
	margin: 0;
	/* Nothing is hard-coded: the text follows the standard Bricks Typography settings of the element. */
	font: inherit;
	color: inherit;
	letter-spacing: inherit;
	text-transform: inherit;
	text-align: inherit;
	text-decoration: inherit;
}

.btr-st__text {
	column-rule-style: solid;
	column-rule-width: 0;
}

/* A manual column break: an empty block that ends the column. Harmless when there is one column. */
.btr-st__cb {
	display: block;
	height: 0;
	break-after: column;
	-webkit-column-break-after: always;
}

.btr-st--1col .btr-st__cb {
	display: inline;
	break-after: auto;
	-webkit-column-break-after: auto;
}

.btr-st--block-center .btr-st__text {
	margin-left: auto;
	margin-right: auto;
}

.btr-st--block-right .btr-st__text {
	margin-left: auto;
	margin-right: 0;
}

.btr-st__sr {
	position: absolute !important;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

.btr-st__u {
	--p: 0;
	display: inline-block;
	backface-visibility: hidden;
}

.btr-st__w {
	display: inline-block;
	white-space: nowrap;
}

/* Hide the raw text until JS has split it, with a failsafe if JS never arrives. */
@media (scripting: enabled) {
	.btr-st:not(.is-ready) .btr-st__text {
		visibility: hidden;
		animation: btr-st-failsafe 0s linear 3s forwards;
	}
}

@keyframes btr-st-failsafe {
	to {
		visibility: visible;
	}
}

/* ---- Opacity based styles ---- */
.btr-st--fade .btr-st__u,
.btr-st--rise .btr-st__u,
.btr-st--drop .btr-st__u,
.btr-st--blur .btr-st__u,
.btr-st--zoom .btr-st__u,
.btr-st--flip .btr-st__u,
.btr-st--slant .btr-st__u {
	opacity: calc(var(--btr-st-o) + (1 - var(--btr-st-o)) * var(--p));
}

.btr-st--rise .btr-st__u {
	transform: translate3d(0, calc((1 - var(--p)) * var(--btr-st-dist)), 0);
}

.btr-st--drop .btr-st__u {
	transform: translate3d(0, calc((var(--p) - 1) * var(--btr-st-dist)), 0);
}

.btr-st--blur .btr-st__u {
	filter: blur(calc((1 - var(--p)) * var(--btr-st-blur)));
}

.btr-st--zoom .btr-st__u {
	transform: scale(calc(var(--btr-st-scale) + (1 - var(--btr-st-scale)) * var(--p)));
}

.btr-st--flip .btr-st__u {
	transform: perspective(700px) rotateX(calc((1 - var(--p)) * var(--btr-st-rot) * -1));
	transform-origin: 50% 100%;
}

.btr-st--slant .btr-st__u {
	transform: translate3d(calc((var(--p) - 1) * var(--btr-st-dist)), 0, 0) skewX(calc((1 - var(--p)) * -18deg));
	transform-origin: 0 100%;
}

/* ---- Mask wipe ---- */
.btr-st--wipe .btr-st__u {
	clip-path: inset(-.15em calc((1 - var(--p)) * 100%) -.15em 0);
}

/* ---- Color fill ---- */
.btr-st--color .btr-st__u {
	color: color-mix(in srgb, var(--btr-st-active) calc(var(--p) * 100%), var(--btr-st-dim));
}

/* ---- Marker highlight ---- */
.btr-st--highlight .btr-st__u {
	color: color-mix(in srgb, var(--btr-st-active) calc(var(--p) * 100%), var(--btr-st-dim));
	background-image: linear-gradient(var(--btr-st-hl), var(--btr-st-hl));
	background-repeat: no-repeat;
	background-position: 0 50%;
	background-size: calc(var(--p) * 100%) 100%;
	padding: 0 .12em;
	margin: 0 -.12em;
	border-radius: .12em;
}

/* ---- Karaoke sweep ---- */
.btr-st--sweep .btr-st__u {
	color: transparent;
	-webkit-text-fill-color: transparent;
	background-image: linear-gradient(90deg, var(--btr-st-active) calc(var(--p) * 130% - 30%), var(--btr-st-dim) calc(var(--p) * 130%));
	-webkit-background-clip: text;
	background-clip: text;
}

/* ---- Typewriter ---- */
.btr-st--typewriter .btr-st__u {
	position: relative;
	opacity: clamp(0, calc(var(--p) * 1000), 1);
}

.btr-st--typewriter.btr-st--caret .btr-st__u.is-cur::after {
	content: "";
	position: absolute;
	right: -.1em;
	top: .1em;
	bottom: .1em;
	width: .07em;
	background: currentColor;
	-webkit-text-fill-color: initial;
	animation: btr-st-blink 1s steps(1) infinite;
}

@keyframes btr-st-blink {
	50% {
		opacity: 0;
	}
}

/* Dim color on every other style: when it is set, text starts in the dim color and fills to its own color.
 * Color fill, Marker highlight and Karaoke sweep always use it and need no extra rule. */
.btr-st--dimmed:not(.btr-st--color):not(.btr-st--highlight):not(.btr-st--sweep) .btr-st__u {
	color: color-mix(in srgb, var(--btr-st-active) calc(var(--p) * 100%), var(--btr-st-dim));
}

/* Browsers without color-mix(): fall back to an opacity fill. */
@supports not (color: color-mix(in srgb, red 50%, blue)) {
	.btr-st--color .btr-st__u {
		opacity: calc(var(--btr-st-o) + (1 - var(--btr-st-o)) * var(--p));
	}

	.btr-st--highlight .btr-st__u {
		color: inherit;
	}
}

/* ---- Pinning ---- */
.btr-st--pin:not(.is-static) {
	height: calc(100vh + var(--btr-st-pin, 150) * 1vh);
	height: calc(100svh + var(--btr-st-pin, 150) * 1svh);
}

.btr-st--pin:not(.is-static) .btr-st__stage {
	position: sticky;
	top: var(--btr-st-top, 0px);
	height: calc(100vh - var(--btr-st-top, 0px));
	height: calc(100svh - var(--btr-st-top, 0px));
	display: flex;
	flex-direction: column;
	justify-content: center;
}

.btr-st--pin.btr-st--align-start:not(.is-static) .btr-st__stage {
	justify-content: flex-start;
}

.btr-st--pin.btr-st--align-end:not(.is-static) .btr-st__stage {
	justify-content: flex-end;
}

/* Finished state when animation is skipped. */
.btr-st.is-static .btr-st__u {
	--p: 1;
}

@media (prefers-reduced-motion: reduce) {
	.btr-st__u {
		transition: none;
	}
}
