/*
 * Shared related-product presentation for single-product carousels and the
 * compact archive context list. This file is loaded after catalog.css so the
 * retired price-filter/drawer geometry cannot reappear through WoodMart's
 * mobile rules.
 */
:root {
	--ems-related-accent: var(--ems-accent, #F6A51C);
	--ems-related-ink: #1b1b1b;
	--ems-related-muted: #777;
	--ems-related-border: #e5e5e5;
}

/* Archive sidebar replacement. */
body.ems-catalog-active .ems-archive-related-sidebar {
	grid-column: 1 !important;
	grid-row: 2 / span 4 !important;
	position: static !important;
	display: block !important;
	width: 100% !important;
	max-height: none !important;
	margin: 0 !important;
	padding: 0 !important;
	overflow: visible !important;
	border: 0 !important;
	background: transparent !important;
	box-shadow: none !important;
	transform: none !important;
	visibility: visible !important;
}

/* On block-theme archives the related list is the left sidebar beside the
 * results toolbar and product grid. It remains a full-width top block only
 * on narrow screens where the archive collapses to one column. */
body.ems-catalog-active.woocommerce-uses-block-theme .ems-archive-related-sidebar.ems-archive-related-top {
	grid-column: 1 !important;
	grid-row: auto !important;
	width: 100% !important;
	max-width: none !important;
	margin: 0 !important;
}

@media (max-width: 767px) {
	body.ems-catalog-active.woocommerce-uses-block-theme .ems-archive-related-sidebar.ems-archive-related-top {
		grid-column: auto !important;
		width: 100% !important;
		max-width: none !important;
		margin: 28px auto 32px !important;
	}
}

body.ems-catalog-active .ems-archive-related__heading {
	margin: 0 0 18px;
	padding: 0;
	border: 0 !important;
	color: var(--ems-related-ink);
	font-size: 17px;
	font-weight: 800;
	letter-spacing: .02em;
	line-height: 1.2;
}

/* The Related Products heading is intentionally borderless. These selectors
 * are scoped to the exact heading wrappers and do not affect product-list
 * separators elsewhere in the store. */
.ems-related-products {
	border-top: 0 !important;
}

.ems-related-products > .ems-product-section-header {
	margin-bottom: 32px !important;
	padding: 0 !important;
	border: 0 !important;
	box-shadow: none !important;
}

.ems-related-products > .ems-product-section-header::before,
.ems-related-products > .ems-product-section-header::after,
body.ems-catalog-active .ems-archive-related__heading::before,
body.ems-catalog-active .ems-archive-related__heading::after {
	display: none !important;
	content: none !important;
}

@media (min-width: 768px) and (max-width: 1100px) {
	.ems-related-products > .ems-product-section-header {
		margin-bottom: 28px !important;
	}

	body.ems-catalog-active .ems-archive-related__heading {
		margin-bottom: 28px;
	}
}

body.ems-catalog-active .ems-archive-related__items {
	display: grid;
	gap: 0;
}

body.ems-catalog-active .ems-archive-related__item {
	display: grid;
	grid-template-columns: 68px minmax(0, 1fr);
	gap: 12px;
	align-items: center;
	min-width: 0;
	padding: 14px 0;
	border-bottom: 1px solid var(--ems-related-border);
	color: var(--ems-related-ink);
	text-decoration: none;
}

body.ems-catalog-active .ems-archive-related__item:first-child { padding-top: 0; }
body.ems-catalog-active .ems-archive-related__item:last-child { border-bottom: 0; }
body.ems-catalog-active .ems-archive-related__item:hover strong,
body.ems-catalog-active .ems-archive-related__item:focus-visible strong { color: var(--ems-accent, #F6A51C); }

body.ems-catalog-active .ems-archive-related__image,
body.ems-catalog-active .ems-archive-related__image img {
	display: block;
	width: 68px;
	height: 68px;
}

body.ems-catalog-active .ems-archive-related__image {
	overflow: hidden;
	background: #fff;
}

body.ems-catalog-active .ems-archive-related__image img { object-fit: contain; }

body.ems-catalog-active .ems-archive-related__copy {
	display: flex;
	min-width: 0;
	flex-direction: column;
}

body.ems-catalog-active .ems-archive-related__copy strong {
	display: -webkit-box;
	min-height: 2.7em;
	max-height: 2.7em;
	overflow: hidden;
	color: var(--ems-related-ink);
	font-size: 13px;
	font-weight: 750;
	line-height: 1.35;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 2;
}

body.ems-catalog-active .ems-archive-related__price {
	display: block;
	min-height: 1.4em;
	margin-top: 6px;
	color: var(--ems-accent, #F6A51C);
	font-size: 13px;
	font-weight: 750;
	line-height: 1.3;
}

body.ems-catalog-active .ems-archive-related__price del {
	margin-right: 5px;
	color: #777 !important;
	text-decoration: line-through !important;
}

body.ems-catalog-active .ems-archive-related__price .amount,
body.ems-catalog-active .ems-archive-related__price .woocommerce-Price-amount,
body.ems-catalog-active .ems-archive-related__price .woocommerce-Price-currencySymbol { color: inherit; }

/* Single-product related/upsell/cross-sell card geometry. */
.ems-related-products .ems-product-section-header { margin-bottom: 22px; }
.ems-related-products .ems-product-section-header p:empty { display: none; }
.ems-related-products .ems-product-section-header h2 {
	margin: 0;
	color: var(--ems-related-ink);
	font-size: clamp(22px, 2.2vw, 32px);
	font-weight: 800;
	line-height: 1.15;
	text-transform: uppercase;
}

.ems-related-carousel {
	position: relative;
	width: 100%;
	max-width: 100%;
	margin: 0;
	/* The product cards own the full content width.  Side rails made the
	 * mobile cards look like a narrow, unrelated widget.  Navigation is in
	 * the dedicated control row below the cards. */
	padding: 0 0 34px;
	overflow: visible;
}

.ems-related-carousel__viewport { width: 100%; overflow: hidden; }
.ems-related-carousel__track {
	display: flex;
	gap: 18px;
	align-items: stretch;
	transition: transform .28s ease;
	will-change: transform;
}
.ems-related-carousel__slide {
	display: flex;
	flex: 0 0 calc((100% - 54px) / 4);
	min-width: 0;
}
.ems-related-carousel__slide > .product-card {
	display: flex;
	width: 100%;
	min-width: 0;
	flex-direction: column;
	height: 100%;
	border: 0 !important;
	background: transparent !important;
	box-shadow: none !important;
}
.ems-related-carousel .product-card__link {
	display: flex;
	min-width: 0;
	flex-direction: column;
	color: inherit;
	text-decoration: none;
}
.ems-related-carousel .product-card__image {
	position: relative;
	display: flex;
	width: 100%;
	aspect-ratio: 1 / 1;
	align-items: center;
	justify-content: center;
	overflow: hidden;
	background: #fff;
}
.ems-related-carousel .product-card__image img {
	display: block;
	width: 100% !important;
	height: 100% !important;
	object-fit: contain;
	background: #fff;
}
.ems-related-carousel .product-card__badge {
	position: absolute;
	top: 10px;
	left: 10px;
	z-index: 2;
	display: inline-flex;
	min-height: 28px;
	align-items: center;
	padding: 6px 9px;
	border-radius: 4px;
	background: var(--ems-related-accent) !important;
	color: #17191c !important;
	font-size: 11px;
	font-weight: 800;
	line-height: 1;
	white-space: nowrap;
}
.ems-related-carousel .product-card__title {
	display: -webkit-box;
	min-height: 4.35em;
	max-height: 4.35em;
	margin: 16px 0 0;
	overflow: hidden;
	color: var(--ems-related-ink);
	font-size: clamp(16px, 1.35vw, 22px);
	font-weight: 800;
	line-height: 1.28;
	text-align: center;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 3;
}
.ems-related-carousel .product-card__term {
	display: block;
	min-height: 1.45em;
	margin: 12px 0 0;
	color: #a0a0a0;
	font-size: clamp(14px, 1vw, 17px);
	font-weight: 500;
	line-height: 1.45;
	text-align: center;
}
.ems-related-carousel .product-card__price {
	display: flex;
	min-height: 2.8em;
	align-items: flex-start;
	justify-content: center;
	margin: 14px 0 0;
	color: var(--ems-accent, #F6A51C) !important;
	font-size: clamp(18px, 1.45vw, 25px);
	font-weight: 800;
	line-height: 1.35;
	text-align: center;
}
.ems-related-carousel .product-card__price .ems-price-stack {
	display: inline-flex;
	flex-wrap: wrap;
	align-items: baseline;
	justify-content: center;
	gap: 3px 8px;
}
.ems-related-carousel .product-card__price del {
	display: inline-block !important;
	color: #777 !important;
	text-decoration: line-through !important;
}
.ems-related-carousel .product-card__price .ems-price-current,
.ems-related-carousel .product-card__price .ems-price-current .amount,
.ems-related-carousel .product-card__price .ems-price-current .woocommerce-Price-amount { color: var(--ems-accent, #F6A51C) !important; }
.ems-related-carousel .product-card__actions { display: none !important; }

.ems-related-carousel__arrow {
	position: absolute;
	top: 43%;
	z-index: 3;
	display: inline-flex;
	width: 36px;
	height: 36px;
	align-items: center;
	justify-content: center;
	padding: 0;
	border: 1px solid #d7d7d7;
	border-radius: 50%;
	background: #fff;
	color: var(--ems-related-ink);
	font-size: 20px;
	line-height: 1;
	cursor: pointer;
}
.ems-related-carousel__arrow--prev { left: 0; }
.ems-related-carousel__arrow--next { right: 0; }
.ems-related-carousel__arrow:hover,
.ems-related-carousel__arrow:focus-visible {
	border-color: var(--ems-related-accent);
	background: var(--ems-related-accent);
	color: #fff;
}
.ems-related-carousel__arrow[hidden],
.ems-related-carousel__dots[hidden] { display: none !important; }
.ems-related-carousel__dots {
	display: flex;
	justify-content: center;
	gap: 7px;
	margin-top: 18px;
}
.ems-related-carousel__dot {
	display: block;
	width: 8px;
	height: 8px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: #c9c9c9;
	cursor: pointer;
}
.ems-related-carousel__dot.is-active,
.ems-related-carousel__dot:hover,
.ems-related-carousel__dot:focus-visible { background: var(--ems-related-accent); }

@media (max-width: 1100px) {
	.ems-related-carousel__slide { flex-basis: calc((100% - 36px) / 3); }
}

@media (max-width: 767px) {
	.ems-related-products > .ems-product-section-header {
		margin-bottom: 24px !important;
	}

	body.ems-catalog-active .ems-archive-related__heading {
		margin-bottom: 24px;
	}

	body.ems-catalog-active .ems-catalog-layout {
		display: flex !important;
		flex-direction: column !important;
		align-items: stretch;
	}
	body.ems-catalog-active .ems-catalog-results {
		display: block !important;
		order: 1;
		min-width: 0;
	}
	body.ems-catalog-active .ems-archive-related-sidebar {
		order: 2;
		width: 100% !important;
		margin: 38px 0 0 !important;
		padding: 24px 0 0 !important;
		border-top: 1px solid var(--ems-related-border) !important;
	}
	body.ems-catalog-active .ems-archive-related-sidebar.ems-archive-related-top {
		width: 100% !important;
		margin: 38px 0 0 !important;
	}
	body.ems-catalog-active .ems-filter-open,
	body.ems-catalog-active .ems-filter-backdrop { display: none !important; }
	.ems-related-carousel { padding-right: 0; padding-left: 0; }
	.ems-related-carousel__track { gap: 14px; }
	.ems-related-carousel__slide { flex-basis: calc((100% - 14px) / 2); }
	.ems-related-carousel__arrow { width: 30px; height: 30px; font-size: 17px; }
	.ems-related-carousel .product-card__badge { top: 7px; left: 7px; min-height: 24px; padding: 5px 7px; font-size: 10px; }
	.ems-related-carousel .product-card__title { margin-top: 14px; font-size: 18px; line-height: 1.28; }
	.ems-related-carousel .product-card__term { margin-top: 9px; font-size: 14px; }
	.ems-related-carousel .product-card__price { margin-top: 12px; font-size: 22px; }
}

/* Filter drawers and Show Sidebar controls are retired in favor of the
 * compact related-products list. This also neutralizes stale cached markup
 * without affecting the category navigation or sorting toolbar. */
body.ems-catalog-active .ems-filter-open,
body.ems-catalog-active .ems-filter-close,
body.ems-catalog-active .ems-filter-panel,
body.ems-catalog-active .ems-filter-backdrop,
body.ems-catalog-active .wd-show-sidebar-btn,
body.ems-catalog-active .wd-filter-btn { display: none !important; }

/* Archive pagination uses the same compact controls as the product-page
 * Related Products carousel. Keep every control a real page link while
 * neutralizing legacy theme widths and the old text-heavy Next button. */
body.ems-catalog-active nav.woocommerce-pagination {
	grid-column: 1 !important;
	width: 100% !important;
	margin: 32px 0 0 !important;
	padding: 0 !important;
	text-align: center !important;
}
body.ems-catalog-active nav.woocommerce-pagination ul.page-numbers {
	display: inline-flex !important;
	width: auto !important;
	max-width: 100% !important;
	flex-wrap: wrap !important;
	align-items: center !important;
	justify-content: center !important;
	gap: 8px !important;
	margin: 0 !important;
	padding: 0 !important;
	border: 0 !important;
	list-style: none !important;
}
body.ems-catalog-active nav.woocommerce-pagination li {
	display: block !important;
	float: none !important;
	width: auto !important;
	margin: 0 !important;
	padding: 0 !important;
}
body.ems-catalog-active nav.woocommerce-pagination a,
body.ems-catalog-active nav.woocommerce-pagination span {
	display: inline-flex !important;
	box-sizing: border-box !important;
	width: 52px !important;
	min-width: 52px !important;
	height: 52px !important;
	align-items: center !important;
	justify-content: center !important;
	padding: 0 !important;
	border: 1px solid #d7d7d7 !important;
	border-radius: 4px !important;
	background: #fff !important;
	color: #111 !important;
	font-size: 14px !important;
	font-weight: 700 !important;
	line-height: 1 !important;
	text-decoration: none !important;
}
body.ems-catalog-active nav.woocommerce-pagination span.current,
body.ems-catalog-active nav.woocommerce-pagination a:hover,
body.ems-catalog-active nav.woocommerce-pagination a:focus-visible {
	border-color: var(--ems-accent, #F6A51C) !important;
	background: var(--ems-accent, #F6A51C) !important;
	color: #111 !important;
}
body.ems-catalog-active nav.woocommerce-pagination span.dots {
	border-color: transparent !important;
	background: transparent !important;
}
body.ems-catalog-active nav.woocommerce-pagination .ems-pagination-chevron {
	border: 0 !important;
	background: transparent !important;
	font-size: 22px !important;
	font-weight: 400 !important;
	line-height: 1 !important;
}
body.ems-catalog-active nav.woocommerce-pagination .screen-reader-text {
	position: absolute !important;
	width: 1px !important;
	height: 1px !important;
	padding: 0 !important;
	margin: -1px !important;
	overflow: hidden !important;
	clip: rect(0, 0, 0, 0) !important;
	white-space: nowrap !important;
	border: 0 !important;
}

@media (max-width: 767px) {
	body.ems-catalog-active nav.woocommerce-pagination {
	margin-top: 24px !important;
	}
	body.ems-catalog-active nav.woocommerce-pagination a,
	body.ems-catalog-active nav.woocommerce-pagination span {
	width: 48px !important;
	min-width: 48px !important;
	height: 48px !important;
	}
}
