/**
 * WPS Cart — token base + accessibility baseline.
 *
 * NAMESPACE: every token this plugin DEFINES is --wpscart-*.
 * The shared --wps-* space belongs to the design system (wps-design) and to
 * the active theme; this stylesheet loads site-wide (the mini-cart drawer and
 * the container block can sit on any page), so defining --wps-text or
 * --wps-radius-card here would repaint every page of the site.
 * Rule: READ --wps-*-set, WRITE --wpscart-*.
 *
 * Fallback chain per token:
 *   --wps-<name>-set (the wps-design bridge) → theme --color-* (Tailwind
 *   v4 @theme) → the WPS palette value (Clean Soft). Every derived
 *   shade uses color-mix(). No hard-coded colours in components.
 *
 * Palette (6 base + warning): page #f5f7f6, surface #ffffff,
 * text #111827, primary/action #2563eb, success/accent #15803d, error #dc2626,
 * warning #b45309.
 */

:root {
	/* --- base colours ------------------------------------------------------ */
	--wpscart-page: var(--wps-page-set, var(--color-background, #f5f7f6));
	--wpscart-surface: var(--wps-surface-set, var(--color-surface, #ffffff));
	--wpscart-text: var(--wps-text-set, var(--color-text, #111827));
	--wpscart-primary: var(--wps-primary-set, var(--color-primary, #2563eb));
	--wpscart-success: var(--wps-success-set, var(--color-success, #15803d));
	--wpscart-error: var(--wps-error-set, var(--color-error, #dc2626));
	--wpscart-warning: var(--wps-warning-set, var(--color-warning, #b45309));
	--wpscart-on-primary: var(--wps-on-primary-set, var(--color-on-primary, #ffffff));

	/* --- derived (color-mix) ----------------------------------------------- */
	--wpscart-field-bg: color-mix(in srgb, var(--wpscart-text) 3%, var(--wpscart-surface));
	--wpscart-muted-bg: color-mix(in srgb, var(--wpscart-text) 6%, var(--wpscart-surface));
	--wpscart-border: color-mix(in srgb, var(--wpscart-text) 14%, var(--wpscart-surface));
	--wpscart-border-strong: color-mix(in srgb, var(--wpscart-text) 30%, var(--wpscart-surface));
	--wpscart-text-muted: color-mix(in srgb, var(--wpscart-text) 62%, var(--wpscart-surface));
	--wpscart-text-soft: color-mix(in srgb, var(--wpscart-text) 46%, var(--wpscart-surface));

	--wpscart-accent-wash: color-mix(in srgb, var(--wpscart-success) 8%, var(--wpscart-surface));
	--wpscart-accent-border: color-mix(in srgb, var(--wpscart-success) 30%, var(--wpscart-surface));
	--wpscart-badge-bg: color-mix(in srgb, var(--wpscart-success) 14%, var(--wpscart-surface));
	--wpscart-badge-text: color-mix(in srgb, var(--wpscart-success) 82%, #000);
	--wpscart-badge-border: color-mix(in srgb, var(--wpscart-success) 45%, var(--wpscart-surface));
	--wpscart-total: color-mix(in srgb, var(--wpscart-success) 72%, #000);
	--wpscart-success-bg: var(--wpscart-accent-wash);

	--wpscart-primary-hover: color-mix(in srgb, var(--wpscart-primary) 88%, #000);
	--wpscart-primary-active: color-mix(in srgb, var(--wpscart-primary) 78%, #000);
	--wpscart-focus: color-mix(in srgb, var(--wpscart-primary) 45%, #fff);
	--wpscart-focus-ring: color-mix(in srgb, var(--wpscart-primary) 38%, transparent);

	--wpscart-error-bg: color-mix(in srgb, var(--wpscart-error) 7%, var(--wpscart-surface));
	--wpscart-warning-bg: color-mix(in srgb, var(--wpscart-warning) 10%, var(--wpscart-surface));

	/* --- shape ------------------------------------------------------------- */
	--wpscart-radius: var(--wps-radius-set, var(--radius, 10px));
	--wpscart-radius-sm: var(--wps-radius-sm-set, var(--radius-sm, 6px));

}

.wps-cart {
	color: var(--wpscart-text);
	box-sizing: border-box;
}

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

/* --- accessibility baseline (applies to all wps-cart blocks) ------------- */

.wps-cart :focus-visible {
	outline: 2px solid var(--wpscart-focus);
	outline-offset: 2px;
	box-shadow: 0 0 0 3px var(--wpscart-focus-ring);
}

.wps-cart .wps-cart__btn,
.wps-cart button.wps-cart__control,
.wps-cart [role="button"].wps-cart__control {
	min-height: 44px;
	min-width: 44px;
}

@media ( prefers-reduced-motion: reduce ) {
	.wps-cart *,
	.wps-cart *::before,
	.wps-cart *::after {
		animation-duration: 0.001ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: 0.001ms !important;
		scroll-behavior: auto !important;
	}
}

@media ( forced-colors: active ) {
	.wps-cart {
		--wpscart-border: CanvasText;
	}
	.wps-cart :focus-visible {
		outline: 2px solid CanvasText;
	}
}

/* --- component layer ---------------------------------------------------- */

/* Foundation engine probe (test element). */
.wps-cart__probe {
	font-size: 0.85em;
	color: var(--wpscart-text-muted);
	background: var(--wpscart-muted-bg);
	border: 1px solid var(--wpscart-border);
	border-radius: var(--wpscart-radius-sm);
	padding: 0.5em 0.75em;
}

/* --- native cart tweaks -------------------------------------------------- */

/*
 * Product titles in the cart and mini-cart are links, but underlining them just
 * invites clicks away from checkout. Drop the underline; use a slightly heavier
 * weight to keep them distinct instead.
 */
.wc-block-components-product-name {
	text-decoration: none;
	font-weight: 600;
}
.wc-block-components-product-name:hover,
.wc-block-components-product-name:focus-visible {
	text-decoration: none;
}

/* --- settings of the product rows and the order button ------------------ */

/* The short description is off: only the name, the chosen variations and
   the price stay in the row. */
body.wps-cart-no-desc :is(.wc-block-mini-cart__items, .wc-block-cart-items) .wc-block-components-product-metadata__description {
	display: none;
}

/* Large order button (without WPS Design; with it the panel decides). */
body.wps-cart-cta-large :is(.wc-block-cart__submit-button, .wc-block-mini-cart__footer-checkout) {
	min-block-size: var(--wpscart-cta-height, 56px);
	font-size: var(--wpscart-cta-size, 18px);
}

/* The copy of the order button WooCommerce pins to the bottom of a phone
   screen is off: the button stays in the totals card. */
@media (max-width: 782px) {
	body.wps-cart-no-sticky .wc-block-cart .wc-block-cart__submit-container--sticky {
		display: none;
	}
}
