/* Bulk Product Price Update - Sale Campaign badges and countdowns (shared base).
 * Fancy badge and countdown layouts live in assets/css/badges/ and assets/css/countdowns/
 * and are only loaded when a live campaign uses them. */

.wcbdi-badge {
	--wcbdi-ink: var(--wcbdi-bg, #d63638);
	--wcbdi-paper: var(--wcbdi-color, #fff);
	--wcbdi-ink-deep: var(--wcbdi-ink);
	--wcbdi-ink-deep: color-mix(in oklab, var(--wcbdi-ink) 72%, #000);
	--wcbdi-lift: 0 0.12em 0.25em rgb(0 0 0 / 0.18), 0 0.35em 0.8em rgb(0 0 0 / 0.12);
	font-weight: 700;
	line-height: 1.2;
	white-space: nowrap;
	font-variant-numeric: tabular-nums;
}

.wcbdi-badge__body,
.wcbdi-badge__line {
	display: inline;
}

.wcbdi-badge__line + .wcbdi-badge__line::before {
	content: " ";
}

/* Simple shapes */
.onsale.wcbdi-badge--simple,
.wc-block-components-product-sale-badge.wcbdi-badge--simple,
.wcbdi-badge--simple {
	background: var(--wcbdi-ink) !important;
	background-color: var(--wcbdi-ink) !important;
	color: var(--wcbdi-paper) !important;
	border-color: var(--wcbdi-ink) !important;
}

.wcbdi-badge--rounded {
	border-radius: 4px !important;
	padding: 0.35em 0.65em !important;
}

.wcbdi-badge--pill {
	border-radius: 999px !important;
	padding: 0.35em 0.9em !important;
}

.wcbdi-badge--square {
	border-radius: 0 !important;
	padding: 0.35em 0.65em !important;
}

.wcbdi-badge--circle {
	display: inline-flex !important;
	align-items: center;
	justify-content: center;
	width: 4.4em;
	height: 4.4em;
	aspect-ratio: 1;
	padding: 0.45em !important;
	border-radius: 50% !important;
	white-space: normal;
	text-align: center;
	line-height: 1.05;
	box-sizing: border-box;
}

.wcbdi-badge--circle .wcbdi-badge__body {
	display: flex;
	flex-direction: column;
	align-items: center;
}

.wcbdi-badge--circle .wcbdi-badge__line + .wcbdi-badge__line::before {
	content: none;
}

/* Placed on the product image by the plugin (classic themes). The product card or
 * product wrapper becomes the anchor; the image is at its top in WooCommerce templates. */
li.product:has(.wcbdi-badge--on-image),
.product:has(> .wcbdi-badge--on-image) {
	position: relative;
}

.onsale.wcbdi-badge--on-image,
.wcbdi-badge--on-image {
	position: absolute !important;
	z-index: 9;
	top: 0.75em !important;
	bottom: auto !important;
	margin: 0 !important;
	transform: none;
}

.wcbdi-badge--on-image-left {
	left: 0.75em !important;
	right: auto !important;
}

.wcbdi-badge--on-image-right {
	right: 0.75em !important;
	left: auto !important;
}

/* Corner and edge designs sit flush with the image edge. */
.wcbdi-badge--on-image.wcbdi-badge--ribbon {
	top: 0 !important;
}

.wcbdi-badge--on-image-left.wcbdi-badge--ribbon {
	left: 0 !important;
}

.wcbdi-badge--on-image-right.wcbdi-badge--ribbon {
	right: 0 !important;
}

.wcbdi-badge--on-image.wcbdi-badge--banner {
	top: 0 !important;
}

/* Inside a block theme's sale badge spot on the product image. WooCommerce's own
 * span.onsale offset would push the badge past the image edge, so reset it. */
.onsale.wcbdi-badge--in-block,
.wcbdi-badge--in-block {
	position: relative !important;
	top: auto !important;
	left: auto !important;
	right: auto !important;
	margin: 0 !important;
}

.wp-block-woocommerce-product-sale-badge:has(> .wcbdi-badge--in-block-right) {
	text-align: right;
}

.wp-block-woocommerce-product-sale-badge:has(> .wcbdi-badge--in-block-center) {
	text-align: center;
}

/* Corner and edge designs: flush with the image corner on the badge's side. */
.wcbdi-badge--in-block.wcbdi-badge--ribbon,
.wcbdi-badge--in-block.wcbdi-badge--banner {
	position: absolute !important;
	z-index: 9;
	top: 0 !important;
}

.wcbdi-badge--in-block.wcbdi-badge--ribbon.wcbdi-badge--side-left {
	left: 0 !important;
}

.wcbdi-badge--in-block.wcbdi-badge--ribbon.wcbdi-badge--side-right {
	right: 0 !important;
	left: auto !important;
}

.wcbdi-badge--in-block.wcbdi-badge--banner.wcbdi-badge--side-left {
	left: 0.75em !important;
}

.wcbdi-badge--in-block.wcbdi-badge--banner.wcbdi-badge--side-right {
	right: 0.75em !important;
	left: auto !important;
}

/* Theme placement (sale flash): where WooCommerce positions .onsale absolutely with a
 * small outward offset, corner designs sit flush instead. Has no effect when the theme
 * keeps the flash in the normal flow. */
.onsale.wcbdi-badge--ribbon:not(.wcbdi-badge--on-image):not(.wcbdi-badge--in-block) {
	top: 0 !important;
	left: 0 !important;
	right: auto !important;
	margin: 0 !important;
}

.onsale.wcbdi-badge--banner:not(.wcbdi-badge--on-image):not(.wcbdi-badge--in-block) {
	top: 0 !important;
	margin-top: 0 !important;
}

/* Block theme product page: the Product Image Gallery block prints the sale flash with
 * WooCommerce's outward offset, which pushes larger designs off the photo. Inset them. */
.wp-block-woocommerce-product-image-gallery > .onsale.wcbdi-badge:not(.wcbdi-badge--ribbon):not(.wcbdi-badge--banner) {
	top: 0.75em !important;
	left: 0.75em !important;
	right: auto !important;
	margin: 0 !important;
}

.wp-block-woocommerce-product-image-gallery > .onsale.wcbdi-badge--banner {
	left: 0.75em !important;
	right: auto !important;
}

/* Fancy layouts draw their own shape: strip whatever the theme gives .onsale. */
.onsale.wcbdi-badge--fancy,
.wc-block-components-product-sale-badge.wcbdi-badge--fancy,
.wcbdi-badge--fancy {
	display: inline-block !important;
	background: transparent !important;
	border: 0 !important;
	border-radius: 0 !important;
	box-shadow: none !important;
	padding: 0 !important;
	min-width: 0 !important;
	min-height: 0 !important;
	width: auto;
	height: auto;
	color: var(--wcbdi-paper) !important;
	line-height: 1 !important;
	text-transform: none;
	letter-spacing: normal;
}

.wcbdi-countdown {
	--wcbdi-cd-size: 0.95em;
	--wcbdi-cd-radius: 4px;
	display: inline-flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.35em 0.5em;
	margin: 0.4em 0 0.8em;
	padding: 0.4em 0.75em;
	border: 2px solid transparent;
	border-radius: var(--wcbdi-cd-radius);
	font-size: var(--wcbdi-cd-size);
	line-height: 1.3;
	box-sizing: border-box;
}

.wcbdi-countdown--loop {
	font-size: calc(var(--wcbdi-cd-size) * 0.85);
	margin: 0.2em 0 0.6em;
}

.wcbdi-countdown__time {
	display: inline-flex;
	flex-wrap: wrap;
	align-items: baseline;
	gap: 0.3em;
	font-weight: 700;
	font-variant-numeric: tabular-nums;
}

.wcbdi-countdown__ends {
	display: none;
}

.wcbdi-cd-unit[hidden] {
	display: none !important;
}

.wcbdi-cd-lbl {
	font-weight: 400;
}

/* Sizes */
.wcbdi-cd--small {
	--wcbdi-cd-size: 0.8em;
}

.wcbdi-cd--large {
	--wcbdi-cd-size: 1.15em;
}

/* Shapes */
.wcbdi-cd--shape-pill {
	--wcbdi-cd-radius: 999px;
}

.wcbdi-cd--shape-square {
	--wcbdi-cd-radius: 0;
}

/* Alignment */
.wcbdi-cd--align-left,
.wcbdi-cd--align-center,
.wcbdi-cd--align-right {
	display: flex;
	width: fit-content;
	max-width: 100%;
}

.wcbdi-cd--align-left {
	margin-right: auto;
}

.wcbdi-cd--align-center {
	margin-left: auto;
	margin-right: auto;
	justify-content: center;
}

.wcbdi-cd--align-right {
	margin-left: auto;
}

.wcbdi-cd--align-center .wcbdi-countdown__label {
	text-align: center;
}

.wcbdi-cd--align-right .wcbdi-countdown__label {
	text-align: right;
}

/* Style: filled */
.wcbdi-cd--filled {
	background: var(--wcbdi-cd-bg, #d63638);
	border-color: var(--wcbdi-cd-bg, #d63638);
	color: var(--wcbdi-cd-color, #fff);
}

/* Style: outline, the main colour is used for border and text */
.wcbdi-cd--outline {
	background: transparent;
	border-color: var(--wcbdi-cd-bg, #d63638);
	color: var(--wcbdi-cd-bg, #d63638);
}

/* Style: minimal, plain text with coloured numbers */
.wcbdi-cd--minimal {
	padding: 0;
	border: 0;
	background: transparent;
	color: inherit;
}

.wcbdi-cd--minimal .wcbdi-countdown__time {
	color: var(--wcbdi-cd-bg, #d63638);
}

/* Style: blocks, one box per unit */
.wcbdi-cd--blocks {
	padding: 0;
	border: 0;
	background: transparent;
	color: inherit;
	gap: 0.4em 0.6em;
}

.wcbdi-cd--blocks .wcbdi-countdown__time {
	gap: 0.35em;
}

.wcbdi-cd--blocks .wcbdi-cd-unit {
	display: inline-flex;
	flex-direction: column;
	align-items: center;
	min-width: 3.2em;
	padding: 0.35em 0.4em;
	border-radius: var(--wcbdi-cd-radius);
	background: var(--wcbdi-cd-bg, #d63638);
	color: var(--wcbdi-cd-color, #fff);
	line-height: 1.1;
}

.wcbdi-cd--blocks.wcbdi-cd--shape-pill .wcbdi-cd-unit {
	border-radius: 0.8em;
}

.wcbdi-cd--blocks .wcbdi-cd-num {
	font-size: 1.35em;
}

.wcbdi-cd--blocks .wcbdi-cd-lbl {
	font-size: max(11px, 0.7em);
	text-transform: uppercase;
	letter-spacing: 0.04em;
	opacity: 0.9;
}
