/**
 * Wix Reviews: star summaries (cards, product page) and the reviews list.
 * Colours come from the storefront design tokens (wixhc-tokens.css) with
 * --wixhc-star-* tokens for the stars; nothing else here is hard-wired.
 *
 * @package Headless_Connect_For_Wix
 */

.wixhc-stars-summary,
.wixhc-reviews {
	--wixhc-star-on: #d4911c;
	--wixhc-star-off: var(--wixhc-border-strong);
	--wixhc-star-size: 1em;
}

/* ---------- stars: an outline row with a clipped filled row on top ---------- */
.wixhc-stars {
	position: relative;
	display: inline-block;
	font-size: var(--wixhc-star-size);
	line-height: 1;
	letter-spacing: 0.08em;
	white-space: nowrap;
	vertical-align: middle;
}
.wixhc-stars::before {
	content: "★★★★★";
	color: var(--wixhc-star-off);
}
.wixhc-stars__fill {
	position: absolute;
	inset: 0 auto 0 0;
	overflow: hidden;
}
.wixhc-stars__fill::before {
	content: "★★★★★";
	color: var(--wixhc-star-on);
}

.wixhc-stars-summary {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	margin: 0;
	color: inherit;
	text-decoration: none;
	font-size: 0.95em;
}
a.wixhc-stars-summary:hover .wixhc-stars-summary__count { text-decoration: underline; }
.wixhc-stars-summary__avg { font-weight: 600; }
.wixhc-stars-summary__count { color: var(--wixhc-muted); }
.wixhc-card__body > .wixhc-stars-summary { margin: 2px 0 6px; }

/* ---------- the list ---------- */
.wixhc-reviews { display: flex; flex-direction: column; gap: 18px; }
.wixhc-reviews [hidden] { display: none !important; }
.wixhc-reviews__heading { margin-top: 1.5em; }

.wixhc-reviews__summary {
	display: grid;
	grid-template-columns: auto 1fr;
	gap: 4px 24px;
	align-items: center;
	padding: var(--wixhc-space-5);
	border: 1px solid var(--wixhc-border);
	border-radius: var(--wixhc-radius-l);
	background: var(--wixhc-surface);
	color: var(--wixhc-ink);
}
.wixhc-reviews__average { display: flex; align-items: center; gap: 10px; margin: 0; --wixhc-star-size: 1.3em; }
.wixhc-reviews__average-num { font-size: 2.2em; font-weight: 700; line-height: 1; }
.wixhc-reviews__count { margin: 0; color: var(--wixhc-muted); grid-column: 1; }
.wixhc-reviews__bars { list-style: none; margin: 0; padding: 0; grid-column: 2; grid-row: 1 / span 2; }
.wixhc-reviews .wixhc-reviews__bar {
	display: grid;
	grid-template-columns: 2.5em 1fr 2.5em;
	align-items: center;
	gap: 8px;
	width: 100%;
	min-height: 0;
	padding: 2px 0;
	border: 0;
	background: none;
	color: inherit;
	border-radius: var(--wixhc-radius-s);
	font-weight: 400;
}
.wixhc-reviews .wixhc-reviews__bar:hover:not(:disabled) { background: var(--wixhc-surface-alt); }
.wixhc-reviews .wixhc-reviews__bar:disabled { cursor: default; opacity: 0.6; }
.wixhc-reviews__bar-track { height: 8px; border-radius: var(--wixhc-radius-pill); background: var(--wixhc-surface-alt); box-shadow: inset 0 0 0 1px var(--wixhc-border); overflow: hidden; }
.wixhc-reviews__bar-fill { display: block; height: 100%; background: var(--wixhc-star-on); }
.wixhc-reviews__bar-n { text-align: right; font-variant-numeric: tabular-nums; color: var(--wixhc-muted); }

.wixhc-reviews__toolbar { display: flex; flex-wrap: wrap; gap: 12px 18px; align-items: flex-end; }
.wixhc-reviews__control { display: inline-flex; flex-direction: column; gap: 4px; font-size: 0.9em; }
.wixhc-reviews__media-only { flex-direction: row; align-items: center; gap: 6px; }

.wixhc-reviews__list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.wixhc-review {
	padding: var(--wixhc-space-5);
	border: 1px solid var(--wixhc-border);
	border-radius: var(--wixhc-radius-l);
	background: var(--wixhc-surface);
	color: var(--wixhc-ink);
}
.wixhc-review__head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; }
.wixhc-review__title { margin: 0; font-size: 1.05em; }
.wixhc-review__meta { display: flex; flex-wrap: wrap; gap: 4px 12px; margin: 6px 0 0; font-size: 0.875em; color: var(--wixhc-muted); }
.wixhc-review__author { font-weight: 600; color: inherit; }
.wixhc-review__verified {
	padding: 0 8px;
	border-radius: var(--wixhc-radius-pill);
	background: var(--wixhc-success-soft);
	color: var(--wixhc-success);
	font-weight: 600;
}
.wixhc-review__body { margin: 10px 0 0; white-space: pre-line; overflow-wrap: anywhere; }
.wixhc-review__media { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.wixhc-review__media-item img { display: block; width: 96px; height: 96px; object-fit: cover; border-radius: var(--wixhc-radius-m); }
.wixhc-review__helpful { margin: 8px 0 0; font-size: 0.85em; color: var(--wixhc-muted); }
.wixhc-review__reply {
	margin-top: var(--wixhc-space-3);
	padding: var(--wixhc-space-3) var(--wixhc-space-4);
	border-left: 3px solid var(--wixhc-brand);
	border-radius: 0 var(--wixhc-radius-m) var(--wixhc-radius-m) 0;
	background: var(--wixhc-surface-alt);
}
.wixhc-review__reply-label { margin: 0; font-weight: 600; font-size: 0.875em; }
.wixhc-review__reply-text { margin: 4px 0 0; white-space: pre-line; overflow-wrap: anywhere; }

/* ---------- writing a review ---------- */
.wixhc-reviews__form { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; max-width: 40em; }
.wixhc-reviews__rate { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 0; padding: 0; border: 0; }
.wixhc-reviews__rate legend { font-weight: 600; margin-bottom: 4px; }
.wixhc-reviews__rate-opt { display: inline-flex; align-items: center; gap: 4px; }
.wixhc-reviews__field { display: flex; flex-direction: column; gap: 4px; }
.wixhc-reviews__field input,
.wixhc-reviews__field textarea { width: 100%; box-sizing: border-box; font: inherit; }
.wixhc-reviews__alert:empty { display: none; }
.wixhc-reviews__alert { margin: 0; color: var(--wixhc-danger); font-weight: 600; }
.wixhc-reviews__success { margin: 0; font-weight: 600; color: var(--wixhc-success); }
.wixhc-reviews__send,
.wixhc-reviews__more { align-self: flex-start; }
.wixhc-reviews .wixhc-reviews__clear { margin-top: 8px; }

@media (max-width: 600px) {
	.wixhc-reviews__summary { grid-template-columns: 1fr; }
	.wixhc-reviews__bars { grid-column: 1; grid-row: auto; }
	.wixhc-reviews__toolbar { flex-direction: column; align-items: stretch; }
}
