/**
 * Basket icon: Kadence block-header fallback (fixed, no layout shift) + mobile badge clarity.
 * Markup is printed on kadence_after_wrapper (outside #wrapper) so position:fixed is not clipped
 * by overflow/transform on .site or #wrapper.
 */

/* Block-based Kadence header: floating cart so we do not alter block layout */
.erm-blocks-header-cart-fallback {
	position: fixed;
	top: 0.85rem;
	right: 0.85rem;
	z-index: 10050;
	display: flex;
	isolation: isolate;
	align-items: center;
	justify-content: center;
	margin: 0;
	padding: 0;
	max-width: none;
	pointer-events: none;
}

@media screen and (max-width: 1024px) {
	/* Sticky #mobile-header / block rows often stack above 10050; match classic floating cart */
	.erm-blocks-header-cart-fallback {
		z-index: 100050;
		right: 3.35rem;
		top: 0.75rem;
	}
}

.erm-blocks-header-cart-fallback .erm-fallback-cart-inner,
.erm-blocks-header-cart-fallback .erm-header-cart-link-inner {
	pointer-events: auto;
}

/**
 * Classic Kadence header: block header is disabled, but the mobile column hook may not run (layout edge cases).
 * Fixed cart on small viewports only; inset from the right so it sits beside the menu toggle, not under it.
 */
.erm-classic-header-cart-floating {
	display: none;
}

@media screen and (max-width: 1024px) {
	.erm-classic-header-cart-floating {
		display: flex;
		align-items: center;
		justify-content: center;
		position: fixed;
		isolation: isolate;
		top: 0.75rem;
		right: 3.35rem;
		z-index: 100050;
		margin: 0;
		padding: 0;
		pointer-events: none;
	}

	.erm-classic-header-cart-floating .erm-header-cart-link-inner {
		pointer-events: auto;
	}

	/* Kadence Customizer “mobile cart” module only (not generic .header-mobile-cart-wrap matches). */
	body:has(#mobile-header [data-section="kadence_customizer_mobile_cart"]) .erm-classic-header-cart-floating {
		display: none !important;
	}

	/* Block-header fallback takes precedence when both are present */
	body:has(.erm-blocks-header-cart-fallback) .erm-classic-header-cart-floating {
		display: none !important;
	}

	/* In-flow cart in #mobile-header: hide the fixed pin (it used position:fixed and sat under the admin bar). */
	body:has(#mobile-header .erm-inline-mobile-header-cart) .erm-classic-header-cart-floating {
		display: none !important;
		visibility: hidden !important;
		pointer-events: none !important;
	}

	/* Kadence Customizer mobile cart module: hide our duplicate in-flow cart */
	#mobile-header:has([data-section="kadence_customizer_mobile_cart"]) .erm-inline-mobile-header-cart {
		display: none !important;
	}
}

body.admin-bar .erm-classic-header-cart-floating {
	top: 2.55rem;
}

@media screen and (max-width: 782px) {
	body.admin-bar .erm-classic-header-cart-floating {
		top: 2.25rem;
	}
}

.erm-classic-header-cart-floating .header-cart-button {
	position: relative;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 2.65rem;
	min-height: 2.65rem;
	padding: 0 0.35rem;
	border-radius: 12px;
	background: rgba(255, 255, 255, 0.92);
	color: #0f172a;
	text-decoration: none;
	box-shadow: 0 4px 18px rgba(15, 23, 42, 0.12);
	border: 1px solid rgba(15, 23, 42, 0.08);
}

.erm-classic-header-cart-floating .header-cart-total {
	position: absolute;
	top: 2px;
	right: 2px;
	min-width: 1.1rem;
	height: 1.1rem;
	padding: 0 4px;
	border-radius: 999px;
	font-size: 0.62rem;
	font-weight: 700;
	line-height: 1.1rem;
	text-align: center;
	background: #1f4d92;
	color: #fff;
	box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.95);
}

body.admin-bar .erm-blocks-header-cart-fallback {
	top: 2.65rem;
}

@media screen and (max-width: 782px) {
	body.admin-bar .erm-blocks-header-cart-fallback {
		top: 2.35rem;
	}
}

.erm-blocks-header-cart-fallback .header-cart-button {
	position: relative;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 2.65rem;
	min-height: 2.65rem;
	padding: 0 0.35rem;
	border-radius: 12px;
	background: rgba(255, 255, 255, 0.92);
	color: #0f172a;
	text-decoration: none;
	box-shadow: 0 4px 18px rgba(15, 23, 42, 0.12);
	border: 1px solid rgba(15, 23, 42, 0.08);
	transition: background-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.erm-blocks-header-cart-fallback .header-cart-button:hover,
.erm-blocks-header-cart-fallback .header-cart-button:focus {
	background: #fff;
	box-shadow: 0 6px 22px rgba(15, 23, 42, 0.16);
	transform: translateY(-1px);
	outline: none;
}

/* Count badge */
.erm-blocks-header-cart-fallback .header-cart-total {
	position: absolute;
	top: 2px;
	right: 2px;
	min-width: 1.1rem;
	height: 1.1rem;
	padding: 0 4px;
	border-radius: 999px;
	font-size: 0.62rem;
	font-weight: 700;
	line-height: 1.1rem;
	text-align: center;
	background: #1f4d92;
	color: #fff;
	box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.95);
}

.erm-blocks-header-cart-fallback .header-cart-is-empty-true.header-cart-total {
	opacity: 0.5;
}

/* Classic Kadence mobile row: keep count legible without fighting desktop theme styles */
@media (max-width: 719px) {
	#mobile-header .header-mobile-cart-wrap .header-cart-total {
		min-width: 1.1rem;
		min-height: 1.1rem;
		line-height: 1.1rem;
		font-size: 0.65rem;
		font-weight: 700;
		padding: 0 5px;
		border-radius: 999px;
	}
}

/*
 * Classic Kadence header: keep cart visible next to primary nav + auth CTAs.
 * Nav often uses fill/stretch; without this the cart flex-item can shrink to nothing
 * or sit under a wide menu row (especially next to Account / Sign in / Sell CTA).
 */
@media screen and (min-width: 1025px) {
	#masthead #main-header .site-header-main-section-right .site-header-item[data-section="kadence_customizer_cart"],
	#masthead #main-header .site-header-main-section-right-center .site-header-item[data-section="kadence_customizer_cart"] {
		flex-shrink: 0;
		/* Avoid z-index stacking over the nav: clip + gap in header-align handle overlap; keep cart in normal paint order */
		position: relative;
		z-index: auto;
	}

	#masthead #main-header .site-header-main-section-right .site-header-item-main-navigation,
	#masthead #main-header .site-header-main-section-right-center .site-header-item-main-navigation {
		min-width: 0;
	}
}

@media screen and (max-width: 1024px) {
	#mobile-header .site-header-main-section-right .site-header-item[data-section="kadence_customizer_mobile_cart"],
	#mobile-header .site-header-main-section-right-center .site-header-item[data-section="kadence_customizer_mobile_cart"] {
		flex-shrink: 0;
		position: relative;
		z-index: 12;
	}

	/* In-flow cart printed before the menu toggle (erm_basket_ux_prepend_inline_mobile_cart_to_row) */
	#mobile-header .site-header-main-section-right .erm-inline-mobile-header-cart,
	#mobile-header .site-header-main-section-right-center .erm-inline-mobile-header-cart {
		flex-shrink: 0;
		align-self: center;
		display: flex;
		align-items: center;
		margin-inline-end: 1.35rem;
		position: relative;
		z-index: 12;
		/* Optical alignment with logo + menu (slightly below raw flex center) */
		transform: translateY(4px);
	}

	#mobile-header .erm-inline-mobile-header-cart .header-cart-button {
		min-height: 44px;
		min-width: 44px;
	}

	#mobile-header .site-header-main-section-center .erm-inline-mobile-header-cart--center {
		margin-inline: 0.35rem;
		margin-inline-end: 1.35rem;
		transform: translateY(4px);
	}

	/*
	 * JS (erm-basket-ux.js) moves .erm-classic-header-cart-floating into the mobile header row.
	 * Strip viewport-fixed positioning so it aligns with logo + menu.
	 */
	#mobile-header .erm-classic-header-cart-floating.erm-mobile-cart-relocated {
		position: static !important;
		top: auto !important;
		right: auto !important;
		left: auto !important;
		bottom: auto !important;
		inset: auto !important;
		display: flex !important;
		align-items: center !important;
		align-self: center !important;
		flex-shrink: 0 !important;
		margin: 0 !important;
		margin-inline-end: 1.35rem !important;
		z-index: auto !important;
		pointer-events: none !important;
		transform: translateY(4px) !important;
	}

	#mobile-header .erm-mobile-cart-relocated .erm-header-cart-link-inner {
		pointer-events: auto !important;
	}
}
