/*
 * Shop / product styles — Alpha Pro Custom Theme
 *
 * Product loop cards (woocommerce/content-product.php) and the products
 * carousel component (includes/products-carousel.php). Enqueued by
 * functions.php after the main child stylesheet, so it inherits the design
 * tokens declared on :root in style.css.
 */

/* =========================================================
   Product Loop Cards
   Output by woocommerce/content-product.php in this theme.
   Applies wherever WooCommerce renders a product loop — category
   archives, related products, shop, and our products carousel.
   Markup it targets:
     <li class="product …">
       <a class="woocommerce-loop-product__link">
         <div class="alpha-product__media">…img…</div>
         <div class="alpha-product__body">…h2…, .price</div>
       </a>
       <a class="button add_to_cart_button …">…</a>
     </li>
   ========================================================= */
.products li.product {
	list-style: none;
	background: #fff;
	border: 1px solid #e5e5e5;
	border-radius: 12px;
	padding: 14px;
	display: flex !important;
	flex-direction: column !important;
	justify-content: space-between !important;
	gap: 10px;
	text-align: center;
}

/* The wrapping link covers image + title + price so the entire
   upper card is one tap target; button stays outside as its own
   action so the user can add to cart without navigating away. */
.products li.product .woocommerce-loop-product__link {
	display: flex;
	flex-direction: column;
	gap: 10px;
	color: inherit;
	text-decoration: none;
}

/* Square image well. object-fit: contain keeps oddly-cropped product
   shots fully visible; swap to "cover" if you'd rather they fill. */
.alpha-product__media {
	aspect-ratio: 1 / 1;
	overflow: hidden;
	border-radius: 8px;
	background: #f7f7f7;
}

.alpha-product__media img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: contain;
}

.alpha-product__body {
	display: flex;
	flex-direction: column;
	gap: 4px;
	align-items: center;
}

.alpha-product__body .woocommerce-loop-product__title {
	margin: 0;
	font-size: 0.95rem;
	font-weight: 700;
	line-height: 1.35;
	color: var(--color-dark);
	/* Clamp to 2 lines so cards in a row keep matching heights. */
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.alpha-product__body .price {
	font-size: 0.9rem;
	font-weight: 700;
	color: var(--color-dark);
}

/* Add-to-cart link rendered as a pill button. margin-top: auto pins
   it to the bottom so cards with different title lengths still align
   their buttons on one row. */
.products li.product .button.add_to_cart_button {
	display: block;
	width: 100%;
	margin-top: auto;
	padding: 10px 16px;
	background: var(--color-gold);
	color: var(--color-dark);
	border: none;
	border-radius: 999px;
	font-weight: 700;
	font-size: 0.9rem;
	text-align: center;
	text-decoration: none;
	cursor: pointer;
	box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
	transition: background-color 0.2s ease;
}

.products li.product .button.add_to_cart_button:hover,
.products li.product .button.add_to_cart_button:focus-visible {
	background: var(--color-gold-hover);
	outline: none;
}

/* WC ajax_add_to_cart in-flight + post-click states. Keep gold tint. */
.products li.product .button.add_to_cart_button.loading,
.products li.product .button.add_to_cart_button.added {
	opacity: 0.85;
}

/* =========================================================
   Products Carousel
   Single overflow-x track; arrows sit in the viewport padding so
   they never obscure product cards. The track is force-LTR (even
   on this RTL page) so scrollLeft math stays a plain positive
   integer; cards inside restore RTL for their own text.
   ========================================================= */
.products-carousel {
	width: 100%;
	margin: 0 auto;
}

.products-carousel__header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	padding: 0 var(--carousel-arrow-wrapper);
	margin-bottom: 1rem;
}

.products-carousel__title {
	margin: 0;
	font-size: 2.5rem;
	font-weight: 700;
	color: var(--color-dark);
}

.products-carousel__title a {
	color: inherit;
	text-decoration: none;
}

.products-carousel__title a:hover,
.products-carousel__title a:focus-visible {
	color: var(--color-gold);
	outline: none;
}

.products-carousel__pause {
	width: 2rem;
	height: 2rem;
	flex-shrink: 0;
	padding: 0;
	background: transparent;
	border: 1px solid var(--color-dark);
	border-radius: 50%;
	color: var(--color-dark);
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition:
		background-color 0.2s ease,
		color 0.2s ease;
}

.products-carousel__pause:hover,
.products-carousel__pause:focus-visible {
	background-color: var(--color-gold);
	outline: none;
}

.products-carousel__icon {
	width: 1rem;
	height: 1rem;
}

/* Swap pause/play glyphs via [data-state]. */
.products-carousel__pause[data-state="playing"] .products-carousel__icon--play,
.products-carousel__pause[data-state="paused"] .products-carousel__icon--pause {
	display: none;
}

/* Viewport: relative container; padding leaves room for the absolute
   nav arrows on either side. */
.products-carousel__viewport {
	position: relative;
	padding: 0 var(--carousel-arrow-wrapper);
	touch-action: pan-y pinch-zoom;
}

.products-carousel__track {
	list-style: none;
	margin: 0;
	padding: 0;
	display: grid;
	grid-auto-flow: column;
	grid-auto-columns: calc(
		(100% - (var(--carousel-per-view) - 1) * var(--carousel-gap)) /
			var(--carousel-per-view)
	);
	gap: var(--carousel-gap);
	width: 100%;
	overflow-x: scroll;
	overscroll-behavior-x: contain;
	scroll-snap-type: x mandatory;
	scroll-behavior: smooth;
	scrollbar-width: none;
	-ms-overflow-style: none;
	direction: ltr;
	/* Disable native horizontal touch pan so our pointer-events drag handler
	   gets the gesture instead of the browser's overflow-x scroller. pan-y +
	   pinch-zoom keep vertical page scroll and pinch-to-zoom working. */
	touch-action: pan-y pinch-zoom;
	/* Stop mousedown on a product title / price from initiating text
	   selection — that selection claims the gesture before pointermove can
	   detect a swipe. Inherited by all descendants. */
	-webkit-user-select: none;
	user-select: none;
}

/* Opt every <img> and <a> inside the track out of the browser's native
   drag-and-drop on mouse, and out of iOS Safari's long-press callout
   menu on touch. Without this, mousedown on a product image or link
   triggers a link-drag / image-drag the moment the cursor moves, which
   intercepts pointer events and prevents the swipe from registering. */
.products-carousel__track img,
.products-carousel__track a {
	-webkit-user-drag: none;
	user-drag: none;
	-webkit-touch-callout: none;
}

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

/* Each WC <li class="product …"> snaps to the start of the viewport
   and restores RTL so its inner text reads naturally. min-width: 0
   prevents grid auto-tracks from blowing past the calc width. */
.products-carousel__track > * {
	scroll-snap-align: start;
	direction: rtl;
	min-width: 0;
}

/* .products-carousel__track ul li a */
.products-carousel__track ul li a {
	color: var(--color-dark) !important;
}

/* Neutralise the WC `ul.products` defaults — we own the layout here. */
.products-carousel__track.products {
	margin: 0;
	padding: 0;
}

.products-carousel--dragging {
	cursor: grabbing;
	-webkit-user-select: none;
	user-select: none;
}

.products-carousel--dragging * {
	pointer-events: none;
}

.products-carousel__nav {
	position: absolute;
	top: 50%;
	transform: translateY(-50%);
	width: var(--carousel-arrow-wrapper);
	height: var(--carousel-arrow-wrapper);
	padding: 0;
	background-color: var(--color-light);
	color: var(--color-dark);
	border: 1px solid var(--color-dark);
	border-radius: 50%;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 2;
	transition:
		background-color 0.2s ease,
		color 0.2s ease;
}

.products-carousel__nav:hover,
.products-carousel__nav:focus-visible {
	background-color: var(--color-gold);
	outline: none;
}

.products-carousel__nav--prev {
	left: 0;
}

.products-carousel__nav--next {
	right: 0;
}

.products-carousel__nav-icon {
	width: var(--carousel-arrow-size);
	height: var(--carousel-arrow-size);
}

/* Single-page fallback — no scroll, no snap; JS hides the nav. */
.products-carousel--single-page .products-carousel__track {
	overflow: visible;
	scroll-snap-type: none;
}

/* Reduced motion — JS skips autoplay; CSS removes smooth scroll so
   programmatic scrollTo jumps are instant rather than animated. */
@media (prefers-reduced-motion: reduce) {
	.products-carousel__track {
		scroll-behavior: auto;
	}
}

/* Visually-hidden utility used by the carousel's aria-live region. */
.sr-only {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

/* =========================================================
   Carousel — responsive
   ========================================================= */
@media (max-width: 767px) {
	/* Products carousel — 2 per view, smaller chrome. */
	:root {
		--carousel-arrow-size: 1rem;
		--carousel-arrow-wrapper: 2rem;
		--carousel-per-view: 2;
	}
}

@media (max-width: 550px) {
	.products-carousel__title {
		font-size: 1.5rem;
	}
}
