/**
 * Post Voting & Star Rating
 *
 * Theme-agnostic styling using currentColor and inherited values.
 *
 * @package add
 */

.add-voting-bar {
	margin-top: 3rem;
	padding-top: 2rem;
	border-top: 1px solid currentColor;
	opacity: 0.75;
	transition: opacity 0.15s ease;
}

.add-voting-bar:hover,
.add-voting-bar:focus-within {
	opacity: 1;
}

.add-voting-bar__heading {
	font-size: 0.8125rem;
	font-weight: 600;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	margin: 0 0 1rem;
	color: inherit;
	opacity: 0.6;
}

.add-voting-bar__body {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1.5rem;
	flex-wrap: wrap;
}

/* ---- Vote buttons ---- */

.add-voting-bar__votes {
	display: flex;
	align-items: center;
	gap: 0.375rem;
}

.add-voting-bar__btn {
	display: inline-flex;
	align-items: center;
	gap: 0.35rem;
	padding: 0.5rem 0.875rem;
	border: 1px solid currentColor;
	border-radius: 4px;
	font-size: 0.8125rem;
	font-weight: 500;
	line-height: 1;
	color: inherit;
	background: transparent;
	cursor: pointer;
	font-family: inherit;
	transition: background 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
}

.add-voting-bar__btn:hover {
	background: rgba(128, 128, 128, 0.1);
}

.add-voting-bar__btn:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

.add-voting-bar__btn[aria-pressed="true"] {
	background: rgba(128, 128, 128, 0.15);
	border-color: currentColor;
	font-weight: 600;
}

.add-voting-bar__btn--up[aria-pressed="true"] {
	color: #16a34a;
	border-color: #16a34a;
}

.add-voting-bar__btn--down[aria-pressed="true"] {
	color: #dc2626;
	border-color: #dc2626;
}

.add-voting-bar__btn svg {
	width: 16px;
	height: 16px;
	flex-shrink: 0;
}

.add-voting-bar__score {
	min-width: 1.25rem;
	text-align: center;
}

/* ---- Star rating ---- */

.add-voting-bar__rating {
	display: flex;
	align-items: center;
	gap: 0.125rem;
}

.add-voting-bar__star {
	display: inline-flex;
	padding: 0.125rem;
	border: none;
	background: transparent;
	color: inherit;
	cursor: pointer;
	transition: transform 0.1s ease;
}

.add-voting-bar__star:hover {
	transform: scale(1.15);
}

.add-voting-bar__star:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 2px;
	border-radius: 2px;
}

.add-voting-bar__star svg {
	width: 20px;
	height: 20px;
}

/* Filled state: foreground path visible */
.add-voting-bar__star[aria-checked="true"] .add-voting-bar__star-fg {
	opacity: 1;
}

.add-voting-bar__star[aria-checked="true"] .add-voting-bar__star-bg {
	opacity: 0;
}

/* Hover preview: highlight stars up to hovered one */
.add-voting-bar__rating:hover .add-voting-bar__star .add-voting-bar__star-fg {
	opacity: 0;
}

.add-voting-bar__rating:hover .add-voting-bar__star .add-voting-bar__star-bg {
	opacity: 0.2;
}

.add-voting-bar__rating:hover .add-voting-bar__star.add-voting-bar__star--preview .add-voting-bar__star-fg {
	opacity: 0.6;
}

.add-voting-bar__rating:hover .add-voting-bar__star.add-voting-bar__star--preview .add-voting-bar__star-bg {
	opacity: 0;
}

.add-voting-bar__rating-text {
	font-size: 0.8125rem;
	margin-left: 0.5rem;
	opacity: 0.7;
	white-space: nowrap;
}

.add-voting-bar__avg {
	font-weight: 600;
}

.add-voting-bar__count {
	opacity: 0.7;
}

/* ---- Loading/error states ---- */

.add-voting-bar__btn[disabled],
.add-voting-bar__star[disabled] {
	opacity: 0.4;
	cursor: not-allowed;
}

.add-voting-bar--error .add-voting-bar__heading {
	color: #dc2626;
}

/* ---- Dark mode ---- */

[data-theme="dark"] .add-voting-bar {
	border-top-color: rgba(255, 255, 255, 0.15);
}

[data-theme="dark"] .add-voting-bar__btn {
	border-color: rgba(255, 255, 255, 0.25);
}

[data-theme="dark"] .add-voting-bar__btn:hover {
	background: rgba(255, 255, 255, 0.08);
}

[data-theme="dark"] .add-voting-bar__btn[aria-pressed="true"] {
	background: rgba(255, 255, 255, 0.12);
}

/* ---- Mobile ---- */

@media (max-width: 480px) {
	.add-voting-bar__body {
		flex-direction: column;
		align-items: flex-start;
		gap: 1rem;
	}

	.add-voting-bar__rating {
		width: 100%;
	}
}
