/**
 * WooCommerce checkout styles: the checkout page only (and its order-pay and
 * order-received endpoints, which share it). Split out of woocommerce.scss so
 * shop, product and cart pages don't load them; loaded after that sheet by
 * Performance::enqueue_woocommerce() when is_checkout(). Sections shared with
 * the cart (step strip, delivery cards and band, editable review, select2)
 * stay in woocommerce.scss.
 */

/* stylelint-disable selector-id-pattern -- WooCommerce's own IDs
   (`#order_review`, `#customer_details`, `#payment`, field IDs). */

/* Distraction-free checkout: hide the site chrome so the form stands alone. */
body.aureon-checkout-lean .aureon-header,
body.aureon-checkout-lean .aureon-footer {
	display: none;
}

/* Labels-as-placeholders checkout: float each field label into its input.
 *
 * WooCommerce renders the `<label>` *before* the input wrapper, so the label
 * can never be selected from the input — the relationship has to be read from
 * the row instead, with `:has()`. Cart_Checkout::float_label_placeholder()
 * gives every field a blank placeholder so `:placeholder-shown` has something
 * to test; without it a field with no placeholder would never lift its label. */

/* `form.checkout` and not any `form`: the coupon box is its own little form
 * sitting above this one, and its label is WooCommerce's "Coupon:" — a string
 * written to sit beside a field, colon and all, which reads as a mistake once
 * it is resting inside one. It keeps its own placeholder. */
body.aureon-checkout-float .woocommerce form.checkout .form-row {
	// The field's metrics, stated once so the label and the input can agree on
	// where the value line is. The padding is top-heavy because that is where
	// the lifted label goes; the *resting* label ignores it and centres in the
	// field instead, which is the difference between an empty field that reads
	// as a placeholder and one that reads as a gap with text under it.
	--aureon-float-pad-top: 1.35em;
	--aureon-float-pad-bottom: 0.35em;
	--aureon-float-inset: 0.9em;
	--aureon-float-line: 1.3;
	// How far the label rises. The field's content is 3em tall (1.35 + 1.3 +
	// 0.35), so a centred label's top edge sits at 0.85em; 0.55em up from
	// there lands it at 0.3em, clear of the value that takes its place.
	--aureon-float-lift: 0.55em;

	position: relative;
	// WooCommerce pads the row itself, which would offset every absolute
	// measurement below by 3px. The row is only a positioning context here.
	padding: 0;

	> label {
		position: absolute;
		z-index: 1;
		// Centred on the field, not placed against the top padding: at rest
		// this label *is* the placeholder, and a placeholder sits on the value
		// line. The top-heavy padding below is only where the value goes once
		// the label has moved out of its way.
		top: 50%;
		inset-inline-start: var(--aureon-float-inset);
		margin: 0;
		font-size: 1em;
		line-height: var(--aureon-float-line);
		color: var(--aureon-color-text-muted, var(--aureon-color-text));
		pointer-events: none;
		transform: translateY(-50%);
		// Scaled rather than re-sized: `font-size` would change what `em`
		// means mid-transition and drag the offset along with it. The origin
		// is the top-left so the label shrinks *towards* where it is going,
		// keeping its leading edge on the field's inset throughout.
		transform-origin: 0 0;
		transition: transform 0.15s ease, color 0.15s ease;
	}

	// The abbr marks required fields — keep it out of the floated label flow.
	> label abbr {
		border: 0;
		text-decoration: none;
	}

	// Address line 2 is the one field WooCommerce labels for screen readers
	// only. Left hidden it is the single row on the page with nothing in its
	// label position, which reads as a field the form forgot to name.
	> label.screen-reader-text {
		position: absolute;
		width: auto;
		height: auto;
		overflow: visible;
		clip: auto;
		clip-path: none;
		white-space: nowrap;
	}

	input.input-text,
	textarea,
	select,
	.select2-container--default .select2-selection--single {
		padding-top: var(--aureon-float-pad-top);
		padding-bottom: var(--aureon-float-pad-bottom);
		line-height: var(--aureon-float-line);
	}

	// WooCommerce's own placeholders ("House number and street name") are
	// hints, not names — shown behind a resting label they simply double up,
	// so they wait until the label has lifted out of the value line.
	input.input-text::placeholder,
	textarea::placeholder {
		color: transparent;
		transition: color 0.15s ease;
	}

	input.input-text:focus::placeholder,
	textarea:focus::placeholder {
		color: var(--aureon-color-text-muted, var(--aureon-color-text));
	}

	// A select (or Select2) has no placeholder state, so its label stays lifted.
	&:has(select) > label,
	&:has(.select2-container) > label,
	&:has(input.input-text:focus) > label,
	&:has(textarea:focus) > label,
	&:has(input.input-text:not(:placeholder-shown)) > label,
	&:has(textarea:not(:placeholder-shown)) > label {
		transform: translateY(calc(-50% - var(--aureon-float-lift))) scale(0.75);
		color: var(--aureon-color-text-muted, var(--aureon-color-text));
	}

	// A textarea is several lines tall, so "the value line" is its first one,
	// not its middle — a centred label there floats in the middle of an empty
	// box. Stated after the rules above so it wins the tie on source order.
	&:has(textarea) > label {
		top: calc(var(--aureon-float-pad-top) + 1px);
		transform: none;
	}

	&:has(textarea:focus) > label,
	&:has(textarea:not(:placeholder-shown)) > label {
		// From the first line up to the same 0.3em the inputs' labels reach.
		transform: translateY(calc(0.3em - var(--aureon-float-pad-top))) scale(0.75);
	}

	&:has(input.input-text:focus) > label,
	&:has(textarea:focus) > label,
	&:has(select:focus) > label {
		color: var(--aureon-color-link);
	}
}

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

	body.aureon-checkout-float .woocommerce form.checkout .form-row > label,
	body.aureon-checkout-float .woocommerce form.checkout .form-row input.input-text::placeholder,
	body.aureon-checkout-float .woocommerce form.checkout .form-row textarea::placeholder {
		transition: none;
	}
}

/* -------------------------------------------------------------------------
 * Checkout totals (classic edition)
 *
 * The foot of the review table — subtotal, discount, fees, tax, shipping, then
 * the grand total. Read as a receipt rather than a table: the components are
 * separated by air instead of hairlines, and the single rule in the block is
 * the one above the total, closing the list off from the figure it adds up to.
 *
 * The label is the quiet half of each row and the amount the loud one — the
 * customer scans the column of figures and only reads across when one of them
 * surprises them. Line items in the body above keep their dividers: those are
 * a list of things, and this is an arithmetic.
 * ---------------------------------------------------------------------- */

.woocommerce-checkout .woocommerce table.woocommerce-checkout-review-order-table tfoot {
	padding-top: var(--aureon-space-xs, 0.5rem);

	tr {
		align-items: center;
		padding: 0.45em 0;
		border-bottom: 0;
	}

	th {
		font-weight: 400;
		color: var(--aureon-color-text-muted, var(--aureon-color-text));
	}

	// A step above the label rather than a token: the scale jumps from 1rem to
	// 1.25rem, which at this density reads as a heading sitting in the middle of
	// an arithmetic. The figures only need to out-weigh the words beside them.
	td {
		font-size: 1.125rem;
		font-weight: 600;
		line-height: 1.3;
		color: var(--aureon-color-heading, var(--aureon-color-text));
	}

	// A cell holding the rate list or the calculator is a block of controls, not
	// a figure, so it keeps the row's own type rather than the amount's.
	tr:has(ul, form) td {
		font-size: inherit;
		font-weight: 400;
		line-height: inherit;
		color: var(--aureon-color-text);
	}

	tr.order-total {
		margin-top: 0.5em;
		padding-top: 1em;
		padding-bottom: 0;

		// The word "Total" stays the size of the labels above it — it is the
		// figure that has grown, not the name of it.
		th {
			font-size: inherit;
			font-weight: 700;
			color: var(--aureon-color-heading, var(--aureon-color-text));
		}

		td {
			font-size: var(--aureon-font-size-lg, 1.25rem);
			font-weight: 700;
		}
	}
}

/* -------------------------------------------------------------------------
 * Checkout review line items
 *
 * Classic only — the theme's `checkout/review-order.php` gives the product
 * cell a media shape (thumbnail beside a body carrying the name, quantity and
 * item data). The block checkout already renders its summary rows with a
 * picture, so it needs nothing here beyond the size below.
 *
 * The thumbnail is deliberately smaller than the cart's: this is a receipt the
 * customer is confirming, not a list they are still editing, so the picture is
 * an identifier rather than the subject of the row.
 * ---------------------------------------------------------------------- */

.woocommerce-checkout-review-order-table td.product-name {
	display: flex;
	align-items: flex-start;
	gap: var(--aureon-space-sm);
}

.aureon-review-item__media {
	flex: none;
	width: var(--aureon-review-thumb);

	img {
		display: block;
		width: 100%;
		height: auto;
		aspect-ratio: 1;
		object-fit: cover;
		border: 1px solid var(--aureon-color-border);
		border-radius: var(--aureon-radius-md, 6px);
	}
}

/* `min-width: 0` so a long unbroken product name wraps inside the column
 * instead of forcing the summary card wider than its track. */
.aureon-review-item__body {
	display: block;
	min-width: 0;
	flex: 1 1 auto;
}

.aureon-review-item__name {
	color: var(--aureon-color-heading, var(--aureon-color-text));
	font-weight: 600;

	a {
		color: inherit;
		text-decoration: none;

		&:hover {
			color: var(--aureon-color-link);
		}
	}
}

/* The quantity is whatever `woocommerce_checkout_cart_item_quantity` returned,
 * so it is styled by class rather than by position — a gateway that filters it
 * into a different element keeps the placement, and loses only the colour. */
.aureon-review-item__body .product-quantity {
	display: block;
	margin-top: 0.15em;
	font-size: var(--aureon-font-size-sm);
	font-weight: 400;
	color: var(--aureon-color-text-muted, var(--aureon-color-text));
}

/* `wc_get_formatted_cart_item_data()` prints the same `dl.variation` the cart
 * rows use — read here as "Sienna │ Large", the values divided by a hairline,
 * with the labels kept for screen readers only. */
.aureon-review-item__body dl.variation {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0 0.75em;
	margin: 0.15em 0 0;
	font-size: var(--aureon-font-size-sm);
	color: var(--aureon-color-text-muted, var(--aureon-color-text));

	dt {
		position: absolute;
		overflow: hidden;
		clip-path: inset(50%);
		width: 1px;
		height: 1px;
		white-space: nowrap;
	}

	dd {
		display: flex;
		align-items: center;
		gap: 0.75em;
		margin: 0;
	}

	dd p {
		margin: 0;
	}

	// `dd:not(:first-of-type)` rather than `dd + dd` — the hidden `dt` sits
	// between them in the DOM, so the adjacent-sibling combinator never matches.
	dd:not(:first-of-type)::before {
		content: "";
		width: 1px;
		height: 1em;
		background: var(--aureon-color-border);
	}
}

/* -------------------------------------------------------------------------
 * Stepped checkout
 *
 * `Cart_Checkout::stepped()` splits the form in two; the step on screen is
 * `data-aureon-step` on the body, and these rules are the whole of what each
 * step shows. Nothing here runs until both the body class and the attribute
 * are present, so a checkout without JavaScript keeps every field on the page.
 *
 * The cut is made differently in each edition, because the two put the payment
 * methods in different places. The classic template renders them inside
 * `#order_review`, so cart-checkout.js moves them into a container of the
 * theme's own after each render and these rules hide that container. The block
 * checkout needs no moving at all — its bands are already separate blocks, in
 * the order the steps want them — so there the split is only ever a question
 * of which of those blocks the step shows.
 * ---------------------------------------------------------------------- */

body.aureon-checkout-stepped {

	// Every rule here keys off `data-aureon-step`, which cart-checkout.js sets
	// only once it has the payment methods in hand — so a checkout whose
	// JavaScript never ran keeps them in the summary, heading and all, and is
	// simply the single-page checkout it was before.
	&[data-aureon-step] .aureon-payment-heading {
		display: none;
	}

	&[data-aureon-step="details"] {

		.aureon-payment {
			display: none;
		}

		// Block: the three bands that belong to the step after this one. The
		// terms box and the place-order button travel with the payment
		// methods — a customer agreeing to terms and paying is one step.
		.wp-block-woocommerce-checkout-payment-block,
		.wp-block-woocommerce-checkout-terms-block,
		.wp-block-woocommerce-checkout-actions-block {
			display: none;
		}
	}

	&[data-aureon-step="payment"] {

		#customer_details > .col-1,
		#customer_details > .col-2,
		.aureon-delivery {
			display: none;
		}

		/* Block: everything *except* those three. Stated as an exclusion
		 * rather than as a list of the details bands so that a band this
		 * theme has never heard of — an extension's, or one a WooCommerce
		 * release adds — lands on the details step, which is the safe side to
		 * fall on: a field the customer cannot reach is a checkout they
		 * cannot finish.
		 *
		 * Narrowed to elements carrying a `wp-block-woocommerce-checkout-*`
		 * class so it only ever reaches WooCommerce's own bands. The form's
		 * first child is an unclassed store-notices container, and hiding
		 * that would swallow the error a failed payment reports. */
		.wc-block-checkout__form > [class*="wp-block-woocommerce-checkout-"]:not(.wp-block-woocommerce-checkout-payment-block, .wp-block-woocommerce-checkout-terms-block, .wp-block-woocommerce-checkout-actions-block) {
			display: none;
		}
	}

	// The strip's two in-page steps are buttons now, so they have to be
	// stripped back to the text the other two are.
	.aureon-checkout-steps__link {
		padding: 0;
		border: 0;
		background: none;
		font: inherit;
		color: inherit;
	}

	.aureon-checkout-steps__item:not(.is-current) .aureon-checkout-steps__link {
		cursor: pointer;
	}
}

.aureon-checkout-nav {
	display: flex;
	flex-direction: column;
	gap: var(--aureon-space-sm);
	align-items: stretch;
	margin-top: var(--aureon-space-lg);
}

/* "Continue to payment" is the one thing to do on the details step, so it is
 * drawn the way the place-order button on the next step is — the same control
 * one step earlier. */
.aureon-checkout-nav__next {
	padding: 0.9em 1.5em;
	border: 0;
	border-radius: var(--aureon-radius-sm, 4px);
	background: var(--aureon-color-heading, var(--aureon-color-text));
	font: inherit;
	font-weight: 600;
	color: var(--aureon-color-background);
	cursor: pointer;
	transition: opacity 0.15s ease;

	&:hover {
		opacity: 0.88;
	}
}

/* Going back is a correction, not a step in the flow — a quiet link under the
 * button that pays, not a second thing competing with it. The cart link is the
 * same control one step further back, so it is drawn the same way; only its
 * element differs, because that step is a page rather than a band of this
 * form. */
.aureon-checkout-nav__back {
	align-self: center;
	padding: 0.35em;
	border: 0;
	background: none;
	font: inherit;
	font-size: var(--aureon-font-size-sm);
	color: var(--aureon-color-text-muted, var(--aureon-color-text));
	text-decoration: none;
	cursor: pointer;

	&:hover {
		color: var(--aureon-color-link);
		text-decoration: underline;
	}
}

/* One back control per step: the cart on the first, the details band on the
 * second — never both, which would read as two different ways out. */
body.aureon-checkout-stepped[data-aureon-step="details"] .aureon-checkout-nav__back[data-aureon-step-back],
body.aureon-checkout-stepped[data-aureon-step="payment"] .aureon-checkout-nav__back--cart,
body.aureon-checkout-stepped[data-aureon-step="payment"] .aureon-checkout-nav__next {
	display: none;
}

/* -------------------------------------------------------------------------
 * Checkout form
 * ---------------------------------------------------------------------- */

.woocommerce-checkout .woocommerce form .form-row {
	margin-bottom: var(--aureon-checkout-gap);
}

/* Block edition. Same setting, two measurements instead of one — the gap
 * between fields inside a band, and the gap between the bands themselves —
 * because that is how WooCommerce's own components are spaced. Both tokens are
 * derived from `--aureon-checkout-gap` where they're declared, so the setting is
 * still the one number behind all of it.
 *
 * The extra `.woocommerce-checkout` step is there for specificity, not for
 * scope — the form selector is already checkout-only. Core's own per-field
 * rules name two classes each, and these have to carry past them. */
.woocommerce-checkout .wc-block-checkout__form .wc-block-components-text-input,
.woocommerce-checkout .wc-block-checkout__form .wc-block-components-country-input,
.woocommerce-checkout .wc-block-checkout__form .wc-block-components-state-input,
.woocommerce-checkout .wc-block-checkout__form .wc-block-components-checkbox,
.woocommerce-checkout .wc-block-checkout__form .wc-blocks-components-select {
	margin-top: var(--aureon-checkout-field-gap);
}

.woocommerce-checkout .wc-block-checkout__form .wc-block-components-checkout-step {
	margin-bottom: var(--aureon-checkout-step-gap);
}

/* The first field of a band sits directly under that band's heading and takes
 * no gap at all — core says so in a long list of `:first-child` selectors, and
 * this says it once over the whole address form, which is what that list adds
 * up to.
 *
 * Restated rather than left to core because only some of that list
 * out-specifies the rules above: the country select's zero in particular names
 * exactly as many classes as they do, and a tie is settled by stylesheet load
 * order, which is not a thing to leave a checkout's spacing resting on. */
.woocommerce-checkout .wc-block-checkout__form .wc-block-components-address-form > :first-child,
.woocommerce-checkout .wc-block-checkout__form .wc-block-components-address-form__country .wc-blocks-components-select {
	margin-top: 0;
}

/* -------------------------------------------------------------------------
 * Section headings
 *
 * WooCommerce already titles each band of the checkout — "Billing details",
 * "Ship to a different address?", "Additional information", "Your order", and
 * the theme's own "Payment" — but leaves them at whatever size the theme's
 * `h3` happens to be, which reads as five unrelated headings down one column.
 * Stated once at a common size and weight, they become one set of section
 * labels, and a long form reads as a short sequence of named steps.
 * ---------------------------------------------------------------------- */

.aureon-checkout-section-title,
.woocommerce-checkout #customer_details h3,
#order_review_heading {
	margin: 0 0 var(--aureon-space-md);
	font-size: var(--aureon-font-size-lg);
	font-weight: 600;
	line-height: 1.3;
	color: var(--aureon-color-heading, var(--aureon-color-text));
}

/* The rule belongs to the band, not the heading, so it spans the column even
 * where a section's heading is conditional (WooCommerce omits the "Additional
 * information" title whenever shipping fields are on screen).
 *
 * `:has()` is doing real work here: both wrappers are printed unconditionally,
 * so a store that ships to the billing address only — or has order notes
 * switched off — would otherwise get a hairline across an empty div. */
.woocommerce-checkout .woocommerce-shipping-fields:has(h3),
.woocommerce-checkout .woocommerce-additional-fields:has(.form-row) {
	padding-top: var(--aureon-space-lg);
	margin-top: var(--aureon-space-lg);
	border-top: 1px solid var(--aureon-color-border);
}

/* "Ship to a different address?" is a heading wrapping a checkbox, so it needs
 * to sit on one line with its control rather than inherit the block layout the
 * other section titles use. */
.woocommerce-checkout h3#ship-to-different-address label {
	display: flex;
	align-items: center;
	gap: 0.5em;
	margin: 0;
	font-weight: inherit;
	cursor: pointer;

	input[type="checkbox"] {
		flex: none;
		// Sized in `em` against the heading, for the same reason the payment
		// radios are: left at the browser's 13px default it reads as an
		// afterthought beside 16px text, and the two controls the checkout asks
		// the customer to tick are then visibly different sizes.
		inline-size: 1.1em;
		block-size: 1.1em;
		margin: 0;
		accent-color: var(--aureon-color-primary);
	}
}

/* Payment sits inside the order-summary card, under the totals, so its heading
 * carries its own divider rather than the band rule above. */
.aureon-payment-heading {
	padding-top: var(--aureon-space-md);
	margin-top: var(--aureon-space-md);
	border-top: 1px solid var(--aureon-color-border);
}

/* -------------------------------------------------------------------------
 * Address field grid
 *
 * WooCommerce lays the checkout fields out with floats: `form-row-first` and
 * `form-row-last` at 47% each, and everything else — country, both address
 * lines, city, state, postcode, phone, email — full width. That leaves eight
 * of the eleven billing fields alone on a line, and a form that is far taller
 * than the information in it.
 *
 * A grid replaces the floats. The pairing is the default: `form-row-wide` opts
 * a field back out to the full width where a half would be genuinely too
 * narrow (an address line, a country select), and the short ones are named
 * back to a single track. Auto-placement handles the rest, so a store that
 * adds, removes or reorders a field through `woocommerce_checkout_fields` gets
 * a sensible layout without touching any of this.
 *
 * Vertical rhythm stays with `.form-row`'s own bottom margin — that is what
 * the density option drives, and a grid `row-gap` here would double it.
 * ---------------------------------------------------------------------- */

.woocommerce-checkout {

	.woocommerce-billing-fields__field-wrapper,
	.woocommerce-shipping-fields__field-wrapper,
	.woocommerce-additional-fields__field-wrapper {
		display: grid;
		grid-template-columns: minmax(0, 1fr);
		gap: 0 var(--aureon-space-md);
	}

	// WooCommerce's float widths are inert on a grid item, but its `width: 47%`
	// is not — left standing, a paired field would fill less than half of the
	// half-track it was just given.
	.woocommerce-billing-fields__field-wrapper .form-row,
	.woocommerce-shipping-fields__field-wrapper .form-row,
	.woocommerce-additional-fields__field-wrapper .form-row {
		width: auto;
		float: none;
	}

	// Float clearers become grid items, and an empty one takes a whole row.
	.woocommerce-billing-fields__field-wrapper .clear,
	.woocommerce-shipping-fields__field-wrapper .clear {
		display: none;
	}
}

/* Container-queried, like the rest of the checkout: a form squeezed beside a
 * theme sidebar has no room to pair fields, and the viewport width would not
 * have told us that. */
@container aureon-woo (min-width: 30rem) {

	.woocommerce-checkout {

		.woocommerce-billing-fields__field-wrapper,
		.woocommerce-shipping-fields__field-wrapper,
		.woocommerce-additional-fields__field-wrapper {
			grid-template-columns: repeat(2, minmax(0, 1fr));
		}

		.form-row-wide,
		.notes {
			grid-column: 1 / -1;
		}

		// Short fields, named back to one track. They ship as `form-row-wide`,
		// so the rule above has to be undone for each — `grid-column: auto`
		// returns them to auto-placement, which pairs city with state and
		// postcode with phone. A country without states hides its field
		// outright, and the remaining three simply re-pair around the gap.
		#billing_city_field,
		#billing_state_field,
		#billing_postcode_field,
		#billing_phone_field,
		#shipping_city_field,
		#shipping_state_field,
		#shipping_postcode_field,
		#shipping_phone_field {
			grid-column: auto;
		}
	}
}

/* Input chrome variants. `outline` is the base rule further up; these two
 * replace it. Both editions, since the block checkout's inputs are the same
 * kind of control under a different class.
 *
 * The classic selectors mirror the theme's own `.woocommerce form .form-row
 * input.input-text` shape rather than naming the fields plainly: that base
 * rule is three elements deep and would otherwise out-specify a body class.
 * The block selectors need the same `.wc-block-components-form` ancestor
 * doubled that the "outline" rule above uses, for the same reason — without
 * it these lose the specificity tie to that rule and the field keeps its
 * outline look no matter which of these a store picks. */
body.aureon-checkout-input-filled {

	.woocommerce form .form-row input.input-text,
	.woocommerce form .form-row textarea,
	.woocommerce form .form-row select,
	.select2-container--default .select2-selection--single,
	.wc-block-components-form.wc-block-components-form .wc-block-components-text-input input,
	.wc-block-components-form.wc-block-components-form .wc-block-components-textarea {
		border-color: transparent;
		background: color-mix(in srgb, var(--aureon-color-text) 5%, var(--aureon-color-background));
	}
}

body.aureon-checkout-input-underline {

	.woocommerce form .form-row input.input-text,
	.woocommerce form .form-row textarea,
	.woocommerce form .form-row select,
	.select2-container--default .select2-selection--single,
	.wc-block-components-form.wc-block-components-form .wc-block-components-text-input input,
	.wc-block-components-form.wc-block-components-form .wc-block-components-textarea {
		border-width: 0 0 1px;
		border-radius: 0;
		background: none;
	}
}

/* Two-column checkout: the form is the grid, so the order review can sit
 * beside the customer details without floats. Container-queried for the same
 * reason as the cart grid above — a checkout squeezed beside a sidebar is
 * better served by one column than by two narrow ones. The threshold is higher
 * here because the summary carries product names, not just amounts. */
@container aureon-woo (min-width: 52rem) {

	body.aureon-checkout-two-column {

		form.checkout {
			display: grid;
			grid-template-columns: minmax(0, 1fr) minmax(0, var(--aureon-summary-track));
			// The customer-details column spans both rows, and a spanning item's
			// height is otherwise shared out across every intrinsic track it
			// covers — which pushed the summary card far below the heading it
			// belongs to. A flexible second track absorbs that height instead,
			// leaving row 1 sized to the heading alone.
			grid-template-rows: auto 1fr;
			gap: 0 var(--aureon-space-xl);
			align-items: start;
		}

		#customer_details {
			grid-column: 1;
			grid-row: 1 / span 2;
			width: 100%;
			float: none;
		}

		#order_review_heading {
			grid-column: 2;
			grid-row: 1;
		}

		#order_review {
			grid-column: 2;
			grid-row: 2;
			width: 100%;
			float: none;
		}

		// Billing and shipping stack inside the narrower left column rather
		// than splitting it in two again.
		#customer_details .col-1,
		#customer_details .col-2 {
			width: 100%;
			float: none;
		}
	}

	body.aureon-checkout-two-column.aureon-checkout-summary-left {

		form.checkout {
			grid-template-columns: minmax(0, var(--aureon-summary-track)) minmax(0, 1fr);
		}

		#customer_details {
			grid-column: 2;
		}

		#order_review_heading,
		#order_review {
			grid-column: 1;
		}
	}
}

/* -------------------------------------------------------------------------
 * Two-column block checkout
 *
 * Split at 43.75rem (700px) rather than at the classic checkout's 52rem,
 * because that is where WooCommerce's own block splits — the same number, and
 * the same reasoning, as the block cart further up. Left at 52rem there was a
 * 132px band in which core drew two columns and every rule below was still
 * switched off: no card, core's own 65/35 widths, and a "Summary position"
 * that did nothing. A checkout squeezed beside the theme sidebar lands
 * squarely inside that band.
 * ---------------------------------------------------------------------- */

@container aureon-woo (min-width: 43.75rem) {

	body.aureon-checkout-two-column {

		/* Which side the summary falls on is decided with `order`, not with
		 * `flex-direction` — and core's own reversal is undone first.
		 *
		 * The block editor's default checkout template saves the *totals*
		 * block ahead of the fields block, and core turns that back around
		 * with `.wc-block-components-sidebar-layout:has(>:last-child
		 * .wp-block-woocommerce-checkout-fields-block) { flex-direction:
		 * row-reverse }`. So the row arrives already reversed, and asking for
		 * `row-reverse` again — which is what "Summary on the left" used to do
		 * — changed nothing at all: the setting worked in one of its two
		 * positions and was a no-op in the other, while the gutter flip below
		 * went ahead anyway and opened the gap against the page edge.
		 *
		 * `order` reads from the column itself rather than from wherever the
		 * block happens to sit in the saved template, so both positions are
		 * real — and a store that reorders the two blocks in the editor still
		 * gets the side it picked here. Compounded with the layout class to
		 * outrank core's `:has()` rule, which is three classes deep. */
		.wc-block-checkout.wc-block-components-sidebar-layout {
			flex-direction: row;
		}

		// WooCommerce's own stylesheet gives `.wc-block-components-main` a flat
		// `width: 65%`, sized for its own default (a sidebar around 35%) — not for
		// `--aureon-summary-width`, which the store owner can set independently.
		// Left alone, the two widths only coincidentally sum to 100%; anywhere
		// they don't, the pair overflows the flex container's width and
		// `flex-wrap: wrap` on `.wc-block-components-sidebar-layout` drops the
		// main column onto its own line under the sidebar instead of beside it.
		// `flex: 1 1 0%` takes whatever the sidebar's fixed width leaves over.
		.wc-block-checkout__main {
			order: 0;
			flex: 1 1 0%;
			width: auto;
		}

		// The card look (padding/border/radius/background) is scoped to
		// `aureon-checkout-two-column` *and* this container query, rather
		// than stated unconditionally beside the classic card further up
		// ("Order summary card") — deliberately: a one-column layout, or a
		// two-column one narrower than this, stacks the summary under the form
		// inside the *same* outer page card the form is already in, and a
		// nested card there would be a box inside a box. Left flat,
		// WooCommerce's own hairline row dividers do the separating instead,
		// the same as every other stacked section on the page (see the
		// matching note on `.wc-block-cart__sidebar` further up).
		.wc-block-checkout__sidebar {
			order: 1;
			flex: 0 1 var(--aureon-summary-width);
			max-width: var(--aureon-summary-track);
			padding: var(--aureon-space-lg);
			border: 1px solid var(--aureon-color-border);
			border-radius: var(--aureon-radius-lg, 10px);
			background: color-mix(in srgb, var(--aureon-color-background) 96%, var(--aureon-color-text));
		}
	}

	body.aureon-checkout-two-column.aureon-checkout-summary-left {

		.wc-block-checkout__main {
			order: 1;
			// Core opens the column gutter with `padding-right` on the main
			// column — right while the form leads, exactly wrong once it
			// trails, where the gap lands against the outer page edge and the
			// form butts straight up against the summary card. Mirroring the
			// same percentage keeps both arrangements identically spaced. See
			// the matching note on the block cart above.
			padding-right: 0;
			padding-left: 4.5283018868%;
		}

		.wc-block-checkout__sidebar {
			order: 0;
		}
	}

	/* One column, block edition. The two columns are stacked by the rule
	 * further down that gives both `flex: 1 1 100%`; what is left here is the
	 * part that only matters above core's own split, where core still thinks
	 * it is drawing a row.
	 *
	 * Source order puts the summary first (the saved template's totals block
	 * leads, and core reverses the row to compensate), so stacking alone left
	 * the summary *above* the form — the opposite of the classic edition, and
	 * the opposite of what a customer asked for a single column expects.
	 * Below the split this is left alone: there core stacks the summary on top
	 * on purpose, behind its own mobile disclosure. */
	body.aureon-checkout-one-column {

		.wc-block-checkout.wc-block-components-sidebar-layout {
			flex-direction: row;
		}

		.wc-block-checkout__main {
			order: 0;
			// Core's gutter is a percentage padding down one side of the main
			// column. Stacked there is no gutter to open, only an indent that
			// left the form ~50px narrower than the summary beneath it.
			padding-inline: 0;
		}

		.wc-block-checkout__sidebar {
			order: 1;
			padding-inline: 0;
			// Core sticks its own summary (`is-sticky`, see the sticky rules
			// above); there is nothing to stick beside once the two stack.
			position: static;
		}
	}
}

/* -------------------------------------------------------------------------
 * Full-bleed summary panel (classic two-column checkout)
 *
 * The split look: the form on one side of the page against the ordinary
 * background, the summary on the other against a tinted panel that runs out to
 * the edge of the screen. The card dissolves into the panel — one surface, not
 * a card sitting on another.
 *
 * The panel is a pseudo-element on the *form* rather than on `#order_review`,
 * and absolutely positioned rather than placed in the grid, for one reason:
 * percentages. An absolutely-positioned box resolves its percentages against
 * its containing block — here the form, which spans the whole content column,
 * and whose width is therefore the one measurement that lets the panel work
 * out where the page edge is. A grid item resolves its percentages against its
 * own track, which is the width the panel is trying to escape.
 *
 * Classic only. The block checkout's sidebar is a React-rendered flex child
 * with its own padding contract, and reaching into it to bleed a background is
 * exactly the kind of thing that breaks on a WooCommerce release.
 * ---------------------------------------------------------------------- */

@container aureon-woo (min-width: 52rem) {

	body.aureon-checkout-summary-panel.aureon-checkout-two-column {

		form.checkout {
			position: relative;
		}

		form.checkout::before {
			content: "";
			position: absolute;
			z-index: 0;
			inset-block: 0;
			// Half a gutter to the left of the summary track, so the card sits
			// centred on the panel rather than flush against its edge.
			inset-inline-start: calc(100% - var(--aureon-summary-track) - var(--aureon-space-xl) / 2);
			// `(100% - 100vw) / 2` is negative — half the margin a centred
			// content column leaves on each side. Pulling the panel out by
			// exactly that much lands its outer edge on the viewport's.
			inset-inline-end: calc((100% - 100vw) / 2);
			border-inline-start: 1px solid var(--aureon-color-border);
			background: color-mix(in srgb, var(--aureon-color-background) 96%, var(--aureon-color-text));
		}

		// Summary on the left: the same two edges, swapped.
		&.aureon-checkout-summary-left form.checkout::before {
			inset-inline-start: calc((100% - 100vw) / 2);
			inset-inline-end: calc(100% - var(--aureon-summary-track) - var(--aureon-space-xl) / 2);
			border-inline-start: 0;
			border-inline-end: 1px solid var(--aureon-color-border);
		}

		// The panel paints at z-index 0, so the form's own children have to be
		// lifted above it — otherwise the tint covers the summary it is behind.

		// `z-index` alone, with no `position`: these are grid items, which take
		// a stacking order without being positioned. Adding `position: relative`
		// here would out-specify the sticky-summary rule and turn its `top`
		// offset into a plain downward shift — the summary would drop by the
		// header's height and hang out of the bottom of the panel.
		#customer_details,
		#order_review_heading,
		#order_review {
			z-index: 1;
		}

		// The panel is the surface now, so the card stops drawing a second one.
		// Its padding stays: that is what insets the totals from the panel edge.
		#order_review {
			border: 0;
			background: none;
		}

		// The heading is a separate grid item, outside the card's padding, so it
		// needs its own — inline to line up with the totals beneath it, and on
		// top because the panel's edge is now the only thing above it.
		#order_review_heading {
			padding-block-start: var(--aureon-space-lg);
			padding-inline: var(--aureon-space-lg);
		}
	}
}

/* `100vw` counts the scrollbar, so the panel overshoots the viewport's right
 * edge by its width. Clipping at the body keeps the overshoot off-screen
 * without a horizontal scrollbar — `clip` rather than `hidden` because `hidden`
 * would make the body a scroll container and break the sticky summary. */
body.aureon-checkout-summary-panel {
	overflow-x: clip;
}

/* …and clipping again at the entry, because "the edge of the page" is not the
 * edge of the viewport on most of this theme's layouts. The default content
 * style draws each entry as a bordered card, and a panel bleeding to the
 * viewport ran straight through that border and out the other side — a grey
 * slab laid over the page rather than one half of a split checkout. Clipped at
 * the card it stops flush against the inside of the border, filling the card's
 * own padding, which is what the split is supposed to look like when the page
 * itself is a card.
 *
 * `clip` again, for the sticky summary's sake, and because it is the one
 * overflow value that trims the bleed without offering to scroll to it.
 *
 * Unboxed content has no card and no border to protect — there the page really
 * does run to the edge of the screen, so the bleed is left alone. */
body.aureon-checkout-summary-panel .aureon-entry {
	overflow: clip;
}

body.aureon-content-unboxed.aureon-checkout-summary-panel .aureon-entry {
	overflow: visible;
}

/* The measure set by `aureon-checkout-form-*` above, applied to the field
 * column in both editions. Unset on `default`, where `max-width: ` resolves to
 * nothing and the declaration is dropped — so no guard is needed.
 *
 * On a one-column checkout the column *is* the page, so it also centres;
 * beside an order summary it just caps the fields and leaves the gap. */
#customer_details,
.wc-block-checkout__main {
	max-width: var(--aureon-checkout-measure);
}

/* One-column checkout: stack the form and the order review in both editions. */
body.aureon-checkout-one-column {

	.col2-set,
	form.checkout {
		display: block;
	}

	#customer_details,
	#order_review,
	#order_review_heading {
		width: 100%;
		float: none;
	}

	// Here the field column *is* the page, so a measure narrower than the
	// container should sit in the middle of it rather than against one edge.
	// A no-op on `default`, where there is no measure to centre within.
	#customer_details,
	.wc-block-checkout__main {
		margin-inline: auto;
	}

	// …and the measure is the *page's*, not just the field column's. Stacked
	// one above the other, the step strip, the coupon field and the order
	// review are part of the same single column the fields are; left at full
	// width they strand a narrow form in the middle of a wide page, which
	// reads as a broken layout rather than as a chosen measure.
	.aureon-checkout-steps,
	.woocommerce-form-coupon-toggle,
	form.checkout_coupon,
	#order_review_heading,
	#order_review {
		max-width: var(--aureon-checkout-measure);
		margin-inline: auto;
	}

	// Billing and shipping are floated at 48% by WooCommerce from
	// `.woocommerce .col2-set .col-1`. Unstacking the outer columns without
	// unstacking these leaves the whole form in the left half of the page,
	// which is what "one column" is meant to stop happening.
	#customer_details .col-1,
	#customer_details .col-2 {
		width: 100%;
		float: none;
	}

	// Same measure for the block edition's two columns, now stacked. The
	// fallback is what makes `default` a no-op: with no measure declared,
	// `max-width` resolves to 100% and the pair simply fills the row.
	.wc-block-checkout__main,
	.wc-block-checkout__sidebar {
		flex: 1 1 100%;
		max-width: var(--aureon-checkout-measure, 100%);
		margin-inline: auto;
	}
}

/* -------------------------------------------------------------------------
 * Collapsible order summary (classic checkout, narrow screens)
 *
 * The block checkout ships its own mobile disclosure, so this is classic-only.
 * cart-checkout.js turns the review heading into the button; the open/closed
 * state is a class on `#order_review`.
 * ---------------------------------------------------------------------- */

.aureon-summary-toggle {
	display: flex;
	align-items: center;
	justify-content: space-between;
	width: 100%;
	padding: 0;
	border: 0;
	background: none;
	color: inherit;
	font: inherit;
	cursor: pointer;
}

.aureon-summary-toggle__caret {
	flex: none;
	width: 0.5em;
	height: 0.5em;
	border: solid currentcolor;
	border-width: 0 2px 2px 0;
	transform: rotate(45deg) translate(-25%, -25%);
	transition: transform 0.2s ease;
}

.aureon-summary-toggle[aria-expanded="true"] .aureon-summary-toggle__caret {
	transform: rotate(-135deg) translate(-25%, -25%);
}

@media (max-width: 782px) {

	body.aureon-checkout-collapsible #order_review:not(.is-open) {
		display: none;
	}

	body.aureon-checkout-collapsible .aureon-summary-heading {
		padding: var(--aureon-space-sm) 0;
		border-block: 1px solid var(--aureon-color-border);
	}
}

@media (min-width: 783px) {

	// On a wide screen the summary is a column; the toggle has nothing to do.
	.aureon-summary-toggle {
		cursor: default;
		pointer-events: none;
	}

	.aureon-summary-toggle__caret {
		display: none;
	}
}

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

	.aureon-summary-toggle__caret {
		transition: none;
	}
}

/* -------------------------------------------------------------------------
 * Checkout coupon
 *
 * WooCommerce ships the field collapsed behind a "Have a coupon?" notice and
 * reveals it with its own script. Both presentations are styled here, and the
 * "always visible" one is opened in CSS rather than by clicking the toggle from
 * JavaScript — the reveal has to survive checkout.js binding its own handler to
 * the same control, and a rule cannot lose that race.
 * ---------------------------------------------------------------------- */

/* The prompt is a WooCommerce notice, which arrives with a decorative glyph
 * from WooCommerce's icon font — a font this theme does not load, so it renders
 * as an empty box. Drop it and let the sentence stand on its own.
 *
 * The login disclosure above it is the same control in the same shape, and is
 * dressed here rather than separately for that reason — see the matching
 * carve-out in wc-notices.js, which is what keeps both on the page instead of
 * promoting them into a toast that times out. */
.woocommerce-form-coupon-toggle .woocommerce-info,
.woocommerce-form-login-toggle .woocommerce-info {
	display: flex;
	flex-wrap: wrap;
	gap: 0.35em;
	align-items: baseline;
	padding: var(--aureon-space-sm) var(--aureon-space-md);
	margin: 0 0 var(--aureon-space-lg);
	border: 1px solid var(--aureon-color-border);
	border-radius: var(--aureon-radius-md, 6px);
	background: color-mix(in srgb, var(--aureon-color-background) 96%, var(--aureon-color-text));
	font-size: var(--aureon-font-size-sm);
	color: var(--aureon-color-text);

	&::before {
		display: none;
	}

	a.showcoupon,
	a.showlogin {
		color: var(--aureon-color-link);
		font-weight: 600;
		text-decoration: none;

		&:hover {
			text-decoration: underline;
		}
	}
}

/* A bordered field and a button, and nothing around them. The panel this used
 * to sit in drew a second border a few pixels outside the input's own, which
 * is a box inside a box — and in the "always visible" presentation it framed a
 * single text field as though it were a section of the form. The row carries
 * itself. */

/* `.woocommerce` prefix throughout: WooCommerce's own `form.checkout_coupon`
 * rule carries it, and the panel below is its padding and border — an
 * unprefixed selector loses the tie and the box stays. */
.woocommerce form.checkout_coupon {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: var(--aureon-space-sm);
	padding: 0;
	margin: 0 0 var(--aureon-space-lg);
	border: 0;

	.form-row {
		padding: 0;
		margin: 0;
	}

	// A discount code is a dozen characters. Stretched across the whole form
	// the field promised a paragraph and stranded its button at the far end of
	// an empty runway; capped, the pair reads as one control. It still shrinks
	// below the cap, which is what keeps it on one line inside a narrow
	// checkout measure (see `aureon-checkout-form-narrow`).
	.form-row-first {
		flex: 0 1 20rem;
	}

	// `flex: 0 0 auto` alone is not enough to size this to the button: WooCommerce
	// gives both halves of the pair `width: 47%` for its own floated layout, and
	// `flex-basis: auto` then resolves back to that. So the button's box sat at
	// 47% of the row whatever the row's width — wide enough to wrap the pair
	// onto two lines well before it had to, and narrow enough on a phone to
	// break "Apply coupon" across two lines inside it.
	.form-row-last {
		flex: 0 0 auto;
		width: auto;
	}

	.input-text {
		width: 100%;
	}

	// Quiet, for the same reason the summary presentation's Apply is quiet
	// (see `.aureon-review-discount__apply`, which this matches): applying a
	// code is an optional detour, and drawing it in the primary colour puts it
	// in competition with the button that actually pays.
	button[type="submit"] {
		flex: 0 0 auto;
		padding: 0.5em 1.1em;
		border: 1px solid var(--aureon-color-border);
		border-radius: var(--aureon-radius-sm, 4px);
		background: color-mix(in srgb, var(--aureon-color-text) 5%, var(--aureon-color-background));
		// Inherited so the button matches the field's box exactly: the theme's
		// own button rules run a smaller font and a tight line-height, which
		// left a 30px button standing beside a 45px input.
		font: inherit;
		font-weight: 600;
		line-height: 1.7;
		color: var(--aureon-color-heading, var(--aureon-color-text));
		transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;

		&:hover:not(:disabled) {
			border-color: var(--aureon-color-primary);
			background: color-mix(in srgb, var(--aureon-color-primary) 8%, var(--aureon-color-background));
			color: var(--aureon-color-link);
		}
	}

	// WooCommerce's float clearer has nothing to clear in a flex row, but it
	// still takes a line of its own.
	.clear {
		display: none;
	}
}

/* "Always visible": show the field, retire the prompt. The template carries an
 * inline `style="display:none"`, which is the one thing a stylesheet cannot
 * outrank without `!important`. */
body.aureon-checkout-coupon-inline {

	.woocommerce-form-coupon-toggle {
		display: none;
	}

	form.checkout_coupon {
		// stylelint-disable-next-line declaration-no-important -- beats the
		// template's own inline `display:none`; see above.
		display: flex !important;
	}
}

/* -------------------------------------------------------------------------
 * Checkout coupon — "In the order summary"
 *
 * The field is rendered as the last row of the review table's body (see
 * WooCommerce::render_summary_coupon()), so it lands between the line items and
 * the subtotal. It is a band rather than a row: a full-strength rule closes off
 * the items above it, and the label/input/button stack fills the width instead
 * of splitting into the label + amount columns every other row uses.
 *
 * Apply is deliberately the quietest control in the column. It is an optional
 * detour on the way to placing the order, and drawing it in the primary colour
 * would put it in competition with the button that actually pays.
 * ---------------------------------------------------------------------- */

.woocommerce-checkout .woocommerce table.woocommerce-checkout-review-order-table tr.aureon-review-discount {
	display: block;
	padding: var(--aureon-space-md) 0;
	border-top: 1px solid var(--aureon-color-border);
	border-bottom: 1px solid var(--aureon-color-border);

	td.aureon-review-discount__cell {
		display: block;
		width: 100%;
		text-align: start;
	}
}

.aureon-review-discount__label {
	display: block;
	margin-bottom: var(--aureon-space-xs);
	font-size: var(--aureon-font-size-sm, 0.875rem);
	font-weight: 500;
	color: var(--aureon-color-heading, var(--aureon-color-text));
}

.aureon-review-discount__row {
	display: flex;
	gap: var(--aureon-space-sm);
	align-items: stretch;
}

/* The field is not in a `.form-row`, so none of the checkout's own field rules
 * reach it. Its box is restated here to the same numbers rather than widened
 * selectors — a discount input that does not match the address fields two
 * columns over is the tell that it was bolted on.
 *
 * `line-height` is restated after each `font: inherit` — the shorthand would
 * otherwise reset it back. The review table runs tighter than the page, so
 * inheriting would land this field 3px short of the address fields it is meant
 * to match; 1.7 is the page's own line-height, which is what their
 * `font: inherit` resolves to. */

.aureon-review-discount__input {
	// `min-width: 0` so a long code shrinks the field rather than pushing the
	// button out of the column — inputs carry an intrinsic minimum otherwise.
	flex: 1 1 auto;
	min-width: 0;
	padding: 0.5em 0.75em;
	border: 1px solid var(--aureon-color-border);
	border-radius: var(--aureon-radius-sm, 4px);
	background: var(--aureon-color-background);
	font: inherit;
	line-height: 1.7;
	color: var(--aureon-color-text);
}

/* Same padding, font and border as the input beside it, so the two agree on a
 * height without either being given one. Tinted rather than white so it still
 * reads as a control to press — but bordered and quiet, because the button
 * that matters in this column is Place order. */
.aureon-review-discount__apply {
	flex: 0 0 auto;
	padding: 0.5em 1em;
	border: 1px solid var(--aureon-color-border);
	border-radius: var(--aureon-radius-sm, 4px);
	background: color-mix(in srgb, var(--aureon-color-text) 5%, var(--aureon-color-background));
	font: inherit;
	font-weight: 600;
	line-height: 1.7;
	color: var(--aureon-color-heading, var(--aureon-color-text));
	cursor: pointer;
	transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;

	&:hover:not(:disabled) {
		border-color: var(--aureon-color-primary);
		background: color-mix(in srgb, var(--aureon-color-primary) 8%, var(--aureon-color-background));
		color: var(--aureon-color-link);
	}

	&:disabled {
		opacity: 0.6;
		cursor: default;
	}
}

.aureon-review-discount__notice {
	margin-top: var(--aureon-space-xs);
	font-size: var(--aureon-font-size-sm, 0.875rem);
	line-height: 1.45;
	color: #dc2626;

	// A live region has to stay in the DOM to be announced, so it is emptied
	// rather than removed — and an empty one must not leave a gap.
	&:empty {
		display: none;
	}
}

/* The applied code, as a chip beside the "Discount" label in the totals.
 *
 * Every length here is stated with a fallback. `--aureon-font-size-xs` is not
 * among the tokens the customizer emits, and a bare `var()` on a missing custom
 * property is not "no font-size" — it is an invalid declaration, so the chip
 * inherited the row's 1rem and came out the size of the label it annotates. */
.aureon-review-discount__code {
	display: inline-block;
	margin-inline-start: 0.5em;
	padding: 0.05em 0.4em;
	border-radius: 3px;
	background: color-mix(in srgb, var(--aureon-color-text) 8%, transparent);
	// Below the type scale's smallest step on purpose. This is a marker on a
	// row, not text to be read — it identifies which code produced the figure
	// beside it, and the word "Discount" has already said what it is.
	font-size: 0.6875rem;
	font-weight: 600;
	// The chip is a box around one line; the row's 1.7 would pad it out.
	line-height: 1.45;
	letter-spacing: 0.03em;
	text-transform: uppercase;
	color: var(--aureon-color-text-muted, var(--aureon-color-text));
}

/* WooCommerce trails a "[Remove]" link after the discount amount, inside the
 * amount cell. The mock has no such control, but a code the customer cannot
 * take off again is a trap — so it stays, sized down to a footnote. It is
 * allowed to drop under the figure rather than squeeze it: the column is narrow
 * and the amount is the part that has to stay readable. */
body.aureon-checkout-coupon-summary .woocommerce-checkout-review-order-table tr.cart-discount {

	th {
		display: flex;
		flex-wrap: wrap;
		align-items: center;
	}

	td .woocommerce-remove-coupon {
		display: inline-block;
		margin-inline-start: 0.5em;
		font-size: var(--aureon-font-size-xs, 0.75rem);
		// The cell now sets the amount's weight; a bold "Remove" would read as a
		// second figure rather than the footnote it is.
		font-weight: 400;
		color: var(--aureon-color-text-muted, var(--aureon-color-text));
		// Underlined only on approach. Sitting under the figure it removes, a
		// permanently ruled link reads as a second, struck-through amount.
		text-decoration: none;

		&:hover,
		&:focus-visible {
			color: var(--aureon-color-text);
			text-decoration: underline;
		}
	}
}

/* -------------------------------------------------------------------------
 * Payment methods (classic checkout)
 *
 * WooCommerce ships this block in its own lilac-grey palette with a speech
 * bubble pointing at the selected method. Restated in the theme's surface
 * colours so it belongs to the order-summary card it sits inside.
 *
 * Each gateway is a tile matching the delivery-method cards above — the two
 * choices the checkout asks the customer to make are drawn the same way. The
 * `li` is the grid rather than the label, because the gateway's description
 * panel is a *sibling* of the label, not a child: only the row can place the
 * radio and title on one line and drop the panel underneath both.
 * ---------------------------------------------------------------------- */

.woocommerce-checkout #payment {
	border-radius: 0;
	background: transparent;

	ul.payment_methods {
		display: flex;
		flex-direction: column;
		// Tiles are cards, not list rows — 4px read as a stack that had failed
		// to separate rather than as three distinct choices.
		gap: var(--aureon-space-sm);
		padding: 0 0 var(--aureon-space-md);
		border-bottom: 1px solid var(--aureon-color-border);

		li {
			list-style: none;
		}
	}

	// Scoped to `.wc_payment_method`: the same list also carries a plain `li`
	// holding the "no payment methods available" notice, which is a message
	// rather than a choice and must not be drawn as one.
	li.wc_payment_method {
		position: relative;
		display: grid;
		grid-template-columns: minmax(0, 1fr);
		align-items: center;
		padding: var(--aureon-space-md);
		// Extra room on the end so the checkmark badge (absolutely
		// positioned, see `.aureon-payment-method__check` below) never
		// sits over the label text it is confirming.
		padding-inline-end: calc(var(--aureon-space-md) + 1.75rem);
		border: 1px solid var(--aureon-color-border);
		border-radius: var(--aureon-radius-md, 6px);
		background: var(--aureon-color-background);
		transition: border-color 0.15s ease, background 0.15s ease;

		&:hover {
			border-color: color-mix(in srgb, var(--aureon-color-primary) 50%, var(--aureon-color-border));
		}

		// The selected tile carries a stronger wash than hover, plus the
		// checkmark badge below — together they read at a glance, matching
		// the delivery-method cards, rather than needing a second look to spot
		// which radio is filled in.
		&:has(input:checked) {
			border-color: var(--aureon-color-primary);
			background: color-mix(in srgb, var(--aureon-color-primary) 6%, var(--aureon-color-background));
		}

		&:has(input:focus-visible) {
			outline: 2px solid var(--aureon-color-primary);
			outline-offset: 2px;
		}

		// WooCommerce clears the row's floats with `content: " "; display: table`
		// on both pseudo-elements. There are no floats left to clear once the
		// row is a grid — but a pseudo-element *is* a grid item, so the pair
		// silently took the first and last cells and pushed the radio into the
		// title's column.
		&::before,
		&::after {
			display: none;
		}

		// The radio stays in the DOM — focusable, labelled, and still what a
		// screen reader or keyboard drives — but drawn nowhere. The tile
		// already carries the selected state twice over (the tinted
		// background and the checkmark badge); a third marker, the small
		// circle WooCommerce draws by default, only crowded the title
		// without telling the customer anything those two didn't already.
		// Visually hidden rather than `display: none`, which would drop it
		// from the tab order.
		> input[type="radio"] {
			position: absolute;
			inline-size: 1px;
			block-size: 1px;
			padding: 0;
			margin: -1px;
			overflow: hidden;
			clip-path: inset(50%);
			white-space: nowrap;
			border: 0;
		}

		> label {
			display: flex;
			grid-column: 1;
			grid-row: 1;
			flex-wrap: wrap;
			align-items: center;
			gap: 0.5em;
			margin: 0;
			font-weight: 600;
			color: var(--aureon-color-heading, var(--aureon-color-text));
			cursor: pointer;
		}

		// Gateway logos come through `WC_Payment_Gateway::get_icon()` at whatever
		// pixel height the gateway chose; cap them against the label's own line
		// so one extension can't set the height of every tile. `max-width` too —
		// a gateway that concatenates several brand marks into one wide image
		// (Stripe's card-brand strip is a common example) would otherwise
		// overflow a narrow tile, since only the height was ever constrained.
		> label img {
			display: inline-block;
			width: auto;
			max-width: 100%;
			max-height: 1.5em;
			margin: 0;
		}
	}

	// The "selected" affordance the delivery-method cards already use: a
	// filled circle with a check, revealed once the radio is checked. Added
	// by the theme's `checkout/payment-method.php` override, right after the
	// label — absolutely positioned, so its place in that markup doesn't
	// affect layout.
	.aureon-payment-method__check {
		position: absolute;
		inset-block-start: 50%;
		inset-inline-end: var(--aureon-space-md);
		transform: translateY(-50%);
		display: grid;
		place-items: center;
		width: 1.25rem;
		height: 1.25rem;
		border-radius: 50%;
		background: var(--aureon-color-primary);
		color: var(--aureon-color-button-text, #fff);
		opacity: 0;
		transition: opacity 0.15s ease;
	}

	.aureon-payment-method__check-icon {
		width: 0.75rem;
		height: 0.75rem;
	}

	li.wc_payment_method:has(input:checked) .aureon-payment-method__check {
		opacity: 1;
	}

	div.payment_box {
		// No longer a filled panel. A grey box inside a tinted tile was a box
		// inside a box, and the inner one carried no meaning the outer one
		// had not already given — the tile is what says "selected". A
		// hairline and the indent do the separating now.
		grid-column: 1;
		margin: var(--aureon-space-sm) 0 0;
		padding: var(--aureon-space-sm) 0 0;
		border-top: 1px solid color-mix(in srgb, var(--aureon-color-border) 70%, transparent);
		border-radius: 0;
		background: none;
		font-size: var(--aureon-font-size-sm, 0.875rem);
		color: var(--aureon-color-text-muted, var(--aureon-color-text));

		// The pointer triangle is drawn in WooCommerce's own lilac.
		&::before {
			display: none;
		}

		p:last-child {
			margin-bottom: 0;
		}

		// A gateway that prints real fields (card number, expiry) rather than a
		// sentence gets the page's field spacing back — the muted description
		// type above is for prose, not for labels.
		.form-row {
			margin-bottom: var(--aureon-space-sm);
		}
	}

	.woocommerce-privacy-policy-text {
		font-size: var(--aureon-font-size-sm);
		color: var(--aureon-color-text-muted, var(--aureon-color-text));
	}
}

/* stylelint-enable selector-id-pattern */
