/*
 * WooCommerce related-products and upsell recommendations
 *
 * The .ch-recs class is added at runtime by woocommerce-recommendations.js
 * to both .related.products and .up-sells.upsells.products on the single
 * product surface. Styling against this single class lets the rules sit
 * at low specificity (0,2,0–0,3,1) and rely on the child stylesheet's
 * source order — which loads after WooCommerce's own CSS — to win.
 *
 * Previous rules used five-segment compound selectors to escalate
 * specificity. That pattern compounds across maintenance cycles. Anyone
 * adding new behavior to this surface should keep selectors anchored on
 * .ch-recs and resist deeper chaining.
 */

.ch-recs {
	display: block;
	width: 100%;
	box-sizing: border-box;
	position: relative;
	margin-top: clamp(2rem, 5vw, 3rem);
	padding: clamp(1.25rem, 3vw, 1.75rem);
	border: 1px solid rgba(17, 19, 25, 0.08);
	border-radius: var(--ch-radius-xl);
	background: linear-gradient(180deg, rgba(255, 255, 255, 0.84), rgba(var(--ch-rec-surface-end), 0.88));
	box-shadow: 0 18px 42px rgba(17, 19, 25, 0.08);
}

/*
 * The archive grid rule `.woocommerce-area .products { display:grid }`
 * (parent woocommerce.css) also matches this <section class="related products">
 * — the class "products" is shared — and two-columns the heading + rail. Re-
 * assert normal block flow at matching specificity; this stylesheet loads after
 * the parent's, so it wins. The grid is meant only for the archive ul.products.
 */
.woocommerce-area .ch-recs {
	display: block;
}

.ch-recs > h2 {
	margin: 0 0 1.25rem;
	font-family: Georgia, "Times New Roman", serif;
	font-size: clamp(1.85rem, 4vw, 2.5rem);
	line-height: 1.08;
	letter-spacing: -0.03em;
	color: var(--ch-ink);
}

/*
 * Viewport row:  <  [ scrollable rail ]  >  — the controls flank the rail and
 * the rail flexes to fill the space between them. min-width:0 lets the rail
 * shrink so the flex row never overflows its container.
 */
.ch-recs .chiseiko-recommendations__viewport {
	display: flex;
	align-items: center;
	gap: 0.85rem;
	width: 100%;
	box-sizing: border-box;
}

.ch-recs .chiseiko-recommendations__control {
	flex-shrink: 0;
	width: 3rem;
	height: 3rem;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	border-radius: var(--ch-radius-pill);
	border: 1px solid rgba(17, 19, 25, 0.12);
	background: rgba(255, 255, 255, 0.92);
	color: var(--ch-ink);
	box-shadow: 0 10px 24px rgba(17, 19, 25, 0.08);
	transition: transform var(--ch-motion-fast) var(--ch-ease), box-shadow var(--ch-motion-fast) var(--ch-ease), background-color var(--ch-motion-fast) var(--ch-ease), opacity var(--ch-motion-fast) var(--ch-ease);
	cursor: pointer;
}

.ch-recs .chiseiko-recommendations__control:hover,
.ch-recs .chiseiko-recommendations__control:focus-visible {
	transform: translateY(-1px);
	box-shadow: 0 14px 28px rgba(17, 19, 25, 0.12);
	background: #fff;
	outline: none;
}

.ch-recs .chiseiko-recommendations__control:focus-visible {
	box-shadow: 0 14px 28px rgba(17, 19, 25, 0.12), var(--ch-focus-ring);
}

.ch-recs .chiseiko-recommendations__control[disabled] {
	opacity: 0.42;
	box-shadow: none;
	cursor: default;
	transform: none;
	background: rgba(255, 255, 255, 0.72);
}

.ch-recs .chiseiko-recommendations__control-icon {
	font-size: 1.5rem;
	line-height: 1;
	font-weight: 400;
	transform: translateY(-1px);
}

.ch-recs ul.products {
	display: flex;
	flex: 1 1 auto;
	min-width: 0;
	max-width: 100%;
	box-sizing: border-box;
	flex-wrap: nowrap;
	gap: 1.25rem;
	list-style: none;
	padding: 0 0 0.85rem;
	margin: 0;
	align-items: stretch;
	overflow: auto hidden;
	scroll-snap-type: x proximity;
	overscroll-behavior-x: contain;
	border-radius: var(--ch-radius-md);
	/* Visible, slim horizontal scrollbar as an explicit "scrolls sideways" cue. */
	scrollbar-width: thin;
	scrollbar-color: rgba(17, 19, 25, 0.32) rgba(17, 19, 25, 0.08);
}

.ch-recs ul.products::-webkit-scrollbar {
	height: 8px;
}

.ch-recs ul.products::-webkit-scrollbar-track {
	background: rgba(17, 19, 25, 0.07);
	border-radius: 999px;
}

.ch-recs ul.products::-webkit-scrollbar-thumb {
	background: rgba(17, 19, 25, 0.28);
	border-radius: 999px;
}

.ch-recs ul.products::-webkit-scrollbar-thumb:hover {
	background: rgba(17, 19, 25, 0.42);
}

/*
 * Visible focus state for the rail itself
 *
 * The carousel JS adds tabindex="0" to the rail so a keyboard user can
 * arrow-scroll. Without an explicit :focus-visible style the user has no
 * cue they have entered the scrollable region (the browser default
 * outline does not consistently render on flex/scroll <ul> containers).
 */
.ch-recs ul.products:focus-visible {
	outline: none;
	box-shadow: var(--ch-focus-ring);
}

.ch-recs ul.products li.product {
	float: none;
	width: 15rem;
	min-width: 15rem;
	max-width: 15rem;
	margin: 0;
	padding: 1rem;
	display: flex;
	flex-direction: column;
	gap: 0.8rem;
	flex: 0 0 15rem;
	border-radius: var(--ch-radius-xl);
	overflow: hidden;
	position: relative;
	scroll-snap-align: start;
	background:
		linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(var(--ch-rec-surface-end), 0.92)),
		radial-gradient(circle at top right, rgba(207, 139, 44, 0.18), transparent 38%);
	box-shadow: 0 18px 42px rgba(17, 19, 25, 0.08);
	border: 1px solid rgba(17, 19, 25, 0.08);
	box-sizing: border-box;
}

.ch-recs ul.products li.product > a:first-child {
	display: grid;
	gap: 0.85rem;
	flex: 1;
	align-content: start;
	color: inherit;
	text-decoration: none;
}

.ch-recs ul.products li.product a img {
	width: 100%;
	aspect-ratio: 1 / 1;
	object-fit: cover;
	margin: 0;
	border-radius: var(--ch-radius-md);
	border: 1px solid rgba(17, 19, 25, 0.08);
	background: rgba(255, 255, 255, 0.82);
	box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.65);
	box-sizing: border-box;
}

.ch-recs ul.products li.product .woocommerce-loop-product__title {
	margin: 0;
	font-family: Georgia, "Times New Roman", serif;
	font-size: 1.12rem;
	line-height: 1.15;
	letter-spacing: -0.02em;
	color: var(--ch-ink);
}

.ch-recs ul.products li.product .price {
	display: flex;
	flex-wrap: wrap;
	gap: 0.35rem;
	align-items: baseline;
	margin: 0;
	color: var(--ch-moss);
	font-size: 1rem;
	font-weight: 700;
}

.ch-recs ul.products li.product .button,
.ch-recs ul.products li.product .added_to_cart {
	width: 100%;
	margin-top: auto;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	text-align: center;
	box-sizing: border-box;
}

/*
 * Reduced-motion guard
 *
 * The carousel control buttons translate up by 1px on hover/focus. The
 * site-wide reduced-motion block in the parent main.css does not include
 * this selector, so the lift still fires for users with the OS-level
 * preference set. Neutralizing it here keeps the focus/hover *visual*
 * change (color, shadow) while removing the motion.
 */
@media (prefers-reduced-motion: reduce) {
	.ch-recs .chiseiko-recommendations__control,
	.ch-recs .chiseiko-recommendations__control:hover,
	.ch-recs .chiseiko-recommendations__control:focus-visible {
		transform: none;
		transition: none;
	}
}

@media (max-width: 640px) {
	.ch-recs {
		padding: 1rem;
		border-radius: var(--ch-radius-lg);
	}

	.ch-recs .chiseiko-recommendations__viewport {
		gap: 0.5rem;
	}

	/* Smaller flank controls on mobile so the rail keeps maximum width. */
	.ch-recs .chiseiko-recommendations__control {
		width: 2.5rem;
		height: 2.5rem;
	}

	.ch-recs ul.products li.product {
		width: min(72vw, 14rem);
		min-width: min(72vw, 14rem);
		max-width: min(72vw, 14rem);
		flex-basis: min(72vw, 14rem);
		padding: 0.9rem;
	}

	.ch-recs > h2 {
		font-size: 1.9rem;
	}
}
