/* Use the image link as the anchor in classic loops and the image block in collections. */
ul.products li.product:has(.noblex-status-badge) .woocommerce-loop-product__link,
.wc-block-components-product-image:has(> .noblex-status-badge),
body.single-product div.product:has(> .noblex-status-badge) {
	position: relative;
}

ul.products li.product:has(.noblex-status-badge) .woocommerce-loop-product__link {
	display: block;
}

/* Include the status class so the theme's out-of-stock card cannot stretch the label. */
body .wc-block-components-product-image > .noblex-status-badge,
body.single-product div.product > .noblex-status-badge,
body ul.products li.product .noblex-status-badge {
	position: absolute;
	z-index: 8;
	top: var(--badge-edge, 10px) !important;
	left: var(--badge-edge, 10px) !important;
	right: auto !important;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	box-sizing: border-box;
	width: 104px !important;
	max-width: calc(100% - 2 * var(--badge-edge, 10px));
	min-width: 0 !important;
	height: 22px !important;
	min-height: 0 !important;
	margin: 0 !important;
	padding: 0 4px !important;
	border: 1px solid var(--badge-surface) !important;
	border-radius: 2px !important;
	background: var(--badge-surface) !important;
	color: var(--badge-ink, #fff) !important;
	box-shadow: 0 2px 6px rgba(26, 21, 12, .18) !important;
	font-family: Arial, sans-serif;
	font-size: 11px !important;
	font-weight: 700 !important;
	line-height: 1.2 !important;
	letter-spacing: .035em;
	white-space: nowrap;
	text-align: center;
	text-transform: uppercase;
	pointer-events: none;
}

body .noblex-status-badge.coming-soon-badge {
	--badge-ink: #241B0A;
	--badge-surface: #FFD052;
}

body .noblex-status-badge.noblex-status-new {
	--badge-ink: #10382F;
	--badge-surface: #9CE0D3;
}

body .noblex-status-badge.noblex-status-sold-out {
	--badge-surface: #A42B3B;
}

body .noblex-status-badge.noblex-status-incoming {
	--badge-surface: #245AA5;
}

/* A sale and a product status can both apply. Give the sale its own position. */
body.single-product div.product:has(> .noblex-status-badge) > .onsale,
body ul.products li.product:has(.noblex-status-badge) .onsale,
.wc-block-components-product-image:has(> .noblex-status-badge) .wc-block-components-product-sale-badge {
	top: calc(16px + 1.55rem) !important;
	left: 10px !important;
	right: auto !important;
	bottom: auto !important;
	margin: 0 !important;
}

@media (max-width: 780px) {
	body .noblex-status-badge[class] {
		--badge-edge: 7px;
	}
}

/* The active image viewport excludes both the thumbnail rail and gallery padding.
   The badge precedes the gallery in classic WooCommerce, so move its rendering
   after the gallery via the summary hook before anchoring to the image. */
@supports (top: anchor(top)) {
	body.single-product div.product {
		anchor-scope: --noblex-main-photo;
	}
	body.single-product .woocommerce-product-gallery :is(.flex-viewport, .woocommerce-product-gallery__wrapper) {
		anchor-name: --noblex-main-photo;
	}
	body.single-product .flex-viewport .woocommerce-product-gallery__wrapper {
		anchor-name: none;
	}
	body.single-product div.product > .noblex-status-badge {
		position-anchor: --noblex-main-photo;
		top: calc(anchor(top, 0px) + var(--badge-edge, 10px)) !important;
		left: calc(anchor(left, 0px) + var(--badge-edge, 10px)) !important;
	}
}
