/*!
 * Testimonials Manager — frontend styles.
 *
 * Structural rules (always applied) keep the slider and grid working.
 * Visual rules are scoped to .tm-styled and can be turned off in Settings.
 * Every value is a custom property so themes can override without !important.
 */

/* ---------------------------------------------------------------------------
 * Tokens
 * ------------------------------------------------------------------------- */
.tm-root {
	/* Transparent by default: the testimonials sit directly on the section background. */
	--tm-gap: 48px;
	--tm-card-bg: transparent;
	--tm-card-border: transparent;
	--tm-card-shadow: none;
	--tm-card-radius: 0;
	--tm-card-padding: 0;
	--tm-text: #333333;
	--tm-muted: rgba(51, 51, 51, 0.65);
	--tm-line: rgba(51, 51, 51, 0.2);
	--tm-accent: #e60f64;
	--tm-star: #e60f64;
	--tm-star-empty: rgba(51, 51, 51, 0.18);
	--tm-dot: rgba(51, 51, 51, 0.25);
	--tm-focus: #e60f64;
	--tm-body-size: 1.125rem;
	--tm-body-line-height: 1.9;
	--tm-body-style: italic;
	box-sizing: border-box;
}

.tm-root *,
.tm-root *::before,
.tm-root *::after {
	box-sizing: inherit;
}

/* ---------------------------------------------------------------------------
 * Card (structural)
 * ------------------------------------------------------------------------- */
.tm-card {
	display: flex;
	flex-direction: column;
	height: 100%;
	margin: 0;
	min-width: 0;
	overflow-wrap: break-word;
}

.tm-card__meta {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 8px 12px;
}

.tm-stars {
	display: inline-flex;
	gap: 2px;
	line-height: 0;
}

.tm-star {
	display: block;
	width: 18px;
	height: 18px;
	fill: var(--tm-star-empty);
}

.tm-star.is-filled {
	fill: var(--tm-star);
}

.tm-card__body {
	flex: 1 1 auto;
	margin: 0;
	padding: 0;
	border: 0;
	quotes: none;
}

.tm-card__body::before,
.tm-card__body::after {
	content: none;
}

.tm-card__body > :first-child {
	margin-top: 0;
}

.tm-card__body > :last-child {
	margin-bottom: 0;
}

/* Long testimonials: collapsed only once JS has confirmed it can expand them. */
.tm-card__body.is-clamped {
	flex: 0 0 auto;
	max-height: var(--tm-clamp-height, 13.6em);
	overflow: hidden;
	-webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 3.4em), transparent);
	mask-image: linear-gradient(to bottom, #000 calc(100% - 3.4em), transparent);
}

.tm-card__more {
	align-self: flex-start;
	padding: 0;
	margin: 0;
	border: 0;
	background: none;
	color: inherit;
	font: inherit;
	font-size: 0.875rem;
	font-weight: 600;
	text-decoration: underline;
	text-underline-offset: 3px;
	cursor: pointer;
}

.tm-card__more[hidden] {
	display: none;
}

.tm-card__more:focus-visible {
	outline: 2px solid var(--tm-focus);
	outline-offset: 2px;
	border-radius: 2px;
}

.tm-card__name {
	font-style: normal;
}

.tm-google-badge {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	white-space: nowrap;
}

.tm-google-badge__icon {
	display: block;
	flex: none;
}

/* ---------------------------------------------------------------------------
 * Slider (structural)
 * ------------------------------------------------------------------------- */
.tm-slider {
	--tm-visible: 1;
	--tm-per-view: var(--tm-visible);
	position: relative;
	width: 100%;
	max-width: 100%;
	container-type: inline-size;
}

.tm-slider[data-visible="2"] { --tm-visible: 2; }
.tm-slider[data-visible="3"] { --tm-visible: 3; }
.tm-slider[data-visible="4"] { --tm-visible: 4; }

.tm-slider__viewport {
	overflow-x: auto;
	overflow-y: hidden;
	scroll-snap-type: x mandatory;
	scroll-behavior: smooth;
	overscroll-behavior-x: contain;
	-webkit-overflow-scrolling: touch;
	scrollbar-width: none;
	/* Vertical room so card shadows are not clipped (no horizontal bleed = no page overflow). */
	padding: 4px 0 16px;
	margin: -4px 0 -16px;
}

.tm-slider[data-tm-ready] .tm-slider__viewport {
	transition: height 0.35s ease;
}

.tm-slider__viewport::-webkit-scrollbar {
	display: none;
}

.tm-slider__viewport:focus-visible {
	outline: 2px solid var(--tm-focus);
	outline-offset: 2px;
	border-radius: var(--tm-card-radius);
}

.tm-slider__track {
	display: flex;
	/* Each slide keeps its own height; JS sizes the viewport to the visible slide(s). */
	align-items: flex-start;
	gap: var(--tm-gap);
	margin: 0;
	padding: 0;
}

/* Center when there are fewer slides than slots; auto margins collapse to 0 on overflow. */
.tm-slider__slide:first-child {
	margin-inline-start: auto;
}

.tm-slider__slide:last-child {
	margin-inline-end: auto;
}

.tm-slider__slide {
	flex: 0 0 calc((100% - (var(--tm-per-view) - 1) * var(--tm-gap)) / var(--tm-per-view));
	min-width: 0;
	scroll-snap-align: start;
	scroll-snap-stop: always;
}

/* Fallback for browsers without container queries: viewport breakpoints. */
@media (max-width: 1024px) {
	.tm-slider[data-visible="3"],
	.tm-slider[data-visible="4"] { --tm-per-view: 2; }
}

@media (max-width: 640px) {
	.tm-slider { --tm-per-view: 1 !important; }
}

/* Adapt to the space the slider actually has (e.g. narrow columns, sidebars). */
@container (max-width: 1080px) {
	.tm-slider__viewport { --tm-per-view: min(var(--tm-visible), 3); }
}

@container (max-width: 860px) {
	.tm-slider__viewport { --tm-per-view: min(var(--tm-visible), 2); }
}

@container (max-width: 560px) {
	.tm-slider__viewport { --tm-per-view: 1; }
}

.tm-slider__controls {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 12px;
	margin-top: 20px;
	min-height: 40px;
}

.tm-slider__controls.is-hidden {
	visibility: hidden;
}

.tm-slider__btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	min-width: 40px;
	padding: 0;
	margin: 0;
	border: 1px solid currentColor;
	border-radius: 999px;
	background: transparent;
	color: inherit;
	cursor: pointer;
	line-height: 1;
	touch-action: manipulation;
}

.tm-slider__btn svg {
	display: block;
	fill: currentColor;
}

.tm-slider__btn:focus-visible,
.tm-slider__dot:focus-visible {
	outline: 2px solid var(--tm-focus);
	outline-offset: 2px;
}

.tm-slider__toggle .tm-icon-play { display: none; }
.tm-slider__toggle.is-paused .tm-icon-play { display: block; }
.tm-slider__toggle.is-paused .tm-icon-pause { display: none; }

.tm-slider__dots {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: center;
	gap: 2px;
	min-height: 24px;
}

.tm-slider__dot {
	/* 24px hit area around an 8px dot. */
	position: relative;
	width: 24px;
	height: 24px;
	padding: 0;
	margin: 0;
	border: 0;
	background: transparent;
	cursor: pointer;
	touch-action: manipulation;
}

.tm-slider__dot::before {
	content: "";
	position: absolute;
	top: 50%;
	left: 50%;
	width: 8px;
	height: 8px;
	margin: -4px 0 0 -4px;
	border-radius: 999px;
	background: var(--tm-dot);
	transition: background-color 0.2s ease, transform 0.2s ease;
}

.tm-slider__dot[aria-current="true"]::before {
	background: var(--tm-accent);
	transform: scale(1.25);
}

/* ---------------------------------------------------------------------------
 * List / grid (structural)
 * ------------------------------------------------------------------------- */
.tm-list {
	--tm-columns: 3;
	--tm-cols: var(--tm-columns);
	width: 100%;
	container-type: inline-size;
}

.tm-list[data-columns="1"] { --tm-columns: 1; }
.tm-list[data-columns="2"] { --tm-columns: 2; }
.tm-list[data-columns="3"] { --tm-columns: 3; }
.tm-list[data-columns="4"] { --tm-columns: 4; }

.tm-list__grid {
	display: grid;
	grid-template-columns: repeat(var(--tm-cols), minmax(0, 1fr));
	gap: var(--tm-gap);
	margin: 0;
	padding: 0;
	list-style: none;
}

.tm-list__item {
	margin: 0;
	padding: 0;
	min-width: 0;
}

.tm-list__item::before,
.tm-list__item::marker {
	content: none;
}

@media (max-width: 1024px) {
	.tm-list[data-columns="3"],
	.tm-list[data-columns="4"] { --tm-cols: 2; }
}

@media (max-width: 640px) {
	.tm-list { --tm-cols: 1 !important; }
}

@container (max-width: 1080px) {
	.tm-list__grid { --tm-cols: min(var(--tm-columns), 3); }
}

@container (max-width: 860px) {
	.tm-list__grid { --tm-cols: min(var(--tm-columns), 2); }
}

@container (max-width: 560px) {
	.tm-list__grid { --tm-cols: 1; }
}

/* ---------------------------------------------------------------------------
 * Visual design (Settings → Frontend styling)
 * Fonts are inherited from the theme; colours come from the tokens above.
 * ------------------------------------------------------------------------- */
.tm-styled {
	color: var(--tm-text);
}

.tm-styled .tm-card {
	gap: 22px;
	padding: var(--tm-card-padding);
	background: var(--tm-card-bg);
	border: 1px solid var(--tm-card-border);
	border-radius: var(--tm-card-radius);
	box-shadow: var(--tm-card-shadow);
	text-align: left;
}

.tm-styled .tm-card__meta {
	justify-content: flex-start;
	gap: 8px 16px;
}

.tm-styled .tm-card__body {
	font-size: var(--tm-body-size);
	font-style: var(--tm-body-style);
	line-height: var(--tm-body-line-height);
	color: var(--tm-text);
	background: none;
}

.tm-styled .tm-card__body p {
	margin: 0 0 1em;
	font-size: inherit;
	font-style: inherit;
	line-height: inherit;
}

.tm-styled .tm-card__body p:last-child {
	margin-bottom: 0;
}

.tm-styled .tm-card__more {
	margin-top: -8px;
	color: var(--tm-accent);
	font-size: 0.8125rem;
	font-weight: 500;
	letter-spacing: 0.12em;
	text-transform: uppercase;
	text-decoration: none;
	border-bottom: 1px solid currentColor;
	padding-bottom: 2px;
}

.tm-styled .tm-card__author {
	display: grid;
	grid-template-columns: 28px minmax(0, 1fr);
	align-items: center;
	column-gap: 14px;
	row-gap: 10px;
	margin-top: 4px;
}

/* Pink dash beside the name; the badge sits on the next row, aligned with the name. */
.tm-styled .tm-card__author::before {
	content: "";
	grid-column: 1;
	width: 28px;
	height: 1px;
	background: var(--tm-accent);
}

.tm-styled .tm-card__name,
.tm-styled .tm-card__source {
	grid-column: 2;
}

.tm-styled .tm-card__source {
	justify-self: start;
}

.tm-styled .tm-card__name {
	font-size: 0.875rem;
	font-weight: 500;
	letter-spacing: 0.12em;
	text-transform: uppercase;
	color: var(--tm-text);
}

.tm-styled .tm-google-badge {
	padding: 3px 10px;
	border: 1px solid var(--tm-line);
	border-radius: 999px;
	background: transparent;
	font-size: 0.75rem;
	font-style: normal;
	line-height: 1.4;
	color: var(--tm-muted);
}

/* Single-column list: readable line length and a clear break between testimonials. */
.tm-styled.tm-list[data-columns="1"] .tm-list__grid {
	max-width: var(--tm-single-width, 780px);
	row-gap: 0;
}

.tm-styled.tm-list[data-columns="1"] .tm-list__item + .tm-list__item {
	margin-top: 56px;
	padding-top: 56px;
	border-top: 1px solid var(--tm-line);
}

.tm-styled .tm-slider__controls {
	justify-content: flex-start;
	margin-top: 32px;
}

.tm-styled .tm-slider__btn {
	width: 44px;
	height: 44px;
	min-width: 44px;
	border: 1px solid var(--tm-accent);
	border-radius: 0;
	background: transparent;
	color: var(--tm-accent);
	transition: background-color 0.2s ease, color 0.2s ease;
}

.tm-styled .tm-slider__btn:hover {
	background: var(--tm-accent);
	color: #fff;
}

@media (max-width: 640px) {
	.tm-root { --tm-gap: 32px; --tm-body-size: 1rem; --tm-body-line-height: 1.8; }
}

@media (prefers-reduced-motion: reduce) {
	.tm-slider__viewport,
	.tm-slider[data-tm-ready] .tm-slider__viewport { scroll-behavior: auto; transition: none; }
	.tm-slider__dot::before,
	.tm-styled .tm-slider__btn { transition: none; }
}
