/**
 * Subpage section: Showcase carousel (template-parts/sections/subpage/section-showcase_carousel.php).
 *
 * Measured from design/subpages/download-app-carousel.png (1963px per slide,
 * TODO: verify in Figma): a black band; a centred ~36px Montserrat title and
 * a ~17px light grey line (#c4c1c0, sampled); phones ~307px wide, ~42px
 * apart, over an orange radial glow (#e87233 at its centre); then two 40px
 * outlined square arrows around a "1/10" counter. Mobile (TODO, no frame):
 * one slide per view, phones scaled to fit (1 large, 2 side by side, 3 or 4
 * in a 2 x 2 grid), controls below. Tokens are local to the section.
 * Logical properties only; the arrow icons mirror in RTL.
 *
 * @package cartrack
 */

/* 0,2,0: the dark band wins over the Section settings background classes. */
.sp-section.sp-section--showcase_carousel {
	--showcase-bg: var(--color-dark);
	--showcase-text: var(--color-text-inverse);
	--showcase-muted: #c4c1c0;            /* Sampled; 11.8:1 on black. */
	--showcase-glow: radial-gradient(closest-side, rgba(232, 114, 51, 0.9) 0%, rgba(232, 114, 51, 0.35) 45%, transparent 100%);
	--showcase-title-gap: var(--space-sm);
	--showcase-phones-gap: var(--space-sm);
	--showcase-phones-space: var(--space-xl);  /* Text → phones. */
	--showcase-phone-max: 19.2rem;        /* ~307px. */
	--showcase-arrow-size: 2.5rem;        /* 40px. */
	--showcase-arrow-border: rgba(255, 255, 255, 0.8);
	--showcase-controls-space: var(--space-xl);

	background: var(--showcase-bg);
	color: var(--showcase-text);
}

@media (min-width: 64em) { /* --bp-lg */
	.sp-section.sp-section--showcase_carousel {
		--showcase-phones-gap: 2.625rem;  /* ~42px. */
		--showcase-phones-space: 3.75rem; /* ~60px. */
		--showcase-controls-space: 3.75rem;
	}
}

.showcase__heading {
	color: inherit;
	text-align: center;
}

.showcase__intro {
	max-inline-size: 45rem;
	margin: var(--space-sm) auto 0;
	color: var(--showcase-muted);
	text-align: center;
}

/* ---------- Track: one slide per view ---------- */

.showcase__track {
	display: grid;
	grid-auto-columns: 100%;
	grid-auto-flow: column;
	overflow-x: auto;
	overscroll-behavior-x: contain;
	scroll-snap-type: x mandatory;
	scroll-behavior: smooth;
	scrollbar-width: thin;                /* Visible without JS, the only way to reach the slides. */
}

.is-ready .showcase__track {
	scrollbar-width: none;
}

.is-ready .showcase__track::-webkit-scrollbar {
	display: none;
}

.showcase__track:focus-visible {
	outline: 2px solid var(--color-focus);
	outline-offset: 4px;
}

.showcase__track.is-dragging {
	scroll-snap-type: none;
	scroll-behavior: auto;
	cursor: grabbing;
}

.showcase__track.is-draggable {
	cursor: grab;
}

.showcase__slide {
	display: flex;
	flex-direction: column;
	align-items: center;
	min-inline-size: 0;
	padding-inline: var(--space-sm);
	scroll-snap-align: start;
	text-align: center;
}

.showcase__title {
	margin: 0;
	color: inherit;
	font-family: var(--t-h2-family);
	font-size: var(--t-h2-size);
	font-weight: var(--t-h2-weight);
	line-height: var(--t-h2-line-height);
	letter-spacing: var(--t-h2-tracking);
	overflow-wrap: anywhere;
}

.showcase__text {
	max-inline-size: 45rem;
	margin: var(--showcase-title-gap) 0 0;
	color: var(--showcase-muted);
	font-family: var(--t-body-family);
	font-size: var(--t-body-size);
	line-height: var(--t-body-line-height);
	overflow-wrap: anywhere;
}

/* ---------- Phones over the orange glow ---------- */

.showcase__phones {
	position: relative;
	isolation: isolate;
	display: grid;
	grid-template-columns: minmax(0, var(--showcase-phone-max));
	justify-content: center;
	gap: var(--showcase-phones-gap);
	inline-size: 100%;
	margin: var(--showcase-phones-space) 0 0;
	padding: 0;
	list-style: none;
}

.showcase__phones::before {
	content: "";
	position: absolute;
	inset: -10% 10%;
	z-index: -1;
	background: var(--showcase-glow);
	pointer-events: none;
}

/* Phones: two side by side, three or four in a 2 x 2 grid (mobile proposal, TODO). */
.showcase__phones--2,
.showcase__phones--3,
.showcase__phones--4 {
	grid-template-columns: repeat(2, minmax(0, var(--showcase-phone-max)));
}

.showcase__phones--1 {
	grid-template-columns: minmax(0, min(var(--showcase-phone-max), 70%));
}

.showcase__image {
	display: block;
	inline-size: 100%;
	block-size: auto;
	user-select: none;
	-webkit-user-drag: none;
}

@media (min-width: 48em) { /* --bp-md: every phone in one row. */
	.showcase__phones--3 {
		grid-template-columns: repeat(3, minmax(0, var(--showcase-phone-max)));
	}

	.showcase__phones--4 {
		grid-template-columns: repeat(4, minmax(0, var(--showcase-phone-max)));
	}

	.showcase__phones--1 {
		grid-template-columns: minmax(0, var(--showcase-phone-max));
	}
}

/* ---------- Controls ---------- */

.showcase__controls {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: var(--space-md);
	margin-block-start: var(--showcase-controls-space);
}

.showcase__controls[hidden] {
	display: none;
}

.showcase__arrow {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	inline-size: var(--showcase-arrow-size);
	block-size: var(--showcase-arrow-size);
	padding: 0;
	border: 1px solid var(--showcase-arrow-border);
	border-radius: 0;
	background: transparent;
	color: inherit;
	cursor: pointer;
}

.showcase__arrow .icon {
	inline-size: 1.125rem;
	block-size: 1.125rem;
}

.showcase__arrow .icon:dir(rtl) {
	transform: scaleX(-1);
}

.showcase__arrow[aria-disabled="true"] {
	opacity: 0.4;
	cursor: default;
}

.showcase__arrow:focus-visible {
	outline: 2px solid var(--color-focus);
	outline-offset: 2px;
}

/* TODO: verify hover state in Figma (no hover frame supplied). */
@media (hover: hover) {
	.showcase__arrow:not([aria-disabled="true"]):hover {
		background: rgba(255, 255, 255, 0.12);
	}
}

.showcase__counter {
	min-inline-size: 3.5em;
	margin: 0;
	font-family: var(--t-small-family);
	font-size: var(--t-small-size);
	font-variant-numeric: tabular-nums;
	text-align: center;
}

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