/**
 * Vibrant Partners - Conversion Carousel
 *
 * Mobile first. The introduction sits above the carousel until there is room
 * for two columns, which is what the desktop design asks for.
 *
 * The carousel is a scroll container with snap points rather than a
 * transformed track: it then scrolls with a swipe, a trackpad and the arrow
 * keys on its own, and a card that takes focus is brought into view by the
 * browser instead of by script.
 *
 * @author  Accent - https://accentinteractive.nl
 * @package Vibrant
 * @since   1.2.0
 */

/* ==========================================================================
   Section
   ========================================================================== */

.wp-block-vibrant-partner-conversion {
	/* Colours - theme presets with the design's own values as fallback. */
	--vb-cv-bg: var(--wp--preset--color--green-800, #2B4231);
	--vb-cv-on-dark: var(--wp--preset--color--white, #FFFFFF);
	--vb-cv-on-dark-muted: var(--wp--preset--color--green-100, #E5ECE6);
	--vb-cv-card-bg: var(--wp--preset--color--white, #FFFFFF);
	--vb-cv-card-title: var(--wp--preset--color--green-800, #2B4231);
	--vb-cv-card-text: #4A5D52;
	--vb-cv-accent: var(--wp--preset--color--terracotta, #A23E2B);

	/*
	 * The design draws the outlines and the inactive dots in #4A5D52, which
	 * lands just under the 3:1 that WCAG 1.4.11 asks of a control. A white at
	 * 45% over the same green keeps the look and clears the bar.
	 */
	--vb-cv-line: rgba(255, 255, 255, 0.45);

	/* Typography */
	--vb-cv-font-display: var(--wp--preset--font-family--fraunces, "Fraunces", Georgia, serif);
	--vb-cv-font-body: var(--wp--preset--font-family--sora, "Sora", sans-serif);

	/*
	 * Layout. The card is sized in rem, so it grows along when someone sets a
	 * larger base font size (WCAG 1.4.4) instead of squeezing the text into a
	 * box that stays put.
	 */
	--vb-cv-card-width: 20rem;
	--vb-cv-card-gap: 16px;

	/*
	 * The same content box and gutter the video page, the header and the
	 * footer use, so the title starts on the line the rest of the page starts
	 * on. The band itself stays full width; only its contents are capped.
	 */
	--vb-cv-max-width: 1280px;
	--vb-cv-gutter: 20px;

	/*
	 * The fade only softens the edge itself. It has to stay clear of the text
	 * inside a card: dimming words that are on screen would put them under
	 * the 4.5:1 that WCAG 1.4.3 asks for. A card carries 24px of padding, so
	 * a fade narrower than that never reaches a letter.
	 */
	--vb-cv-fade: 24px;

	box-sizing: border-box;
	display: block;
	padding: 32px var(--vb-cv-gutter);
	background: var(--vb-cv-bg);
	color: var(--vb-cv-on-dark);
}

.vb-conversion__inner {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 32px;
	max-width: var(--vb-cv-max-width);
	margin-inline: auto;
}

.wp-block-vibrant-partner-conversion *,
.wp-block-vibrant-partner-conversion *::before,
.wp-block-vibrant-partner-conversion *::after {
	box-sizing: border-box;
}

/* ==========================================================================
   Header
   ========================================================================== */

.vb-conversion__header {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 16px;
	width: 100%;
}

.wp-block-vibrant-partner-conversion .vb-conversion__title {
	margin: 0;
	font-family: var(--vb-cv-font-display);
	font-weight: 900;
	font-size: 2rem;
	line-height: 1.2;
	color: var(--vb-cv-on-dark);
}

.wp-block-vibrant-partner-conversion .vb-conversion__intro {
	margin: 0;
	font-family: var(--vb-cv-font-body);
	font-weight: 400;
	font-size: 0.9375rem;
	line-height: 1.6;
	color: var(--vb-cv-on-dark-muted);
}

/* ==========================================================================
   Carousel frame
   ========================================================================== */

.vb-conversion__carousel {
	display: flex;
	flex-direction: column;
	gap: 20px;
	width: 100%;
	min-width: 0;
}

.vb-conversion__bar {
	display: flex;
	justify-content: flex-end;
	align-items: center;
	gap: 12px;
	width: 100%;
	min-height: 40px;
}

.wp-block-vibrant-partner-conversion .vb-conversion__count {
	margin: 0;
	font-family: var(--vb-cv-font-body);
	font-weight: 700;
	font-size: 0.875rem;
	line-height: 1.3;
	color: var(--vb-cv-on-dark);
}

.vb-conversion__nav {
	display: flex;
	align-items: center;
	gap: 8px;
}

.vb-conversion__nav[hidden] {
	display: none;
}

.wp-block-vibrant-partner-conversion .vb-conversion__arrow {
	display: flex;
	flex: 0 0 auto;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	padding: 0;
	background: transparent;
	border: 1.5px solid var(--vb-cv-line);
	border-radius: 100px;
	color: var(--vb-cv-on-dark-muted);
	cursor: pointer;
	transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

/* The step forward is the one the design puts the weight on. */
.wp-block-vibrant-partner-conversion .vb-conversion__arrow.is-next {
	background: var(--vb-cv-on-dark);
	border-color: var(--vb-cv-on-dark);
	color: var(--vb-cv-bg);
}

.wp-block-vibrant-partner-conversion .vb-conversion__arrow:hover {
	background: var(--vb-cv-on-dark);
	border-color: var(--vb-cv-on-dark);
	color: var(--vb-cv-bg);
}

.wp-block-vibrant-partner-conversion .vb-conversion__arrow:focus-visible {
	outline: 2px solid var(--vb-cv-on-dark);
	outline-offset: 3px;
}

/*
 * At either end the arrow has nothing left to do. Dimmed rather than removed,
 * so the pair keeps its place and nothing shifts under the pointer. It keeps
 * its focus ring: the button is still reachable, see view.js.
 */
.wp-block-vibrant-partner-conversion .vb-conversion__arrow[aria-disabled="true"] {
	opacity: 0.4;
	cursor: default;
}

.wp-block-vibrant-partner-conversion .vb-conversion__arrow[aria-disabled="true"]:hover {
	background: transparent;
	border-color: var(--vb-cv-line);
	color: var(--vb-cv-on-dark-muted);
}

.wp-block-vibrant-partner-conversion .vb-conversion__arrow.is-next[aria-disabled="true"]:hover {
	background: var(--vb-cv-on-dark);
	border-color: var(--vb-cv-on-dark);
	color: var(--vb-cv-bg);
}

.vb-conversion__arrow-icon {
	display: block;
	width: 16px;
	height: 16px;
}

/* ==========================================================================
   Track
   ========================================================================== */

.vb-conversion__viewport {
	position: relative;
	width: 100%;
	min-width: 0;
}

.wp-block-vibrant-partner-conversion .vb-conversion__track {
	display: flex;
	gap: var(--vb-cv-card-gap);
	margin: 0;
	padding: 0;
	list-style: none;
	overflow-x: auto;
	overscroll-behavior-x: contain;
	scroll-snap-type: x mandatory;
	scroll-behavior: smooth;

	/* The scrollbar is replaced by the arrows and the dots. */
	scrollbar-width: none;
	-ms-overflow-style: none;
}

.wp-block-vibrant-partner-conversion .vb-conversion__track::-webkit-scrollbar {
	display: none;
}

.wp-block-vibrant-partner-conversion .vb-conversion__slide {
	flex: 0 0 auto;
	width: var(--vb-cv-card-width);
	max-width: 100%;
	margin: 0;
	padding: 0;
	list-style: none;
	scroll-snap-align: start;
}

/* ==========================================================================
   Card
   ========================================================================== */

.vb-conversion__card {
	display: flex;
	flex-direction: column;
	justify-content: space-between;
	gap: 20px;
	height: 100%;
	min-height: 18.75rem;
	padding: 24px;
	background: var(--vb-cv-card-bg);
	border-radius: 24px;
}

.vb-conversion__card-top {
	display: flex;
	flex-direction: column;
	gap: 20px;
}

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

.wp-block-vibrant-partner-conversion .vb-conversion__avatar {
	display: flex;
	flex: 0 0 auto;
	align-items: center;
	justify-content: center;
	width: 56px;
	height: 56px;
	border-radius: 100px;
	object-fit: cover;
}

.vb-conversion__avatar.is-placeholder {
	background: var(--wp--preset--color--green-100, #E5ECE6);
	font-family: var(--vb-cv-font-display);
	font-weight: 900;
	font-size: 1.375rem;
	line-height: 1;
	color: var(--vb-cv-card-title);
	text-transform: uppercase;
}

.wp-block-vibrant-partner-conversion .vb-conversion__position {
	margin: 0;
	font-family: var(--vb-cv-font-body);
	font-weight: 700;
	font-size: 0.8125rem;
	line-height: 1.23;
	color: var(--vb-cv-accent);
	white-space: nowrap;
}

.vb-conversion__card-copy {
	display: flex;
	flex-direction: column;
	gap: 10px;
}

.wp-block-vibrant-partner-conversion .vb-conversion__card-name {
	margin: 0;
	font-family: var(--vb-cv-font-display);
	font-weight: 900;
	font-size: 1.375rem;
	line-height: 1.2;
	color: var(--vb-cv-card-title);
}

.wp-block-vibrant-partner-conversion .vb-conversion__card-text {
	margin: 0;
	font-family: var(--vb-cv-font-body);
	font-weight: 400;
	font-size: 0.875rem;
	line-height: 1.6;
	color: var(--vb-cv-card-text);
}

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

.wp-block-vibrant-partner-conversion .vb-conversion__cta {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 40px;
	padding: 12px 20px;
	background: var(--vb-cv-accent);
	border-radius: 100px;
	font-family: var(--vb-cv-font-body);
	font-weight: 700;
	font-size: 0.8125rem;
	line-height: 1.23;
	color: var(--wp--preset--color--white, #FFFFFF);
	text-decoration: none;
	box-shadow: none;
	transition: background-color 0.2s ease;
}

.wp-block-vibrant-partner-conversion .vb-conversion__cta:hover,
.wp-block-vibrant-partner-conversion .vb-conversion__cta:focus-visible {
	background: var(--vb-cv-card-title);
	color: var(--wp--preset--color--white, #FFFFFF);
}

.wp-block-vibrant-partner-conversion .vb-conversion__cta:focus-visible {
	outline: 2px solid var(--vb-cv-card-title);
	outline-offset: 2px;
}

/* ==========================================================================
   Fade and dots
   ========================================================================== */

.vb-conversion__fade {
	position: absolute;
	top: 0;
	right: 0;
	bottom: 0;
	width: var(--vb-cv-fade);
	background: linear-gradient(90deg, rgba(43, 66, 49, 0) 0%, rgba(43, 66, 49, 0.9) 100%);
	pointer-events: none;
	opacity: 1;
	transition: opacity 0.2s ease;
}

/* Nothing left to cut off once the last card is in view. */
.vb-conversion__viewport.is-at-end .vb-conversion__fade {
	opacity: 0;
}

.vb-conversion__dots {
	display: flex;
	justify-content: center;
	align-items: center;
	gap: 8px;
	width: 100%;
	padding-top: 0;
}

.vb-conversion__dot {
	display: block;
	flex: 0 0 auto;
	width: 8px;
	height: 8px;
	background: var(--vb-cv-line);
	border-radius: 100px;
	transition: width 0.2s ease, height 0.2s ease, background-color 0.2s ease;
}

.vb-conversion__dot.is-active {
	width: 10px;
	height: 10px;
	background: var(--vb-cv-on-dark);
}

/* ==========================================================================
   Desktop
   ==========================================================================
   Two columns: the introduction stands still on the left while the carousel
   runs beside it. The track bleeds into the right padding, so the card that
   is cut off shows it can be scrolled. */

@media (min-width: 1024px) {

	.wp-block-vibrant-partner-conversion {
		--vb-cv-card-width: 23.75rem;
		--vb-cv-fade: 64px;
		--vb-cv-gutter: clamp(24px, 5.5vw, 80px);

		padding-block: 64px;
	}

	.vb-conversion__inner {
		flex-direction: row;
		/* Stretch, so the introduction can centre itself against the cards. */
		align-items: stretch;
		gap: 60px;
	}

	.vb-conversion__header {
		flex: 0 0 auto;
		justify-content: center;
		width: 520px;
		max-width: 40%;
	}

	.wp-block-vibrant-partner-conversion .vb-conversion__title {
		font-size: 2.5rem;
	}

	.vb-conversion__carousel {
		flex: 1 1 auto;
	}

	.vb-conversion__dots {
		padding-top: 20px;
	}
}

/* ==========================================================================
   Reduced motion
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {

	.wp-block-vibrant-partner-conversion .vb-conversion__track {
		scroll-behavior: auto;
	}

	.wp-block-vibrant-partner-conversion *,
	.wp-block-vibrant-partner-conversion *::before,
	.wp-block-vibrant-partner-conversion *::after {
		transition-duration: 0.01ms !important;
	}
}
