/**
 * Storefront styles.
 *
 * WHY THIS FILE EXISTS
 * --------------------
 * Every customer-facing surface used to be built from inline style attributes carrying fourteen
 * hard-coded hex values: a burnt orange on cream. A shop with a blue brand installed this and got
 * orange widgets on its own storefront, with no way to change them short of editing the plugin.
 * There were sixty-seven inline style attributes and not one enqueued stylesheet.
 *
 * So: one stylesheet, everything driven by custom properties, and the accent is a setting the
 * merchant picks. It should look considered on a shop that never opens the settings, and look like
 * theirs the moment they do.
 *
 * THEMING
 * -------
 * Every colour is a token on .fjl. A theme or child theme overrides any of them with ordinary CSS
 * and no !important, because nothing here is more specific than a single class. The accent comes
 * through as an inline custom property on the wrapper, which is the one thing that has to be
 * dynamic, and it is a property rather than a rule so it cannot fight a theme's own styles.
 *
 * Dark mode follows the visitor's system setting. A shop that wants to opt out sets the tokens
 * itself.
 *
 * @package FactoryJet_Loyalty
 */

.fjl {
	/*
	 * THE COLOUR STRATEGY, AND WHY IT IS NOT DARK MODE.
	 *
	 * The first version of this file carried a full light palette plus a prefers-color-scheme block
	 * that swapped in a dark one. On a light theme viewed by somebody whose system is set to dark,
	 * that produced near-black cards sitting on a white page: the widget followed the visitor's
	 * operating system while the shop around it did not. Half the layout went dark and half stayed
	 * light, on the same screen, in the same viewport.
	 *
	 * An embedded widget has no business having an opinion about that. It is a guest on somebody
	 * else's page. So nothing here sets an ink colour or a page ground at all: text inherits, and
	 * every surface and rule is mixed from currentColor, which means the component takes the theme's
	 * own foreground whatever it happens to be. A dark theme gets subtle light-on-dark panels and a
	 * light theme gets subtle dark-on-light ones, from one set of rules, with no media query and no
	 * guessing.
	 *
	 * The accent is the single exception, because that is the merchant's brand and is meant to
	 * stand out. Text on the accent is picked for contrast in PHP, not here.
	 */

	/* Surfaces, mixed from whatever the theme's text colour is. */
	--fjl-raised: color-mix( in srgb, currentColor 4%, transparent );
	--fjl-line: color-mix( in srgb, currentColor 15%, transparent );
	--fjl-line-soft: color-mix( in srgb, currentColor 8%, transparent );
	--fjl-ink-soft: color-mix( in srgb, currentColor 78%, transparent );
	--fjl-ink-faint: color-mix( in srgb, currentColor 60%, transparent );

	/* Overridden inline from the merchant's chosen accent. */
	--fjl-accent: #b45309;
	--fjl-accent-ink: #ffffff;
	--fjl-accent-wash: color-mix( in srgb, var( --fjl-accent ) 9%, transparent );
	--fjl-accent-edge: color-mix( in srgb, var( --fjl-accent ) 32%, transparent );

	/* Semantic colours are stated rather than mixed, because a plus and a minus on a money figure
	   have to stay legible and distinguishable on either ground. */
	--fjl-positive: #15803d;
	--fjl-negative: #b91c1c;

	--fjl-radius: 12px;
	--fjl-radius-sm: 8px;
	--fjl-gap: 20px;

	font-size: 16px;
	line-height: 1.55;
	container-type: inline-size;
}

/* On a dark ground the two semantic colours need lifting, and this is the one thing worth a media
   query: it asks about the ground the component is actually sitting on rather than about the
   visitor's operating system. */
@supports ( color: color-mix( in srgb, currentColor 50%, transparent ) ) {
	@media ( prefers-color-scheme: dark ) {
		.fjl {
			--fjl-positive: #4ade80;
			--fjl-negative: #fca5a5;
		}
	}
}

.fjl *,
.fjl *::before,
.fjl *::after {
	box-sizing: border-box;
}

/* ---------------------------------------------------------------- layout */

.fjl-stack {
	display: grid;
	gap: var( --fjl-gap );
}

.fjl-cards {
	display: grid;
	gap: var( --fjl-gap );
	grid-template-columns: 1fr;
}

@container ( min-width: 640px ) {
	.fjl-cards {
		grid-template-columns: 1fr 1fr;
	}
}

.fjl-card {
	background: var( --fjl-raised );
	border: 1px solid var( --fjl-line );
	border-radius: var( --fjl-radius );
	padding: 22px;
}

.fjl-card--feature {
	background: var( --fjl-accent-wash );
	border-color: var( --fjl-accent-edge );
}

/* ------------------------------------------------------------ typography */

.fjl-label {
	display: block;
	margin: 0 0 6px;
	font-size: 12px;
	font-weight: 600;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	color: var( --fjl-ink-faint );
}

.fjl-figure {
	display: block;
	margin: 0;
	font-size: clamp( 34px, 8cqw, 46px );
	font-weight: 700;
	line-height: 1.05;
	letter-spacing: -0.02em;
	font-variant-numeric: tabular-nums;
}

.fjl-figure__unit {
	font-size: 0.45em;
	font-weight: 600;
	letter-spacing: 0;
	color: var( --fjl-ink-faint );
}

.fjl-sub {
	margin: 6px 0 0;
	font-size: 14px;
	color: var( --fjl-ink-soft );
}

.fjl h2,
.fjl h3 {
	margin: 0 0 4px;
	line-height: 1.25;
	text-wrap: balance;
}

.fjl h2 {
	font-size: 20px;
	font-weight: 650;
}

.fjl h3 {
	font-size: 16px;
	font-weight: 600;
}

/* ----------------------------------------------------------------- tiers */

.fjl-tier {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 5px 12px 5px 8px;
	border-radius: 999px;
	background: var( --fjl-accent );
	color: var( --fjl-accent-ink );
	font-size: 13px;
	font-weight: 650;
	line-height: 1.3;
}

.fjl-tier__mark {
	font-size: 15px;
	line-height: 1;
}

.fjl-progress {
	margin-top: 14px;
}

.fjl-progress__track {
	/* Explicit, so this cannot break if the markup around it ever stops blockifying its children. */
	display: block;
	height: 8px;
	border-radius: 999px;
	background: var( --fjl-line );
	overflow: hidden;
}

.fjl-progress__fill {
	display: block;
	height: 100%;
	border-radius: 999px;
	background: var( --fjl-accent );
	transition: width 0.5s cubic-bezier( 0.22, 1, 0.36, 1 );
}

@media ( prefers-reduced-motion: reduce ) {
	.fjl-progress__fill {
		transition: none;
	}
}

.fjl-progress__caption {
	margin: 8px 0 0;
	font-size: 13px;
	color: var( --fjl-ink-soft );
}

/* --------------------------------------------------------------- ladder */

.fjl-ladder {
	display: grid;
	gap: 10px;
	margin: 0;
	padding: 0;
	list-style: none;
}

.fjl-rung {
	display: grid;
	grid-template-columns: auto 1fr auto;
	align-items: center;
	gap: 12px;
	padding: 12px 14px;
	border: 1px solid var( --fjl-line );
	border-radius: var( --fjl-radius-sm );
	background: var( --fjl-raised );
}

.fjl-rung[data-current="yes"] {
	border-color: var( --fjl-accent );
	background: var( --fjl-accent-wash );
}

.fjl-rung__mark {
	font-size: 20px;
	line-height: 1;
}

.fjl-rung__name {
	font-weight: 600;
}

.fjl-rung__need {
	display: block;
	font-size: 13px;
	color: var( --fjl-ink-faint );
}

.fjl-rung__rate {
	font-weight: 650;
	color: var( --fjl-accent );
	font-variant-numeric: tabular-nums;
	white-space: nowrap;
}

/* -------------------------------------------------------------- history */

.fjl-history-wrap {
	overflow-x: auto;
	border: 1px solid var( --fjl-line );
	border-radius: var( --fjl-radius-sm );
}

.fjl-history {
	width: 100%;
	min-width: 420px;
	border-collapse: collapse;
	font-size: 14px;
}

.fjl-history th {
	padding: 11px 14px;
	text-align: left;
	font-size: 11px;
	font-weight: 600;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	color: var( --fjl-ink-faint );
	background: var( --fjl-raised );
	border-bottom: 1px solid var( --fjl-line );
	white-space: nowrap;
}

.fjl-history td {
	padding: 12px 14px;
	border-bottom: 1px solid var( --fjl-line-soft );
	vertical-align: top;
}

.fjl-history tr:last-child td {
	border-bottom: 0;
}

.fjl-history__when {
	color: var( --fjl-ink-faint );
	white-space: nowrap;
}

.fjl-history__points {
	font-weight: 650;
	text-align: right;
	font-variant-numeric: tabular-nums;
	white-space: nowrap;
}

.fjl-history__points[data-sign="up"] {
	color: var( --fjl-positive );
}

.fjl-history__points[data-sign="down"] {
	color: var( --fjl-negative );
}

/* ------------------------------------------------------------- checkout */

.fjl-redeem {
	border: 1px solid var( --fjl-line );
	border-radius: var( --fjl-radius-sm );
	background: var( --fjl-raised );
	padding: 16px;
	margin: 0 0 18px;
}

.fjl-redeem__head {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	justify-content: space-between;
	gap: 8px;
	margin-bottom: 12px;
}

.fjl-redeem__balance {
	font-weight: 650;
	font-variant-numeric: tabular-nums;
}

.fjl-redeem__controls {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}

.fjl-input {
	flex: 1 1 120px;
	min-width: 0;
	padding: 9px 12px;
	font: inherit;
	font-size: 15px;
	color: inherit;
	background: transparent;
	border: 1px solid var( --fjl-line );
	border-radius: var( --fjl-radius-sm );
}

.fjl-input:focus-visible,
.fjl-btn:focus-visible {
	outline: 2px solid var( --fjl-accent );
	outline-offset: 2px;
}

.fjl-btn {
	flex: 0 0 auto;
	padding: 9px 18px;
	font: inherit;
	font-size: 15px;
	font-weight: 600;
	color: var( --fjl-accent-ink );
	background: var( --fjl-accent );
	border: 1px solid transparent;
	border-radius: var( --fjl-radius-sm );
	cursor: pointer;
}

.fjl-btn:hover {
	filter: brightness( 0.92 );
}

.fjl-btn[disabled] {
	opacity: 0.55;
	cursor: default;
	filter: none;
}

.fjl-btn--quiet {
	color: inherit;
	background: transparent;
	border-color: var( --fjl-line );
}

.fjl-applied {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
}

.fjl-applied__text {
	font-weight: 600;
	color: var( --fjl-positive );
}

.fjl-note {
	margin: 10px 0 0;
	font-size: 13px;
	color: var( --fjl-ink-faint );
}

.fjl-error {
	margin: 10px 0 0;
	font-size: 13px;
	color: var( --fjl-negative );
	font-weight: 500;
}

/* --------------------------------------------------------------- states */

.fjl-empty {
	padding: 28px 22px;
	text-align: center;
	color: var( --fjl-ink-soft );
	background: var( --fjl-raised );
	border: 1px dashed var( --fjl-line );
	border-radius: var( --fjl-radius-sm );
}

.fjl-empty h3 {
	margin-bottom: 6px;
}

/* Screen-reader-only, for the live regions that announce a redemption. */
.fjl-sr {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect( 0, 0, 0, 0 );
	white-space: nowrap;
	border: 0;
}
