/*
 * Customer Reviews Carousel
 *
 * Every colour and font falls back to the active theme: block-theme presets
 * (theme.json), Elementor globals, then common classic-theme palettes
 * (Astra, Kadence, Blocksy, GeneratePress), then plain inheritance.
 * Values set in the plugin settings arrive as --crc-* custom properties.
 * Logical properties keep the layout correct in RTL languages.
 */

.crc {
	--_accent: var(--crc-accent, var(--wp--preset--color--primary, var(--wp--preset--color--accent, var(--wp--preset--color--accent-1, var(--e-global-color-primary, var(--e-global-color-accent, var(--ast-global-color-0, var(--global-palette1, var(--theme-palette-color-1, var(--accent, currentColor))))))))));
	--_star: var(--crc-star, #f5b400);
	--_base: var(--wp--preset--color--base, var(--e-global-color-background, var(--ast-global-color-5, var(--global-palette9, var(--theme-palette-color-8, #fff)))));
	--_card-bg: var(--crc-card-bg, var(--_base));
	--_avatar-bg: var(--crc-avatar-bg, color-mix(in srgb, var(--_accent) 22%, var(--_card-bg)));
	--_avatar-text: var(--crc-avatar-text, currentColor);
	--_line: color-mix(in srgb, currentColor 12%, transparent);
	--_gap: var(--crc-gap, 24px);
	--_radius: var(--crc-radius, 16px);
	--_per-view: var(--crc-per-view-mobile, 1);

	container-type: inline-size;
	box-sizing: border-box;
	font-family: inherit;
	margin-block: 0;
	max-inline-size: 100%;
}

.crc *,
.crc *::before,
.crc *::after {
	box-sizing: border-box;
}

.crc--has-bg {
	background: var(--crc-section-bg);
	padding: clamp(24px, 5vw, 64px) clamp(16px, 4vw, 48px);
	border-radius: var(--_radius);
}

/* Header ------------------------------------------------------------------ */

.crc__header {
	text-align: center;
	margin-block-end: clamp(20px, 4vw, 40px);
}

.crc__heading {
	margin-block: 0 0.4em;
}

/* Colours below apply only when set in the settings, so the theme's own heading and text colours win otherwise. */
.crc--text-color {
	color: var(--crc-text);
}

.crc--heading-color .crc__heading,
.crc--heading-color .crc__name {
	color: var(--crc-heading);
}

.crc--heading-size .crc__heading {
	font-size: var(--crc-heading-size);
}

.crc__subtitle {
	margin: 0 auto;
	max-inline-size: 60ch;
	opacity: 0.8;
}

.crc__summary {
	display: inline-flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: center;
	gap: 0.5em;
	margin-block: 0.75em 0;
	font-size: 0.9em;
}

/* Carousel ---------------------------------------------------------------- */

.crc__viewport {
	display: grid;
	grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
	grid-template-areas:
		"track track"
		"prev next";
	align-items: center;
	gap: 16px;
}

.crc__track {
	grid-area: track;
	display: flex;
	gap: var(--_gap);
	margin: 0;
	padding: 4px 4px 24px;
	list-style: none;
	overflow-x: auto;
	overscroll-behavior-x: contain;
	scroll-snap-type: x mandatory;
	scroll-behavior: smooth;
	scrollbar-width: none;
	-webkit-overflow-scrolling: touch;
}

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

.crc__track:focus-visible {
	outline: 2px solid var(--_accent);
	outline-offset: 4px;
	border-radius: var(--_radius);
}

.crc__slide {
	/* Never narrower than ~240px, however many cards per view are set. */
	flex: 0 0 max(calc((100% - (var(--_per-view) - 1) * var(--_gap)) / var(--_per-view)), min(240px, 100%));
	display: flex;
	margin: 0;
	padding: 0;
	scroll-snap-align: start;
	min-inline-size: 0;
}

.crc__slide::before,
.crc__slide::marker {
	content: none;
}

/* Arrows: hidden until the script runs; on narrow screens they sit under the cards. */
.crc__nav {
	display: none;
	align-items: center;
	justify-content: center;
	inline-size: 44px;
	block-size: 44px;
	margin: 0;
	padding: 0;
	border: 1px solid var(--_line);
	border-radius: 50%;
	background: var(--_card-bg);
	color: inherit;
	font: inherit;
	line-height: 1;
	cursor: pointer;
	box-shadow: 0 2px 8px color-mix(in srgb, currentColor 8%, transparent);
	transition: background-color 0.2s, color 0.2s, border-color 0.2s, opacity 0.2s;
}

.crc--js .crc__nav {
	display: inline-flex;
}

.crc--static .crc__nav {
	display: none;
}

.crc__nav--prev {
	grid-area: prev;
	justify-self: end;
}

.crc__nav--next {
	grid-area: next;
	justify-self: start;
}

/* Tinted rather than filled, so the icon stays readable with light accent colours too. */
.crc__nav:hover,
.crc__nav:focus-visible {
	background: color-mix(in srgb, var(--_accent) 22%, var(--_card-bg));
	border-color: var(--_accent);
}

.crc__nav:focus-visible {
	outline: 2px solid var(--_accent);
	outline-offset: 3px;
}

.crc__nav svg {
	display: block;
}

.crc__nav--prev svg {
	transform: scaleX(-1);
}

.crc:dir(rtl) .crc__nav--prev svg,
.rtl .crc__nav--prev svg {
	transform: none;
}

.crc:dir(rtl) .crc__nav--next svg,
.rtl .crc__nav--next svg {
	transform: scaleX(-1);
}

/* Card -------------------------------------------------------------------- */

.crc__card {
	display: flex;
	flex-direction: column;
	gap: 14px;
	inline-size: 100%;
	margin: 0;
	padding: clamp(20px, 3cqi, 32px);
	background: var(--_card-bg);
	border: 1px solid var(--_line);
	border-radius: var(--_radius);
	box-shadow: 0 4px 16px color-mix(in srgb, currentColor 6%, transparent);
}

.crc__top {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 12px;
}

.crc__quote {
	inline-size: 36px;
	block-size: 36px;
	color: var(--_accent);
	opacity: 0.6;
	flex-shrink: 0;
}

.crc__source {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	font-size: 0.75em;
	opacity: 0.7;
}

.crc__stars {
	display: inline-flex;
	gap: 2px;
	color: color-mix(in srgb, currentColor 20%, transparent);
	line-height: 1;
}

.crc__star {
	inline-size: var(--crc-star-size, 18px);
	block-size: var(--crc-star-size, 18px);
}

.crc__star.is-on {
	color: var(--_star);
}

.crc__text {
	margin: 0;
	padding: 0;
	border: 0;
	background: none;
	font: inherit;
	font-style: normal;
	quotes: none;
}

.crc__text::before,
.crc__text::after {
	content: none;
}

.crc__text p {
	margin: 0;
	white-space: pre-line;
	overflow-wrap: break-word;
	line-height: 1.6;
}

.crc--text-size .crc__text p {
	font-size: var(--crc-text-size);
}

.crc__text[data-lines] p {
	display: -webkit-box;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: var(--crc-lines, 6);
	line-clamp: var(--crc-lines, 6);
	overflow: hidden;
}

.crc__text.is-expanded p {
	display: block;
	-webkit-line-clamp: unset;
	line-clamp: none;
	overflow: visible;
}

.crc__more {
	align-self: flex-start;
	margin: -6px 0 0;
	padding: 0;
	border: 0;
	background: none;
	color: inherit;
	font: inherit;
	font-size: 0.9em;
	font-weight: 600;
	text-decoration-color: var(--_accent);
	text-decoration-thickness: 2px;
	text-decoration: underline;
	text-underline-offset: 3px;
	cursor: pointer;
}

.crc__more[hidden] {
	display: none;
}

.crc__author {
	display: flex;
	align-items: center;
	gap: 12px;
	margin-block-start: auto;
	padding-block-start: 16px;
	border-block-start: 1px solid var(--_line);
}

.crc__avatar {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	inline-size: var(--crc-avatar-size, 48px);
	block-size: var(--crc-avatar-size, 48px);
	border-radius: 50%;
	background: var(--_avatar-bg);
	color: var(--_avatar-text);
	font-weight: 700;
	font-size: calc(var(--crc-avatar-size, 48px) * 0.36);
	letter-spacing: 0.02em;
	object-fit: cover;
}

.crc__meta {
	display: flex;
	flex-direction: column;
	min-inline-size: 0;
	line-height: 1.35;
}

.crc__name {
	font-style: normal;
	font-weight: 700;
	overflow-wrap: break-word;
}

.crc__city,
.crc__date {
	font-size: 0.875em;
	opacity: 0.7;
}

.crc-empty {
	padding: 1em;
	border: 1px dashed currentColor;
	opacity: 0.7;
}

/* Responsive: sized by the space the section gets, not the screen, so it also
   fits sidebars and narrow columns. ------------------------------------- */

@container (min-width: 640px) {
	.crc__viewport {
		--_per-view: var(--crc-per-view-tablet, 2);
	}
}

@container (min-width: 1000px) {
	.crc__viewport {
		--_per-view: var(--crc-per-view, 3);
	}
}

@container (min-width: 760px) {
	.crc__viewport {
		grid-template-columns: auto minmax(0, 1fr) auto;
		grid-template-areas: "prev track next";
	}

	.crc__nav--prev,
	.crc__nav--next {
		justify-self: center;
	}
}

@media (prefers-reduced-motion: reduce) {
	.crc__track {
		scroll-behavior: auto;
	}

	.crc__nav {
		transition: none;
	}
}

@media (forced-colors: active) {
	.crc__card,
	.crc__nav {
		border: 1px solid CanvasText;
	}

	.crc__star.is-on {
		color: CanvasText;
	}
}
