/* Shared by the Reviews List, Reviews Rating and Review Form widgets. */

/* ── Stars ─────────────────────────────────────────────────────────── */
.cct-stars {
	display: inline-flex;
	gap: var(--cct-star-gap, 2px);
	font-size: var(--cct-star-size, 18px);
	line-height: 1;
}

.cct-star {
	position: relative;
	flex: none;
	width: 1em;
	height: 1em;
	color: var(--cct-star-empty, #d9d9d9);
}

.cct-star svg,
.cct-star-input-star svg {
	display: block;
	width: 1em;
	height: 1em;
}

/* Clips a filled star on top of the empty one; the width is the fill share. */
.cct-star-fill {
	position: absolute;
	top: 0;
	inset-inline-start: 0;
	height: 100%;
	overflow: hidden;
	color: var(--cct-star-color, #f5a623);
}

/* ── Reviews List ──────────────────────────────────────────────────── */
.cct-reviews {
	/* Leaves room for a sticky header when a page change scrolls back up. */
	scroll-margin-top: 100px;
	transition: opacity 0.2s;
}

.cct-reviews:focus {
	outline: none;
}

.cct-reviews.cct-reviews-loading {
	opacity: 0.5;
	pointer-events: none;
}

.cct-reviews-list {
	display: flex;
	flex-direction: column;
	gap: 24px;
}

.cct-review {
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.cct-review-header {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	gap: 4px 12px;
}

.cct-review-author {
	font-weight: 600;
}

.cct-review-date {
	font-size: 0.85rem;
	opacity: 0.7;
}

.cct-review-rating {
	display: flex;
}

.cct-review-text > :last-child {
	margin-bottom: 0;
}

.cct-reviews-empty {
	margin: 0;
}

/* ── List / form views ─────────────────────────────────────────────── */
.cct-reviews-list-view[hidden],
.cct-reviews-form-view[hidden] {
	display: none;
}

/* ── Leave a Review button ─────────────────────────────────────────── */
.cct-reviews-add-wrap {
	display: flex;
	flex-direction: column;
}

.cct-reviews-add-top {
	margin-bottom: var(--cct-add-spacing, 24px);
}

.cct-reviews-add-bottom {
	margin-top: var(--cct-add-spacing, 24px);
}

.cct-reviews .cct-reviews-add {
	align-self: flex-start;
	border: none;
	cursor: pointer;
	padding: 10px 18px;
	border-radius: 4px;
	font-size: 0.9rem;
	font-weight: 600;
	color: #fff;
	background: #333;
	transition: background-color 0.2s, color 0.2s, border-color 0.2s;
}

.cct-reviews .cct-reviews-add:hover {
	background: #111;
}

/* ── Back button (form view) ───────────────────────────────────────── */
.cct-reviews-back-wrap {
	display: flex;
	flex-direction: column;
}

.cct-reviews-back-top {
	margin-bottom: var(--cct-back-spacing, 16px);
}

.cct-reviews-back-bottom {
	margin-top: var(--cct-back-spacing, 16px);
}

.cct-reviews .cct-reviews-back {
	align-self: flex-start;
	border: none;
	cursor: pointer;
	padding: 0;
	background: none;
	color: inherit;
	font-size: 0.9rem;
	font-weight: 500;
	text-decoration: underline;
	text-underline-offset: 0.2em;
	transition: color 0.2s, opacity 0.2s;
}

.cct-reviews .cct-reviews-back:hover {
	opacity: 0.7;
}

/* ── Pagination ────────────────────────────────────────────────────── */
/* The row under the reviews: pagination plus, optionally, the button. */
.cct-reviews-footer {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 12px 16px;
	margin-top: 32px;
}

.cct-reviews-footer-start {
	justify-content: flex-start;
}

.cct-reviews-footer-end {
	justify-content: flex-end;
}

.cct-reviews-footer-start .cct-reviews-add-wrap {
	order: -1;
}

.cct-reviews-footer .cct-reviews-add-wrap {
	flex: none;
}

.cct-reviews-pagination {
	display: flex;
	flex: 1 1 auto;
	flex-wrap: wrap;
	align-items: center;
	justify-content: center;
	gap: 6px;
	font-size: 0.9rem;
}

.cct-reviews-pagination .cct-reviews-page {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	box-sizing: border-box;
	min-width: 2.4em;
	padding: 0.5em 0.6em;
	border-radius: 4px;
	color: inherit;
	line-height: 1;
	text-decoration: none;
	transition: background-color 0.2s, color 0.2s, border-color 0.2s;
}

.cct-reviews-pagination a.cct-reviews-page:hover {
	background: rgba(0, 0, 0, 0.08);
}

.cct-reviews-pagination .cct-reviews-page.cct-reviews-page-current {
	background: #333;
	color: #fff;
}

.cct-reviews-pagination .cct-reviews-page.cct-reviews-page-disabled {
	opacity: 0.35;
}

/* ── Reviews Rating ────────────────────────────────────────────────── */
.cct-rating {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: var(--cct-rating-align, flex-start);
	gap: 8px;
}

.cct-rating-average {
	font-weight: 600;
}

/* ── Review Form ───────────────────────────────────────────────────── */
.cct-review-form-title {
	margin: 0 0 16px;
}

.cct-review-form-notice {
	margin: 0;
}

.cct-review-form-fields {
	display: flex;
	flex-direction: column;
	gap: 16px;
}

.cct-review-form-fields[hidden] {
	display: none;
}

.cct-review-form .cct-review-form-field {
	min-width: 0;
	margin: 0;
	padding: 0;
	border: none;
}

/* Name and email side by side; they stack once there's no room for both. */
.cct-review-form-row {
	display: flex;
	flex-wrap: wrap;
	gap: 16px;
}

.cct-review-form-row > .cct-review-form-field {
	flex: 1 1 200px;
}

.cct-review-form .cct-review-form-label {
	display: block;
	margin-bottom: 8px;
	padding: 0;
	font-size: 0.9rem;
	font-weight: 500;
}

.cct-review-form-required {
	color: #e44;
}

.cct-review-form .cct-review-form-input {
	display: block;
	width: 100%;
	box-sizing: border-box;
	border: 1px solid #ddd;
	border-radius: 4px;
	padding: 10px 12px;
	font-size: 0.9rem;
	font-family: inherit;
	background: #fff;
	color: inherit;
	transition: border-color 0.2s, background-color 0.2s;
}

.cct-review-form .cct-review-form-input:focus {
	outline: none;
	border-color: #999;
}

.cct-review-form textarea.cct-review-form-input {
	min-height: 120px;
	resize: vertical;
}

/* Star input: five radios, each drawn as a star. */
.cct-star-input {
	display: inline-flex;
	font-size: var(--cct-star-size, 28px);
	line-height: 1;
}

.cct-star-input-star {
	position: relative;
	overflow: hidden;
	/* Spacing is padding rather than a gap so moving across the stars never
	   leaves the hover state. */
	padding-inline-end: var(--cct-star-gap, 4px);
	color: var(--cct-star-empty, #d9d9d9);
	cursor: pointer;
	transition: color 0.15s;
}

.cct-star-input-star:last-child {
	padding-inline-end: 0;
}

/* The radio stays in place but invisible, so it keeps keyboard focus and the
   browser's "required" prompt. */
.cct-review-form .cct-star-input-star input {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	margin: 0;
	opacity: 0;
	cursor: pointer;
}

.cct-star-input-star:has(input:focus-visible) {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

/* Selected: the checked star and every star before it. The :where() wrappers
   keep all three rules at the same weight so the later one wins. */
.cct-star-input-star:where(:has(input:checked), :has(~ .cct-star-input-star input:checked)) {
	color: var(--cct-star-color, #f5a623);
}

/* Hovering previews a rating in place of the selected one. */
.cct-star-input:where(:has(.cct-star-input-star:hover)) .cct-star-input-star {
	color: var(--cct-star-empty, #d9d9d9);
}

.cct-star-input .cct-star-input-star:where(:hover, :has(~ .cct-star-input-star:hover)) {
	color: var(--cct-star-color, #f5a623);
}

.cct-review-form .cct-review-form-submit {
	align-self: flex-start;
	border: none;
	cursor: pointer;
	padding: 10px 18px;
	border-radius: 4px;
	font-size: 0.9rem;
	font-weight: 600;
	color: #fff;
	background: #333;
	transition: background-color 0.2s, color 0.2s, border-color 0.2s, opacity 0.2s;
}

.cct-review-form .cct-review-form-submit:hover {
	background: #111;
}

.cct-review-form .cct-review-form-submit:disabled {
	opacity: 0.6;
	cursor: wait;
}

/* ── Messages ──────────────────────────────────────────────────────── */
.cct-review-form-message {
	padding: 10px 14px;
	border-radius: 4px;
	font-size: 0.9rem;
}

.cct-review-form-message:empty {
	display: none;
}

/* Below the form for an error; on its own once the form is gone. */
.cct-review-form-fields:not([hidden]) + .cct-review-form-message {
	margin-top: 16px;
}

.cct-review-form-message.cct-message-error {
	color: #a94442;
	background: #f8e6e6;
}

.cct-review-form-message.cct-message-success {
	color: #3c763d;
	background: #e7f4e7;
}
