/**
 * CHGA Services block.
 *
 * Grey cards with a large navy icon sitting half over the top edge. Above
 * 1200px they share one row; below that the row becomes a snapping slider
 * rather than wrapping, the same way the Trusted By stats do.
 */

.chga-services {
	--chga-sv-columns: 4;
	--chga-sv-card: var(--chga-grey);
	--chga-sv-icon-size: 59%;
	--chga-sv-corner-opacity: 1;
	--chga-sv-corner-ratio: 963 / 520;

	position: relative;
	isolation: isolate;
	overflow: hidden;
	padding-block: clamp(2.75rem, 1.2rem + 4vw, 5.5rem);
	color: var(--chga-navy);
	background-color: var(--chga-white);
}

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

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

.chga-services__corner-wrap--bottom-left {
	left: -4%;
	bottom: -8%;
}

.chga-services__corner-wrap--bottom-right {
	right: -4%;
	bottom: -8%;
}

.chga-services__corner-wrap--top-left {
	left: -4%;
	top: -8%;
}

.chga-services__corner-wrap--top-right {
	right: -4%;
	top: -8%;
}

.chga-services__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-services__corner-wrap--bottom-left .chga-services__corner {
	transform: scaleX(-1);
}

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

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

/* Layout ----------------------------------------------------------------- */

.chga-services__inner {
	position: relative;
	z-index: 2;
	display: flex;
	flex-direction: column;
	gap: clamp(2rem, 1rem + 3vw, 4.25rem);
	width: 100%;
	max-width: var(--chga-container);
	margin-inline: auto;
}

.chga-services__head {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: clamp(0.75rem, 0.55rem + 0.7vw, 1.375rem);
	padding-inline: var(--chga-gutter);
	text-align: center;
}

.chga-services__heading {
	margin: 0;
	font-size: clamp(1.625rem, 2.6vw, 3.125rem);
	font-weight: 700;
	line-height: 1.15;
	letter-spacing: -0.015em;
	color: var(--chga-gold-mid);
}

.chga-services__rule {
	display: block;
	width: clamp(3.25rem, 4.5vw, 5.375rem);
	height: 2px;
	background-color: var(--chga-navy);
	transform-origin: center;
}

.chga-services__intro {
	max-width: 56rem;
	margin: 0;
	font-size: clamp(0.9375rem, 0.85rem + 0.55vw, 1.375rem);
	line-height: 1.45;
	color: var(--chga-navy);
	text-wrap: pretty;
}

/* Cards ------------------------------------------------------------------ */

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

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

/*
 * The icon is 59% of its card in the design. Sizing it as a percentage keeps
 * that ratio at any width, where a viewport clamp drifts once the container
 * stops growing. Percentage margin and padding both resolve against the
 * containing block's width, so the overlap and the card's top padding follow.
 * Everything derives from the one --chga-sv-icon-size variable, which is what
 * lets the slider breakpoints shrink the icon in a single place.
 */
/*
 * No CSS shadow here: the icon artwork already carries the design's shadow as an
 * SVG filter. Stacking a drop-shadow on top doubled it, and Safari renders that
 * outer filter against the SVG's square filter region rather than its alpha, so
 * the icons sat on a grey box.
 */
.chga-services__icon-wrap {
	position: relative;
	z-index: 2;
	display: block;
	width: var(--chga-sv-icon-size);
	margin-bottom: calc(var(--chga-sv-icon-size) / -2);
	line-height: 0;
}

.chga-services__icon {
	display: block;
	width: 100%;
	height: auto;
	/*
	 * The bundled fallback is an SVG carried in without width/height attributes, so
	 * until it loads the icon is zero tall and everything below it moves once it
	 * arrives - enough to land an anchor link 140px short of the Contact section.
	 * "auto 1 / 1" only reserves the square while there is no natural ratio to use,
	 * so an icon uploaded at some other shape is still drawn at its own.
	 */
	aspect-ratio: auto 1 / 1;
}

.chga-services__card {
	display: flex;
	flex: 1;
	flex-direction: column;
	align-items: center;
	gap: clamp(0.75rem, 0.5rem + 0.7vw, 1.375rem);
	width: 100%;
	padding:
		calc(var(--chga-sv-icon-size) / 2 + clamp(1rem, 0.6rem + 1.3vw, 2.25rem))
		clamp(0.875rem, 0.5rem + 1.1vw, 1.75rem)
		clamp(1.5rem, 1rem + 1.5vw, 2.75rem);
	background-color: var(--chga-sv-card);
	border-radius: clamp(0.625rem, 0.4rem + 0.7vw, 1.1875rem);
	text-align: center;
}

.chga-services__card-title {
	margin: 0;
	font-size: clamp(1.0625rem, 0.85rem + 1.1vw, 1.9375rem);
	font-weight: 700;
	line-height: 1.2;
	color: var(--chga-gold-mid);
	text-wrap: balance;
}

.chga-services__card-link {
	color: inherit;
	text-decoration: none;
	transition: color 0.35s var(--chga-ease);
}

.chga-services__card-link:hover,
.chga-services__card-link:focus-visible {
	color: var(--chga-gold);
	text-decoration: underline;
}

/* The whole card is the target, not just the words. */
.chga-services__card-link::after {
	content: "";
	position: absolute;
	inset: 0;
}

.chga-services__card-wrap:has(.chga-services__card-link) {
	position: relative;
}

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

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

/* Shared rows ------------------------------------------------------------ */

/*
 * Same trick as the Framework: subgrid hands the name, rule and description rows
 * up to the outer grid so all the cards measure them together, and the rules
 * stay level however long a service name the client types. The row gaps become a
 * margin on the rule, because a subgrid takes its gutters from the parent.
 */
@supports (grid-template-rows: subgrid) {
	@media (min-width: 75.0625rem) {
		.chga-services__cards {
			/* icon, name, rule, description */
			grid-template-rows: auto auto auto 1fr;
			row-gap: 0;
		}

		.chga-services__card-wrap {
			display: grid;
			grid-template-rows: subgrid;
			grid-row: span 4;
			justify-items: center;
		}

		.chga-services__card {
			display: grid;
			grid-template-rows: subgrid;
			grid-row: 2 / span 3;
			gap: 0;
			justify-items: center;
			align-items: start;
		}

		.chga-services__card-rule {
			margin-block: clamp(0.75rem, 0.5rem + 0.7vw, 1.375rem);
		}
	}
}

/* Dots ------------------------------------------------------------------- */

.chga-services__dots {
	display: none;
	align-items: center;
	justify-content: center;
	gap: 0.6875rem;
}

.chga-services__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-services__dot:hover {
	background-color: rgba(0, 31, 83, 0.45);
	transform: scale(1.15);
}

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

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

/* Slider ----------------------------------------------------------------- */

@media (max-width: 75rem) {
	/*
	 * A slide is far wider than a column in the four-across grid, so holding the
	 * design's 59% would make the icon enormous. These are the Trusted By badge
	 * sizes exactly, so the two rows of circles read as one set on a phone.
	 */
	.chga-services {
		--chga-sv-icon-size: min(38%, 7rem);
	}

	.chga-services__cards {
		--chga-sv-slide: 44%;

		display: flex;
		grid-template-columns: none;
		overflow-x: auto;
		/* Paired with the block padding below: room for the icon 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-services__cards::-webkit-scrollbar {
		display: none;
	}

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

	.chga-services__card-wrap {
		flex: 0 0 var(--chga-sv-slide);
		scroll-snap-align: start;
	}

	.chga-services--scrollable .chga-services__dots {
		display: flex;
	}
}

@media (max-width: 48rem) {
	.chga-services {
		--chga-sv-icon-size: min(34%, 6rem);
	}

	.chga-services__cards {
		--chga-sv-slide: 68%;
	}
}

@media (max-width: 30rem) {
	.chga-services__cards {
		--chga-sv-slide: 82%;
	}
}

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

.chga-services--preview {
	padding-block: 2.5rem;
}
