/**
 * Viora Stats widget.
 *
 * A pull quote over a band of figures. The counters are not boxed: they sit in
 * one row under a full-width rule, divided only by short vertical hairlines, so
 * the numbers read as a line of type rather than as a table of cards.
 */

.viora-stats {
	--viora-stats-quote-size: clamp(1.5rem, 2.71vw, 2.44rem);   /* 35 */
	--viora-stats-value-size: clamp(2.75rem, 5.55vw, 5rem);     /* 80 */

	position: relative;
	padding-block: clamp(3.5rem, 7.64vw, 6.875rem);
	overflow: hidden;
}

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

/* -------------------------------------------------- *
 * Quote
 * -------------------------------------------------- */

.viora-stats__quote {
	/* Wide enough to read as a pull quote now that it has the whole page; the
	   old narrow column was a leftover from sitting beside the counters. */
	max-width: 46ch;
	margin: 0;
	min-width: 0;
}

.viora-stats__quote-label {
	display: flex;
	align-items: center;
	gap: clamp(1rem, 2.917vw, 2.625rem);
	max-width: clamp(12rem, 16.47vw, 14.83rem);
	margin-bottom: clamp(1.5rem, 2.6vw, 2.35rem);
}

.viora-stats__quote-text {
	position: relative;
	margin: 0;
	color: var(--viora-ink, var(--viora-color-heading));
	font-family: var(--viora-font-display);
	font-size: var(--viora-stats-quote-size);
	font-weight: 400;
	font-style: italic;
	line-height: 1.28;
	letter-spacing: -0.02em;
}

/* Hangs into the margin like a printed drop quote. */
.viora-stats__mark {
	position: absolute;
	left: -0.42em;
	top: -0.28em;
	color: var(--viora-color-accent);
	font-size: 2.4em;
	font-style: normal;
	line-height: 1;
	opacity: 0.45;
	pointer-events: none;
}

.viora-stats__author {
	display: flex;
	flex-direction: column;
	gap: 0.25rem;
	margin-top: clamp(1.5rem, 2.85vw, 2.56rem);
	font-family: var(--viora-font-ui);
}

.viora-stats__author-name {
	color: var(--viora-ink, var(--viora-color-heading));
	font-size: 0.875rem;
	font-weight: var(--viora-weight-medium);
	line-height: 1.7;
	letter-spacing: 0.24em;
	text-transform: uppercase;
}

.viora-stats__author-role {
	color: var(--viora-ink-soft, var(--viora-color-heading-soft));
	font-size: 0.9375rem;
	line-height: 1.643;
}

/* -------------------------------------------------- *
 * Counters
 * -------------------------------------------------- */

/*
 * Columns follow the number of counters (paired up, so four make a 2×2), with
 * the count written inline by the view. An empty cell would show the grid's
 * own background as a grey block.
 *
 * Two hops: the inline value lands on `--viora-stats-auto`, because an inline
 * declaration would otherwise be unreachable from the breakpoints below.
 */
.viora-stats__grid {
	--viora-stats-cols-default: var(--viora-stats-auto, 4);

	display: grid;
	grid-template-columns: repeat(var(--viora-stats-cols, var(--viora-stats-cols-default)), minmax(0, 1fr));
	margin: clamp(3rem, 6vw, 5rem) 0 0;
	padding: clamp(2rem, 3.6vw, 3.25rem) 0 0;
	list-style: none;
	/* One rule across the top of the band. No box: the figures are held by the
	   line above them and by each other, the way a printed table of contents is. */
	border-top: 1px solid var(--viora-hairline, rgba(17, 17, 17, 0.14));
}

.viora-stats__cell {
	display: flex;
	flex-direction: column;
	gap: clamp(0.5rem, 0.9vw, 0.8rem);
	padding-inline: clamp(1rem, 2.4vw, 2.25rem);
}

/* Dividers between the figures only — never on the outer edges. */
.viora-stats__cell + .viora-stats__cell {
	border-left: 1px solid var(--viora-hairline, rgba(17, 17, 17, 0.14));
}

.viora-stats__cell:first-child {
	padding-inline-start: 0;
}

.viora-stats__cell:last-child {
	padding-inline-end: 0;
}

.viora-stats__value {
	display: flex;
	align-items: baseline;
	gap: 0.06em;
	color: var(--viora-ink, var(--viora-color-heading));
	font-family: var(--viora-font-display);
	font-size: var(--viora-stats-value-size);
	font-weight: 400;
	line-height: 0.94;
	letter-spacing: -0.045em;
	/* Digits must not jitter as they count. */
	font-variant-numeric: tabular-nums;
}

.viora-stats__affix {
	color: var(--viora-color-accent);
	font-size: 0.42em;
	letter-spacing: 0;
}

.viora-stats__label {
	color: var(--viora-ink-soft, var(--viora-color-heading-soft));
	font-family: var(--viora-font-ui);
	font-size: 0.75rem;
	font-weight: var(--viora-weight-medium);
	line-height: 1.7;
	letter-spacing: 0.24em;
	text-transform: uppercase;
}

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

.viora-stats.is-animated .viora-stats__item {
	opacity: 0;
	transform: translateY(22px);
}

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

/* -------------------------------------------------- *
 * Tablet
 * -------------------------------------------------- */

@media (max-width: 1024px) {
	.viora-stats {
		--viora-stats-value-size: clamp(2.5rem, 7vw, 4rem);
		padding-block: clamp(3rem, 6vw, 4.5rem);
	}

	/* Four figures across stop reading at this width; two rows of two do. */
	.viora-stats__grid {
		--viora-stats-cols-default: 2;
		row-gap: clamp(1.75rem, 4vw, 2.5rem);
	}

	.viora-stats__cell:nth-child(odd) {
		padding-inline-start: 0;
		border-left: 0;
	}

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

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

@media (max-width: 767px) {
	/* The fallback, not the property: setting the grid here would make the
	   Columns control's mobile value inert. */
	.viora-stats__grid {
		--viora-stats-cols-default: 1;
		row-gap: clamp(1.5rem, 5vw, 2rem);
	}

	/* Stacked, the dividers would run down the side of a single column. */
	.viora-stats__cell,
	.viora-stats__cell + .viora-stats__cell {
		padding-inline: 0;
		border-left: 0;
	}

	.viora-stats {
		--viora-stats-quote-size: clamp(1.375rem, 6vw, 1.75rem);
		/* Continuous with the tablet ramp at 767 (≈54px). */
		--viora-stats-value-size: clamp(2.25rem, 9vw, 3.5rem);
	}

	.viora-stats__mark {
		left: -0.1em;
		top: -0.34em;
		font-size: 2em;
	}

	.viora-stats__cell {
		padding: 1.5rem 1.25rem;
	}
}

@media (prefers-reduced-motion: reduce) {
	.viora-stats.is-animated .viora-stats__item {
		opacity: 1;
		transform: none;
		transition: none;
	}
}
