/**
 * sg-promo badge.
 *
 * RTL-native: every edge is a logical property, so the badge sits top-start in
 * Hebrew and top-left in English without a separate stylesheet.
 *
 * Colour comes from the theme's --sg-* contract when it exists and falls back
 * to the BGlass gold otherwise. The pair below is 6.9:1, which clears WCAG AA
 * for normal text, so the badge never costs an accessibility point.
 */

:root {
	--sg-promo-bg: var(--sg-gold, #c4a35a);
	--sg-promo-fg: var(--sg-ink, #1b1205);
	--sg-promo-radius: var(--sg-radius-sm, 8px);
}

.sg-promo-badge {
	display: inline-flex;
	align-items: center;
	gap: 0.25em;
	padding: 0.3em 0.65em;
	border-radius: var(--sg-promo-radius);
	background: var(--sg-promo-bg);
	color: var(--sg-promo-fg);
	font-size: 0.8125rem;
	font-weight: 700;
	line-height: 1.3;
	letter-spacing: 0.01em;
	white-space: nowrap;
	/* Keep the gradient of the shimmer variant inside the rounded corners. */
	position: relative;
	overflow: hidden;
	isolation: isolate;
}

/* ---- On a product card: floating over the image, top-start ---- */

.sg-promo-badge--card {
	position: absolute;
	inset-block-start: 0.625rem;
	inset-inline-start: 0.625rem;
	z-index: 2;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
	pointer-events: none;
}

/* The card needs a positioning context. WooCommerce themes usually set this,
   but not all of them do, and an unpositioned parent would drop the badge at
   the top of the page instead. */
.woocommerce ul.products li.product,
.woocommerce-page ul.products li.product {
	position: relative;
}

/* ---- On the single product page: beside the price ----

   The badge sits next to the number it describes, not above the page, so the
   percentage and the price are read as one statement. margin-inline-start is
   the gap from the price; the small block margin keeps it from touching the
   price when a narrow column wraps it onto its own line. */

.sg-promo-badge--single {
	font-size: 0.875rem;
	margin-inline-start: 0.6rem;
	margin-block: 0.15rem;
	vertical-align: middle;
}

/* A theme that renders its price inside a flex container would otherwise let
   the badge stretch to the container's height. */
.sg-promo-price-row {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0 0.1rem;
}

.sg-promo-price-row > .sg-promo-badge--single {
	align-self: center;
	flex: 0 0 auto;
}

/* ---- Effect: pulse ---- */

.sg-promo-badge--pulse {
	animation: sg-promo-pulse 2.2s ease-in-out infinite;
}

@keyframes sg-promo-pulse {
	0%,
	100% {
		transform: scale(1);
	}

	50% {
		transform: scale(1.06);
	}
}

/* ---- Effect: shimmer ---- */

.sg-promo-badge--shimmer::after {
	content: "";
	position: absolute;
	inset: 0;
	background: linear-gradient(
		100deg,
		rgba(255, 255, 255, 0) 30%,
		rgba(255, 255, 255, 0.55) 50%,
		rgba(255, 255, 255, 0) 70%
	);
	transform: translateX(-100%);
	animation: sg-promo-shimmer 2.6s ease-in-out infinite;
	z-index: -1;
}

@keyframes sg-promo-shimmer {
	0% {
		transform: translateX(-100%);
	}

	60%,
	100% {
		transform: translateX(100%);
	}
}

/* ---- Motion is a preference, not a decoration ---- */

@media (prefers-reduced-motion: reduce) {

	.sg-promo-badge--pulse,
	.sg-promo-badge--shimmer::after {
		animation: none;
	}

	.sg-promo-badge--pulse {
		transform: none;
	}
}

/* ---- Small screens: a slightly tighter badge so it never covers the art ---- */

@media (max-width: 480px) {

	.sg-promo-badge--card {
		inset-block-start: 0.5rem;
		inset-inline-start: 0.5rem;
		padding: 0.25em 0.5em;
		font-size: 0.75rem;
	}
}
