/**
 * Custom Elementor Product Grid — carousel layout.
 * Loaded alongside product-grid.css, which owns the shared card styling.
 */

/*
 * Side padding reserves dedicated gutter space for the arrows below, so
 * they sit fully clear of the first/last card's own content instead of
 * overlapping it — the padding edge is where card content actually starts,
 * and the -20px arrow offset (measured from the OUTER edge, before padding)
 * lands just short of it. Reset to 0 at the breakpoint below: there isn't
 * enough width on tablet/mobile to reserve a matching gutter without
 * shrinking the cards themselves, so those arrows keep the older, more
 * compact "pulled inward, slight overlap accepted" placement instead.
 */
.cepg-carousel {
	position: relative;
	padding: 0 24px;
}

@media (max-width: 1120px) {
	.cepg-carousel {
		padding: 0;
	}
}

/*
 * .cepg-carousel__track's own padding/negative-margin pair (below) reserves
 * room for a card's hover shadow without shifting layout, but the negative
 * margin pulls the track's box a few px past this wrapper's own edges —
 * harmless on a wide viewport, but on mobile that bleed was enough to make
 * the whole page horizontally pannable by a couple of px (confirmed live:
 * document.documentElement.scrollWidth a few px over window.innerWidth).
 * Clipping it here keeps the shadow-room trick intact for any card not at
 * the very edge, while stopping that bleed from ever reaching the page.
 */
@media (max-width: 767px) {
	.cepg-carousel {
		overflow-x: hidden;
	}
}

/*
 * A CSS grid, not flex: grid-auto-flow:column fills each column top-to-
 * bottom before starting the next one, so with --cepg-rows > 1 the same
 * markup — one flat list of slides — lays out as genuine multi-row pages
 * instead of a single scrolling row. The JS paging math (product-grid.js)
 * relies on this column-major fill order.
 */
.cepg-carousel__track {
	--cepg-cols: var(--cepg-columns, var(--cepg-columns-fallback, 4));
	--cepg-track-rows: var(--cepg-rows, var(--cepg-rows-fallback, 1));

	display: grid;
	grid-auto-flow: column;
	grid-template-rows: repeat(var(--cepg-track-rows), auto);
	/* Column width math specifically needs the horizontal (column) gap value. */
	grid-auto-columns: calc((100% - (var(--cepg-cols) - 1) * var(--cepg-gap-column, 20px)) / var(--cepg-cols));
	/* Same Equal Height Cards switch as the grid layout — see product-grid.css. */
	align-items: var(--cepg-align-items, stretch);
	column-gap: var(--cepg-gap-column, 20px);
	row-gap: var(--cepg-gap-row, 20px);
	overflow-x: auto;
	overflow-y: hidden;
	/*
	 * Proximity, not mandatory: the script animates paging frame by frame to
	 * honour the panel's transition speed, and mandatory snapping re-snaps on
	 * every programmatic scroll, which fights that animation. Proximity still
	 * lands touch swipes cleanly on a card edge.
	 */
	scroll-snap-type: x proximity;
	scrollbar-width: none;
	-ms-overflow-style: none;
	-webkit-overflow-scrolling: touch;
	/* keeps momentum scrolling from fighting the vertical page scroll */
	touch-action: pan-x pan-y;
	/*
	 * overflow-y is clipped by the horizontal scroller, so reserve room on
	 * every edge for the card hover lift and shadow, then pull the box back
	 * with an equal negative margin so surrounding layout doesn't shift.
	 */
	padding: 12px 12px 16px;
	margin: -12px -12px -16px;
}

.cepg-carousel__track::-webkit-scrollbar {
	display: none;
}

.cepg-carousel__track:focus-visible {
	outline: 2px solid var(--cepg-obsidian);
	outline-offset: 4px;
}

.cepg-carousel__slide {
	display: flex;
	min-width: 0;
	scroll-snap-align: start;
}

/*
 * Explicit height:100%, not just relying on flex's implicit stretch
 * default: .cepg-card's OWN height:100% (product-grid.css) needs a
 * definite height on ITS parent to resolve against, and this makes that
 * chain unambiguous rather than depending on a browser correctly applying
 * the flex cross-axis stretch default through a grid-in-flex-in-grid
 * nesting — otherwise a short card could size to its own content instead
 * of the row's tallest when Equal Height Cards is on.
 */
.cepg-carousel__slide > .cepg-card {
	width: 100%;
	height: 100%;
}

@media (max-width: 1024px) {
	.cepg-carousel {
		--cepg-columns-fallback: 2;
	}
}

@media (max-width: 767px) {
	.cepg-carousel {
		--cepg-columns-fallback: 2;
	}
}

/* Arrows */

.cepg-carousel__arrow {
	position: absolute;
	top: 50%;
	z-index: 3;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	padding: 0;
	background: var(--cepg-obsidian);
	border: 0;
	border-radius: 50%;
	color: #ffffff;
	cursor: pointer;
	/* translateY(-50%) alone centers correctly regardless of height, so the mobile size bump below needs no matching offset. */
	transform: translateY(-50%);
	transition: background-color 0.2s ease, opacity 0.2s ease;
}

.cepg-carousel__arrow svg {
	width: 18px;
	height: 18px;
	fill: none;
	stroke: currentColor;
	stroke-width: 2;
	stroke-linecap: round;
	stroke-linejoin: round;
}

.cepg-carousel__arrow--prev {
	left: -20px;
}

.cepg-carousel__arrow--next {
	right: -20px;
}

.cepg-carousel__arrow:hover:not(:disabled),
.cepg-carousel__arrow:focus-visible:not(:disabled) {
	background: var(--cepg-orange);
}

.cepg-carousel__arrow:focus-visible {
	outline: 2px solid var(--cepg-orange);
	outline-offset: 2px;
}

.cepg-carousel__arrow:disabled {
	opacity: 0.25;
	cursor: default;
}

/* Nothing to page through — the script adds this class. */
.cepg-carousel--static .cepg-carousel__arrow,
.cepg-carousel--static .cepg-carousel__dots {
	display: none;
}

/*
 * Tablet and mobile: keep the arrows (touch users still get them) but pull
 * them inside the container so they never overflow the viewport.
 */
@media (max-width: 1120px) {
	.cepg-carousel__arrow--prev {
		left: 4px;
	}

	.cepg-carousel__arrow--next {
		right: 4px;
	}
}

@media (max-width: 767px) {
	.cepg-carousel__arrow {
		width: 44px;
		height: 44px;
		background: rgba(13, 15, 18, 0.82);
	}

	.cepg-carousel__arrow svg {
		width: 16px;
		height: 16px;
	}
}

/* Dots */

.cepg-carousel__dots {
	display: flex;
	align-items: center;
	justify-content: center;
	margin-top: 18px;
	/*
	 * No gap here — each dot's own padding (below) both creates its touch
	 * target and sets the visual spacing between pills. Adding a flex gap
	 * on top would stack with that padding and spread the row out.
	 */
}

.cepg-carousel__dots[hidden] {
	display: none;
}

/*
 * The visible pill stays a compact 8px, but the clickable box is padded out
 * via background-clip so adjacent touch targets abut with no dead zone
 * between them. A small, well-spaced pagination dot is a broadly-accepted
 * exception to the strict 44px target (WCAG 2.5.8's "spacing" allowance)
 * precisely because arrows and swipe, which do meet 44px, already cover the
 * same action.
 */
.cepg-carousel__dot {
	width: 8px;
	height: 8px;
	padding: 6px;
	box-sizing: content-box;
	background-color: #d4d4d8;
	background-clip: content-box;
	border: 0;
	border-radius: 999px;
	cursor: pointer;
	transition: background-color 0.2s ease, width 0.2s ease;
}

.cepg-carousel__dot:hover {
	background-color: var(--cepg-obsidian);
}

.cepg-carousel__dot.is-active {
	width: 22px;
	background-color: var(--cepg-orange);
}

.cepg-carousel__dot:focus-visible {
	outline: 2px solid var(--cepg-obsidian);
	outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
	.cepg-carousel__arrow,
	.cepg-carousel__dot {
		transition: none;
	}
}
