/**
 * Viora Statement widget.
 *
 * No label, no rule, no lead paragraph — one sentence at poster size, with a
 * word that changes under you, a plate sitting in the line, and a note hung in
 * the margin. Deliberately the opposite of the section head every other block
 * on the site opens with.
 */

.viora-statement {
	--viora-statement-size: clamp(2.5rem, 8.33vw, 7.5rem);

	position: relative;
	padding-block: clamp(4rem, 9.03vw, 8.125rem);
	overflow: hidden;
}

.viora-statement__inner {
	position: relative;
}

.viora-statement--boxed .viora-statement__inner {
	width: min(1082px, 100% - 2 * var(--viora-layout-container-pad));
	margin-inline: auto;
}

.viora-statement--bleed .viora-statement__inner {
	width: calc(100% - 2 * var(--viora-layout-edge));
	margin-inline: auto;
}

/* -------------------------------------------------- *
 * The sentence
 * -------------------------------------------------- */

.viora-statement__text {
	margin: 0;
	color: var(--viora-ink, var(--viora-color-heading));
	font-family: var(--viora-font-display);
	font-size: var(--viora-statement-size);
	font-weight: 400;
	line-height: 0.98;
	letter-spacing: -0.04em;
	text-wrap: balance;
}

/*
 * Each word is masked by its own wrapper: the reveal slides the inner span up
 * from below the line rather than fading the block, which is what makes a
 * sentence this size read as typeset rather than animated.
 */
.viora-statement__word-wrap {
	display: inline-block;
	overflow: hidden;
	vertical-align: bottom;
	/* Descenders would be clipped by the mask without a little room. */
	padding-bottom: 0.12em;
	margin-bottom: -0.12em;
}

.viora-statement__word-inner {
	display: inline-block;
}

/*
 * The rotating slot needs horizontal slack the other words do not: italic
 * display type overhangs its advance width, and the mask's `overflow: hidden`
 * was slicing the tail off the last letter. The negative margin keeps the
 * extra room from opening a gap in the line.
 */
.viora-statement__word-wrap--slot {
	padding-inline: 0.14em;
	margin-inline: -0.14em;
}

/* -------------------------------------------------- *
 * Inline plate
 * -------------------------------------------------- */

.viora-statement__plate {
	display: inline-block;
	width: 0.92em;
	height: 0.62em;
	margin-inline: 0.12em;
	overflow: hidden;
	vertical-align: baseline;
	transform: translateY(0.02em);
}

.viora-statement__plate img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

/* -------------------------------------------------- *
 * Rotating word
 * -------------------------------------------------- */

.viora-statement__word {
	position: relative;
	display: inline-block;
	color: var(--viora-color-accent);
	font-style: italic;
}

/*
 * All the ghosts share one grid cell, so the slot is permanently as wide as
 * the widest word. The layout is settled at first paint and never moves —
 * only the visible word changes.
 */
.viora-statement__word-ghosts {
	display: inline-grid;
	visibility: hidden;
}

.viora-statement__word-ghost {
	grid-area: 1 / 1;
	white-space: nowrap;
}

.viora-statement__word-item {
	position: absolute;
	left: 0;
	top: 0;
	white-space: nowrap;
	opacity: 0;
	transform: translateY(0.9em);
	transition:
		opacity 0.45s var(--viora-motion-easing),
		transform 0.55s var(--viora-motion-easing);
}

.viora-statement__word-item.is-current {
	opacity: 1;
	transform: none;
}

.viora-statement__word-item.is-leaving {
	opacity: 0;
	transform: translateY(-0.9em);
}

/* -------------------------------------------------- *
 * Margin note
 * -------------------------------------------------- */

.viora-statement__note {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 0.5rem;
	max-width: 22ch;
	margin-top: clamp(2rem, 4vw, 3.5rem);
}

/* On a wide screen it hangs beside the sentence rather than under it. */
@media (min-width: 1025px) {
	.viora-statement__note {
		position: absolute;
		bottom: 0;
		max-width: 20ch;
		margin-top: 0;
	}

	.viora-statement--note-right .viora-statement__note {
		right: 0;
		text-align: right;
		align-items: flex-end;
	}

	.viora-statement--note-left .viora-statement__note {
		left: 0;
	}

	/* The sentence gives up the corner the note occupies. */
	.viora-statement__text {
		max-width: 88%;
	}
}

.viora-statement__note-label {
	color: var(--viora-color-accent);
}

.viora-statement__note-text {
	margin: 0;
	color: var(--viora-ink-soft, var(--viora-color-heading-soft));
	font-family: var(--viora-font-ui);
	font-size: 0.875rem;
	line-height: 1.7;
}

.viora-statement__link {
	margin-top: 0.35rem;
	font-size: 0.6875rem;
}

/* -------------------------------------------------- *
 * Reveal
 * -------------------------------------------------- */

.viora-statement.is-animated .viora-statement__word-inner,
.viora-statement.is-animated .viora-statement__plate,
.viora-statement.is-animated .viora-statement__word {
	transform: translateY(105%);
}

.viora-statement.is-animated.is-in .viora-statement__word-inner,
.viora-statement.is-animated.is-in .viora-statement__plate,
.viora-statement.is-animated.is-in .viora-statement__word {
	transform: none;
	transition: transform 0.9s var(--viora-motion-easing);
	transition-delay: var(--viora-statement-delay, 0ms);
}

.viora-statement.is-animated .viora-statement__note {
	opacity: 0;
	transform: translateY(18px);
}

.viora-statement.is-animated.is-in .viora-statement__note {
	opacity: 1;
	transform: none;
	transition:
		opacity 0.9s var(--viora-motion-easing) 0.35s,
		transform 0.9s var(--viora-motion-easing) 0.35s;
}

/* -------------------------------------------------- *
 * Mobile
 * -------------------------------------------------- */

@media (max-width: 767px) {
	.viora-statement {
		--viora-statement-size: clamp(2rem, 11vw, 3rem);
		padding-block: clamp(3rem, 8vw, 4.5rem);
	}

	.viora-statement__note {
		max-width: none;
	}
}

@media (prefers-reduced-motion: reduce) {
	.viora-statement.is-animated .viora-statement__word-inner,
	.viora-statement.is-animated .viora-statement__plate,
	.viora-statement.is-animated .viora-statement__word,
	.viora-statement.is-animated .viora-statement__note {
		opacity: 1;
		transform: none;
		transition: none;
	}

	.viora-statement__word-item {
		transition: none;
	}
}
