/**
 * WooCommerce's chips (woocommerce/product-filter-chips) — the framework's
 * field look.
 *
 * One block draws the options of a variable product (the Add to Cart with
 * Options block's variation selector) and the shop's filter chips. Its
 * colours are block attributes, written as custom properties on the
 * wrapper, so no theme.json default reaches them and WooCommerce's own
 * fallbacks are the system colours (a black selected chip).
 *
 * A chip is a small field: the box of wage/form-field, read from the same
 * `settings.custom.input.*` tokens (woo-fields.css), at a compact padding
 * of its own. A page whose chips are its main choice sizes them up itself
 * (wage-core's WooCommerce Gift Cards integration). The selected chip is
 * the button's fill. The defaults are set as the block's own properties at
 * no specificity, so a colour picked on the block in the editor (an inline
 * style on the wrapper) still wins. Font size is theme.json's
 * (styles.blocks).
 *
 * Attached to the block, so it loads only where a chip is drawn
 * (features/woocommerce/woocommerce.php).
 */

:where(.wp-block-woocommerce-product-filter-chips) {
	--wc-product-filter-chips-text: currentColor;
	--wc-product-filter-chips-background: var(--wp--custom--input--bg, var(--wp--preset--color--raised));
	--wc-product-filter-chips-border: var(--wp--custom--input--border-color, color-mix(in oklch, var(--wp--preset--color--contrast) 30%, transparent));
	--wc-product-filter-chips-selected-text: var(--wp--preset--color--primary-foreground);
	--wc-product-filter-chips-selected-background: var(--wp--custom--button--background);
	--wc-product-filter-chips-selected-border: var(--wp--custom--button--background);

	/* The field's accent, as on .form-field. */
	--chip-accent: var(--wp--preset--color--secondary);
	--chip-hover-border-color: var(--wp--custom--input--hover-border-color, var(--chip-accent));
	--chip-hover-glow: var(--wp--custom--input--hover-glow, color-mix(in oklch, var(--chip-accent) 14%, transparent));
}

/* ── The chip ──────────────────────────────────────── */

/* Radius and padding set on the block are inline on each chip, and win. */
.wp-block-woocommerce-product-filter-chips .wc-block-product-filter-chips__item {
	min-width: 2.5rem; /* one-letter labels (S, M) keep a chip's shape */
	/* Compact, to sit many to a row in a filter sidebar: tighter than the
	   smallest spacing step, so in ems of the chip's own text. */
	padding: 0.25em 0.75em;
	border: var(--wp--custom--input--border-width, var(--wp--custom--border--width)) solid var(--wc-product-filter-chips-border);
	border-radius: var(--wp--custom--input--radius, var(--wp--preset--border-radius--s));
	background: var(--wc-product-filter-chips-background);
	color: var(--wc-product-filter-chips-text);
	line-height: 1.5;
	text-align: center;
	transition: border-color var(--wp--custom--transition--fast), box-shadow var(--wp--custom--transition--fast), background-color var(--wp--custom--transition--fast), color var(--wp--custom--transition--fast);
}

.wp-block-woocommerce-product-filter-chips .wc-block-product-filter-chips__item[aria-checked="true"] {
	border-color: var(--wc-product-filter-chips-selected-border);
	background: var(--wc-product-filter-chips-selected-background);
	color: var(--wc-product-filter-chips-selected-text);
}

/* Hover: the field's soft glow. */
.wp-block-woocommerce-product-filter-chips .wc-block-product-filter-chips__item:hover:not(:disabled) {
	box-shadow: 0 0 0 4px var(--chip-hover-glow); /* .wage-control's glow */
}
.wp-block-woocommerce-product-filter-chips .wc-block-product-filter-chips__item:hover:not(:disabled):not([aria-checked="true"]) {
	border-color: var(--chip-hover-border-color);
}

/* Focus: the field's sharp ring, for the keyboard only. */
.wp-block-woocommerce-product-filter-chips .wc-block-product-filter-chips__item:focus {
	outline: none;
}
.wp-block-woocommerce-product-filter-chips .wc-block-product-filter-chips__item:focus-visible {
	box-shadow: none;
	outline: 2px solid var(--chip-accent); /* .form-field's ring */
	outline-offset: 2px;
}
