/* Kadence Product Badges – front-end */

.kpb-badges {
	position: absolute;
	top: 0;
	right: 0;
	bottom: 0;
	left: 0;
	pointer-events: none;
	z-index: 8;
	overflow: visible;
	--kpb-offset: 10px;
	--kpb-scale: 1;
}

.kpb-corner {
	position: absolute;
	left: var(--kpb-offset);
	right: var(--kpb-offset);
	display: flex;
	flex-direction: column;
	gap: 6px;
	margin: 0;
	padding: 0;
}

.kpb-corner--top-left,
.kpb-corner--top-center,
.kpb-corner--top-right { top: var(--kpb-offset); }

.kpb-corner--bottom-left,
.kpb-corner--bottom-center,
.kpb-corner--bottom-right { bottom: var(--kpb-offset); }

.kpb-corner--top-left,
.kpb-corner--bottom-left { align-items: flex-start; }

.kpb-corner--top-center,
.kpb-corner--bottom-center { align-items: center; text-align: center; }

.kpb-corner--top-right,
.kpb-corner--bottom-right { align-items: flex-end; }

.kpb-badge {
	display: inline-block;
	box-sizing: border-box;
	line-height: 1;
	margin: 0;
	max-width: 100%;
}

/* Text badges */
.kpb-badge--text {
	background: var(--kpb-bg, #d63638);
	color: var(--kpb-color, #fff);
	font-size: calc(var(--kpb-fs, 12px) * var(--kpb-scale));
	font-weight: 600;
	font-family: inherit;
	letter-spacing: .04em;
	text-transform: uppercase;
	text-decoration: none;
	padding: .55em .9em;
	white-space: nowrap;
}

.kpb-shape-rectangle { border-radius: 0; }
.kpb-shape-rounded   { border-radius: 4px; }
.kpb-shape-pill      { border-radius: 999px; }
.kpb-shape-circle {
	border-radius: 50%;
	width: 4.2em;
	height: 4.2em;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	text-align: center;
	padding: .3em;
	white-space: normal;
	line-height: 1.1;
}

/* Image / SVG badges – sized by the badge setting, never by WordPress' 1×1 SVG guess */
.kpb-badge--image img {
	display: block;
	width: calc(var(--kpb-w, 90px) * var(--kpb-scale));
	max-width: 100%;
	height: auto;
	margin: 0;
	border: 0;
	box-shadow: none;
	background: transparent;
}

@media (max-width: 782px) {
	.kpb-badges { --kpb-scale: .85; }
}

@media (max-width: 480px) {
	.kpb-badges { --kpb-scale: .7; }
}

/* Containers that host badges need to be positioned. These are already
   positioned by WooCommerce / Kadence in practice; this is a safety net. */
.woocommerce ul.products li.product,
.wc-block-grid__product,
.wc-block-grid__product-image,
.wc-block-components-product-image,
.woocommerce-product-gallery {
	position: relative;
}

/* The badge overlay is anchored to the wrapper around the product *thumbnail*.
   Kadence already renders its image link as a positioned block; classic
   WooCommerce themes leave the link inline, so fix that wherever a badge
   overlay is present (before the script runs, to avoid a flash). */
.woocommerce ul.products li.product a.woocommerce-loop-image-link,
a.woocommerce-LoopProduct-link:has(> .kpb-badges),
.kpb-image-wrap {
	position: relative;
	display: block;
}

/* Never let an overlay sit on the card's details / add-to-cart area. If one
   ends up there (old cached script, custom template), keep the button usable
   until the script moves the overlay onto the image. */
.product-action-wrap > .kpb-badges,
.product-details > .kpb-badges,
.entry-content-wrap > .kpb-badges {
	display: none;
}
