/**
 * ZYMARG OS — Component: WooCommerce notices (brand skin)
 * -----------------------------------------------------------------------------
 * WHAT THIS FIXES
 * Every "saved" / "error" message in the account area — Profile save, Address
 * save, login, cart, checkout — is printed by WooCommerce core through
 * wc_add_notice(). Until now nothing in this theme styled those classes, so
 * the messages rendered in WooCommerce's stock grey-box look while the rest of
 * the account UI was fully branded. This file brands them.
 *
 * TOKENS ONLY
 * Every value below references a --zym-* token from the shared `zymarg-tokens`
 * stylesheet (ZYMARG DESIGN TOKENS v3, PART 1 — FRONT END DESIGN). No raw
 * colour or size is written in a rule (token rule 5).
 *
 * STATE IS NEVER COLOUR ALONE (token rule 9)
 * Each notice type carries its own icon in addition to its colour:
 *   success -> check in a circle, brand primary
 *   info    -> i in a circle, brand primary
 *   error   -> alert triangle, --zym-color-danger
 * Success and info intentionally share the brand purple: PART 1 has no green,
 * and "never introduce a new purple, red or orange" forbids inventing one. The
 * icon is what separates them.
 *
 * SPECIFICITY NOTE (token rule 7 — reasserting over core)
 * Selectors are prefixed with `body` purely to beat WooCommerce core's
 * `.woocommerce-error, .woocommerce-info, .woocommerce-message` block
 * (grey #f6f6f6 fill, 3px top border, glyph ::before), because woocommerce.css
 * is enqueued after the theme's stylesheets. No !important is used.
 *
 * Depends on: zymarg-tokens
 *
 * @package ZYMARG_OS
 */

/* Collapse WooCommerce's empty notice wrapper so it never adds dead space
   above a panel. Core prints it on every Woo template, empty or not. */
body .woocommerce-notices-wrapper:empty {
	display: none;
}

/* ---- Shared shell ---------------------------------------------------- */

body .woocommerce-message,
body .woocommerce-info,
body .woocommerce-error {
	/* Component-local channels. Dark mode repoints these further down; the
	   --zym-* tokens themselves are never redefined (token rule 5). */
	--zn-accent:  var(--zym-color-primary);
	--zn-surface: var(--zym-color-surface);
	--zn-tint:    var(--zym-color-bg);
	--zn-text:    var(--zym-color-text);
	--zn-border:  var(--zym-color-border);

	position: relative;
	display: block;
	overflow: hidden;
	width: auto;
	margin: 0 0 var(--zym-space-8);
	/* Left padding reserves room for the state icon. */
	padding: var(--zym-space-6) var(--zym-space-7) var(--zym-space-6) var(--zym-space-12);
	border: 1px solid var(--zn-border);
	border-radius: var(--zym-radius-card);
	background: var(--zn-tint);
	background: color-mix(in srgb, var(--zn-accent) 6%, var(--zn-surface));
	box-shadow: var(--zym-shadow-card);
	color: var(--zn-text);
	font-family: var(--zym-font);
	font-size: var(--zym-font-size-sm);
	font-weight: var(--zym-font-weight-medium);
	line-height: 1.55;
	list-style: none outside;
	word-wrap: break-word;
}

/* 3px brand strip on the top edge — the same treatment the brand uses on a
   panel header. Replaces core's flat border-top. */
body .woocommerce-message::after,
body .woocommerce-info::after,
body .woocommerce-error::after {
	content: "";
	position: absolute;
	inset: 0 0 auto 0;
	height: 3px;
	background: var(--zn-accent);
}

/* ---- State icon ------------------------------------------------------ */
/* Core prints a WooCommerce-font glyph in ::before; it is replaced by a masked
   SVG so the icon takes its colour from the token. The colour inside the data
   URI is mask geometry only — it is never painted. */
body .woocommerce-message::before,
body .woocommerce-info::before,
body .woocommerce-error::before {
	content: "";
	position: absolute;
	top: var(--zym-space-6);
	left: var(--zym-space-7);
	width: var(--zym-font-size-md);
	height: var(--zym-font-size-md);
	background-color: var(--zn-accent);
	-webkit-mask-position: center;
	        mask-position: center;
	-webkit-mask-repeat: no-repeat;
	        mask-repeat: no-repeat;
	-webkit-mask-size: contain;
	        mask-size: contain;
}

/* ---- Success ("Address updated.", "Account details changed…") -------- */

body .woocommerce-message::before {
	-webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M8 12.5l2.5 2.5L16 9.5'/%3E%3C/svg%3E");
	        mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M8 12.5l2.5 2.5L16 9.5'/%3E%3C/svg%3E");
}

/* ---- Info ------------------------------------------------------------ */

body .woocommerce-info::before {
	-webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 11v5'/%3E%3Cpath d='M12 7.6v.1'/%3E%3C/svg%3E");
	        mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 11v5'/%3E%3Cpath d='M12 7.6v.1'/%3E%3C/svg%3E");
}

/* ---- Error ("Phone number is required.", failed login, …) ------------ */

body .woocommerce-error {
	--zn-accent: var(--zym-color-danger);
}

body .woocommerce-error::before {
	-webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 3.8L21 20H3z'/%3E%3Cpath d='M12 10v4'/%3E%3Cpath d='M12 17.2v.1'/%3E%3C/svg%3E");
	        mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 3.8L21 20H3z'/%3E%3Cpath d='M12 10v4'/%3E%3Cpath d='M12 17.2v.1'/%3E%3C/svg%3E");
}

/* Multi-error lists (WooCommerce prints <ul class="woocommerce-error">).
   The icon marks the block; each row stays readable without its own bullet. */
body .woocommerce-error li,
body .woocommerce-message li,
body .woocommerce-info li {
	margin: 0;
	padding: 0;
	list-style: none;
}

body .woocommerce-error li + li,
body .woocommerce-message li + li,
body .woocommerce-info li + li {
	margin-top: var(--zym-space-2);
}

/* Field names WooCommerce bolds inside its messages. */
body .woocommerce-error strong,
body .woocommerce-message strong,
body .woocommerce-info strong {
	color: var(--zym-color-dark);
	font-weight: var(--zym-font-weight-semibold);
}

/* ---- Links inside a notice ------------------------------------------- */

body .woocommerce-message a:not(.button),
body .woocommerce-info a:not(.button),
body .woocommerce-error a:not(.button) {
	color: var(--zn-accent);
	font-weight: var(--zym-font-weight-semibold);
	text-decoration: none;
	transition: opacity var(--zym-motion-fast) var(--zym-ease);
}

body .woocommerce-message a:not(.button):hover,
body .woocommerce-info a:not(.button):hover,
body .woocommerce-error a:not(.button):hover {
	opacity: 0.92;
}

/* Keyboard focus only, using the brand ring (token rule 8). */
body .woocommerce-message a:focus-visible,
body .woocommerce-info a:focus-visible,
body .woocommerce-error a:focus-visible,
body .woocommerce-message .button:focus-visible,
body .woocommerce-info .button:focus-visible,
body .woocommerce-error .button:focus-visible {
	outline: 3px solid var(--zym-color-primary);
	outline-offset: 2px;
	box-shadow: var(--zym-focus-ring);
}

/* ---- Inline action button ("View cart", "Continue shopping") ---------- *
 * The gradient itself already comes from components/buttons.css; this only
 * aligns it inside the notice and matches the front end button radius.
 * ------------------------------------------------------------------- */

body .woocommerce-message .button,
body .woocommerce-info .button,
body .woocommerce-error .button {
	float: right;
	margin: 0 0 0 var(--zym-gap-small);
	padding: var(--zym-space-4) var(--zym-space-9);
	border-radius: var(--zym-radius-button);
	font-size: var(--zym-font-size-sm);
	font-weight: var(--zym-font-weight-semibold);
	line-height: 1.2;
}

/* ---- Mobile -------------------------------------------------------- */

@media (max-width: 767px) {
	body .woocommerce-message,
	body .woocommerce-info,
	body .woocommerce-error {
		padding: var(--zym-space-5) var(--zym-space-5) var(--zym-space-5) var(--zym-space-11);
	}

	body .woocommerce-message::before,
	body .woocommerce-info::before,
	body .woocommerce-error::before {
		top: var(--zym-space-5);
		left: var(--zym-space-5);
	}

	/* A floated button next to two lines of text gets cramped under 768px. */
	body .woocommerce-message .button,
	body .woocommerce-info .button,
	body .woocommerce-error .button {
		float: none;
		display: inline-block;
		margin: var(--zym-space-5) 0 0;
	}
}

/* ---- Dark scheme ----------------------------------------------------- *
 * The --zym-* palette is light-mode only, so the notice's local channels are
 * repointed at the theme's dark tokens (set on <html data-theme>), which is
 * how every other component in this theme flips. No --zym-* value is changed.
 * ------------------------------------------------------------------- */

[data-theme="dark"] body .woocommerce-message,
[data-theme="dark"] body .woocommerce-info,
[data-theme="dark"] body .woocommerce-error {
	--zn-surface: var(--color-surface-low);
	--zn-tint:    var(--color-surface-container);
	--zn-text:    var(--color-text-body);
	--zn-border:  var(--color-outline-variant);
}

[data-theme="dark"] body .woocommerce-message,
[data-theme="dark"] body .woocommerce-info {
	--zn-accent: var(--color-primary);
}

@media (prefers-color-scheme: dark) {
	[data-theme="auto"] body .woocommerce-message,
	[data-theme="auto"] body .woocommerce-info,
	[data-theme="auto"] body .woocommerce-error {
		--zn-surface: var(--color-surface-low);
		--zn-tint:    var(--color-surface-container);
		--zn-text:    var(--color-text-body);
		--zn-border:  var(--color-outline-variant);
	}

	[data-theme="auto"] body .woocommerce-message,
	[data-theme="auto"] body .woocommerce-info {
		--zn-accent: var(--color-primary);
	}
}

/* ---- Reduced motion -------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
	body .woocommerce-message a:not(.button),
	body .woocommerce-info a:not(.button),
	body .woocommerce-error a:not(.button) {
		transition: none;
	}
}


/* ===========================================================================
 * 5. BLOCK CART & CHECKOUT NOTICES (the AJAX path)
 *
 * Everything above targets WooCommerce's classic notice markup
 * (.woocommerce-message / -info / -error). Those classes are branded no matter
 * when they enter the DOM — CSS is class-based, so a notice injected by AJAX
 * (the account SPA swapping a section, a classic cart update) is styled the
 * instant it appears, with no JS hook needed.
 *
 * The Cart and Checkout BLOCKS are the real gap. They never render the classic
 * classes at all: they mount their own React banner,
 * .wc-block-components-notice-banner, client-side after hydration. That is why
 * a message there can appear a second or two after the page settles, wearing
 * WooCommerce's own palette instead of the brand's.
 *
 * Specificity: core ships `.wc-block-components-notice-banner` (0,1,0) and
 * modifiers like `.wc-block-components-notice-banner.is-error` (0,2,0) from
 * wc-blocks-style, which loads after the theme. The `body` prefix here lifts
 * each rule one class above its core counterpart without !important.
 * ======================================================================== */

body .wc-block-components-notice-banner {
	/* Local channels, repointed per state below. Never redefines a --zym-* value. */
	--zn-accent:  var(--zym-color-primary);
	--zn-surface: var(--zym-color-surface);
	--zn-text:    var(--zym-color-text);

	/* Overrides core's white fill, 1px full border and 4px radius. */
	background: var(--zn-surface);
	background: color-mix(in srgb, var(--zn-accent) 6%, var(--zn-surface));
	border: 1px solid color-mix(in srgb, var(--zn-accent) 28%, transparent);
	border-radius: var(--zym-radius-card);
	box-shadow: var(--zym-shadow-card);
	color: var(--zn-text);
	padding: var(--zym-space-5) var(--zym-space-7);
	margin: 0 0 var(--zym-space-8);
	gap: var(--zym-gap-small);
	font-family: var(--zym-font);
	font-size: var(--zym-font-size-sm);
	font-weight: var(--zym-font-weight-medium);
}

/*
 * Core tints the inline SVG per state; follow the local accent instead.
 *
 * The state class MUST be repeated in each of these selectors. Core ships
 * `.wc-block-components-notice-banner.is-success > svg` (0,2,1), so a plain
 * `body .wc-block-components-notice-banner > svg` (0,1,2) LOSES the cascade on
 * class count and the icon stays WooCommerce green. Verified in a browser.
 */
body .wc-block-components-notice-banner.is-success > svg,
body .wc-block-components-notice-banner.is-error > svg,
body .wc-block-components-notice-banner.is-warning > svg,
body .wc-block-components-notice-banner.is-info > svg,
body .wc-block-components-notice-banner > svg {
	fill: var(--zn-accent);
	background: transparent;
}

body .wc-block-components-notice-banner__content {
	color: inherit;
	font-size: inherit;
}

/*
 * Per-state accent.
 *
 * border-color is re-declared in each state rule on purpose. Core sets it on
 * `.wc-block-components-notice-banner.is-success` (0,2,0), which outranks the
 * shorthand `border` in the base rule above (0,1,1) on class count, so without
 * this the shell kept WooCommerce's green/red/blue edge. Same cascade trap as
 * the icon fill. Verified in a browser.
 *
 * Success and info share the brand accent, as in the classic notices above.
 */
body .wc-block-components-notice-banner.is-success,
body .wc-block-components-notice-banner.is-info {
	--zn-accent: var(--zym-color-primary);
	border-color: color-mix(in srgb, var(--zn-accent) 28%, transparent);
}

body .wc-block-components-notice-banner.is-warning {
	--zn-accent: var(--zym-color-warning);
	border-color: color-mix(in srgb, var(--zn-accent) 28%, transparent);
}

body .wc-block-components-notice-banner.is-error {
	--zn-accent: var(--zym-color-danger);
	border-color: color-mix(in srgb, var(--zn-accent) 28%, transparent);
}

/* Links and the dismiss control inside a block notice. */
body .wc-block-components-notice-banner a:not(.button) {
	color: var(--zym-color-primary);
	text-decoration: none;
}

body .wc-block-components-notice-banner .wc-block-components-button:focus-visible,
body .wc-block-components-notice-banner a:focus-visible {
	outline: none;
	box-shadow: var(--zym-focus-ring);
	border-radius: var(--zym-radius-chip);
}

/*
 * Inline field validation in the Checkout block ("Please enter a valid...").
 * Core renders this in its own red; align it with the palette's single red so a
 * failed checkout field matches a failed account field.
 */
body .wc-block-components-validation-error {
	color: var(--zym-color-danger);
	font-family: var(--zym-font);
	font-size: var(--zym-font-size-xs);
	font-weight: var(--zym-font-weight-medium);
}

body .wc-block-components-validation-error > p {
	color: inherit;
}

/* ---- Dark scheme ------------------------------------------------------- */
[data-theme="dark"] body .wc-block-components-notice-banner {
	--zn-surface: var(--color-surface-container);
	--zn-text:    var(--color-text-body);
}

[data-theme="dark"] body .wc-block-components-notice-banner.is-success,
[data-theme="dark"] body .wc-block-components-notice-banner.is-info {
	--zn-accent: var(--color-primary);
}

@media (prefers-color-scheme: dark) {
	[data-theme="auto"] body .wc-block-components-notice-banner {
		--zn-surface: var(--color-surface-container);
		--zn-text:    var(--color-text-body);
	}

	[data-theme="auto"] body .wc-block-components-notice-banner.is-success,
	[data-theme="auto"] body .wc-block-components-notice-banner.is-info {
		--zn-accent: var(--color-primary);
	}
}
