/*
 * BrikFront theme: star ratings in WooCommerce's blocks (product rating in cards and on the product
 * page, review lists, the rating filter, the older product grids). WooCommerce writes them with its
 * icon font, whose @font-face comes with the general stylesheet the theme leaves out, so they read
 * "SSSSS". Here they are drawn with a mask, like the classic stars in woocommerce.css: nothing to
 * download and no late swap. Filled stars take the block's text colour, so a colour picked for the
 * block shows; empty ones a light share of it. WordPress loads this file only on pages where one of
 * these blocks shows something (brikfront_theme_rating_styles()); the editor always has it.
 * The selector list is WooCommerce's own, from every block stylesheet that sets its font. Its
 * "no reviews" star is left out: WooCommerce draws it only in the editor's preview, where the font
 * is loaded.
 */

/* Forced colours (Windows high contrast) would paint both parts as the page background. */
@media (forced-colors: active) {
	:root {
		--bf-star-off: GrayText;
		--bf-star-on: CanvasText;
	}
}

/* The row of five stars. */
:root :is(
	.wc-block-grid__product-rating .star-rating,
	.wp-block-woocommerce-product-review-rating .star-rating,
	.wc-block-grid__product-rating__stars,
	.wc-block-product-review-rating__stars,
	.wc-block-components-product-rating__stars,
	.wc-block-components-product-rating-stars__stars,
	.wc-block-components-review-list-item__rating__stars
) {
	position: relative;
	inline-size: 5em;
	block-size: 1em;
	overflow: hidden;
	background-color: var(--bf-star-off, color-mix(in srgb, currentColor 24%, transparent));
	forced-color-adjust: none;
	mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='m12 2.6 2.9 6.1 6.7.8-4.9 4.6 1.2 6.6L12 17.4l-5.9 3.3 1.2-6.6-4.9-4.6 6.7-.8z'/%3E%3C/svg%3E") 0 0 / 1em 1em repeat-x;
}
/* WooCommerce's glyphs: the empty row, and the filled row in the span. */
:root :is(
	.wc-block-grid__product-rating .star-rating,
	.wp-block-woocommerce-product-review-rating .star-rating,
	.wc-block-grid__product-rating__stars,
	.wc-block-product-review-rating__stars,
	.wc-block-components-product-rating__stars,
	.wc-block-components-product-rating-stars__stars,
	.wc-block-components-review-list-item__rating__stars
)::before,
:root :is(
	.wc-block-grid__product-rating .star-rating,
	.wp-block-woocommerce-product-review-rating .star-rating,
	.wc-block-grid__product-rating__stars,
	.wc-block-product-review-rating__stars,
	.wc-block-components-product-rating__stars,
	.wc-block-components-product-rating-stars__stars,
	.wc-block-components-review-list-item__rating__stars
) span::before {
	content: none;
}
/* The filled share: WooCommerce gives the span its width (4.5 of 5 is 90%) and pushes the span's
   text ("Rated 4.50 out of 5") below the row, where the row clips it. */
:root :is(
	.wc-block-grid__product-rating .star-rating,
	.wp-block-woocommerce-product-review-rating .star-rating,
	.wc-block-grid__product-rating__stars,
	.wc-block-product-review-rating__stars,
	.wc-block-components-product-rating__stars,
	.wc-block-components-product-rating-stars__stars,
	.wc-block-components-review-list-item__rating__stars
) > span {
	position: absolute;
	inset-block: 0;
	inset-inline: 0 auto;
	overflow: hidden;
	background-color: var(--bf-star-on, currentColor);
}

/* The older product grids' add to cart button took a spinner and a tick from the same font. The
   theme's classic buttons show neither: the button fades while the product is added. */
:root .wc-block-grid__product-add-to-cart.wp-block-button .wp-block-button__link:is(.loading, .added)::after {
	content: none;
}
:root .wc-block-grid__product-add-to-cart.wp-block-button .wp-block-button__link.loading {
	opacity: 0.6;
	pointer-events: none;
}
