/* ─────────────────────────────────────────────────────────────────────────────
   Related Products Strip — Add-On Rules
   Loaded on single product pages only (is_product()).
   catalog.css (and its :root vars) is not loaded on product pages, so all
   card styles are self-contained here.
───────────────────────────────────────────────────────────────────────────── */

.hhd-related-products {
	/* CSS custom properties — mirrors catalog.css :root, scoped here */
	--hhd-blue:   #002b66;
	--hhd-green:  #67b900;
	--hhd-red:    #b91924;
	--hhd-ink:    #061b3a;
	--hhd-muted:  #5e6b7d;
	--hhd-border: #e4e9ef;

	margin-top: 48px;
	contain: layout;
}

/* ── Product card shell ───────────────────────────────────────────────────── */

.hhd-related-products ul.products.hhd-related-strip li.product {
	min-width: 0;
	border: 1px solid var(--hhd-border);
	border-radius: 6px;
	padding: 12px;
	background: #fff;
	/* Reset any WooCommerce default float/width that would break grid cells */
	float: none !important;
	width: auto !important;
}

/* Image area — grey background matches archive cards */
.hhd-related-products ul.products.hhd-related-strip li.product figure,
.hhd-related-products ul.products.hhd-related-strip li.product .ct-media-container {
	background: #f2f4f6;
}

/* Fix Blocksy swap-image: without archive CSS, ct-swap renders inline.
   Force it absolutely positioned so only the main image shows by default. */
.hhd-related-products .ct-media-container {
	position: relative;
	display: block;
	overflow: hidden;
}

.hhd-related-products .ct-media-container .ct-swap {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
	opacity: 0;
	transition: opacity 0.3s;
}

.hhd-related-products .ct-media-container:hover .ct-swap {
	opacity: 1;
}

/* ── Title ───────────────────────────────────────────────────────────────── */

.hhd-related-products .hhd-product-card__title {
	min-height: 42px;
	font-size: 14px !important;
	line-height: 1.25 !important;
	font-weight: 700;
	margin: 10px 0 6px;
}

/* ── Price ───────────────────────────────────────────────────────────────── */

.hhd-related-products .price {
	display: block;
	margin: 8px 0;
	font-size: 15px;
	font-weight: 800;
	color: var(--hhd-ink);
}

/* ── Add to basket button ────────────────────────────────────────────────── */

.hhd-related-products .hhd-add-to-basket,
.hhd-related-products .ct-woo-card-actions .button {
	display: flex;
	width: 100%;
	min-height: 34px;
	justify-content: center;
	align-items: center;
	border-radius: 2px;
	background: var(--hhd-green) !important;
	color: #fff !important;
	font-size: 12px;
	font-weight: 800;
	text-transform: uppercase;
	text-decoration: none;
}

.hhd-related-products .hhd-section-heading {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin-bottom: 18px;
}

.hhd-related-products .hhd-section-heading h2 {
	margin: 0;
	font-size: 1.3em;
}

/* ── Slider controls (scoped — catalog.css not loaded on product pages) ─────── */

.hhd-related-products .hhd-slider-controls {
	display: none;
}

@media (min-width: 761px) {
	.hhd-related-products .hhd-slider-controls {
		display: flex;
		gap: 8px;
	}

	.hhd-related-products .hhd-slider-controls button {
		display: inline-grid;
		place-items: center;
		width: 44px;
		height: 44px;
		padding: 0;
		border: 1px solid var(--hhd-border);
		border-radius: 50%;
		background: #fff;
		color: var(--hhd-blue);
		font-size: 28px;
		line-height: 1;
		cursor: pointer;
		transition: none;
	}

	.hhd-related-products .hhd-slider-controls button:disabled {
		opacity: 0.35;
		cursor: default;
	}
}

/* ── Dots (mobile only — scoped) ─────────────────────────────────────────── */

.hhd-related-products .hhd-slider-dots {
	display: none;
	justify-content: center;
	gap: 0;
	margin-top: 6px;
}

.hhd-related-products .hhd-slider-dot {
	position: relative;
	width: 44px;
	height: 44px;
	padding: 0;
	border: 0;
	background: transparent;
	cursor: pointer;
	transition: none;
}

.hhd-related-products .hhd-slider-dot::after {
	content: '';
	position: absolute;
	width: 9px;
	height: 9px;
	top: 50%;
	left: 50%;
	border-radius: 50%;
	background: #c8d2de;
	transform: translate(-50%, -50%);
}

.hhd-related-products .hhd-slider-dot.is-active::after {
	background: var(--hhd-blue);
}

.hhd-related-products .hhd-slider-dot:focus-visible {
	outline: 2px solid var(--hhd-blue);
	outline-offset: -8px;
}

/* ── Strip grid — desktop default (≤ 6 products, no slider needed) ─────────── */

.hhd-related-products ul.products.hhd-related-strip {
	display: grid;
	grid-template-columns: repeat(6, minmax(0, 1fr));
	gap: 14px;
	margin: 0;
	padding: 0;
	list-style: none;
}

/* ── Strip slider — desktop (> 6 products, arrows active) ──────────────────── */

@media (min-width: 1181px) {
	.hhd-related-products ul.products.hhd-related-strip.hhd-slider {
		display: flex;
		flex-wrap: nowrap;
		overflow-x: auto;
		overflow-y: hidden;
		scroll-snap-type: x mandatory;
		scrollbar-width: none;
		gap: 14px;
		padding: 2px 2px 10px;
	}

	.hhd-related-products ul.products.hhd-related-strip.hhd-slider::-webkit-scrollbar {
		display: none;
	}

	.hhd-related-products ul.products.hhd-related-strip.hhd-slider li.product {
		flex: 0 0 calc((100% - 70px) / 6);
		max-width: calc((100% - 70px) / 6);
		scroll-snap-align: start;
	}
}

/* ── Tablet: 4 columns ──────────────────────────────────────────────────────── */

@media (min-width: 761px) and (max-width: 1180px) {
	.hhd-related-products ul.products.hhd-related-strip {
		grid-template-columns: repeat(4, minmax(0, 1fr));
	}

	.hhd-related-products ul.products.hhd-related-strip.hhd-slider li.product {
		flex-basis: calc((100% - 42px) / 4);
		max-width: calc((100% - 42px) / 4);
	}
}

/* ── Mobile: horizontal scroll, 2 cards visible ────────────────────────────── */

@media (max-width: 760px) {
	.hhd-related-products ul.products.hhd-related-strip {
		display: flex;
		flex-wrap: nowrap;
		overflow-x: auto;
		overflow-y: hidden;
		scroll-snap-type: x mandatory;
		-webkit-overflow-scrolling: touch;
		scrollbar-width: none;
		gap: 12px;
		padding-bottom: 4px;
		margin: 0;
	}

	.hhd-related-products ul.products.hhd-related-strip::-webkit-scrollbar {
		display: none;
	}

	.hhd-related-products ul.products.hhd-related-strip li.product {
		flex: 0 0 42vw;
		max-width: 42vw;
		scroll-snap-align: start;
	}

	.hhd-related-products .hhd-slider-dots {
		display: flex;
	}
}

@media (prefers-reduced-motion: reduce) {
	.hhd-related-products ul.products.hhd-related-strip {
		scroll-behavior: auto;
	}
}

/* ── Cart "Did you need?" section wrapper ──────────────────────────────────── */

.hhd-cart-crosssells {
	position: relative;
	padding: 40px 0;
	margin-top: 32px;
}

/* Full-bleed background via pseudo-element — extends to viewport edges while
   card content stays at page width. Uses Blocksy's --scrollbar-width variable
   so Windows scrollbars don't cause a horizontal scroll. */
.hhd-cart-crosssells::before {
	content: '';
	position: absolute;
	top: 0;
	bottom: 0;
	left: 50%;
	transform: translateX(-50%);
	width: calc(100vw - var(--scrollbar-width, 0px));
	background: #eff6ff;
	z-index: 0;
}

.hhd-cart-crosssells .hhd-related-products {
	position: relative;
	z-index: 1;
	max-width: 1200px;
	margin: 0 auto;
	padding: 0 20px;
}

.hhd-cart-crosssells .hhd-section-heading h2 {
	font-size: 22px;
	color: #00205c;
}

@media (max-width: 760px) {
	.hhd-cart-crosssells {
		padding: 28px 0;
	}

	.hhd-cart-crosssells .hhd-related-products {
		padding: 0 16px;
	}
}
