/**
 * td/testimonials + td/testimonial
 */

.td-testimonials {

	/* Longer quotes are cut to this many lines and get Read more (an ~80-word
	   quote fits at the 390px and 1440px design widths). */
	--td-quote-lines: 12;
	padding-block: 48px;
	background-color: var(--wp--preset--color--ink);
	color: var(--wp--preset--color--stone);
}

.td-testimonials__inner {
	display: flex;
	flex-direction: column;
	gap: 48px;
}

.td-testimonials__header {
	display: flex;
	flex-direction: column;
	gap: 24px;
	max-width: 765px;
}

.td-testimonials__eyebrow {
	color: var(--wp--preset--color--champagne);
}

.td-testimonials__title {
	text-wrap: balance;
	font-family: var(--wp--preset--font-family--serif);
	font-size: 32px;
	font-weight: 400;
	line-height: 40px;
	color: var(--wp--preset--color--ivory);
}

/* Slides ------------------------------------------------------------------ */

.td-testimonials__slides {
	display: grid;
}

/* Every quote shares one grid cell and only the current one is visible, so
   the slides area is always as tall as the tallest quote (it still grows
   with longer text, e.g. on phones) and the counter and arrows below it
   never move. Quote text is limited to --td-quote-lines, so one long quote
   no longer leaves empty space under the short ones. visibility also keeps
   hidden quotes out of the accessibility tree. */
.td-testimonial {
	display: flex;
	flex-direction: column;
	grid-area: 1 / 1;
	gap: 48px;
	margin: 0;
	visibility: hidden;
}

.td-testimonial.is-current {
	visibility: visible;
	animation: td-testimonial-in 0.45s var(--td-ease);
}

.td-testimonial__quote {
	--td-quote-lh: 32px;
	margin: 0;
	font-family: var(--wp--preset--font-family--serif);
	font-size: 24px;
	line-height: var(--td-quote-lh);
	color: var(--wp--preset--color--ivory);
}

.td-testimonial__author {
	color: var(--wp--preset--color--ivory);
}

/* Read more / Read less ---------------------------------------------------
   Expanding never changes the quote's height: the full text scrolls inside
   the same --td-quote-lines box, so the slides area, counter and arrows stay
   put. The button sits in the gap below the quote (out of the flow), so
   showing it moves nothing either. */
.td-testimonial__body {
	position: relative;
}

.td-testimonial__text {
	display: -webkit-box;
	overflow: hidden;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: var(--td-quote-lines);
	line-clamp: var(--td-quote-lines);
}

.td-testimonial.is-expanded .td-testimonial__text {
	display: block;
	max-height: calc(var(--td-quote-lines) * var(--td-quote-lh));
	overflow-y: auto;
	overscroll-behavior: contain;
	scrollbar-color: currentcolor transparent;
	scrollbar-width: thin;
	-webkit-line-clamp: none;
	line-clamp: none;
}

/* Shows that the expanded text continues below (set by view.js). */
.td-testimonial.is-expanded .td-testimonial__text.has-more-below {
	mask-image: linear-gradient(to bottom, #000 calc(100% - var(--td-quote-lh)), transparent);
}

.td-testimonial__text:focus-visible {
	outline: 1px solid currentcolor;
	outline-offset: 4px;
}

.td-testimonial__more {
	position: absolute;
	top: 100%;
	left: 0;
	margin-top: 12px;
	border: 0;
	background-color: transparent;
	color: var(--wp--preset--color--ivory);
	cursor: pointer;
}

.td-testimonial__more[hidden] {
	display: none;
}

/* Hidden full-size copies of every quote (render.php), only needed from
   1200px where the next quote is previewed small. */
.td-testimonials__ghost {
	display: none;
}

@keyframes td-testimonial-in {

	from {
		opacity: 0;
	}

	to {
		opacity: 1;
	}
}

/* Pagination -------------------------------------------------------------- */

.td-testimonials__pagination {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 64px;
}

.td-testimonials__count {
	font-size: 12px;
	line-height: 20px;
	color: var(--wp--preset--color--ivory);
}

.td-testimonials__controls {
	display: flex;
	gap: 11px;
}

.td-testimonials__control {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	padding: 4px;
	border: 0.5px solid var(--wp--preset--color--ivory);
	background: transparent;
	color: var(--wp--preset--color--ivory);
	cursor: pointer;
	transition: background-color 0.2s var(--td-ease), color 0.2s var(--td-ease);
}

.td-testimonials__control:hover {
	background-color: var(--wp--preset--color--ivory);
	color: var(--wp--preset--color--ink);
}

@media (min-width: 600px) {

	.td-testimonials {
		--td-quote-lines: 8;
	}
}

@media (min-width: 1024px) {

	.td-testimonials {
		--td-quote-lines: 10;
		padding-block: 32px 150px;
	}

	.td-testimonials__inner {
		gap: 64px;
	}

	.td-testimonials__header {
		gap: 32px;
	}

	.td-testimonials__title {
		font-size: 48px;
		line-height: 56px;
	}

	.td-testimonial {
		gap: 64px;
		max-width: 765px;
	}

	.td-testimonial__quote {
		--td-quote-lh: 48px;
		font-size: 40px;
	}

	.td-testimonial__more {
		margin-top: 16px;
	}

	.td-testimonials__count {
		line-height: 13px;
	}

	.td-testimonials__control {
		width: 40px;
		height: 40px;
		padding: 8px;
	}
}

/* The "next" preview needs the full desktop width beside the current quote. */
@media (min-width: 1200px) {

	/* The quote column is narrower than 765px up to ~1370px wide. */
	.td-testimonials {
		--td-quote-lines: 12;
	}

	.td-testimonials__slides {
		grid-template-columns: minmax(0, 765px) minmax(0, 427px);
		justify-content: space-between;
		column-gap: 64px;
	}

	.td-testimonial.is-current {
		grid-column: 1;
		grid-row: 1;
	}

	.td-testimonials__ghost {
		display: flex;
		flex-direction: column;
		grid-area: 1 / 1;
		gap: 64px;
		max-width: 765px;
		visibility: hidden;
		pointer-events: none;
	}

	.td-testimonial.is-next {
		grid-column: 2;
		grid-row: 1;
		visibility: visible;
		gap: 32px;
		animation: td-testimonial-in 0.45s var(--td-ease);
	}

	/* The preview is never expanded and stays shorter than the current quote
	   (18 x 25px < 12 x 48px), so it cannot make the row taller. */
	.td-testimonial.is-next .td-testimonial__quote {
		--td-quote-lines: 18;
		font-family: var(--wp--preset--font-family--sans);
		font-size: 16px;
		line-height: 25px;
		color: var(--wp--preset--color--stone);
	}

	.td-testimonial.is-next .td-testimonial__more {
		display: none;
	}

	.td-testimonial.is-next .td-testimonial__author {
		color: var(--wp--preset--color--stone);
	}
}

/* Light style: sand section with ink text ------------------------------- */

.td-testimonials.is-style-light {
	background-color: var(--wp--preset--color--sand);
	color: var(--wp--preset--color--slate);
}

.td-testimonials.is-style-light .td-testimonials__eyebrow {
	color: var(--wp--preset--color--bronze);
}

.td-testimonials.is-style-light .td-testimonials__title,
.td-testimonials.is-style-light .td-testimonial__quote,
.td-testimonials.is-style-light .td-testimonial__author,
.td-testimonials.is-style-light .td-testimonial__more,
.td-testimonials.is-style-light .td-testimonials__count {
	color: var(--wp--preset--color--ink);
}

.td-testimonials.is-style-light .td-testimonials__control {
	border-color: var(--wp--preset--color--ink);
	color: var(--wp--preset--color--ink);
}

.td-testimonials.is-style-light .td-testimonials__control:hover,
.td-testimonials.is-style-light .td-testimonials__control:focus-visible {
	background-color: var(--wp--preset--color--ink);
	color: var(--wp--preset--color--ivory);
}

@media (min-width: 1024px) {

	.td-testimonials.is-style-light {
		padding-block: 150px;
	}
}

@media (min-width: 1200px) {

	.td-testimonials.is-style-light .td-testimonial.is-next .td-testimonial__quote,
	.td-testimonials.is-style-light .td-testimonial.is-next .td-testimonial__author {
		color: var(--wp--preset--color--slate);
	}
}
