/**
 * Testimonials — cards, grid and carousel.
 *
 * Colours, typography, sizes and spacing are injected per-widget by Elementor
 * via the controls' `selectors` (mostly as CSS custom properties on `.tst`).
 * This file defines the card skeleton, the responsive grid and the carousel.
 */

.tst {
	--tst-cols: 2;
	--tst-per-view: 2;
	--tst-col-gap: 24px;
	--tst-row-gap: 24px;
	--tst-align: flex-start;
	--tst-text-align: left;
	--tst-avatar-size: 48px;
	--tst-avatar-ratio: 1;
	--tst-avatar-gap: 14px;
	--tst-star: #f5a623;
	--tst-star-empty: #e2e2e8;
	--tst-arrow-size: 40px;
	--tst-arrow-offset: -20px;
	--tst-dot: #c9c9d6;
	--tst-dot-active: #22285b;
	--tst-dot-size: 9px;
	--tst-nav-gap: 14px;
	--tst-nav-top: 28px;
}

/* ---------------- Card ---------------- */
.tst-card {
	display: flex;
	flex-direction: column;
	align-items: var(--tst-align);
	box-sizing: border-box;
	width: 100%;
	padding: 32px;
	border-radius: 16px;
	background-color: #fff; /* fallback until the Background group control loads */
	color: inherit;
	text-align: var(--tst-text-align);
	text-decoration: none;
	transition-property: transform, box-shadow, background-color, border-color, color;
	transition-duration: 0.2s;
	transition-timing-function: ease;
}

.tst-equal .tst-card {
	height: 100%;
}

.tst-empty {
	margin: 0;
	font-style: italic;
	opacity: 0.7;
}

/* ---------------- Grid ---------------- */
.tst-grid {
	display: grid;
	grid-template-columns: repeat(var(--tst-cols), minmax(0, 1fr));
	column-gap: var(--tst-col-gap);
	row-gap: var(--tst-row-gap);
}

/* Without equal heights each card is only as tall as its own content. */
.tst:not(.tst-equal) .tst-grid {
	align-items: start;
}

/* ---------------- Quote icon ---------------- */
.tst-quote-icon {
	display: block;
	flex: 0 0 auto;
	margin-bottom: 24px;
	color: #8a7a52;
	font-size: 26px;
	line-height: 1;
	transform: translate( var( --tst-qi-x, 0px ), var( --tst-qi-y, 0px ) );
}

.tst-quote-icon svg {
	display: block;
	width: auto;
	height: 1em;
	fill: currentColor;
}

.tst-quote-icon--glyph {
	/* A quote glyph's visible ink is only about a quarter of its font-size, and
	   it sits high in the line box. Scale the glyph up and pull it flush with the
	   top of a 1em-tall box, so Size means the same here as for the bars icon.
	   Ratios measured across system-ui, Georgia, Helvetica and Courier. */
	height: 1em;
	overflow: hidden;
}

.tst-quote-icon--glyph > span {
	display: block;
	font-size: 3.9em;
	line-height: 1;
	margin-top: -0.147em; /* em here resolves against the span's own size */
}

.tst-quote-icon--guille > span {
	font-size: 2.6em;
	margin-top: -0.39em;
}

.tst-quote-icon--custom svg {
	height: 1em;
}

.tst-quote-icon--custom i {
	font-size: inherit;
	line-height: 1;
}

/* ---------------- Quote ---------------- */
.tst-quote {
	margin-bottom: 28px;
	color: #22285b;
	font-size: 18px;
	line-height: 1.6;
}

.tst-quote p {
	margin: 0 0 0.75em;
}

.tst-quote p:last-child {
	margin-bottom: 0;
}

/* ---------------- Author row ---------------- */
.tst-author {
	display: flex;
	align-items: center;
	gap: var(--tst-avatar-gap);
	max-width: 100%;
}

/* Keeps the name row on the same line across cards of differing quote length. */
.tst-author-bottom .tst-author {
	margin-top: auto;
}

.tst-img-top .tst-author {
	flex-direction: column;
	align-items: var(--tst-align);
}

.tst-author-text {
	display: flex;
	flex-direction: column;
	align-items: var(--tst-align);
	min-width: 0;
}

.tst-name {
	display: block;
	color: #22285b;
	font-weight: 700;
	text-decoration: none;
}

.tst-meta {
	display: block;
	margin-top: 2px;
	color: #9a9a9a;
}

/* ---------------- Avatar ---------------- */
.tst-avatar {
	display: block;
	flex: 0 0 auto;
	width: var(--tst-avatar-size);
	max-width: 100%;
	aspect-ratio: var(--tst-avatar-ratio);
	overflow: hidden;
	border-radius: 50%;
	line-height: 0;
}

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

/* Image sitting at the top of the card, above the quote mark. */
.tst-img-quote .tst-card > .tst-avatar {
	margin-bottom: var(--tst-avatar-gap);
}

/* ---------------- Rating ---------------- */
.tst-rating {
	position: relative;
	display: block;
	width: max-content;
	max-width: 100%;
	margin-bottom: 14px;
	font-size: 16px;
	line-height: 1;
	letter-spacing: 2px;
	white-space: nowrap;
}

.tst-rating-bg {
	color: var(--tst-star-empty);
}

.tst-rating-fg {
	position: absolute;
	top: 0;
	left: 0;
	overflow: hidden;
	color: var(--tst-star);
}

/* Inside the author block the rating sits under the name, not over the quote. */
.tst-author-text .tst-rating {
	margin-top: 6px;
	margin-bottom: 0;
}

/* ---------------- Carousel ---------------- */
.tst-viewport {
	position: relative;
}

.tst-track {
	position: relative; /* offsetLeft of the slides is measured against this */
	display: flex;
	align-items: stretch;
	gap: var(--tst-col-gap);
	overflow-x: auto;
	scroll-snap-type: x mandatory;
	scrollbar-width: none;
	-ms-overflow-style: none;
	-webkit-overflow-scrolling: touch;
}

.tst-track::-webkit-scrollbar {
	display: none;
}

.tst-track:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 4px;
}

.tst:not(.tst-equal) .tst-track {
	align-items: flex-start;
}

.tst-slide {
	display: flex;
	flex: 0 0 calc((100% - (var(--tst-per-view) - 1) * var(--tst-col-gap)) / var(--tst-per-view));
	min-width: 0;
	scroll-snap-align: start;
}

/* While dragging with the mouse, suppress snap so the motion tracks the cursor. */
.tst-dragging .tst-track {
	scroll-snap-type: none;
	cursor: grabbing;
	user-select: none;
}

.tst-dragging .tst-card {
	pointer-events: none;
}

/* ---------------- Arrows & dots ---------------- */
.tst-nav {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: var(--tst-nav-gap);
	margin-top: var(--tst-nav-top);
}

.tst-arrow {
	display: inline-flex;
	flex: 0 0 auto;
	align-items: center;
	justify-content: center;
	width: var(--tst-arrow-size);
	height: var(--tst-arrow-size);
	padding: 0;
	border: 0;
	border-radius: 50%;
	background-color: #fff;
	color: #22285b;
	cursor: pointer;
	transition: opacity 0.2s ease, background-color 0.2s ease, color 0.2s ease;
}

.tst-arrow svg {
	width: 18px;
	height: 18px;
}

.tst-arrow[disabled] {
	opacity: 0.35;
	cursor: default;
}

/* Arrows overlaying the sides of the cards. */
.tst-viewport .tst-arrow {
	position: absolute;
	top: 50%;
	z-index: 2;
	transform: translateY(-50%);
}

.tst-viewport .tst-arrow--prev {
	left: 0;
	margin-left: var(--tst-arrow-offset);
}

.tst-viewport .tst-arrow--next {
	right: 0;
	margin-right: var(--tst-arrow-offset);
}

.tst-dots {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: var(--tst-nav-gap);
}

.tst-dot {
	width: var(--tst-dot-size);
	height: var(--tst-dot-size);
	padding: 0;
	border: 0;
	border-radius: 50%;
	background-color: var(--tst-dot);
	cursor: pointer;
	transition: background-color 0.2s ease, transform 0.2s ease;
}

.tst-dot.is-active {
	background-color: var(--tst-dot-active);
}

/* One page of slides means nothing to navigate to. */
.tst-is-static .tst-nav,
.tst-is-static .tst-arrow {
	display: none;
}

/* Respect the visitor's motion preference: the script also skips autoplay. */
@media (prefers-reduced-motion: reduce) {
	.tst-card {
		transition: none;
	}
}
