/**
 * Star ratings — the input and the read-only average.
 *
 * Two components that look like one thing. `.mim-rate` is five radios a person
 * clicks; `.mim-rate-out` is a static average with no controls in it at all.
 * They share the star outline and the gold, and nothing else.
 *
 * Every colour is a custom property so the Elementor controls can retune the
 * whole thing without a rule here changing.
 */

.mim-rate,
.mim-rate-out {
	--mim-star-on: #FF9E0B;
	--mim-star-off: rgba(37, 51, 78, 0.22);
	--mim-star-glow: rgba(255, 158, 11, 0.9);
	--mim-star-size: 26px;
}

/* ═══════════════════════════════════════════════════════════
   The input
   ═══════════════════════════════════════════════════════════ */

.mim-rate {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 10px 12px;
	font-family: var(--mim-font, inherit);
}

.mim-rate__label {
	font-size: 13.5px;
	font-weight: 700;
	color: var(--mim-account-ink, #25334E);
}

/* Reversed, because the source order is 5 → 1 so that `~` can reach the
   lower stars. This puts them back the way they are read. */
.mim-rate__stars {
	display: flex;
	flex-direction: row-reverse;
	justify-content: flex-end;
	align-items: center;
	gap: 4px;
}

/* Clipped rather than hidden: a `display: none` radio cannot be focused, and
   the keyboard would lose the group entirely. Stated twice because a theme
   only has to win once to put the native circle back on the page. */
.mim-rate__stars .mim-rate__input,
input.mim-rate__input {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	border: 0;
	opacity: 0;
	overflow: hidden;
	clip-path: inset(50%);
	appearance: none;
	-webkit-appearance: none;
}

.mim-rate__stars .mim-rate__pick,
label.mim-rate__pick {
	position: relative;
	display: inline-flex;
	box-sizing: border-box;
	width: auto;
	margin: 0;
	padding: 0;
	line-height: 0;
	cursor: pointer;
	transition: transform 0.25s ease;
}

.mim-rate__star {
	display: block;
	width: var(--mim-star-size);
	height: var(--mim-star-size);
	fill: var(--mim-star-off);
	transition: fill 0.25s ease, filter 0.25s ease;
}

/* ── Chosen ───────────────────────────────────────────────── */

/* The checked star and every star printed after it — which, in the reversed
   source, means every star below it. */
.mim-rate__input:checked ~ .mim-rate__pick .mim-rate__star {
	fill: var(--mim-star-on);
	filter: drop-shadow(0 0 10px var(--mim-star-glow));
}

/* ── Hovering ─────────────────────────────────────────────── */

/* Hover has to beat the checked state, or dragging across a lower star while
   a higher one is set would show both lit and neither meaning anything. */
.mim-rate__stars:hover .mim-rate__input:checked ~ .mim-rate__pick .mim-rate__star {
	fill: var(--mim-star-off);
	filter: none;
}

.mim-rate__stars .mim-rate__pick:hover .mim-rate__star,
.mim-rate__stars .mim-rate__pick:hover ~ .mim-rate__pick .mim-rate__star {
	fill: var(--mim-star-on);
	filter: drop-shadow(0 0 14px var(--mim-star-glow));
}

.mim-rate__stars .mim-rate__pick:hover {
	transform: scale(1.16);
}

.mim-rate__input:focus-visible + .mim-rate__pick {
	outline: 2px solid var(--mim-star-on);
	outline-offset: 3px;
	border-radius: 4px;
}

/* ── The moment it lands ──────────────────────────────────── */

/* One pulse on the star that was clicked, and nothing else. The original had
   every star pulsing forever, which turned a settled choice into something
   that still looked like it was waiting to be made. */
.mim-rate.is-saved .mim-rate__input:checked + .mim-rate__pick .mim-rate__star {
	animation: mim-star-pop 0.5s ease;
}

@keyframes mim-star-pop {
	0%   { transform: scale(1); }
	45%  { transform: scale(1.35); filter: drop-shadow(0 0 22px var(--mim-star-glow)); }
	100% { transform: scale(1); }
}

.mim-rate.is-busy {
	opacity: 0.6;
	pointer-events: none;
}

/* ── Locked out ───────────────────────────────────────────── */

.mim-rate--locked .mim-rate__pick {
	cursor: default;
}

.mim-rate--locked .mim-rate__stars:hover .mim-rate__pick .mim-rate__star,
.mim-rate--locked .mim-rate__pick:hover ~ .mim-rate__pick .mim-rate__star {
	fill: var(--mim-star-off);
	filter: none;
}

.mim-rate--locked .mim-rate__pick:hover {
	transform: none;
}

/* ── Meta and status ──────────────────────────────────────── */

.mim-rate__meta {
	display: inline-flex;
	align-items: baseline;
	gap: 5px;
	font-size: 12.5px;
	color: var(--mim-account-muted, rgba(37, 51, 78, 0.6));
}

.mim-rate__meta strong {
	font-size: 15px;
	font-weight: 800;
	color: var(--mim-account-ink, #25334E);
}

/* Full width so it drops to its own line under the stars rather than
   squeezing them. Empty and unstyled until there is something to say. */
.mim-rate__status {
	flex: 1 0 100%;
	margin: 0;
	font-size: 12.5px;
	line-height: 1.6;
	color: var(--mim-account-muted, rgba(37, 51, 78, 0.6));
}

.mim-rate__status:empty {
	display: none;
}

.mim-rate__status.is-error {
	color: #D9534F;
}

.mim-rate__status.is-ok {
	color: #2E7D57;
}

/* ═══════════════════════════════════════════════════════════
   The read-only average

   Two identical rows of stars, one clipped to a percentage width over the
   other. Whole-star rounding would show 4.3 as either 4 or 5 — a score nobody
   voted for, printed next to the real number that disagrees with it.
   ═══════════════════════════════════════════════════════════ */

.mim-rate-out {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	--mim-star-size: 15px;
}

.mim-rate-out__track {
	position: relative;
	display: inline-flex;
	gap: 2px;
	line-height: 0;
}

.mim-rate-out__track .mim-rate__star {
	width: var(--mim-star-size);
	height: var(--mim-star-size);
	fill: var(--mim-star-off);
}

.mim-rate-out__fill {
	position: absolute;
	inset-block-start: 0;
	inset-inline-start: 0;
	display: inline-flex;
	gap: 2px;
	overflow: hidden;
	line-height: 0;
	pointer-events: none;
}

.mim-rate-out__fill .mim-rate__star {
	flex: 0 0 auto;
	fill: var(--mim-star-on);
}

.mim-rate-out__count {
	font-size: 11.5px;
	color: var(--mim-account-muted, rgba(37, 51, 78, 0.55));
}

@media (prefers-reduced-motion: reduce) {
	.mim-rate__pick,
	.mim-rate__star {
		transition: none;
	}

	.mim-rate__pick:hover,
	.mim-rate.is-saved .mim-rate__input:checked + .mim-rate__pick .mim-rate__star {
		transform: none;
		animation: none;
	}
}
