/**
 * DKM Price - the PriceTag of Diilikaubamaja Design System v2.
 *
 * The whole units carry the tag: they set its height, and everything else is
 * measured against them in ems, so one size variable moves the whole thing and
 * the proportions never drift apart. The cents, the currency and the old price
 * stack in a column beside the figure, aligned to the top of the digits rather
 * than to a baseline - a superscript would sit where the font decided, and the
 * design puts the cents level with the cap height.
 */

.wcg-price {
	/* Diilikaubamaja Design System v2. The shop's own Elementor globals come
	   first, so a kit change carries; the literal is the token's own value. */
	/* Not var(--wcg-accent): that is the gallery's accent, and the
	   settings screen writes every chosen colour onto every one of this
	   plugin's roots - so chaining through it made the gallery's colour
	   the price tag's colour too. */
	--wcg-price-accent: var(--bg-brand);
	--wcg-price-ink: var(--bg-inverse);
	--wcg-price-secondary: var(--action-primary);
	--wcg-price-on-light: var(--text-primary);
	--wcg-price-on-dark: var(--text-inverse);
	--wcg-price-old: var(--text-tertiary);
	--wcg-price-badge-bg: var(--wcg-price-accent);
	--wcg-price-badge-text: var(--text-primary);

	/* The figure, and everything measured off it. */
	--wcg-price-figure: 44px;
	--wcg-price-radius: 14px;
	--wcg-price-pad: 0.28em 0.34em;

	position: relative;
	display: inline-flex;
	align-items: flex-start;
	box-sizing: border-box;
	max-width: 100%;
	margin: 0;
	padding: var(--wcg-price-pad);
	border-radius: var(--wcg-price-radius);
	color: var(--wcg-price-on-light);
	font-size: var(--wcg-price-figure);
	font-weight: 800;
	line-height: 0.9;
	letter-spacing: -0.02em;
	/* The digits have to line up between one tag and the next on a shelf, and
	   between one state of a tag and the next as a variation is chosen. */
	font-variant-numeric: tabular-nums lining-nums;
	font-feature-settings: "tnum" 1, "lnum" 1;
}

/* In a column container (a product card) the default is to stretch every
   child to the card's width, and a tag stretched is a banner. Low weight
   (:where), so a container or the Style tab that wants it wide still wins. */
:where(.wcg-price) {
	align-self: flex-start;
}

/* --------------------------------------------------------------- surfaces */

.wcg-price--accent {
	background: var(--wcg-price-accent);
	color: var(--wcg-price-on-light);
}

.wcg-price--ink {
	background: var(--wcg-price-ink);
	color: var(--wcg-price-on-dark);
}

/* The Visual Identity guidelines' tag: the same ink surface with the figure in
   the brand lime. */
.wcg-price--ink-lime {
	background: var(--wcg-price-ink);
	color: var(--wcg-price-accent);
}

.wcg-price--secondary {
	background: var(--wcg-price-secondary);
	color: var(--wcg-price-on-dark);
}

/* No tag at all - the figure on the page, which is what a product page wants
   where the price is already the largest thing on it. */
.wcg-price--plain {
	padding: 0;
	background: transparent;
	color: var(--wcg-price-on-light);
}

/* ----------------------------------------------------------------- shapes */

.wcg-price--square {
	--wcg-price-radius: 0px;
}

.wcg-price--rounded {
	--wcg-price-radius: 0.32em;
}

/* Squared off at the top left, so the discount can sit into the corner rather
   than on top of it. */
.wcg-price--notch {
	--wcg-price-radius: 0.32em;

	border-top-left-radius: 0;
}

/* ------------------------------------------------------------------ sizes */

.wcg-price--size-sm {
	--wcg-price-figure: 32px;
}

.wcg-price--size-md {
	--wcg-price-figure: 44px;
}

.wcg-price--size-lg {
	--wcg-price-figure: 64px;
}

/* ----------------------------------------------------------------- pieces */

.wcg-price__whole,
.wcg-price__free {
	display: block;
	font-size: 1em;
	line-height: 0.86;
	/* The digits sit on their own optical baseline inside the tag; the tag's
	   padding is what holds them off the edge. */
	padding-top: 0.04em;
}

.wcg-price__free {
	font-size: 0.62em;
	line-height: 1;
	padding-top: 0.12em;
}

/* Cents, currency, old price - one under the other, hard against the figure. */
.wcg-price__column {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	min-width: 0;
	margin-left: 0.06em;
}

.wcg-price__micro {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
}

.wcg-price__prefix {
	display: contents;
}

.wcg-price__cents {
	font-size: 0.42em;
	line-height: 1;
	letter-spacing: 0;
}

.wcg-price__symbol {
	font-size: 0.3em;
	font-weight: 700;
	line-height: 1.1;
	letter-spacing: 0;
}

.wcg-price__symbol--before {
	align-self: flex-start;
	margin-right: 0.08em;
	font-size: 0.42em;
	line-height: 1;
}

/* What it used to cost. Struck through and quieter than everything else, in a
   grey that holds on every one of the four surfaces. */
.wcg-price .wcg-price__old {
	color: var(--wcg-price-old);
	font-size: 0.26em;
	font-weight: 700;
	line-height: 1.2;
	letter-spacing: 0;
	text-decoration: line-through;
	/* Themes reach `del` and give it their own colour and opacity. */
	opacity: 1;
}

/* On the dark surfaces the design system's ink grey would disappear, so the
   old price lightens rather than the tag darkening. */
.wcg-price--ink .wcg-price__old,
.wcg-price--ink-lime .wcg-price__old,
.wcg-price--secondary .wcg-price__old {
	color: rgba(255, 255, 255, 0.62);
}

.wcg-price__from {
	align-self: flex-start;
	margin-right: 0.14em;
	font-size: 0.26em;
	font-weight: 700;
	line-height: 1.4;
	letter-spacing: 0;
	text-transform: lowercase;
}

/* ------------------------------------------------------------------ badge */

/* How much has come off, on the corner. It sits inside the tag's own box so
   nothing around the tag has to make room for it. */
.wcg-price__badge {
	position: absolute;
	top: 0;
	left: 0;
	padding: 0.28em 0.5em;
	border-radius: var(--wcg-price-radius) 0 0.32em 0;
	background: var(--wcg-price-badge-bg);
	color: var(--wcg-price-badge-text);
	font-size: 0.26em;
	font-weight: 800;
	line-height: 1.1;
	letter-spacing: 0;
	white-space: nowrap;
}

/* With the corner squared off, the badge is what rounds it. */
.wcg-price--notch .wcg-price__badge {
	border-radius: 0 0 0.32em 0;
}

/* The figure moves down to make room rather than the badge covering it. */
.wcg-price.has-badge {
	padding-top: 1em;
}

.wcg-price--plain.has-badge {
	padding-top: 0.9em;
	padding-left: 0;
}

/* A lime badge on a lime tag is not a badge. */
.wcg-price--accent .wcg-price__badge {
	background: var(--wcg-price-ink);
	color: var(--wcg-price-accent);
}

.wcg-price__badge:empty {
	display: none;
}

.wcg-price__sale-meta {
	display: contents;
}

.wcg-price__badge[hidden],
.wcg-price__old[hidden] {
	display: none !important;
}

/* The sale layout can supply a mobile badge without changing the desktop tag. */
.wcg-price.has-mobile-badge:not(.has-badge) .wcg-price__badge {
	display: none;
}

/* Announced, not shown: the old price needs saying for a screen reader, which
   would otherwise read two numbers with nothing between them. */
.wcg-price .screen-reader-text {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
	border: 0;
}

/* A tag on a phone is still a tag, but a 64px figure in a product card is not
   a price, it is a headline. */
@media (max-width: 480px) {
	.wcg-price--size-lg {
		--wcg-price-figure: 52px;
	}
}

@media (max-width: 767px) {
	/* Keep the original shelf tag as the default. These are opt-in per widget. */
	.wcg-price--mobile-compact,
	.wcg-price--mobile-stacked,
	.wcg-price--mobile-sale {
		--wcg-price-figure: clamp(32px, 9vw, 40px);
		--wcg-price-pad: 0.16em 0.2em;
	}

	.wcg-price--mobile-compact.wcg-price--plain,
	.wcg-price--mobile-stacked.wcg-price--plain,
	.wcg-price--mobile-sale.wcg-price--plain {
		--wcg-price-pad: 0;
	}

	.wcg-price--mobile-compact .wcg-price__column,
	.wcg-price--mobile-stacked .wcg-price__column,
	.wcg-price--mobile-sale .wcg-price__column {
		margin-left: 0.04em;
	}

	/* One line, including the former price, for tight sticky bars. */
	.wcg-price--mobile-compact {
		align-items: baseline;
		--wcg-price-figure: clamp(29px, 7.8vw, 36px);
	}

	.wcg-price--mobile-compact .wcg-price__column {
		flex-direction: row;
		align-items: baseline;
		gap: 0.09em;
		white-space: nowrap;
	}

	.wcg-price--mobile-compact .wcg-price__micro {
		flex-direction: row;
		align-items: baseline;
		gap: 0.09em;
	}

	.wcg-price--mobile-compact .wcg-price__cents {
		font-size: 0.6em;
	}

	.wcg-price--mobile-compact .wcg-price__cents::before {
		content: attr(data-wcg-price-separator);
	}

	.wcg-price--mobile-compact .wcg-price__symbol {
		font-size: 0.34em;
	}

	.wcg-price--mobile-compact .wcg-price__old {
		font-size: 0.34em;
	}

	.wcg-price--mobile-stacked.is-on-sale {
		padding-bottom: 0.62em;
	}

	.wcg-price--mobile-stacked.is-on-sale .wcg-price__old {
		position: absolute;
		bottom: 0.2em;
		left: 0.75em;
		font-size: 0.32em;
	}

	.wcg-price--mobile-stacked.wcg-price--plain.is-on-sale .wcg-price__old {
		left: 0;
	}

	/* Keep the former price and discount together below the current price. */
	.wcg-price.wcg-price--mobile-sale {
		display: inline-grid;
		grid-template-columns: max-content max-content max-content;
		column-gap: 0.08em;
		row-gap: 0.08em;
		align-items: start;
		padding: var(--wcg-price-pad);
	}

	.wcg-price--mobile-sale .wcg-price__prefix {
		display: flex;
		grid-column: 1;
		grid-row: 1;
	}

	.wcg-price--mobile-sale .wcg-price__whole {
		grid-column: 2;
		grid-row: 1;
	}

	.wcg-price--mobile-sale .wcg-price__column {
		display: contents;
	}

	.wcg-price--mobile-sale .wcg-price__micro {
		grid-column: 3;
		grid-row: 1;
	}

	.wcg-price--mobile-sale .wcg-price__sale-meta {
		display: flex;
		grid-column: 1 / -1;
		grid-row: 2;
		align-items: baseline;
		gap: 0.1em;
	}

	.wcg-price.wcg-price--mobile-sale.has-mobile-badge .wcg-price__badge {
		display: block;
		position: static;
		padding: 0;
		border-radius: 0;
		background: none;
		color: inherit;
		font-size: 0.32em;
		line-height: 1.2;
	}

	.wcg-price.wcg-price--mobile-sale .wcg-price__old {
		position: static;
		font-size: 0.32em;
		line-height: 1.2;
	}
}
