/**
 * CHGA Trusted By block.
 *
 * The ticker is a pure CSS marquee so it runs without JavaScript; the view
 * script repeats the logo row until half the track covers the ticker, which is
 * what keeps the loop seamless, and holds the scroll speed steady while it does.
 */

.chga-trusted-by {
	--chga-tb-columns: 5;
	--chga-tb-card: var(--chga-grey);
	--chga-tb-logo-height: 78px;
	--chga-tb-ticker-duration: 45s;
	--chga-tb-logo-gap: clamp(2.5rem, 1rem + 4.4vw, 5.5rem);
	--chga-tb-corner-width: 42%;
	--chga-tb-corner-opacity: 1;
	--chga-tb-corner-ratio: 963 / 520;
	--chga-tb-badge-size: 56%;

	position: relative;
	isolation: isolate;
	overflow: hidden;
	padding-block: clamp(2.5rem, 1rem + 3.1vw, 4.75rem) clamp(3rem, 1.5rem + 4.4vw, 6rem);
	color: var(--chga-navy);
}

.chga-trusted-by__inner {
	position: relative;
	z-index: 2;
	display: flex;
	flex-direction: column;
	gap: clamp(2.25rem, 1.2rem + 3.4vw, 4.5rem);
}

/* Corner graphic --------------------------------------------------------- */

.chga-trusted-by__corner-wrap {
	position: absolute;
	width: var(--chga-tb-corner-width);
	min-width: 18rem;
	max-width: 60rem;
	/* Reserves the right box before the lazy-loaded artwork arrives. */
	aspect-ratio: var(--chga-tb-corner-ratio);
	opacity: var(--chga-tb-corner-opacity);
	pointer-events: none;
	z-index: 1;
	line-height: 0;
}

.chga-trusted-by__corner-wrap--bottom-right {
	right: -4%;
	bottom: -6%;
}

.chga-trusted-by__corner-wrap--bottom-left {
	left: -4%;
	bottom: -6%;
}

.chga-trusted-by__corner-wrap--top-right {
	right: -4%;
	top: -6%;
}

.chga-trusted-by__corner-wrap--top-left {
	left: -4%;
	top: -6%;
}

.chga-trusted-by__corner {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: contain;
}

/*
 * The artwork is drawn for the bottom right, so the other corners flip it. This
 * has to live on the image: the wrapper's transform belongs to the scroll
 * parallax, which would otherwise wipe the flip out on its first tick.
 */
.chga-trusted-by__corner-wrap--bottom-left .chga-trusted-by__corner {
	transform: scaleX(-1);
}

.chga-trusted-by__corner-wrap--top-left .chga-trusted-by__corner {
	transform: scale(-1);
}

.chga-trusted-by__corner-wrap--top-right .chga-trusted-by__corner {
	transform: scaleY(-1);
}

/* Heading ---------------------------------------------------------------- */

.chga-trusted-by__head {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: clamp(0.75rem, 0.6rem + 0.5vw, 1.25rem);
	padding-inline: var(--chga-gutter);
	text-align: center;
}

.chga-trusted-by__heading {
	margin: 0;
	font-size: clamp(1.5rem, 2.13vw, 2.5rem);
	font-weight: 700;
	line-height: 1.2;
	letter-spacing: -0.01em;
	color: var(--chga-gold-mid);
}

.chga-trusted-by__rule {
	display: block;
	width: clamp(4.5rem, 6.4vw, 7.75rem);
	height: 2px;
	background-color: var(--chga-navy);
	transform-origin: center;
}

/* Ticker ----------------------------------------------------------------- */

.chga-trusted-by__ticker {
	position: relative;
	overflow: hidden;
	-webkit-mask-image: linear-gradient(90deg, transparent 0, #000 4%, #000 96%, transparent 100%);
	mask-image: linear-gradient(90deg, transparent 0, #000 4%, #000 96%, transparent 100%);
}

.chga-trusted-by__track {
	display: flex;
	width: max-content;
	will-change: transform;
	animation: chga-tb-ticker var(--chga-tb-ticker-duration) linear infinite;
}

.chga-trusted-by__ticker--right .chga-trusted-by__track {
	animation-direction: reverse;
}

.chga-trusted-by--pausable .chga-trusted-by__ticker:hover .chga-trusted-by__track,
.chga-trusted-by--pausable .chga-trusted-by__ticker:focus-within .chga-trusted-by__track {
	animation-play-state: paused;
}

@keyframes chga-tb-ticker {
	from {
		transform: translate3d(0, 0, 0);
	}

	to {
		transform: translate3d(-50%, 0, 0);
	}
}

.chga-trusted-by__group {
	display: flex;
	align-items: center;
	gap: var(--chga-tb-logo-gap);
	margin: 0;
	/*
	 * The space that follows the last logo belongs to the pass, so the join
	 * between one pass and the next looks exactly like the space between two
	 * logos. It cannot be a gap on the track instead: the loop slides the track
	 * by half its own width, and that only lands on a join while the passes are
	 * the only thing the track is made of.
	 */
	padding: 0 var(--chga-tb-logo-gap) 0 0;
	list-style: none;
}

.chga-trusted-by__logo {
	flex: 0 0 auto;
	margin: 0;
	line-height: 0;
}

.chga-trusted-by__logo-image {
	display: block;
	width: auto;
	height: min(var(--chga-tb-logo-height), 14vw);
	max-width: none;
	object-fit: contain;
}

/*
 * Hovering lifts and enlarges the logo rather than fading it - dimming reads as
 * "disabled" on something you are being invited to click. The ticker pauses at
 * the same time, so the logo is a steady target while the pointer is over it.
 */
.chga-trusted-by__logo-link {
	display: block;
	line-height: 0;
	border-radius: 4px;
	transform-origin: center;
	transition:
		transform 0.45s var(--chga-ease),
		filter 0.45s var(--chga-ease);
}

/* Lift and scale only - a CSS filter over an SVG logo is unreliable in Safari. */
.chga-trusted-by__logo-link:hover,
.chga-trusted-by__logo-link:focus-visible {
	transform: translateY(-3px) scale(1.07);
}

.chga-trusted-by__logo-link:focus-visible {
	outline: 2px solid var(--chga-gold-mid);
	outline-offset: 6px;
}

.chga-trusted-by__logo-link:active {
	transform: translateY(-1px) scale(1.03);
}

@media (prefers-reduced-motion: reduce) {
	.chga-trusted-by__logo-link:hover,
	.chga-trusted-by__logo-link:focus-visible {
		transform: none;
	}
}

/* Stats ------------------------------------------------------------------ */

.chga-trusted-by__stats {
	display: grid;
	grid-template-columns: repeat(var(--chga-tb-columns), minmax(0, 1fr));
	gap: clamp(1.25rem, 0.4rem + 2.6vw, 3.5rem);
	width: 100%;
	max-width: var(--chga-container);
	margin: 0 auto;
	padding-inline: var(--chga-gutter);
	list-style: none;
}

.chga-trusted-by__stat {
	display: flex;
	flex-direction: column;
	align-items: center;
	margin: 0;
}

/*
 * The badge is 56% of its card in the design. Sizing it as a percentage holds
 * that ratio at any width, where a viewport clamp drifts once the container
 * stops growing; percentage margin resolves against the card's width too. The
 * overlap and the card's top padding are both derived from the one variable, so
 * changing it per breakpoint keeps them in step.
 */
.chga-trusted-by__stat-badge {
	position: relative;
	z-index: 2;
	display: flex;
	align-items: center;
	justify-content: center;
	width: var(--chga-tb-badge-size);
	aspect-ratio: 1;
	margin-bottom: calc(var(--chga-tb-badge-size) / -2);
	border-radius: 50%;
	background-color: var(--chga-navy);
	box-shadow: 0 16px 30px -18px rgba(0, 31, 83, 0.65);
}

/* The bundled badges already draw their own circle and shadow. */
.chga-trusted-by__stat-badge:has(.chga-trusted-by__stat-icon) {
	background-color: transparent;
	box-shadow: none;
}

.chga-trusted-by__stat-icon {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: contain;
}

.chga-trusted-by__stat-card {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: clamp(0.75rem, 0.55rem + 0.6vw, 1.1875rem);
	width: 100%;
	flex: 1;
	padding:
		calc(var(--chga-tb-badge-size) / 2 + clamp(1rem, 0.6rem + 1.2vw, 2rem))
		clamp(0.75rem, 0.4rem + 1.1vw, 1.5rem)
		clamp(1.5rem, 1rem + 1.5vw, 2.5rem);
	background-color: var(--chga-tb-card);
	border-radius: clamp(0.625rem, 0.4rem + 0.7vw, 1.1875rem);
	text-align: center;
}

.chga-trusted-by__stat-value {
	margin: 0;
	font-size: clamp(1.25rem, 0.85rem + 1.4vw, 2.375rem);
	font-weight: 700;
	line-height: 1.15;
	letter-spacing: -0.005em;
	color: var(--chga-gold-mid);
}

.chga-trusted-by__stat-rule {
	display: block;
	width: 39%;
	min-width: 2.75rem;
	height: 2px;
	background-color: var(--chga-navy);
}

.chga-trusted-by__stat-caption {
	margin: 0;
	font-size: clamp(0.875rem, 0.78rem + 0.34vw, 1.1875rem);
	line-height: 1.45;
	color: var(--chga-navy);
}

/* Stat dots -------------------------------------------------------------- */

/*
 * Hidden until the view script confirms the row really does overflow, so a
 * configuration whose cards all fit never shows dead controls.
 */
.chga-trusted-by__stat-dots {
	display: none;
	align-items: center;
	justify-content: center;
	gap: 0.6875rem;
	margin-top: clamp(1.25rem, 0.9rem + 1.1vw, 2rem);
}

.chga-trusted-by__stat-dot {
	width: 0.8125rem;
	height: 0.8125rem;
	padding: 0;
	background-color: transparent;
	border: 1px solid var(--chga-navy);
	border-radius: 50%;
	cursor: pointer;
	transition:
		background-color 0.4s var(--chga-ease),
		transform 0.4s var(--chga-ease);
}

.chga-trusted-by__stat-dot:hover {
	background-color: rgba(0, 31, 83, 0.45);
	transform: scale(1.15);
}

.chga-trusted-by__stat-dot:focus-visible {
	outline: 2px solid var(--chga-gold-mid);
	outline-offset: 3px;
}

.chga-trusted-by__stat-dot.is-active {
	background-color: var(--chga-navy);
	transform: scale(1.18);
}

/* Responsive ------------------------------------------------------------- */

/*
 * Below the width where every card fits on one row the grid becomes a
 * swipeable, snapping row. Wrapping to three then two columns left the last
 * line ragged and pushed the section very tall on a phone.
 */
@media (max-width: 75rem) {
	/*
	 * A slide is far wider than a column in the five-across grid, so holding the
	 * design's 56% would make the badge enormous. Cap it near the size it has on
	 * a desktop row instead.
	 */
	.chga-trusted-by {
		--chga-tb-badge-size: min(38%, 7rem);
	}

	.chga-trusted-by__stats {
		--chga-tb-slide: 38%;

		display: flex;
		grid-template-columns: none;
		overflow-x: auto;
		/* Paired with the block padding below: room for the badge shadow. */
		overflow-y: hidden;
		padding-block: 0.5rem 1.25rem;
		scroll-snap-type: x mandatory;
		scroll-padding-inline: var(--chga-gutter);
		overscroll-behavior-x: contain;
		scrollbar-width: none;
		-webkit-overflow-scrolling: touch;
	}

	.chga-trusted-by__stats::-webkit-scrollbar {
		display: none;
	}

	.chga-trusted-by__stats:focus-visible {
		outline: 2px solid var(--chga-gold-mid);
		outline-offset: 2px;
	}

	.chga-trusted-by__stat {
		flex: 0 0 var(--chga-tb-slide);
		scroll-snap-align: start;
	}

	.chga-trusted-by--scrollable .chga-trusted-by__stat-dots {
		display: flex;
	}
}

@media (max-width: 48rem) {
	.chga-trusted-by {
		--chga-tb-badge-size: min(34%, 6rem);
	}

	.chga-trusted-by__stats {
		--chga-tb-slide: 62%;
	}
}

@media (max-width: 30rem) {
	.chga-trusted-by__stats {
		--chga-tb-slide: 78%;
	}
}

@media (prefers-reduced-motion: reduce) {
	.chga-trusted-by__track {
		animation: none;
	}

	.chga-trusted-by__stats {
		scroll-behavior: auto;
	}
}

/* Editor preview --------------------------------------------------------- */

.chga-trusted-by--preview .chga-trusted-by__track {
	animation-play-state: paused;
}
