/**
 * Trustpilot reviews — design system "Trustpilot" card and summary.
 * Uses the theme's tokens when present (Palletways V2) with plain fallbacks.
 */
.pw-tp {
	display: flex;
	flex-direction: column;
	gap: var(--wp--preset--spacing--xl, 2rem);
	box-sizing: border-box;
}

.pw-tp:where(:not(.has-background)) {
	padding: var(--wp--preset--spacing--lg, 1.5rem);
	background-color: var(--wp--preset--color--surface, #fff);
}

.pw-tp__header {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: var(--wp--preset--spacing--md, 1rem);
}

.pw-tp__title {
	margin: 0;
	color: var(--wp--preset--color--text-secondary, #44536a);
}

/* Summary: "Excellent ★★★★★ TrustScore 4.6 | 5,159 reviews ★ Trustpilot" */
.pw-tp__summary {
	display: inline-flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.5rem 0.75rem;
	padding: var(--wp--preset--spacing--xs, 0.5rem) var(--wp--preset--spacing--md, 1rem);
	border-radius: var(--wp--custom--radius--sm, 8px);
	background-color: var(--wp--preset--color--surface-natural, #f8f8f8);
	color: var(--wp--preset--color--text, #0f172a);
	font-size: var(--wp--preset--font-size--small, 0.875rem);
	text-decoration: none;

	&:hover {
		text-decoration: underline;
	}
}

.pw-tp__summary-label {
	font-size: var(--wp--preset--font-size--body, 1rem);
	font-weight: 600;
}

.pw-tp__brand {
	display: inline-flex;
	align-items: center;
	gap: 0.25rem;
	font-weight: 600;
}

.pw-tp__brand-star {
	width: 1.125rem;
	height: 1.125rem;
	background-color: #00B67A;
	mask: url("star.svg") center / contain no-repeat;
}

/* Stars: green squares with a white star, partially filled for decimals. */
.pw-tp__stars {
	--pw-tp-star: 16px;

	display: inline-flex;
	gap: 1px;

	&.is-md {
		--pw-tp-star: 20px;

		gap: 2px;
	}
}

.pw-tp__star {
	position: relative;
	width: var(--pw-tp-star);
	height: var(--pw-tp-star);
	background: linear-gradient(90deg, #00B67A var(--pw-tp-fill, 100%), #DCDCE6 var(--pw-tp-fill, 100%));

	&::after {
		content: "";
		position: absolute;
		inset: 10%;
		background-color: #fff;
		mask: url("star.svg") center / contain no-repeat;
	}
}

/* Cards */
.pw-tp__grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(max(15rem, calc((100% - (var(--pw-tp-columns, 4) - 1) * 1.5rem) / var(--pw-tp-columns, 4))), 1fr));
	gap: var(--wp--preset--spacing--lg, 1.5rem);
	margin: 0;
	padding: 0;
	list-style: none;
}

.pw-tp__card {
	display: flex;
	flex-direction: column;
	gap: 12px;
	min-height: 16.375rem;
	margin: 0;
	padding: 12px 16px;
	border: 1px solid var(--wp--preset--color--border-subtle, #e2e8f0);
	border-radius: var(--wp--custom--radius--sm, 8px);
	background-color: var(--wp--preset--color--surface, #fff);
	box-sizing: border-box;
}

.pw-tp__reviewer {
	display: flex;
	align-items: center;
	gap: 8px;
}

.pw-tp__avatar {
	display: inline-flex;
	flex: 0 0 auto;
	align-items: center;
	justify-content: center;
	width: 2rem;
	height: 2rem;
	border-radius: 999px;
	background-color: var(--wp--preset--color--brand-blue-light, #dfedff);
	color: var(--wp--preset--color--text, #0f172a);
	font-size: var(--wp--preset--font-size--caption, 0.75rem);
	font-weight: 600;
	line-height: 1;
}

.pw-tp__reviewer-meta {
	display: flex;
	flex-direction: column;
	min-width: 0;
}

.pw-tp__name {
	overflow: hidden;
	font-weight: 600;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.pw-tp__date {
	color: var(--wp--preset--color--text-secondary, #44536a);
	font-size: var(--wp--preset--font-size--caption, 0.75rem);
	font-weight: 300;
	line-height: 1;
}

.pw-tp__review-title {
	margin: 0;
	font-weight: 600;
}

.pw-tp__text {
	flex: 1;
	margin: 0;
	color: var(--wp--preset--color--text-secondary, #44536a);
	font-size: var(--wp--preset--font-size--small, 0.875rem);
	line-height: 1.28571;
}

.pw-tp__more {
	display: inline-flex;
	align-items: center;
	align-self: flex-end;
	gap: 4px;
	color: var(--wp--preset--color--info, #005dd0);
	font-size: var(--wp--preset--font-size--small, 0.875rem);
	text-decoration: none;

	&::after {
		content: "";
		width: 16px;
		height: 16px;
		background-color: currentColor;
		mask: url("external-link.svg") center / contain no-repeat;
	}

	&:hover {
		text-decoration: underline;
	}
}

.pw-tp__notice {
	margin: 0;
	padding: 1rem;
	border: 1px dashed currentColor;
	border-radius: 8px;
	opacity: 0.8;
}

.pw-tp .pw-visually-hidden {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
}

/*
 * Carousel layout: one row of cards that scrolls sideways, `columns` cards in view
 * (never narrower than 15rem), with arrow buttons under it. The track's block padding
 * keeps the cards' shadows from being clipped by its overflow.
 */
.pw-tp__carousel {
	display: flex;
	flex-direction: column;
	gap: var(--wp--preset--spacing--md, 1rem);
	min-width: 0;
}

.pw-tp--carousel .pw-tp__grid {
	--pw-tp-gap: var(--wp--preset--spacing--lg, 1.5rem);
	--pw-tp-bleed: 12px;

	grid-template-columns: none;
	grid-auto-columns: min(100%, max(15rem, calc((100% - (var(--pw-tp-columns, 4) - 1) * var(--pw-tp-gap)) / var(--pw-tp-columns, 4))));
	grid-auto-flow: column;
	gap: var(--pw-tp-gap);
	margin-block: calc(-1 * var(--pw-tp-bleed)) calc(-2 * var(--pw-tp-bleed));
	padding-block: var(--pw-tp-bleed) calc(2 * var(--pw-tp-bleed));
	overflow-x: auto;
	overscroll-behavior-x: contain;
	scroll-snap-type: x mandatory;
	scrollbar-width: none;

	&::-webkit-scrollbar {
		display: none;
	}

	&:focus-visible {
		outline: 2px solid currentColor;
		outline-offset: -2px;
	}
}

.pw-tp--carousel .pw-tp__card {
	scroll-snap-align: start;
}

.pw-tp__nav {
	display: flex;
	justify-content: flex-end;
	gap: 8px;
}

.pw-tp--carousel.is-static .pw-tp__nav {
	display: none;
}

.pw-tp__nav-button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 2.5rem;
	height: 2.5rem;
	padding: 0;
	border: 1px solid var(--wp--preset--color--border-subtle, #e2e8f0);
	border-radius: 999px;
	background-color: var(--wp--preset--color--surface-raised, var(--wp--preset--color--surface, #fff));
	color: var(--wp--preset--color--text-primary, var(--wp--preset--color--text, #0f172a));
	cursor: pointer;
	transition: opacity 0.15s ease, border-color 0.15s ease;

	& svg {
		width: 20px;
		height: 20px;
		fill: none;
		stroke: currentColor;
		stroke-linecap: round;
		stroke-linejoin: round;
		stroke-width: 2;
	}

	&:hover:not(:disabled) {
		border-color: currentColor;
	}

	&:focus-visible {
		outline: 2px solid currentColor;
		outline-offset: 2px;
	}

	&:disabled {
		cursor: default;
		opacity: 0.4;
	}
}

.pw-tp__toggle {
	margin-inline-end: auto;

	& .pw-tp__icon-play {
		fill: currentColor;
		stroke: none;
	}
}

.pw-tp__toggle .pw-tp__icon-play,
.pw-tp.is-paused .pw-tp__toggle .pw-tp__icon-pause {
	display: none;
}

.pw-tp.is-paused .pw-tp__toggle .pw-tp__icon-play {
	display: block;
}

/* Placed "inside the quote form": hidden until the order wizard adopts it */
.pw-tp--quote-form:not(.is-in-quote-form) {
	display: none;
}
