/**
 * From Our Clients carousel (template-parts/quotes.php), shared by the
 * homepage and the Our Clients page.
 */

.quotes {
	padding: var(--section-space) 0;
	background: var(--c-navy-900);
	color: var(--c-white);
}

/* Narrow screens: heading, photo, testimonial, controls. Wide screens: the
 * photo on the left, and the controls resting on its bottom edge. */
.quotes__inner {
	display: grid;
	grid-template-columns: minmax(0, 1fr); /* The thumbnail row scrolls instead of widening the page. */
	grid-template-areas:
		"head"
		"media"
		"quote"
		"controls";
	gap: 32px;
}

@media (min-width: 900px) {
	.quotes__inner {
		grid-template-rows: auto auto 1fr;
		grid-template-columns: minmax(0, 7fr) minmax(0, 8fr);
		grid-template-areas:
			"media head"
			"media quote"
			"media controls";
		gap: 0 clamp(48px, 11vw, 180px);
	}

	.quotes__head {
		padding-bottom: clamp(36px, 3.4vw, 54px);
	}

	.quotes__controls {
		align-self: end;
		margin-top: 40px;
	}
}

.quotes__head {
	display: flex;
	flex-direction: column;
	gap: 24px;
	grid-area: head;
}

.quotes__media {
	position: relative;
	grid-area: media;
	align-self: start;
	width: 100%;
	max-width: 440px;
	aspect-ratio: 4 / 5;
	overflow: hidden;
	background: #1b233e;
	touch-action: pan-y; /* Sideways swipes go to quotes.js. */
}

@media (min-width: 900px) {
	.quotes__media {
		max-width: none;
	}
}

/* Every photo fills the frame; the current one fades in over the others. */
.quotes__photo {
	position: absolute;
	inset: 0;
	visibility: hidden;
	opacity: 0;
	transform: scale(1.04);
	transition: opacity 0.6s ease, transform 1.2s var(--ease-out), visibility 0s linear 0.6s;
}

.quotes__photo.is-active {
	visibility: visible;
	opacity: 1;
	transform: none;
	transition: opacity 0.8s ease, transform 1.4s var(--ease-out), visibility 0s;
}

/* Keeps the company name readable on light photos. */
.quotes__photo::after {
	position: absolute;
	inset: 0;
	background: linear-gradient(to top, rgba(17, 26, 49, 0.9), rgba(17, 26, 49, 0.45) 14%, rgba(17, 26, 49, 0) 32%);
	content: "";
}

.quotes__img,
.quotes__placeholder {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
}

.quotes__img {
	max-width: none;
	object-fit: cover;
	object-position: center top;
}

.quotes__placeholder,
.quotes__initials {
	--ph-a: #1b233e;
	--ph-b: #252d47;

	color: rgba(255, 255, 255, 0.3);
	font: 400 clamp(56px, 7vw, 96px) var(--font-serif);
	letter-spacing: 0.04em;
}

.quotes__company {
	position: absolute;
	right: 28px;
	bottom: 24px;
	left: 28px;
	z-index: 1;
	color: var(--c-gold-light);
	font-size: 11.5px;
	font-weight: 600;
	letter-spacing: 0.22em;
	text-transform: uppercase;
}

/* Without JavaScript the testimonials are simply listed. */
.quotes__track {
	display: grid;
	grid-area: quote;
	gap: 48px;
	touch-action: pan-y;
}

.quote {
	display: flex;
	flex-direction: column;
	gap: 28px;
	margin: 0;
}

.quote__text {
	margin: 0;
	font-size: clamp(18px, 10px + 0.8vw, 23px);
	font-style: italic;
	font-weight: 300;
	line-height: 1.65;
	text-wrap: pretty;
}

.quote--long .quote__text {
	font-size: clamp(16px, 9px + 0.6vw, 19px);
	line-height: 1.6;
}

.quote__text p + p {
	margin-top: 0.6em;
}

.quote__text p:first-child::before {
	content: "\201C";
}

.quote__text p:last-child::after {
	content: "\201D";
}

.quote__author {
	display: flex;
	flex-direction: column;
	gap: 4px;
}

.quote__name {
	font-size: 15px;
	font-weight: 600;
}

.quote__position {
	color: rgba(255, 255, 255, 0.62);
	font-size: 13px;
	line-height: 1.6;
}

/* With JavaScript the testimonials share one cell and cross-fade; the cell
 * takes the height of the longest one, so nothing below jumps. */
.js .quotes__track {
	gap: 0;
}

.js .quote {
	grid-area: 1 / 1;
	visibility: hidden;
	opacity: 0;
	transform: translateY(14px);
	transition: opacity 0.35s ease, transform 0.35s ease, visibility 0s linear 0.35s;
}

.js .quote.is-active {
	visibility: visible;
	opacity: 1;
	transform: none;
	transition: opacity 0.8s ease 0.15s, transform 1s var(--ease-out) 0.15s, visibility 0s;
}

.quotes__controls {
	display: flex;
	grid-area: controls;
	align-items: center;
	justify-content: space-between;
	gap: 24px;
	padding-top: 24px;
	border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.quotes__controls[hidden] {
	display: none;
}

/* Scrolls sideways when there are more thumbnails than room; theme.js fades
 * the edge that still has thumbnails behind it. */
.quotes__thumbs {
	--thumb: 64px;
	--fade-start: 0px;
	--fade-end: 0px;

	position: relative;
	display: flex;
	gap: 4px;
	min-width: 0;
	overflow-x: auto;
	overscroll-behavior-x: contain;
	scrollbar-width: none;
	-webkit-mask-image: linear-gradient(to right, transparent, #000 var(--fade-start), #000 calc(100% - var(--fade-end)), transparent);
	mask-image: linear-gradient(to right, transparent, #000 var(--fade-start), #000 calc(100% - var(--fade-end)), transparent);
}

.quotes__thumbs::-webkit-scrollbar {
	display: none;
}

.quotes__thumbs.has-more-start {
	--fade-start: 28px;
}

.quotes__thumbs.has-more-end {
	--fade-end: 28px;
}

.quotes__thumb {
	display: flex;
	flex: none;
	flex-direction: column;
	align-items: center;
	gap: 6px;
	padding: 0;
	border: 0;
	background: none;
	cursor: pointer;
}

.quotes__frame {
	display: block;
	width: var(--thumb);
	height: var(--thumb);
	padding: 3px;
	border: 1px solid rgba(255, 255, 255, 0.06);
	transition: border-color 0.3s;
}

.quotes__frame > img,
.quotes__initials {
	width: 100%;
	height: 100%;
	opacity: 0.55;
	transition: opacity 0.3s;
}

.quotes__frame > img {
	display: block;
	object-fit: cover;
	object-position: center top;
}

.quotes__initials {
	font-size: 20px;
}

.quotes__thumb:hover .quotes__frame > *,
.quotes__thumb[aria-current="true"] .quotes__frame > * {
	opacity: 1;
}

.quotes__thumb[aria-current="true"] .quotes__frame {
	border-color: var(--c-gold);
}

/* The row clips anything outside it, so the focus ring sits inside the frame. */
.quotes__thumb:focus-visible {
	outline: none;
}

.quotes__thumb:focus-visible .quotes__frame {
	outline: 2px solid var(--c-gold-light);
	outline-offset: -2px;
}

.quotes__bar {
	position: relative;
	display: block;
	width: calc(var(--thumb) - 8px);
	height: 2px;
	overflow: hidden;
	background: rgba(255, 255, 255, 0.14);
}

.quotes__fill {
	position: absolute;
	top: 0;
	bottom: 0;
	left: 0;
	width: 0;
	background: var(--c-gold);
}

/* The fill of the current testimonial times the carousel: quotes.js moves on
 * when it ends. It waits until the section has scrolled into view, and
 * hovering or focusing the carousel pauses it. */
.quotes__thumb[aria-current="true"] .quotes__fill {
	animation: quote-progress var(--quote-duration, 9s) linear forwards;
}

.quotes__track:not(.is-revealed) ~ .quotes__controls .quotes__fill,
.quotes__inner.is-paused .quotes__fill {
	animation-play-state: paused;
}

@keyframes quote-progress {
	to {
		width: 100%;
	}
}

.quotes__arrows {
	display: flex;
	flex: none;
	gap: 8px;
}

.quotes .carousel-btn {
	border-color: rgba(255, 255, 255, 0.2);
	color: var(--c-white);
}

.quotes .carousel-btn:hover {
	border-color: var(--c-white);
	background: var(--c-white);
	color: var(--c-navy);
}

.quotes .carousel-btn--next {
	border-color: var(--c-gold);
	background: var(--c-gold);
	color: var(--c-navy-900);
}

.quotes .carousel-btn--next:hover {
	border-color: var(--c-gold-light);
	background: var(--c-gold-light);
}

@media (max-width: 599.98px) {
	.quotes__thumbs {
		--thumb: 56px;
	}

	.quotes__controls {
		gap: 16px;
	}

	.quotes .carousel-btn {
		width: 48px;
		height: 48px;
		font-size: 17px;
	}
}

/* No automatic rotation for reduced motion: the bar just marks the current one. */
@media (prefers-reduced-motion: reduce) {
	.quotes__thumb[aria-current="true"] .quotes__fill {
		width: 100%;
		animation: none;
	}

	.quotes__photo,
	.quotes__photo.is-active,
	.js .quote,
	.js .quote.is-active {
		transform: none;
		transition: none;
	}
}
