/*
 * Section 14 — the testimonials, as a slider.
 *
 * The design's row never moves and its arrows are a picture. This is a deliberate departure: the
 * client wants a slider, so the row is a scrolling list with snap points and the arrows are buttons.
 * At rest it is the design — three cards across above the phone — and the geometry measured against
 * it is unchanged.
 *
 * Until now the phone ran a marquee that loops by itself. It is gone: something that moves on its own
 * and something the reader drags cannot share one row, and the drag is the one that was asked for.
 *
 * The red line down the left of each card is not a border on the card. The design draws it on a
 * pseudo-element, which is why the box dump reported no border here; it is 1px of --as-red on all
 * three, confirmed by sampling the pixels after two probes disagreed with what the screenshots
 * looked like.
 */

.as-voices {
	display: flex;
	flex-direction: column;
	gap: 40px;
	align-items: center;
	justify-content: center;
	padding: 114px 32px;
	background: var(--as-navy);
}

.as-voices__head {
	display: flex;
	flex-direction: row;
	gap: 8px;
	align-items: center;
	justify-content: space-between;
	width: 100%;
	max-width: var(--as-container-narrow);
}

.as-voices__title {
	color: var(--as-mist);
	font-size: 40px;
	font-weight: 400;
	line-height: var(--as-lh-snug);
	letter-spacing: -0.02em;
}

.as-voices__arrows {
	display: none;
	flex: 0 0 52px;
	flex-direction: row;
	width: 52px;
	height: 20px;
	color: var(--as-mist);
}

/* Shown only once the script is there to answer the click. */
.as-voices.is-live .as-voices__arrows {
	display: flex;
}

.as-voices__arrow {
	position: relative;
	display: block;
	flex: 0 0 26px;
	width: 26px;
	height: 20px;
	padding: 0;
	border: 0;
	background: none;
	color: inherit;
	cursor: pointer;
}

/*
 * 26 by 20 is too small to hit. The target grows past the drawn box instead of the box growing, so the
 * 52px total and the position of the ink stay as the design draws them. The two targets meet at the
 * join rather than overlapping.
 */
.as-voices__arrow::before {
	content: "";
	position: absolute;
	inset: -14px 0;
}

.as-voices__arrow--prev::before {
	left: -14px;
}

.as-voices__arrow--next::before {
	right: -14px;
}

.as-voices__arrow:hover {
	color: var(--as-white);
}

.as-voices__arrow:focus-visible {
	outline: 2px solid var(--as-red);
	outline-offset: 2px;
}

/*
 * The row of cards is 297 tall at every width, and that is a number the design states rather than
 * one its contents produce. At 1440 the tallest card happens to be exactly 297; at 810 it is 326 and
 * at 390 it is 320, and the design keeps the row at 297 in both cases and lets the longest
 * testimonial run past the bottom of it into the band's padding. The band stays 613 because of it.
 *
 * So the height is stated here, and only the horizontal axis is clipped — the marquee on the phone
 * needs that, the overspill does not. `clip` is what makes the pair possible: with `hidden` the
 * browser is required to clip the other axis too, which would cut the third testimonial's last line.
 *
 * The spill lands in 114px of padding, so there is room for it. A testimonial materially longer than
 * the three placeholders here would eventually run out of that room — see the note to the designer.
 */
.as-voices__viewport {
	position: relative;
	width: 100%;
	max-width: var(--as-container-narrow);
	height: 297px;
}

/*
 * The track is the scroller, and it is taller than the 297 the row occupies in the layout.
 *
 * A scrolling box has to clip on both axes, so it cannot let the longest testimonial run past the
 * bottom of the row into the band's padding the way the design does. Instead the box is given the
 * room — 360 — and hangs below its 297-tall wrapper, which has no overflow rule of its own and so
 * lets it. The layout still sees 297 and the band is still 613. A testimonial that needs more than
 * 360 would be cut, which is roughly twice what the three placeholders ask for.
 */
.as-voices__track {
	display: flex;
	flex-direction: row;
	gap: 0;
	align-items: flex-start;
	width: 100%;
	height: 360px;
	margin: 0;
	padding: 0;
	list-style: none;
	overflow-x: auto;
	overflow-y: hidden;
	scroll-snap-type: x mandatory;
	overscroll-behavior-x: contain;
	scrollbar-width: none;
}

.as-voices__track::-webkit-scrollbar {
	display: none;
}

.as-voices__track:focus-visible {
	outline: 2px solid var(--as-red);
	outline-offset: 4px;
}

/* A third of the track, so three fill it exactly as they did when they divided a row. */
.as-voices__item {
	flex: 0 0 calc(100% / 3);
	scroll-snap-align: start;
}

/*
 * The browser's own margins have to go before anything here can be measured.
 *
 * This card is built from <figure>, <blockquote> and <p>, and all three carry margins from the
 * browser's default stylesheet. The blockquote's is the expensive one: `1em 40px`. The 40 pushed
 * every quote 40px right of the card it belongs to — the whole row of three read as misaligned — and
 * the 1em above and below added 32px to each card, which is how a band the design draws at 613 came
 * out at 661. Nothing in the stylesheet was wrong; what was missing was saying no to the default.
 */
.as-voice,
.as-voice__quote,
.as-voice__text {
	margin: 0;
}

.as-voice {
	position: relative;
	display: flex;
	flex-direction: column;
	gap: 4px;
	align-items: flex-start;
	padding: 0 40px;
	/*
	 * All three cards are the same height even though the testimonials are not.
	 *
	 * No box measurement objected to letting them end with their own text: the section, the row and
	 * every word landed where the design puts them. The divider below gave it away — in the design
	 * all three run 300px, in ours they ran 274, 274 and 297, one length per testimonial. 300 is 3px
	 * more than the longest card needs, so it is a height the design states rather than the tallest
	 * card stretching its neighbours.
	 */
	height: 300px;
}

/*
 * The line is drawn on the card's own pseudo-element rather than as a border, so the 40px of padding
 * belongs to the content and the line sits at the very edge of the card — which is where the design
 * puts it, including on the first card where there is nothing to its left.
 */
.as-voice::after {
	content: "";
	position: absolute;
	inset: 0 auto 0 0;
	width: 1px;
	background: var(--as-red);
}

.as-voice__head {
	display: flex;
	flex-direction: row;
	gap: 8px;
	align-items: center;
	justify-content: space-between;
	width: 100%;
}

.as-voice__portrait {
	display: block;
	flex: 0 0 80px;
	width: 80px;
	height: 80px;
	object-fit: cover;
	border-radius: 100%;
}

.as-voice__who {
	display: flex;
	flex-direction: column;
}

.as-voice__name {
	color: var(--as-mist);
	font-size: 16px;
	font-weight: 600;
	line-height: var(--as-lh-snug);
}

.as-voice__role {
	color: var(--as-red);
	font-size: 16px;
	font-weight: 500;
	line-height: var(--as-lh-snug);
}

.as-voice__quote {
	display: flex;
	flex-direction: column;
	gap: 4px;
	align-items: flex-start;
	width: 100%;
	padding-top: 24px;
}

.as-voice__mark {
	color: var(--as-mist);
	font-size: 40px;
	font-weight: 600;
	line-height: var(--as-lh-snug);
}

.as-voice__text {
	color: var(--as-mist);
	font-size: 19px;
	font-weight: 500;
	line-height: var(--as-lh-snug);
	letter-spacing: -0.01em;
}

/*
 * The tablet keeps the row, halves the card's side padding and shrinks the portrait — all three are
 * the design's, and the portrait is the one that is easy to miss. It is 80 at 1440 and 80 again on
 * the phone, and 64 only here, which is the width where three cards have the least room each.
 */
@media (max-width: 1199px) and (min-width: 810px) {
	.as-voice {
		padding: 0 16px;
		/* The one band where the design lets each card end with its own testimonial: 281, 326, 326. */
		height: auto;
	}

	.as-voice__portrait {
		flex: 0 0 64px;
		width: 64px;
		height: 64px;
	}
}

@media (max-width: 809px) {
	/* One card and a sliver of the next, which is what the marquee showed and tells the reader there is more. */
	.as-voices__item {
		flex: 0 0 320px;
	}

	/*
	 * The design has no arrows on the phone, and beside a 40px heading in a 326px column there is no
	 * room for them: they wrapped onto a line of their own and the band grew from 613 to 661. They go
	 * into the band's bottom padding instead, under the row, where nothing is drawn and the layout does
	 * not notice. The longest card spills 23px below the row and this sits a good deal lower than that.
	 */
	.as-voices {
		position: relative;
	}

	.as-voices__arrows {
		position: absolute;
		bottom: 40px;
		left: 32px;
	}
}
