/**
 * E-Potion Product Carousel
 *
 * Shared styles for [ep_new_products_carousel] and [ep_categories_carousel].
 *
 * Architecture:
 *   • Track scrolls horizontally with native CSS scroll-snap.
 *   • Each card snaps individually on touch swipe (mobile UX).
 *   • Arrow buttons & dot indicators advance by viewport-width (one page).
 *   • Cards are absolute-width via flex-basis calc() to guarantee
 *     5-per-row on desktop, 3-per-row on tablet, 2-per-row on mobile.
 *   • Card heights are equalized via flex column + min-height on title
 *     + margin-top:auto on the CTA, so buttons always align at the bottom.
 *
 * Brand: uses --ep-* design tokens with hardcoded fallbacks so the carousel
 * still looks right if loaded before design-tokens.css.
 *
 * @package Shoptimizer_Child
 */

/* ==========================================================================
   1. Container
   ========================================================================== */

.ep-pc {
	position: relative;
	width: 100%;
	margin: 0;
	font-family: inherit;
	color: var(--ep-text-primary, #0e1116);
	box-sizing: border-box;
}

.ep-pc *,
.ep-pc *::before,
.ep-pc *::after {
	box-sizing: border-box;
}

/* ==========================================================================
   2. Header — heading + arrow nav
   ========================================================================== */

.ep-pc-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	margin-bottom: 20px;
	padding: 0 4px;
}

.ep-pc-heading {
	font-size: 24px;
	font-weight: 700;
	line-height: 1.2;
	letter-spacing: -0.01em;
	color: var(--ep-text-primary, #0e1116);
	margin: 0;
}

.ep-pc-nav {
	display: flex;
	gap: 8px;
	flex-shrink: 0;
}

.ep-pc-arrow {
	width: 40px;
	height: 40px;
	padding: 0;
	border-radius: 50%;
	border: 1px solid var(--ep-border-default, #e1e3e6);
	background: var(--ep-bg-surface, #ffffff);
	color: var(--ep-text-primary, #0e1116);
	display: inline-flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	transition: background-color 200ms ease, color 200ms ease, border-color 200ms ease, opacity 200ms ease;
	-webkit-appearance: none;
	appearance: none;
}

.ep-pc-arrow:hover:not(:disabled),
.ep-pc-arrow:focus-visible {
	background: #0e1116;
	color: #ffffff;
	border-color: #0e1116;
}

.ep-pc-arrow:focus-visible {
	outline: 2px solid var(--ep-accent, #ff6b1a);
	outline-offset: 2px;
}

.ep-pc-arrow:disabled {
	opacity: 0.35;
	cursor: not-allowed;
}

.ep-pc-arrow svg {
	display: block;
}

/* ==========================================================================
   3. Track — horizontally scrollable, scroll-snap parent
   ========================================================================== */

.ep-pc-track {
	position: relative;
	overflow-x: auto;
	overflow-y: hidden;
	scroll-snap-type: x mandatory;
	scroll-behavior: smooth;
	-webkit-overflow-scrolling: touch;
	scrollbar-width: none;
	-ms-overflow-style: none;
	padding: 4px 0 8px;        /* room for the focus ring & hover lift */
	margin: 0 -4px;            /* counteract padding visually */
}

.ep-pc-track::-webkit-scrollbar {
	display: none;
}

.ep-pc-track:focus-visible {
	outline: none;
}

.ep-pc-track:focus-visible .ep-pc-list {
	box-shadow: inset 0 0 0 2px var(--ep-accent, #ff6b1a);
	border-radius: var(--ep-radius-md, 8px);
}

/* ==========================================================================
   4. List — flex row of cards
   ========================================================================== */

.ep-pc-list {
	display: flex;
	gap: 16px;
	list-style: none;
	padding: 0 4px;
	margin: 0;
}

/* ==========================================================================
   5. Card — fixed flex-basis = consistent card width across breakpoints
   ========================================================================== */

.ep-pc-card {
	flex: 0 0 calc((100% - 4 * 16px) / 5);   /* desktop: 5 cards × 4 gaps */
	min-width: 0;
	scroll-snap-align: start;
	background: var(--ep-bg-surface, #ffffff);
	border: 1px solid var(--ep-border-default, #e1e3e6);
	border-radius: var(--ep-radius-md, 8px);
	overflow: hidden;
	display: flex;
	flex-direction: column;
	position: relative;
	transition: transform 250ms ease, box-shadow 250ms ease, border-color 250ms ease;
}

.ep-pc-card:hover {
	transform: translateY(-2px);
	box-shadow: 0 6px 20px rgba(14, 17, 22, 0.08);
	border-color: rgba(14, 17, 22, 0.12);
}

/* ==========================================================================
   6. Card image — square aspect, hover zoom
   ========================================================================== */

.ep-pc-image-link {
	display: block;
	aspect-ratio: 1 / 1;
	overflow: hidden;
	background: #f5f5f7;
	text-decoration: none;
}

.ep-pc-image-link .ep-pc-image,
.ep-pc-image-link img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	object-position: center center;
	display: block;
	transition: transform 350ms ease;
}

.ep-pc-card:hover .ep-pc-image-link img {
	transform: scale(1.04);
}

/* ==========================================================================
   7. Card body
   ========================================================================== */

.ep-pc-body {
	padding: 14px;
	display: flex;
	flex-direction: column;
	flex: 1 1 auto;
	gap: 10px;
}

/* ==========================================================================
   8. Title — 2-line clamp, locked min-height for symmetry
   ========================================================================== */

.ep-pc-title {
	font-size: 14px;
	font-weight: 600;
	line-height: 1.4;
	margin: 0;
	min-height: 2.8em;          /* 2 lines × 1.4 line-height */
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	line-clamp: 2;
	overflow: hidden;
	text-overflow: ellipsis;
	overflow-wrap: anywhere;    /* break long unbreakable strings (SKUs, codes) */
	word-break: normal;         /* but break at word boundaries when possible */
}

.ep-pc-title a {
	color: var(--ep-text-primary, #0e1116);
	text-decoration: none;
	transition: color 200ms ease;
}

.ep-pc-title a:hover {
	color: var(--ep-accent, #ff6b1a);
}

/* ==========================================================================
   9. Price
   ========================================================================== */

.ep-pc-price {
	font-size: 16px;
	font-weight: 700;
	color: var(--ep-text-primary, #0e1116);
	line-height: 1.2;
}

.ep-pc-price .woocommerce-Price-amount {
	color: inherit;
}

.ep-pc-price del,
.ep-pc-price del .woocommerce-Price-amount {
	font-weight: 400;
	font-size: 13px;
	color: var(--ep-text-muted, #8a9098);
	margin-right: 6px;
	text-decoration: line-through;
}

.ep-pc-price ins,
.ep-pc-price ins .woocommerce-Price-amount {
	text-decoration: none;
	/* #d44a00 on #fff = 4.7:1 contrast — passes WCAG AA.
	   Original var(--ep-accent, #ff6b1a) was 2.71:1 — failed. */
	color: var(--ep-accent-dark, #d44a00);
}

/* ==========================================================================
   10. Sale badge — top-left corner
   ========================================================================== */

.ep-pc-badge {
	position: absolute;
	top: 10px;
	left: 10px;
	z-index: 2;
	padding: 4px 10px;
	font-size: 11px;
	font-weight: 700;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	border-radius: 999px;
	/* #d44a00 bg + #fff text = 4.7:1 contrast — passes WCAG AA.
	   Original var(--ep-accent, #ff6b1a) bg was 2.71:1 — failed. */
	background: var(--ep-accent-dark, #d44a00);
	color: #ffffff;
	box-shadow: 0 2px 6px rgba(212, 74, 0, 0.25);
}

/* ==========================================================================
   11. Actions — add-to-cart button, pinned to bottom of card
   ========================================================================== */

.ep-pc-actions {
	margin-top: auto;
	padding-top: 4px;
}

.ep-pc-actions .ep-pc-cart-btn,
.ep-pc-actions .button {
	display: block;
	width: 100%;
	padding: 10px 14px;
	background: #0e1116;
	color: #ffffff;
	border: 1px solid #0e1116;
	border-radius: 6px;
	font-size: 13px;
	font-weight: 600;
	letter-spacing: 0.03em;
	text-align: center;
	text-decoration: none;
	line-height: 1.3;
	cursor: pointer;
	transition: background-color 200ms ease, border-color 200ms ease, color 200ms ease;
	-webkit-appearance: none;
	appearance: none;
}

.ep-pc-actions .ep-pc-cart-btn:hover,
.ep-pc-actions .button:hover,
.ep-pc-actions .ep-pc-cart-btn:focus-visible,
.ep-pc-actions .button:focus-visible {
	background: var(--ep-accent, #ff6b1a);
	border-color: var(--ep-accent, #ff6b1a);
	color: #ffffff;
}

.ep-pc-actions .ep-pc-cart-btn:focus-visible {
	outline: 2px solid var(--ep-accent-dark, #d44a00);
	outline-offset: 2px;
}

/* WooCommerce AJAX states */
.ep-pc-actions .ep-pc-cart-btn.loading {
	opacity: 0.65;
	padding-right: 32px;
	position: relative;
}

.ep-pc-actions .ep-pc-cart-btn.added::after {
	content: " \2713";
}

/* ==========================================================================
   12. Dots — page indicators below the track
   ========================================================================== */

.ep-pc-dots {
	display: flex;
	justify-content: center;
	gap: 8px;
	margin-top: 18px;
}

.ep-pc-dot {
	width: 8px;
	height: 8px;
	padding: 0;
	border: 0;
	border-radius: 999px;
	background: var(--ep-border-default, #d1d5db);
	cursor: pointer;
	transition: width 250ms cubic-bezier(0.16, 1, 0.3, 1), background-color 200ms ease;
	-webkit-appearance: none;
	appearance: none;
}

.ep-pc-dot:hover {
	background: #8a9098;
}

.ep-pc-dot.is-active {
	width: 24px;
	background: #0e1116;
}

.ep-pc-dot:focus-visible {
	outline: 2px solid var(--ep-accent, #ff6b1a);
	outline-offset: 2px;
}

/* ==========================================================================
   13. Category card variant — no price, no CTA, centered text
   ========================================================================== */

.ep-pc-card--cat .ep-pc-body {
	text-align: center;
	padding-bottom: 18px;
}

.ep-pc-card--cat .ep-pc-title {
	min-height: 2.8em;
	justify-content: center;
}

.ep-pc-count {
	font-size: 12px;
	color: var(--ep-text-muted, #8a9098);
	margin-top: -4px;
}

/* ==========================================================================
   14. Responsive
   ========================================================================== */

/* Tablet: 3 cards per row */
@media (min-width: 769px) and (max-width: 1024px) {
	.ep-pc-card {
		flex: 0 0 calc((100% - 2 * 16px) / 3);
	}
}

/* Mobile: 2 cards per row */
@media (max-width: 768px) {
	.ep-pc-card {
		flex: 0 0 calc((100% - 1 * 12px) / 2);
	}

	.ep-pc-list {
		gap: 12px;
	}

	.ep-pc-header {
		margin-bottom: 16px;
	}

	.ep-pc-heading {
		font-size: 18px;
	}

	.ep-pc-arrow {
		width: 34px;
		height: 34px;
	}

	.ep-pc-body {
		padding: 12px;
		gap: 8px;
	}

	.ep-pc-title {
		font-size: 13px;
	}

	.ep-pc-price {
		font-size: 15px;
	}

	.ep-pc-actions .ep-pc-cart-btn,
	.ep-pc-actions .button {
		padding: 8px 12px;
		font-size: 12px;
	}

	.ep-pc-badge {
		font-size: 10px;
		padding: 3px 8px;
	}
}

/* ==========================================================================
   15. Reduced motion
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
	.ep-pc-track {
		scroll-behavior: auto;
	}
	.ep-pc-card,
	.ep-pc-image-link img,
	.ep-pc-arrow,
	.ep-pc-dot {
		transition: none;
	}
	.ep-pc-card:hover {
		transform: none;
	}
	.ep-pc-card:hover .ep-pc-image-link img {
		transform: none;
	}
}
