/**
 * DKM Stock Status
 *
 * One line, five states. The colour is the state's; everything else - the
 * size, the weight, the spacing - is the Style tab's, because this is a line
 * of text on somebody's product page and it should read like the rest of it.
 */

.wcg-stock {
	/* Diilikaubamaja Design System v2. Green 500 and amber 500 fail AA as
	   text on white (4.44:1, 2.75:1), so the words take the darker 700 steps
	   and the dot keeps the bright one - a saturated step is a surface, not
	   text. */
	--wcg-stock-in: var(--text-success);
	--wcg-stock-last: var(--text-warning);
	--wcg-stock-low: var(--text-warning);
	--wcg-stock-in-dot: var(--mark-success);
	--wcg-stock-warn-dot: var(--mark-warning);
	--wcg-stock-out: var(--text-danger);
	--wcg-stock-backorder: var(--text-tertiary);
	--wcg-stock-dot: 8px;

	display: block;
	min-width: 0;

	/* No spacing of our own: margin and padding are the Style tab's job. */
	margin: 0;
	padding: 0;
}

.wcg-stock__line {
	display: inline-flex;
	align-items: baseline;
	gap: 8px;
}

.wcg-stock__dot {
	position: relative;
	top: -1px;
	width: var(--wcg-stock-dot);
	height: var(--wcg-stock-dot);
	flex: none;
	border-radius: 50%;
	background: currentColor;
}

/* The text carries the state's colour, so the dot - which is currentColor -
   comes along without being told twice, except where the text had to go a
   step darker than the state's own colour to stay readable. */
.wcg-stock.is-in .wcg-stock__line {
	color: var(--wcg-stock-in);
}

.wcg-stock.is-last .wcg-stock__line {
	color: var(--wcg-stock-last);
}

.wcg-stock.is-low .wcg-stock__line {
	color: var(--wcg-stock-low);
}

.wcg-stock.is-out .wcg-stock__line {
	color: var(--wcg-stock-out);
}

.wcg-stock.is-backorder .wcg-stock__line {
	color: var(--wcg-stock-backorder);
}

.wcg-stock.is-in .wcg-stock__dot {
	background: var(--wcg-stock-in-dot);
}

.wcg-stock:is(.is-last, .is-low) .wcg-stock__dot {
	background: var(--wcg-stock-warn-dot);
}

/* Nothing to say for this state: the element takes no room rather than
   leaving a gap where a line would have been. */
.wcg-stock__inner:empty {
	display: none;
}

.wcg-stock--loading .wcg-stock__inner::before {
	content: "";
	display: inline-block;
	width: 8em;
	height: 1em;
	border-radius: var(--radius-full);
	background: repeating-linear-gradient(135deg, var(--bg-subtle), var(--bg-subtle) 12px, var(--bg-press) 12px, var(--bg-press) 24px);
}

/* The chip: the line on a pill tinted by the state, as wide as its words. */
.wcg-stock--chip .wcg-stock__line {
	align-items: center;
	padding: 4px 12px;
	border-radius: var(--radius-full);
	font-size: 0.92em;
}

.wcg-stock--chip.is-in .wcg-stock__line {
	background: var(--bg-success);
}

.wcg-stock--chip:is(.is-last, .is-low) .wcg-stock__line {
	background: var(--bg-warning);
}

.wcg-stock--chip.is-out .wcg-stock__line {
	background: var(--bg-danger);
}

.wcg-stock--chip.is-backorder .wcg-stock__line {
	background: var(--bg-subtle);
}
