/* Product star rating redesign - "compact pill" style
   (store-profile feature "rating_redesign"; loaded only on product pages of
   stores that have it, and scoped under .wd-rating).

   Layout:   (★ 4.0)  ★★★★☆  |  2 reviews ›
   - score pill: outlined in the theme accent colour, text in the title's colour
   - stars: bright amber rounded SVG stars, filled to the exact average (4.3 shows 4.3 stars)
   - thin divider, then the review count; the whole row links to #reviews

   Colours: accent and text follow the theme's own variables (Blocksy palette /
   heading colour - the same colour as the product title). Star amber is fixed,
   as in the design, and can be changed with --wd-rating-star. */

.wd-rating {
	--wd-rating-accent: var(--theme-palette-color-1, #1e7a4c);
	--wd-rating-star: #f5a623;
	--wd-rating-empty: #dfe5e2;
	--wd-rating-text: var(--theme-heading-1-color, var(--theme-headings-color, #0f3b26));
	position: relative;
	display: inline-flex;
	align-items: center;
	flex-wrap: nowrap;
	gap: 12px;
	max-width: 100%;
	margin: 6px 0 14px;
	padding: 0;
	line-height: 1;
}

/* Score pill: outlined in the accent colour (no fill), text and star in the
   title's colour */
.wd-rating-score {
	display: inline-flex;
	align-items: center;
	gap: 5px;
	flex: none;
	padding: 4.5px 12px 5.5px 10px;
	border: 1.5px solid var(--wd-rating-accent);
	border-radius: 999px;
	background: transparent;
	color: var(--wd-rating-text);
	font-size: 12px;
	font-weight: 700;
	letter-spacing: .01em;
	line-height: 1;
}
.wd-rating-score svg { display: block; flex: none; width: 12px; height: 12px; }

/* Stars: five rounded SVG stars used as a mask over a hard-edged gradient, so the
   fill stops at the exact average (4.3 fills four stars and 30% of the fifth).
   Size with --wd-rating-star-size. */
.wd-rating-stars {
	--wd-rating-star-size: 18px;
	flex: none;
	display: block;
	position: relative;
	top: .4px;
	width: calc(var(--wd-rating-star-size) * 5);
	height: var(--wd-rating-star-size);
	background: linear-gradient(90deg, var(--wd-rating-star) calc(var(--wd-rating, 0) / 5 * 100%), var(--wd-rating-empty) 0);
	-webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 24'%3E%3Cg fill='black' stroke='black' stroke-width='2.4' stroke-linejoin='round'%3E%3Cpolygon points='12.00,3.00 14.65,8.76 20.94,9.50 16.28,13.79 17.53,20.00 12.00,16.90 6.47,20.00 7.72,13.79 3.06,9.50 9.35,8.76'/%3E%3Cpolygon points='36.00,3.00 38.65,8.76 44.94,9.50 40.28,13.79 41.53,20.00 36.00,16.90 30.47,20.00 31.72,13.79 27.06,9.50 33.35,8.76'/%3E%3Cpolygon points='60.00,3.00 62.65,8.76 68.94,9.50 64.28,13.79 65.53,20.00 60.00,16.90 54.47,20.00 55.72,13.79 51.06,9.50 57.35,8.76'/%3E%3Cpolygon points='84.00,3.00 86.65,8.76 92.94,9.50 88.28,13.79 89.53,20.00 84.00,16.90 78.47,20.00 79.72,13.79 75.06,9.50 81.35,8.76'/%3E%3Cpolygon points='108.00,3.00 110.65,8.76 116.94,9.50 112.28,13.79 113.53,20.00 108.00,16.90 102.47,20.00 103.72,13.79 99.06,9.50 105.35,8.76'/%3E%3C/g%3E%3C/svg%3E") center / 100% 100% no-repeat;
	mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 24'%3E%3Cg fill='black' stroke='black' stroke-width='2.4' stroke-linejoin='round'%3E%3Cpolygon points='12.00,3.00 14.65,8.76 20.94,9.50 16.28,13.79 17.53,20.00 12.00,16.90 6.47,20.00 7.72,13.79 3.06,9.50 9.35,8.76'/%3E%3Cpolygon points='36.00,3.00 38.65,8.76 44.94,9.50 40.28,13.79 41.53,20.00 36.00,16.90 30.47,20.00 31.72,13.79 27.06,9.50 33.35,8.76'/%3E%3Cpolygon points='60.00,3.00 62.65,8.76 68.94,9.50 64.28,13.79 65.53,20.00 60.00,16.90 54.47,20.00 55.72,13.79 51.06,9.50 57.35,8.76'/%3E%3Cpolygon points='84.00,3.00 86.65,8.76 92.94,9.50 88.28,13.79 89.53,20.00 84.00,16.90 78.47,20.00 79.72,13.79 75.06,9.50 81.35,8.76'/%3E%3Cpolygon points='108.00,3.00 110.65,8.76 116.94,9.50 112.28,13.79 113.53,20.00 108.00,16.90 102.47,20.00 103.72,13.79 99.06,9.50 105.35,8.76'/%3E%3C/g%3E%3C/svg%3E") center / 100% 100% no-repeat;
}

/* Review count, after a thin divider. Its ::before stretches the click target
   over the whole row. Text size / weight / colour are deliberately not set here:
   the site's own rule for .woocommerce-review-link (and the theme's link colour)
   decides them, so the count matches the rest of the store. */
.wd-rating-link {
	display: inline-flex;
	align-items: center;
	gap: .3em;
	flex: none;
	min-height: 24px;
	padding-left: 14px;
	border-left: 1.5px solid #cfd8d3;
	line-height: 1;
	text-decoration: none;
	white-space: nowrap;
}
.wd-rating-link::before {
	content: "";
	position: absolute;
	inset: -6px -4px;
	border-radius: 12px;
}
.wd-rating-link::after {
	content: "";
	flex: none;
	width: 6px;
	height: 6px;
	margin-left: 3px;
	border-top: 1.6px solid currentColor;
	border-right: 1.6px solid currentColor;
	transform: rotate(45deg);
	transition: transform .2s ease;
}
/* The theme underlines links on hover; the review count must not be. */
.wd-rating-link,
.wd-rating-link:hover,
.wd-rating-link:focus,
.wd-rating-link:active {
	text-decoration: none !important;
}
.wd-rating:hover .wd-rating-link::after { transform: translateX(3px) rotate(45deg); }
.wd-rating-link:focus-visible {
	outline: 2px solid var(--wd-rating-accent);
	outline-offset: 6px;
	border-radius: 6px;
}

@media (max-width: 400px) {
	.wd-rating { gap: 9px; }
	.wd-rating-link { padding-left: 10px; }
}
@media (prefers-reduced-motion: reduce) {
	.wd-rating-link::after { transition: none; }
}
