/*
 * Customer Reviews Carousel — three layouts: cards, spotlight, marquee.
 *
 * 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.
 * Settings the admin changes arrive as --crc-* custom properties plus a
 * class per property, so untouched properties keep the theme's own styles.
 * Logical properties keep everything correct in RTL languages.
 *
 * Responsive rules use width classes the script sets from the section's own
 * width (crc--sm < 600px, crc--md >= 640px, crc--side >= 760px, crc--lg >= 1000px),
 * with viewport media queries as the fallback before the script has run.
 * (CSS container queries are avoided on purpose: inside Elementor's flex
 * containers they make the page reserve a large empty space on phones.)
 */

.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))))))))));
	--_ink: color-mix(in srgb, var(--_accent) 72%, 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));
	--_tint: color-mix(in srgb, var(--_accent) 12%, var(--_card-bg));
	--_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);
	--_muted: color-mix(in srgb, currentColor 68%, transparent);
	--_shadow: 0 1px 2px color-mix(in srgb, currentColor 6%, transparent), 0 8px 24px -8px color-mix(in srgb, currentColor 14%, transparent);
	--_shadow-hover: 0 2px 4px color-mix(in srgb, currentColor 6%, transparent), 0 18px 40px -12px color-mix(in srgb, currentColor 22%, transparent);
	--_gap: var(--crc-gap, 24px);
	--_radius: var(--crc-radius, 16px);
	--_ease: cubic-bezier(0.22, 1, 0.36, 1);
	--_per-view: var(--crc-per-view-mobile, 1);

	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, 72px) clamp(16px, 4vw, 48px);
	border-radius: var(--_radius);
}

.crc--text-color {
	color: var(--crc-text);
}

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

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

.crc--align-start .crc__header {
	text-align: start;
}

.crc--align-end .crc__header {
	text-align: end;
}

.crc__heading {
	margin-block: 0 0.35em;
	text-wrap: balance;
}

.crc__subtitle {
	max-inline-size: 62ch;
	margin-block: 0;
	margin-inline: auto;
	color: var(--_muted);
	text-wrap: pretty;
}

.crc--align-start .crc__subtitle {
	margin-inline: 0 auto;
}

.crc--align-end .crc__subtitle {
	margin-inline: auto 0;
}

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

/* Heading and subtitle typography: each rule applies only when set in the settings. */
.crc--heading-color .crc__heading { color: var(--crc-heading); }
.crc--h-font .crc__heading { font-family: var(--crc-h-font); }
.crc--h-weight .crc__heading { font-weight: var(--crc-h-weight); }
.crc--h-size .crc__heading { font-size: var(--crc-h-size); }
.crc--h-lh .crc__heading { line-height: var(--crc-h-lh); }
.crc--h-ls .crc__heading { letter-spacing: var(--crc-h-ls); }
.crc--subtitle-color .crc__subtitle { color: var(--crc-subtitle); }
.crc--s-font .crc__subtitle { font-family: var(--crc-s-font); }
.crc--s-weight .crc__subtitle { font-weight: var(--crc-s-weight); }
.crc--s-size .crc__subtitle { font-size: var(--crc-s-size); }
.crc--s-lh .crc__subtitle { line-height: var(--crc-s-lh); }
.crc--s-ls .crc__subtitle { letter-spacing: var(--crc-s-ls); }

.crc--sm.crc--h-size-m .crc__heading { font-size: var(--crc-h-size-m); }
.crc--sm.crc--s-size-m .crc__subtitle { font-size: var(--crc-s-size-m); }

@media (max-width: 599px) {
	.crc:not(.crc--measured).crc--h-size-m .crc__heading { font-size: var(--crc-h-size-m); }
	.crc:not(.crc--measured).crc--s-size-m .crc__subtitle { font-size: var(--crc-s-size-m); }
}

/* Shared controls ---------------------------------------------------------- */

.crc__nav {
	display: none;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	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: var(--_shadow);
	transition: background-color 0.2s, border-color 0.2s, transform 0.2s var(--_ease);
}

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

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

.crc__nav:hover,
.crc__nav:focus-visible {
	background: var(--_tint);
	border-color: var(--_accent);
}

.crc__nav:active {
	transform: scale(0.94);
}

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

.crc__nav svg {
	display: block;
}

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

.crc--rtl .crc__nav--prev svg {
	transform: none;
}

.crc__controls {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 12px;
	margin-block-start: 20px;
}

/* Card (cards + marquee) --------------------------------------------------- */

.crc__card {
	display: flex;
	flex-direction: column;
	gap: 14px;
	inline-size: 100%;
	margin: 0;
	padding: clamp(20px, 2.4vw, 32px);
	background: var(--_card-bg);
	border: 1px solid var(--_line);
	border-radius: var(--_radius);
	box-shadow: var(--_shadow);
	transition: transform 0.35s var(--_ease), box-shadow 0.35s var(--_ease), border-color 0.35s;
}

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

.crc__quote {
	flex-shrink: 0;
	inline-size: 40px;
	block-size: 40px;
	padding: 9px;
	border-radius: 50%;
	background: var(--_tint);
	color: var(--_ink);
}

.crc__source {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	font-size: 0.75em;
	color: var(--_muted);
}

.crc__stars {
	display: inline-flex;
	gap: 2px;
	color: color-mix(in srgb, currentColor 18%, 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,
.crc-spot__quote {
	margin: 0;
	padding: 0;
	border: 0;
	background: none;
	font: inherit;
	font-style: normal;
	quotes: none;
}

.crc__text::before,
.crc__text::after,
.crc-spot__quote::before,
.crc-spot__quote::after {
	content: none;
}

.crc__text p,
.crc-spot__quote p {
	margin: 0;
	white-space: pre-line;
	overflow-wrap: break-word;
}

.crc__text p {
	line-height: 1.65;
}

.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: -4px 0 0;
	padding: 0;
	border: 0;
	background: none;
	color: inherit;
	font: inherit;
	font-size: 0.9em;
	font-weight: 600;
	text-decoration: underline;
	text-decoration-color: var(--_ink);
	text-decoration-thickness: 2px;
	text-underline-offset: 4px;
	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 {
	position: relative;
	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%;
	overflow: hidden;
	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;
	line-height: 1;
}

.crc__avatar.has-photo {
	background: var(--_line);
}

/* Themes often style every <img> (square corners, auto height): keep photos round. */
.crc .crc__avatar > img {
	display: block !important;
	flex: none;
	inline-size: 100% !important;
	block-size: 100% !important;
	max-inline-size: none !important;
	margin: 0 !important;
	padding: 0 !important;
	border: 0 !important;
	border-radius: 50% !important;
	box-shadow: none !important;
	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--heading-color .crc__name {
	color: var(--crc-heading);
}

.crc__city,
.crc__date {
	font-size: 0.875em;
	color: var(--_muted);
}

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

/* Card height from the settings. Every card is at least this tall; the script
   limits long texts so cards stay at this height (never below three lines of
   text), and they fade out with "Read more". */
.crc--fixed-h .crc__card,
.crc--fixed-h .crc-spot__panel {
	min-block-size: var(--crc-card-h);
}

.crc--fixed-h .crc__text {
	max-block-size: var(--crc-text-max, none);
	overflow: hidden;
}

.crc--fixed-h .crc__text.is-cut {
	-webkit-mask-image: linear-gradient(#000 70%, transparent);
	mask-image: linear-gradient(#000 70%, transparent);
}

.crc--fixed-h .crc__text[data-lines] p {
	display: block;
	-webkit-line-clamp: unset;
	line-clamp: none;
}

.crc--fixed-h .crc__text.is-expanded {
	max-block-size: none;
	-webkit-mask-image: none;
	mask-image: none;
}

/* Layout 1: cards ----------------------------------------------------------- */

.crc__viewport {
	display: grid;
	grid-template-columns: 1fr auto auto 1fr;
	grid-template-areas:
		"track track track track"
		". prev next .";
	align-items: center;
	gap: 8px 12px;
}

.crc__viewport > .crc__nav--prev { grid-area: prev; }
.crc__viewport > .crc__nav--next { grid-area: next; }

.crc__track {
	grid-area: track;
	display: flex;
	gap: var(--_gap);
	margin: 0;
	padding: 6px 4px 28px;
	list-style: none;
	overflow-x: auto;
	overscroll-behavior-x: contain;
	scroll-snap-type: x mandatory;
	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;
}

.crc--cards .crc__card:hover,
.crc--marquee .crc__card:hover {
	transform: translateY(-4px);
	box-shadow: var(--_shadow-hover);
	border-color: color-mix(in srgb, var(--_accent) 45%, transparent);
}

.crc--md .crc__viewport {
	--_per-view: var(--crc-per-view-tablet, 2);
}

.crc--lg .crc__viewport {
	--_per-view: var(--crc-per-view, 3);
}

/* Wide: arrows beside the cards. */
.crc--side .crc__viewport {
	grid-template-columns: auto minmax(0, 1fr) auto;
	grid-template-areas: "prev track next";
	column-gap: 16px;
}

.crc--side .crc__track {
	padding-block-end: 20px;
}

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

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

/* Layout 2: spotlight ------------------------------------------------------- */

.crc-spot {
	position: relative;
	max-inline-size: 960px;
	margin-inline: auto;
}

.crc-spot__stage {
	display: grid;
}

.crc-spot__panel {
	grid-area: 1 / 1;
	position: relative;
	display: flex;
	flex-direction: column;
	gap: clamp(14px, 2vw, 24px);
	margin: 0;
	padding: clamp(22px, 4vw, 52px);
	overflow: hidden;
	background:
		radial-gradient(120% 90% at 100% 0%, color-mix(in srgb, var(--_accent) 14%, transparent), transparent 60%),
		var(--_card-bg);
	border: 1px solid var(--_line);
	border-radius: calc(var(--_radius) * 1.5);
	box-shadow: var(--_shadow);
	opacity: 0;
	visibility: hidden;
	transform: translateY(12px);
	transition: opacity 0.5s var(--_ease), transform 0.6s var(--_ease), visibility 0s linear 0.5s;
}

.crc--rtl .crc-spot__panel {
	background:
		radial-gradient(120% 90% at 0% 0%, color-mix(in srgb, var(--_accent) 14%, transparent), transparent 60%),
		var(--_card-bg);
}

.crc-spot__panel.is-active {
	opacity: 1;
	visibility: visible;
	transform: none;
	transition-delay: 0s;
}

.crc-spot__top {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
}

.crc-spot__mark {
	inline-size: clamp(40px, 5vw, 56px);
	block-size: auto;
	color: var(--_ink);
}

.crc-spot__quote p {
	font-size: clamp(1.1rem, 0.95rem + 0.9vw, 1.7rem);
	font-weight: 500;
	line-height: 1.45;
	letter-spacing: -0.01em;
	text-wrap: pretty;
}

.crc-spot__quote.is-long p {
	font-size: clamp(1rem, 0.95rem + 0.4vw, 1.25rem);
	line-height: 1.6;
}

.crc--h-font .crc-spot__quote p {
	font-family: var(--crc-h-font);
}

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

.crc-spot__panel .crc__more {
	margin-block-start: -8px;
}

.crc-spot__author {
	display: flex;
	align-items: center;
	gap: 14px;
	margin-block-start: auto;
}

.crc-spot__author .crc__avatar {
	--crc-avatar-size: 56px;
}

.crc-spot__author .crc__source {
	margin-inline-start: auto;
}

.crc-spot__nav {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 12px;
	margin-block-start: 24px;
}

.crc-spot__tabs {
	display: flex;
	align-items: center;
	gap: 10px;
	min-inline-size: 0;
	padding: 6px;
	overflow-x: auto;
	scrollbar-width: none;
}

.crc-spot__tabs::-webkit-scrollbar {
	display: none;
}

.crc-spot__tab {
	flex-shrink: 0;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: none;
	color: inherit;
	font: inherit;
	cursor: pointer;
	opacity: 0.55;
	transition: opacity 0.25s, transform 0.35s var(--_ease), box-shadow 0.25s;
}

.crc-spot__tab .crc__avatar {
	--crc-avatar-size: 44px;
}

.crc-spot__tab:hover {
	opacity: 0.9;
}

.crc-spot__tab[aria-selected="true"] {
	opacity: 1;
	transform: scale(1.08);
	box-shadow: 0 0 0 2px var(--_card-bg), 0 0 0 4px var(--_ink);
}

/* Narrow: avatars get their own row above the arrows. */
.crc--sm .crc-spot__nav {
	flex-wrap: wrap;
	row-gap: 14px;
}

.crc--sm .crc-spot__tabs {
	order: -1;
	flex: 1 0 100%;
	justify-content: safe center;
}

.crc-spot__progress {
	display: block;
	block-size: 3px;
	max-inline-size: 240px;
	margin: 16px auto 0;
	border-radius: 3px;
	background: var(--_line);
	overflow: hidden;
}

.crc-spot__progress span {
	display: block;
	block-size: 100%;
	background: var(--_ink);
	transform: scaleX(0);
	transform-origin: left;
}

.crc--rtl .crc-spot__progress span {
	transform-origin: right;
}

.crc-spot__progress.is-running span {
	animation: crc-progress var(--crc-delay, 5s) linear forwards;
}

.crc-spot__progress.is-paused span {
	animation-play-state: paused;
}

@keyframes crc-progress {
	to {
		transform: scaleX(1);
	}
}

/* Without JavaScript only the first review is shown. */
.crc--spotlight:not(.crc--js) .crc-spot__nav,
.crc--spotlight:not(.crc--js) .crc-spot__progress {
	display: none;
}

/* Layout 3: marquee ---------------------------------------------------------- */

.crc-marquee {
	display: grid;
	gap: var(--_gap);
}

.crc-marquee__row {
	/* The rows move by transform in LTR coordinates; cards restore RTL below. */
	direction: ltr;
	overflow-x: auto;
	scrollbar-width: none;
	padding-block: 6px 12px;
	-webkit-mask-image: linear-gradient(to right, transparent, #000 7%, #000 93%, transparent);
	mask-image: linear-gradient(to right, transparent, #000 7%, #000 93%, transparent);
}

.crc--js .crc-marquee__row {
	overflow: hidden;
	touch-action: pan-y;
	cursor: grab;
	user-select: none;
}

.crc-marquee__row::-webkit-scrollbar {
	display: none;
}

/* An opened "Read more" grows only its own card, not the whole row. */
.crc-marquee__track:has(.is-expanded) {
	align-items: flex-start;
}

.crc-marquee__track {
	display: flex;
	gap: var(--_gap);
	inline-size: max-content;
	margin: 0;
	padding: 0 4px;
	list-style: none;
	will-change: transform;
}

.crc-marquee .crc__slide {
	flex: 0 0 clamp(260px, 30vw, 380px);
}

.crc-marquee .crc__card {
	gap: 12px;
	padding: 22px;
}

.crc--rtl .crc-marquee .crc__card {
	direction: rtl;
}

/* Layout 4: stack ------------------------------------------------------------ */

.crc-stack {
	max-inline-size: 640px;
	margin-inline: auto;
}

.crc-stack__deck {
	display: grid;
	margin: 0;
	/* Room for the cards peeking out below the front card. */
	padding: 0 0 36px;
	list-style: none;
	touch-action: pan-y;
}

.crc-stack__item {
	grid-area: 1 / 1;
	display: flex;
	margin: 0;
	padding: 0;
	transform-origin: 50% 100%;
	transition: transform 0.55s var(--_ease), opacity 0.45s var(--_ease);
	will-change: transform;
}

.crc-stack__item::before,
.crc-stack__item::marker {
	content: none;
}

.crc-stack__item .crc__card {
	box-shadow: var(--_shadow-hover);
}

.crc-stack__item[data-pos="0"] {
	z-index: 4;
}

.crc-stack__item[data-pos="1"] {
	z-index: 3;
	transform: translateY(16px) scale(0.95);
	opacity: 0.9;
}

.crc-stack__item[data-pos="2"] {
	z-index: 2;
	transform: translateY(32px) scale(0.9);
	opacity: 0.6;
}

.crc-stack__item[data-pos="3"] {
	z-index: 1;
	transform: translateY(40px) scale(0.86);
	opacity: 0;
	pointer-events: none;
}

.crc-stack__item[data-pos="1"] .crc__card,
.crc-stack__item[data-pos="2"] .crc__card,
.crc-stack__item[data-pos="3"] .crc__card {
	pointer-events: none;
}

/* Cards behind the front one show as clean paper, not as half-visible text. */
.crc--js .crc-stack__item:not([data-pos="0"]):not(.is-leaving) .crc__card > * {
	visibility: hidden;
}

/* The front card leaving: forwards to the start side, backwards from it. */
.crc-stack__item.is-leaving {
	z-index: 5;
	transform: translateX(-110%) rotate(-7deg);
	opacity: 0;
}

.crc--rtl .crc-stack__item.is-leaving {
	transform: translateX(110%) rotate(7deg);
}

.crc-stack__item.is-dragging {
	transition: none;
}

.crc--js .crc-stack__item[data-pos="0"] {
	cursor: grab;
	user-select: none;
}

.crc-stack__count {
	min-inline-size: 4.5em;
	text-align: center;
	font-variant-numeric: tabular-nums;
	color: var(--_muted);
	font-size: 0.9em;
}

/* Without JavaScript the first card is shown on its own. */
.crc--stack:not(.crc--js) .crc-stack__item:not(:first-child) {
	display: none;
}

.crc--stack:not(.crc--js) .crc-stack__deck {
	padding-block-end: 0;
}

/* Motion preferences --------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
	.crc__nav,
	.crc__card,
	.crc-spot__panel,
	.crc-spot__tab,
	.crc-stack__item {
		transition: none;
	}

	.crc--cards .crc__card:hover,
	.crc--marquee .crc__card:hover {
		transform: none;
	}

	.crc-spot__progress {
		display: none;
	}
}

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

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