/**
 * Swipeable product grid.
 *
 * EVERY DECLARATION CARRIES !important, AND THAT IS NOT LAZINESS.
 * haddiction.com runs Elementor over Astra. Elementor lays `ul.products` out
 * as its own grid with `.elementor-grid`, Astra adds column widths to
 * `li.product`, and several of those rules are themselves `!important` and
 * load after a plugin stylesheet. Specificity alone loses that fight — the
 * same rule the other four haddiction.lv plugins learned. See
 * ../../Haddiction workout program/CLAUDE.md for the full reasoning.
 *
 * Exempt, because nothing in a theme targets them: transition, animation,
 * scroll-* properties and scrollbar pseudo-elements.
 *
 * The JS adds `.hadc-carousel` only when a grid holds more products than fit
 * on screen, so none of this applies to a short category grid.
 */

/* The track. The list itself becomes the scroller. */
ul.products.hadc-carousel {
	display: flex !important;
	flex-wrap: nowrap !important;
	grid-template-columns: none !important;
	overflow-x: auto !important;
	overflow-y: hidden !important;
	margin: 0 0 12px !important;
	padding: 0 !important;
	list-style: none !important;

	/* Not exempt-listed above but theme-proof anyway: these are the scroll. */
	scroll-snap-type: x mandatory;
	scroll-behavior: smooth;
	-webkit-overflow-scrolling: touch;

	/*
	 * Firefox and the WebKit bar are styled separately. A visible scrollbar
	 * under a row of product cards reads as a mistake, and the dots already
	 * say where you are.
	 */
	scrollbar-width: none;
}

ul.products.hadc-carousel::-webkit-scrollbar {
	display: none;
}

/*
 * The focus ring matters: the track is tabbable so a keyboard user can scroll
 * it with the arrow keys, and an invisible focus target is a trap.
 */
ul.products.hadc-carousel:focus-visible {
	outline: 2px solid currentColor !important;
	outline-offset: 2px !important;
}

/*
 * Card width. `--hadc-cols` is the number of cards on screen; the fallback
 * chain below sets it per breakpoint. flex-basis rather than width, because
 * flex items shrink out of a declared width and then four cards quietly
 * become five.
 */
ul.products.hadc-carousel > li,
ul.products.hadc-carousel > li.product {
	flex: 0 0 calc( 100% / var( --hadc-cols, 4 ) ) !important;
	max-width: calc( 100% / var( --hadc-cols, 4 ) ) !important;
	width: calc( 100% / var( --hadc-cols, 4 ) ) !important;
	margin: 0 !important;
	padding: 0 8px !important;
	box-sizing: border-box !important;
	scroll-snap-align: start;
}

@media ( max-width: 1024px ) {
	ul.products.hadc-carousel {
		--hadc-cols: 3;
	}
}

@media ( max-width: 767px ) {
	ul.products.hadc-carousel {
		--hadc-cols: 2;
	}
}

/* The dots and arrows row. */
.hadc-carousel-bar {
	display: flex !important;
	align-items: center !important;
	justify-content: center !important;
	gap: 14px !important;
	margin: 4px 0 24px !important;
	padding: 0 !important;
	background: none !important;
	border: 0 !important;
}

.hadc-carousel-dots {
	display: flex !important;
	align-items: center !important;
	justify-content: center !important;
	gap: 8px !important;
}

.hadc-carousel-dot {
	appearance: none !important;
	-webkit-appearance: none !important;
	display: block !important;
	width: 9px !important;
	height: 9px !important;
	min-width: 0 !important;
	min-height: 0 !important;
	padding: 0 !important;
	margin: 0 !important;
	border: 0 !important;
	border-radius: 50% !important;
	background: #c9ced6 !important;
	box-shadow: none !important;
	cursor: pointer !important;
	transition: background .18s ease, transform .18s ease;
}

/*
 * The dot itself is 9px, which is well under the 24px a thumb needs. The
 * pseudo-element enlarges the TAP TARGET without enlarging the dot, so the
 * row stays visually light and is still usable on a phone.
 */
.hadc-carousel-dot::after {
	content: '' !important;
	position: absolute !important;
	inset: -8px !important;
}

.hadc-carousel-dot {
	position: relative !important;
}

.hadc-carousel-dot.is-current {
	background: #0f172a !important;
	transform: scale( 1.25 );
}

.hadc-carousel-arrow {
	appearance: none !important;
	-webkit-appearance: none !important;
	display: flex !important;
	align-items: center !important;
	justify-content: center !important;
	width: 34px !important;
	height: 34px !important;
	padding: 0 !important;
	margin: 0 !important;
	border: 1px solid #e3e5e8 !important;
	border-radius: 50% !important;
	background: #ffffff !important;
	color: #0f172a !important;
	box-shadow: none !important;
	cursor: pointer !important;
	transition: opacity .18s ease, border-color .18s ease;
}

.hadc-carousel-arrow::before {
	content: '' !important;
	display: block !important;
	width: 8px !important;
	height: 8px !important;
	border-right: 2px solid currentColor !important;
	border-bottom: 2px solid currentColor !important;
}

.hadc-carousel-prev::before {
	transform: rotate( 135deg ) translate( -1px, -1px );
}

.hadc-carousel-next::before {
	transform: rotate( -45deg ) translate( -1px, -1px );
}

/*
 * Disabled rather than hidden at the ends. A control that vanishes shifts the
 * dots sideways every time you reach an end, which looks like a bug.
 */
.hadc-carousel-arrow[disabled] {
	opacity: .35 !important;
	cursor: default !important;
}

/* Arrows are no use without a pointer, and the swipe is the real control. */
@media ( hover: none ) {
	.hadc-carousel-arrow {
		display: none !important;
	}
}

/*
 * The pagination this replaces. Still in the DOM on purpose — if the carousel
 * ever fails to build, the links are there and the shop still works.
 */
.woocommerce-pagination.hadc-carousel-hidden-pagination {
	display: none !important;
}
