/* Forms: contact form, checkout, and account. Owned by the forms workstream. */

/*
 * Loaded by inc/enqueue.php on checkout, cart and account pages, and on any
 * page containing a [fluentform] shortcode. It is registered AFTER
 * assets/css/woocommerce.css, so where the two sheets touch the same selector
 * at equal specificity this file wins by source order. That is deliberate and
 * is relied on in section 3.
 *
 * Scope discipline
 * ----------------------------------------------------------------------------
 * assets/css/woocommerce.css already owns store buttons, notice banners,
 * checkout text fields, placeholder colour, required markers and validation
 * text. This sheet does NOT restate any of that. It covers only:
 *
 *   1. FluentForms (.ff-*) — untouched by any other sheet.
 *   2. The block checkout radio rows, where the control overlaps its label.
 *   3. The My Account page width, which the page template constrains.
 *   4. The Interac e-Transfer badge, using the client's official artwork.
 *
 * Colour and contrast
 * ----------------------------------------------------------------------------
 * Every value below was measured, not estimated. Ratios quoted inline.
 *
 *   Ink      #14171c on cream #f7f4ed ........ 16.35:1  AAA
 *   Slate    #4a5058 on cream ................  7.41:1  AAA
 *   Slate    #4a5058 on white ................  8.14:1  AAA
 *   Accent   #9d2f2a on cream ................  6.65:1  AA
 *   Accent   #9d2f2a on white ................  7.31:1  AAA
 *   Brass-dk #8a5c1f on cream ................  5.26:1  AA
 *
 * Plain brass --primary (#a8712a) measures 3.78:1 on cream and is NEVER used
 * for text here — only for rules and non-text accents. FluentForms' stock
 * error red #f56c6c measures 2.64:1 on cream and fails outright; it is
 * replaced with accent throughout section 2.
 *
 * No state in this sheet is signalled by colour alone: every error carries a
 * glyph and a weight change, and every success carries a glyph.
 */

/* ==========================================================================
   0. Tokens
   ==========================================================================
   Defined locally rather than reused from woocommerce.css: that sheet only
   loads on store pages, and this one also has to work on /contact/, where it
   is the sole source of form styling. */

.fluentform,
.wp-block-woocommerce-checkout,
.wp-block-woocommerce-cart,
.woocommerce-account .woocommerce {
	--mtsf-field-bg: #fff;
	--mtsf-field-border-color: var(--wp--preset--color--contrast-2, #4a5058);
	--mtsf-field-radius: 2px;

	/* Matches the metrics in woocommerce.css section 4, so a FluentForms
	   control and a checkout control are the same object visually. */
	--mtsf-field-pad: 0.6em 0.8em;
	--mtsf-field-min-h: 44px;

	--mtsf-error: var(--wp--preset--color--accent, #9d2f2a);
	--mtsf-success: var(--wp--preset--color--secondary, #1b3a5c);

	/* WCAG 2.5.8 (AA) floor; 44px is the 2.5.5 (AAA) target. */
	--mtsf-touch-min: 24px;
	--mtsf-touch: 44px;

	--mtsf-focus-w: var(--wp--custom--focus-ring--width, 3px);
	--mtsf-focus-o: var(--wp--custom--focus-ring--offset, 2px);
	--mtsf-transition: var(--wp--custom--transition--base, 180ms cubic-bezier(0.2, 0, 0.2, 1));
}

/*
 * Repoint FluentForms' own design tokens at the palette.
 *
 * The plugin funnels most of its colour through three custom properties, so
 * redefining them here fixes every consumer at once — the required asterisk,
 * the help tooltip, inline error text and any control the plugin adds in a
 * future release — without a per-selector specificity fight. Two of its stock
 * values are genuine WCAG failures on this background:
 *
 *   --fluentform-danger  #f56c6c on cream = 2.64:1  FAIL  -> accent  6.65:1 AA
 *   --fluentform-primary #1a7efb on cream = 3.68:1  FAIL  -> secondary 10.58:1
 *
 * The asterisk is a real text character, so it has to clear 4.5:1 rather than
 * the 3:1 non-text threshold. "Required" is not signalled by that colour
 * alone in any case — the controls carry the `required` attribute.
 */
.fluentform {
	--fluentform-danger: var(--wp--preset--color--accent, #9d2f2a);
	--fluentform-primary: var(--wp--preset--color--secondary, #1b3a5c);
	--fluentform-border-color: var(--wp--preset--color--contrast-2, #4a5058);
	--fluentform-border-radius: 2px;
}

/* ==========================================================================
   1. FluentForms — contact form
   ==========================================================================
   FluentForms ships fluentform-public-default.css, which renders every control
   at 13px in -apple-system with a 1px #dadbdd border. This section replaces
   that wholesale. forms.css is enqueued after the plugin's stylesheet, so
   matching specificity is sufficient; nothing here needs !important. */

/* --- Layout ------------------------------------------------------------- */

.fluentform .ff-el-group {
	margin-block-end: var(--wp--preset--spacing--30, 1.25rem);
}

.fluentform .ff-el-group:last-child {
	margin-block-end: 0;
}

/*
 * The name field is not an .ff-el-group — FluentForms wraps First and Last in
 * an .ff-field_container, which carried no bottom margin at all. Measured on
 * /contact/: the gap between the name row and Email was 0px while every other
 * gap in the form was 16px, so Email sat flush against the names.
 *
 * The container is given the group spacing, and the groups nested inside it
 * have theirs removed, so the row contributes one gap rather than two.
 */
.fluentform .ff-field_container {
	margin-block-end: var(--wp--preset--spacing--30, 1.25rem);
}

.fluentform .ff-field_container:last-child {
	margin-block-end: 0;
}

.fluentform .ff-field_container .ff-el-group {
	margin-block-end: 0;
}

/* --- Labels -------------------------------------------------------------
   Every control on this form already has a real <label for="…">; verified in
   the rendered DOM, not assumed. These rules only restyle them. */

/*
 * The wrapper is the flex row, not the <label>.
 *
 * FluentForms puts an optional help tooltip (.ff-el-tooltip, an inline SVG)
 * inside this wrapper as a sibling of the label. An earlier revision of this
 * file set `display: block` on the label itself, which pushed that tooltip
 * onto its own line above the field — visible on the Email row. Laying the
 * wrapper out as a flex row keeps label and tooltip on one baseline and still
 * puts the control underneath.
 */
.fluentform .ff-el-input--label {
	display: flex;
	align-items: center;
	gap: 0.15em;
	margin-block-end: 0.35em;
}

.fluentform .ff-el-input--label label {
	display: inline-block;
	margin-block-end: 0;
	font-family: var(--wp--preset--font-family--display, "Oswald", sans-serif);
	font-size: var(--wp--preset--font-size--small, 0.875rem);
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	color: var(--wp--preset--color--contrast, #14171c); /* 16.35:1 — AAA */
}

/* The required marker is a glyph, so "required" is never colour-alone. It is
   also exposed natively: the inputs carry the `required` attribute. */
/*
 * Colour now arrives via --fluentform-danger above; the weight bump still
 * needs to out-rank the plugin's own
 *   .fluentform .ff-el-input--label.ff-el-is-required.asterisk-right label::after
 * which is (0,4,2). Matching that chain and relying on load order keeps this
 * from silently reverting, as it did on the first pass.
 */
.fluentform .ff-el-input--label.ff-el-is-required.asterisk-left label::before,
.fluentform .ff-el-input--label.ff-el-is-required.asterisk-right label::after,
.fluentform .ff-el-is-asterisk {
	color: var(--mtsf-error); /* 6.65:1 on cream — AA */
	font-weight: 700;
	text-decoration: none;
}

/*
 * Help tooltip trigger. The plugin renders a bare 16px SVG with no hit area of
 * its own; it opens on hover/focus and its text is also exposed via the
 * data-content attribute. Giving it a 24px box satisfies WCAG 2.5.8 without
 * changing the icon's drawn size.
 */
.fluentform .ff-el-tooltip {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: var(--mtsf-touch-min);
	min-height: var(--mtsf-touch-min);
	cursor: help;
}

.fluentform .ff-el-tooltip svg {
	fill: var(--wp--preset--color--secondary, #1b3a5c); /* 10.58:1 — AAA */
	width: 15px;
	height: 15px;
}

/* --- Controls -----------------------------------------------------------
   THE FIX the client asked for by name.

   The <select> rendered as a native 42px control at 13px in the system font
   while the text inputs were 40px — a visible mismatch. Listing input, select
   and textarea in one rule guarantees they cannot drift apart again.

   `appearance: none` is what lets the select take these metrics at all; it
   also removes the native arrow, which is redrawn below. Checkbox and radio
   inputs use .ff-el-form-check-input, not .ff-el-form-control, so they are not
   caught by this rule — but they are excluded explicitly so a future
   FluentForms release cannot break them silently. */

.fluentform .ff-el-form-control:not([type="checkbox"]):not([type="radio"]) {
	-webkit-appearance: none;
	appearance: none;
	box-sizing: border-box;
	width: 100%;
	min-height: var(--mtsf-field-min-h);
	height: auto; /* beats the plugin's fixed 40px/42px */
	padding: var(--mtsf-field-pad);
	font-family: var(--wp--preset--font-family--body, "Inter", sans-serif);
	font-size: var(--wp--preset--font-size--medium, 1.0625rem);
	line-height: 1.5;
	color: var(--wp--preset--color--contrast, #14171c);
	background-color: var(--mtsf-field-bg);
	border: 1px solid var(--mtsf-field-border-color); /* 8.14:1 on white */
	border-radius: var(--mtsf-field-radius);
	box-shadow: none;
	transition:
		border-color var(--mtsf-transition),
		box-shadow var(--mtsf-transition);
}

/* Font-size is deliberately >=16px at the fluid minimum: iOS Safari zooms the
   viewport when a focused control is smaller, which is a usability defect. */

.fluentform textarea.ff-el-form-control {
	min-height: 8rem;
	resize: vertical;
}

/* Redraw the select arrow removed by `appearance: none`. An inline SVG data
   URI keeps this a no-build-step sheet. Stroke is slate (#4a5058, 8.14:1 on
   white) — decorative, but it costs nothing to make it legible. */
.fluentform select.ff-el-form-control {
	padding-inline-end: 2.5rem;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1.5 1.5 6 6l4.5-4.5' fill='none' stroke='%234a5058' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right 0.85rem center;
	background-size: 12px 8px;
}

/* The arrow must not sit under the text in a right-to-left locale. */
[dir="rtl"] .fluentform select.ff-el-form-control {
	background-position: left 0.85rem center;
}

.fluentform .ff-el-form-control::placeholder {
	color: var(--wp--preset--color--contrast-2, #4a5058); /* 8.14:1 — AAA */
	opacity: 1;
}

.fluentform .ff-el-form-control:hover {
	border-color: var(--wp--preset--color--contrast, #14171c);
}

.fluentform .ff-el-form-control:focus,
.fluentform .ff-el-form-control:focus-visible {
	border-color: var(--wp--preset--color--contrast, #14171c);
	outline: var(--mtsf-focus-w) solid var(--mtsf-error);
	outline-offset: var(--mtsf-focus-o);
}

/* --- Checkbox and radio -------------------------------------------------
   Grow the label, not the box: that keeps the plugin's alignment intact while
   lifting the real activation target past the 24px WCAG 2.5.8 floor. */

.fluentform .ff-el-form-check-label {
	display: flex;
	align-items: center;
	gap: 0.5em;
	min-height: var(--mtsf-touch-min);
	font-size: var(--wp--preset--font-size--medium, 1.0625rem);
	line-height: 1.4;
}

.fluentform .ff-el-form-check-input {
	flex: 0 0 auto;
	width: 1.15em;
	height: 1.15em;
	margin: 0;
	accent-color: var(--wp--preset--color--contrast, #14171c);
}

/* --- Submit button ------------------------------------------------------
   Mirrors the theme.json button element styles so the form's primary action
   matches every other button on the site. Cream on ink measures 16.35:1. */

.fluentform .ff-btn-submit,
.fluentform .ff_submit_btn_wrapper button {
	min-height: var(--mtsf-touch);
	padding: 0.85em 1.75em;
	font-family: var(--wp--preset--font-family--display, "Oswald", sans-serif);
	font-size: var(--wp--preset--font-size--small, 0.875rem);
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.08em;
	color: var(--wp--preset--color--base, #f7f4ed);
	background-color: var(--wp--preset--color--contrast, #14171c);
	border: 2px solid var(--wp--preset--color--contrast, #14171c);
	border-radius: var(--mtsf-field-radius);
	cursor: pointer;
	transition:
		background-color var(--mtsf-transition),
		border-color var(--mtsf-transition);
}

/*
 * FluentForms stores a per-form button colour and prints it into the page as
 * an inline <style>:
 *
 *   form.fluent_form_3 .ff-btn-submit:not(.ff_btn_no_style)
 *   { background-color: #8c6b3f; color: #fff }
 *
 * That is (0,3,1) and beat the rule above, so the button kept rendering brass
 * while every other button on the site renders ink.
 *
 * For the record it was not an accessibility defect — white on #8c6b3f
 * measures 4.90:1 and clears AA. It was purely inconsistent, which is what the
 * client actually reported. The chain below is (0,4,1) and reclaims it for
 * theme.json's button element styles (cream on ink, 16.35:1).
 *
 * TRADE-OFF, worth knowing before someone is confused by it: this now wins
 * over the colour pickers in the FluentForms form editor, so changing the
 * button colour there will have no visible effect. Changing it is a CSS edit
 * here, which is the same place every other button on the site is defined.
 */
.fluentform form.frm-fluent-form .ff-btn-submit:not(.ff_btn_no_style) {
	color: var(--wp--preset--color--base, #f7f4ed);
	background-color: var(--wp--preset--color--contrast, #14171c);
	border-color: var(--wp--preset--color--contrast, #14171c);
}

.fluentform form.frm-fluent-form .ff-btn-submit:not(.ff_btn_no_style):hover,
.fluentform form.frm-fluent-form .ff-btn-submit:not(.ff_btn_no_style):focus-visible,
.fluentform .ff-btn-submit:hover,
.fluentform .ff-btn-submit:focus-visible,
.fluentform .ff_submit_btn_wrapper button:hover {
	/* Brass-dark, not brass: cream on #8a5c1f measures 5.78:1 (AA). Cream on
	   plain brass would be 2.9:1 and would fail. */
	color: var(--wp--preset--color--base, #f7f4ed);
	background-color: var(--wp--preset--color--primary-dark, #8a5c1f);
	border-color: var(--wp--preset--color--primary-dark, #8a5c1f);
}

.fluentform .ff-btn-submit:disabled,
.fluentform .ff-btn-submit[disabled] {
	opacity: 1; /* opacity alone reads as "faded", not "unavailable" */
	color: var(--wp--preset--color--base, #f7f4ed);
	background-color: var(--wp--preset--color--contrast-2, #4a5058);
	border-color: var(--wp--preset--color--contrast-2, #4a5058);
	cursor: not-allowed;
}

/* ==========================================================================
   2. FluentForms — error and success states
   ==========================================================================
   What the plugin already does, verified by forcing a real validation failure
   in the browser rather than reading the source:

     - inline errors render as <div class="error text-danger" role="alert">
     - the failing control gets aria-invalid="true"
     - the success panel renders as
       <div class="ff-message-success" role="status" aria-live="polite"> and
       receives focus

   So announcement is handled by FluentForms. These rules supply the visual
   half: contrast, a non-colour cue, and a consistent shape.

   Known gap, NOT fixable from a stylesheet: the inline error <div> has no id
   and the control has no aria-describedby, so the message is announced by
   role="alert" but is not programmatically tied to its field. Flagged in the
   hand-off notes; closing it needs JS, which this workstream does not own. */

/* --- Inline field error -------------------------------------------------- */

/*
 * The :not() pair is repeated from the base control rule on purpose. Each
 * :not([type=…]) contributes an attribute selector's weight, so the base rule
 * is (0,4,0); a plain `.fluentform .ff-el-is-error .ff-el-form-control` is
 * (0,3,0) and silently lost the border back to it. Caught by reading the
 * computed border on a genuinely failing field rather than trusting the rule.
 *
 * The heavier border is a redundant cue — the ⚠ glyph and the message text
 * below carry the meaning, so the state does not depend on colour.
 */
.fluentform
	.ff-el-is-error
	.ff-el-form-control:not([type="checkbox"]):not([type="radio"]) {
	border-color: var(--mtsf-error);
	border-width: 2px;
}

.fluentform .error.text-danger {
	display: flex;
	align-items: flex-start;
	gap: 0.4em;
	margin-block-start: 0.4em;
	font-family: var(--wp--preset--font-family--body, "Inter", sans-serif);
	font-size: var(--wp--preset--font-size--small, 0.875rem);
	font-weight: 500;
	line-height: 1.45;
	/* Replaces the plugin's #f56c6c, which measures 2.64:1 on cream. */
	color: var(--mtsf-error); /* 6.65:1 on cream, 7.31:1 on white — AA */
}

/* Non-colour cue. aria-hidden is unavailable on a pseudo-element, but
   generated content is not exposed as text by any current screen reader, and
   role="alert" already carries the message. */
.fluentform .error.text-danger::before {
	content: "\26A0"; /* warning sign */
	flex: 0 0 auto;
	font-size: 1em;
	line-height: 1.45;
}

/* --- Form-level error summary -------------------------------------------
   FluentForms appends server-side and submission errors to .ff-errors-in-stack
   and toggles it with jQuery .show()/.hide(), which writes an inline display.
   `display` is therefore deliberately not set here — doing so would either be
   overridden or would pin the box open. Only appearance is styled. */

.fluentform .ff-errors-in-stack,
.ff-errors-in-stack {
	margin-block-start: var(--wp--preset--spacing--30, 1.25rem);
	padding: var(--wp--preset--spacing--30, 1.25rem);
	background-color: var(--wp--preset--color--base, #f7f4ed);
	border: 1px solid var(--mtsf-error);
	border-inline-start: 4px solid var(--mtsf-error);
	border-radius: var(--mtsf-field-radius);
}

.ff-errors-in-stack .error {
	display: flex;
	align-items: flex-start;
	gap: 0.5em;
	margin: 0;
	font-size: var(--wp--preset--font-size--medium, 1.0625rem);
	font-weight: 500;
	line-height: 1.5;
	color: var(--mtsf-error); /* 6.65:1 on cream — AA */
}

.ff-errors-in-stack .error + .error {
	margin-block-start: 0.5em;
}

.ff-errors-in-stack .error::before {
	content: "\26A0";
	flex: 0 0 auto;
}

/* The dismiss affordance the plugin injects is a bare span; give it a target. */
.ff-errors-in-stack .error-clear {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: var(--mtsf-touch-min);
	min-height: var(--mtsf-touch-min);
	margin-inline-start: auto;
	color: var(--mtsf-error);
}

/* --- Success confirmation ------------------------------------------------
   The plugin gives this role="status" aria-live="polite" and focuses it, so it
   is announced. It is also given tabindex by FluentForms; the focus ring below
   makes that focus visible instead of silent. */

/*
 * Block flow, not flex.
 *
 * The confirmation message is author-editable in the FluentForms settings and
 * this one contains two <p> elements. An earlier revision used `display: flex`
 * here to seat the tick glyph, which promoted each paragraph to a flex item
 * and rendered the message as two side-by-side columns — caught on screen, not
 * in the markup. Keeping normal flow and absolutely positioning the glyph lets
 * the message hold any number of blocks and still stack correctly.
 */
.ff-message-success {
	position: relative;
	margin-block-start: var(--wp--preset--spacing--30, 1.25rem);
	padding: var(--wp--preset--spacing--30, 1.25rem);
	/* Reserve the gutter the glyph sits in. */
	padding-inline-start: calc(var(--wp--preset--spacing--30, 1.25rem) + 1.9rem);
	font-family: var(--wp--preset--font-family--body, "Inter", sans-serif);
	font-size: var(--wp--preset--font-size--medium, 1.0625rem);
	line-height: 1.6;
	color: var(--wp--preset--color--contrast, #14171c); /* 16.35:1 — AAA */
	background-color: var(--wp--preset--color--base-2, #ece6d8);
	border: 1px solid var(--mtsf-success);
	border-inline-start: 4px solid var(--mtsf-success);
	border-radius: var(--mtsf-field-radius);
	/* Replaces the plugin's grey 1px box + drop shadow. */
	box-shadow: none;
}

.ff-message-success::before {
	content: "\2713"; /* check mark — success is not colour-alone */
	position: absolute;
	inset-block-start: var(--wp--preset--spacing--30, 1.25rem);
	inset-inline-start: var(--wp--preset--spacing--30, 1.25rem);
	font-size: 1.15em;
	font-weight: 700;
	/* Matches the panel's line-height so the tick sits on the first text line. */
	line-height: 1.6;
	color: var(--mtsf-success); /* 10.58:1 on sand — AAA */
}

/* The message is author-editable, so trim whatever leading/trailing block the
   editor happens to produce. */
.ff-message-success > :first-child {
	margin-block-start: 0;
}

.ff-message-success > :last-child {
	margin-block-end: 0;
}

.ff-message-success:focus-visible {
	outline: var(--mtsf-focus-w) solid var(--mtsf-error);
	outline-offset: var(--mtsf-focus-o);
}

/* Keep every state legible when the OS overrides colour. */
@media (forced-colors: active) {
	.fluentform .error.text-danger,
	.ff-errors-in-stack .error,
	.ff-message-success {
		border: 1px solid CanvasText;
		color: CanvasText;
	}

	.fluentform .ff-el-form-control:focus-visible {
		outline: 3px solid CanvasText;
	}
}

/* ==========================================================================
   3. Block checkout — radio row / label collision
   ==========================================================================
   THE CLIENT'S BUG, measured rather than eyeballed.

   WooCommerce Blocks positions .wc-block-components-radio-control__input
   absolutely at `left: 16px; top: 30px` (20x20). woocommerce.css then gives
   .wc-block-components-radio-control__option a uniform 8px padding, which does
   not reserve a gutter for that absolutely-positioned control. Measured on
   /checkout/ with a populated cart:

       radio  x 42 -> 62
       label  x 34 -> 466
       overlap 28px

   i.e. the control sat on top of "Interac e-Transfer" — exactly what was
   reported. Both the shipping rows and the payment rows were affected.

   Fix: take the input out of absolute flow and let a flex row lay the pieces
   out, so the gutter can never collapse again regardless of padding.

   The input keeps `position: relative` rather than `static` on purpose. Woo
   draws the checked dot with an absolutely-positioned ::before on the input
   itself; the input must stay a containing block or the dot escapes. Its 20px
   box is also left alone, because those ::before offsets are authored against
   a 20px box and would decentre at any other size.

   Target size (WCAG 2.5.8) is met by the row, not the dot: the whole <label>
   is the activation target and is >=44px tall via woocommerce.css. */

.wc-block-components-radio-control__option {
	display: flex;
	align-items: flex-start;
	gap: 0.75rem;
	position: relative;
}

/*
 * Specificity note: WooCommerce ships
 *   .wc-block-components-radio-control .wc-block-components-radio-control__input
 *   { position: absolute; top: 50%; left: 16px; transform: translateY(-50%) }
 * at (0,2,0). A bare `.wc-block-components-radio-control__input` is (0,1,0) and
 * loses regardless of source order, so the ancestor is repeated here to match
 * at (0,2,0) and win on load order. The transform is reset explicitly: leaving
 * it would drag the control half its own height out of the flex row.
 */
.wc-block-components-radio-control .wc-block-components-radio-control__input {
	position: relative;
	inset: auto; /* clears Woo's top: 50% / left: 16px */
	transform: none; /* clears Woo's translateY(-50%) */
	flex: 0 0 auto;
	margin: 0;
	/* Nudge onto the first text line's optical centre. */
	margin-block-start: 0.15em;
}

.wc-block-components-radio-control__option-layout {
	flex: 1 1 auto;
	min-width: 0; /* let long method names wrap instead of overflowing */
}

/*
 * Shipping rows need a second, more specific reset. WooCommerce's checkout.css
 * ships
 *   .wp-block-woocommerce-checkout
 *   .wc-block-components-shipping-rates-control__package
 *   .wc-block-components-radio-control
 *   .wc-block-components-radio-control__input { top: 16px }
 * at (0,4,0), which beat the `inset: auto` above (0,2,0). Once the control was
 * back in flow that 16px stopped being a centring offset and became a straight
 * 16px shove downwards — measured as the radio sitting 18.2px below its own
 * label's centre on all three shipping rows, while the payment row was fine.
 *
 * Repeating the chain plus __option puts this at (0,5,0) so it wins outright
 * rather than depending on which of the two sheets happens to load last.
 */
.wp-block-woocommerce-checkout
	.wc-block-components-shipping-rates-control__package
	.wc-block-components-radio-control
	.wc-block-components-radio-control__option
	.wc-block-components-radio-control__input {
	top: auto;
}

/* The native control is kept, not replaced, so :checked, keyboard operation
   and forced-colors all keep working for free. It only needs a visible ring —
   Woo ships `outline: none` on it in some states. */
/*
 * Woo ships
 *   .wc-block-components-radio-control .…__input:focus
 *   { outline: color-mix(in srgb, currentcolor 80%, transparent) solid 1px }
 * at (0,3,0) — a 1px near-black hairline. It beat a plain
 * `.…__input:focus-visible` (0,2,0), so keyboard focus was landing on the
 * radio with only that hairline: verified by tabbing to it and reading the
 * computed outline, not by assuming the theme ring applied. Adding __option to
 * the chain takes this to (0,4,0) and restores the 3px accent ring.
 *
 * Accent red measures 6.65:1 against cream and 7.31:1 against the white
 * checked row — both well past the 3:1 WCAG 1.4.11 floor for a focus
 * indicator.
 */
.wc-block-components-radio-control
	.wc-block-components-radio-control__option
	.wc-block-components-radio-control__input:focus-visible {
	outline: var(--mtsf-focus-w, 3px) solid var(--wp--preset--color--accent, #9d2f2a);
	outline-offset: var(--mtsf-focus-o, 2px);
}

/* Checked rows: weight + background, matching woocommerce.css, never colour
   alone — the filled dot is the primary cue and is drawn by Woo. */
.wc-block-components-radio-control__option--checked-option-highlighted
	.wc-block-components-radio-control__label {
	font-weight: 600;
}

/* ==========================================================================
   4. My Account — page width
   ==========================================================================
   /my-account/ is the classic [woocommerce_my_account] shortcode rendered
   inside templates/page.html. Its .entry-content is `is-layout-constrained`,
   so every child is capped at --wp--style--global--content-size (44rem /
   704px). The logged-out screen puts the login and register forms in two
   columns inside that cap, which is what "all compressed and screwed up"
   describes.

   Fixed here rather than in the template, as requested. Redefining the custom
   property on the account page's own .entry-content is the layout engine's
   documented mechanism: children inherit it and resolve their own max-width
   against the new value. Nothing global is touched, so this cannot collide
   with the global width work happening in parallel — and because it points at
   --wide-size rather than a hard number, it follows that work automatically. */

.woocommerce-account .entry-content.is-layout-constrained {
	--wp--style--global--content-size: var(--wp--style--global--wide-size, 76rem);
}

/*
 * Logged-out login/register pair.
 *
 * The real markup is deeper than it looks, which matters:
 *
 *   .woocommerce                       <- woocommerce.css makes this a grid
 *     .woocommerce-notices-wrapper
 *     .u-columns.col2-set              <- the actual pair wrapper
 *       .u-column1.col-1               <- Woo floats these at 48%
 *       .u-column2.col-2
 *
 * woocommerce.css sets `.woocommerce-account .woocommerce` to a
 * `minmax(12rem, 1fr) 3fr` grid for the logged-IN dashboard (narrow nav + wide
 * panel). Logged out there is no nav, so that grid instead puts the notices
 * wrapper in track 1 and the entire login/register pair in track 2 — halving
 * the space the pair gets. Measured at a 1200px viewport: the two forms came
 * out 231px each inside a 482px track, because Woo's own 48% floats were doing
 * the side-by-side work within half the page.
 *
 * So the grid is removed from .woocommerce here and applied to .col2-set,
 * which is the element that actually wraps the two columns.
 */
.woocommerce-account .woocommerce:has(.u-column1) {
	display: block;
}

/*
 * auto-fit + minmax(min(100%, 22rem), 1fr) gives two equal columns when there
 * is room and collapses to one below ~22rem per column, with no media query
 * and no breakpoint to keep in sync with the rest of the theme.
 */
.woocommerce-account .u-columns.col2-set {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr));
	align-items: start;
	gap: var(--wp--preset--spacing--40, 2rem);
}

/*
 * Neutralise Woo's floats. woocommerce-layout.css ships
 *   .woocommerce .col2-set .col-1 { width: 48%; float: left }
 * at (0,3,0); a plain `.woocommerce-account .u-column1` is (0,2,0) and lost,
 * which is what left the columns at 231px of their 482px tracks. This chain is
 * (0,4,0). Woo's small-screen sheet already sets width:100% under its own
 * media query and is left alone.
 */
.woocommerce-account .woocommerce .col2-set .col-1,
.woocommerce-account .woocommerce .col2-set .col-2 {
	float: none;
	width: auto;
	margin: 0;
}

/*
 * Drop Woo's clearfix, which is actively harmful once .col2-set is a grid.
 *
 * woocommerce-layout.css puts `content: " "; display: table` on
 * .col2-set::before and ::after to contain the floats. Generated content in a
 * grid container becomes a grid ITEM, so those two invisible boxes were taking
 * cells (1,1) and (2,2) and displacing the real columns into (1,2) and (2,1) —
 * "Login" appeared on the right and "Register" dropped to a second row. It
 * looked like a grid-placement bug and was actually two empty pseudo-elements.
 *
 * The clearfix has nothing left to contain: the floats are removed above.
 */
.woocommerce-account .woocommerce .col2-set::before,
.woocommerce-account .woocommerce .col2-set::after {
	content: none;
}

/* woocommerce.css caps the form cards at 32rem, which is right for a single
   centred form but leaves a gap inside a grid column. */
.woocommerce-account .u-column1 .woocommerce-form,
.woocommerce-account .u-column2 .woocommerce-form {
	max-width: none;
	height: 100%;
}

/*
 * :has() is unsupported in Firefox < 121 and Safari < 15.4. There .woocommerce
 * keeps woocommerce.css's dashboard grid, but .col2-set still lays the pair out
 * correctly inside it, so the result is a narrower but well-formed two-column
 * block rather than the crushed original. The page-width fix above does not
 * depend on :has() and applies everywhere.
 */
@supports not selector(:has(*)) {
	.woocommerce-account .woocommerce {
		display: block;
	}
}

/* ==========================================================================
   5. Interac e-Transfer badge
   ==========================================================================
   TRADEMARK NOTE. "Interac" and the Interac logo are registered trademarks of
   Interac Corp. Displaying the name to indicate an accepted payment method is
   normal merchant use, but nothing here is a reproduction of their mark. The
   official mark should be taken from Interac's brand centre under their
   merchant guidelines and dropped in at assets/images/interac-etransfer.webp,
   whose slot and dimensions inc/shop.php already defines. See
   docs/pre-launch-checklist.md.

   WHY THIS IS TYPOGRAPHIC AND NOT A DRAWN GLYPH.
   A previous revision drew a dark tile carrying two overlapping warm discs —
   amber and red — as an abstract stand-in. That was a mistake and was replaced:
   two overlapping warm circles is the Mastercard visual idiom, and on a payment
   method selector that is actively harmful, not merely off-brand. A customer
   scanning checkout could read it as "pay by card" and choose this method
   expecting a card form, when it is a manual bank transfer. Avoiding one
   registered logo by accidentally evoking another is the worst of both
   outcomes.

   What replaces it imitates nobody: the gateway's own name, set in the theme's
   display face and palette on a solid chip, exactly as this site sets any other
   label. It is a type treatment, not a logotype.

   WHERE THIS ACTUALLY RENDERS — verified, not assumed:
   The `woocommerce_gateway_icon` filter in inc/shop.php does NOT fire in the
   block checkout; that is documented in shop.php and confirmed here by
   querying the live page, where the payment icon container is empty. So the
   <img> badge appears on the classic order-received page and in admin only.
   The rule below therefore hangs off the gateway's rendered LABEL, which does
   exist in the block checkout, and is what makes a badge appear there at all.

   The gateway is WooCommerce's built-in Cheque gateway, repurposed — hence the
   `cheque` id in the selector. */

/*
 * The badge is now the official Interac mark, supplied by the client and
 * stored at assets/images/interac-etransfer.webp.
 *
 * It replaces the type treatment that stood in while no artwork existed. The
 * mark carries its own yellow ground, which is part of the brand, so it is
 * neither trimmed nor recoloured and it sits on no chip of ours.
 *
 * Drawn as a ::before background-image rather than an <img> because
 * woocommerce_gateway_icon does not fire in the block checkout - confirmed,
 * the payment-icon container is empty there. An empty content string adds
 * nothing to the accessibility tree, and the adjacent real text
 * "Interac e-Transfer" remains the accessible name.
 */
#radio-control-wc-payment-method-options-cheque
	~ .wc-block-components-radio-control__option-layout
	.wc-block-components-payment-method-label {
	display: inline-flex;
	align-items: center;
	gap: 0.5em;
}

#radio-control-wc-payment-method-options-cheque
	~ .wc-block-components-radio-control__option-layout
	.wc-block-components-payment-method-label::before {
	content: "";
	flex: 0 0 auto;
	inline-size: 1.75rem;
	block-size: 1.75rem;
	background-image: url("../images/interac-etransfer.webp");
	background-repeat: no-repeat;
	background-position: center;
	background-size: contain;
	border-radius: 3px;
}

/*
 * Forced-colors mode replaces both background-color and color with the system
 * pair, which would flatten the chip into the row. An explicit border keeps it
 * legible as a discrete object. No gradient, mask or background-image is used
 * anywhere in this badge, so there is nothing else for that mode to strip.
 */
@media (forced-colors: active) {
	#radio-control-wc-payment-method-options-cheque
		~ .wc-block-components-radio-control__option-layout
		.wc-block-components-payment-method-label {
		border: 1px solid CanvasText;
	}
}

/*
 * If the official artwork is ever wired into the block checkout, the <img>
 * becomes the badge and the type treatment must get out of its way, or the
 * mark would sit inside a redundant coloured chip.
 */
.wc-block-components-payment-method-label:has(.mts-gateway-icon) {
	padding: 0;
	color: inherit;
	background-color: transparent;
	border: 0;
	letter-spacing: inherit;
	text-transform: none;
}
