/**
 * Storefront spot ticker.
 *
 * Enqueued by Frontend\SpotTickerShortcode only on pages that render a
 * ticker, so these rules never load on a page that has no use for them.
 *
 * The ticker is dropped on arbitrary pages — a homepage, a header block, a
 * sidebar — under a theme we do not control, so the rules here stay
 * deliberately thin: layout, spacing and a de-emphasised timestamp. Colour
 * and type are inherited from the theme rather than asserted, because a
 * ticker that fights its host looks more broken than one that is plain.
 *
 * The one exception is the direction of a move, green or red. A theme sets
 * both on any ancestor, `:root` included:
 *
 *     --gc-spot-ticker-up    (default #007a1f)
 *     --gc-spot-ticker-down  (default #b32d2e)
 *
 * They are read with a fallback and never declared here, so a value a theme
 * puts on `:root` is not shadowed by one on the ticker.
 */

.gc-spot-ticker {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	gap: 8px 18px;
	margin: 0 0 1em;
}

.gc-spot-ticker__label {
	font-weight: 700;
}

.gc-spot-ticker__list {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	gap: 8px 18px;
	list-style: none;
	margin: 0;
	padding: 0;
}

.gc-spot-ticker__item {
	display: flex;
	align-items: baseline;
	gap: 6px;
	margin: 0;
}

.gc-spot-ticker__metal {
	opacity: 0.75;
}

.gc-spot-ticker__price {

	/* Tabular figures so a digit changing on a poll does not reflow the
	   row — the price updates in place, and the line either side of it
	   should not move when it does. */
	font-feature-settings: "tnum";
	font-variant-numeric: tabular-nums;
	font-weight: 700;
	white-space: nowrap;
}

.gc-spot-ticker__price--flash-up {
	animation: gc-spot-ticker-flash-up 1s ease-out;
}

.gc-spot-ticker__price--flash-down {
	animation: gc-spot-ticker-flash-down 1s ease-out;
}

/* Only a `from`: the animation ends on the theme's own colour, so a flash
   cannot leave a price coloured once its class is gone. */
@keyframes gc-spot-ticker-flash-up {

	from {
		color: var(--gc-spot-ticker-up, #007a1f);
	}
}

@keyframes gc-spot-ticker-flash-down {

	from {
		color: var(--gc-spot-ticker-down, #b32d2e);
	}
}

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

	.gc-spot-ticker__price--flash-up,
	.gc-spot-ticker__price--flash-down {
		animation: none;
	}
}

.gc-spot-ticker__change {
	white-space: nowrap;
}

.gc-spot-ticker__change--up {
	color: var(--gc-spot-ticker-up, #007a1f);
}

.gc-spot-ticker__change--down {
	color: var(--gc-spot-ticker-down, #b32d2e);
}

/* The direction word is for screen readers only. Defined here as well as by
   WordPress's own `screen-reader-text`, which not every theme carries. */
.gc-spot-ticker .gc-spot-ticker__change-direction {
	border: 0;
	clip: rect(1px, 1px, 1px, 1px);
	clip-path: inset(50%);
	height: 1px;
	margin: -1px;
	overflow: hidden;
	padding: 0;
	position: absolute;
	width: 1px;
	word-wrap: normal;
}

.gc-spot-ticker__stamp {
	font-size: 0.85em;
	opacity: 0.65;
}

/* On a phone the arrow alone; the amount stays for screen readers. */
@media (max-width: 480px) {

	.gc-spot-ticker .gc-spot-ticker__change-amount {
		border: 0;
		clip: rect(1px, 1px, 1px, 1px);
		clip-path: inset(50%);
		height: 1px;
		margin: -1px;
		overflow: hidden;
		padding: 0;
		position: absolute;
		width: 1px;
		word-wrap: normal;
	}
}

