/*
 * RahkarTheme — reviews-extra.css
 *
 * The PS-port additions on top of the verbatim product-reviews.css: the
 * percentage-fill star bar, the inline rating next to the price, the rating
 * breakdown bars, review-card photos, the submit form (star input + photo
 * uploader) and the photo lightbox. Loaded on the product page only
 * (rahkarchrome::setupProductSurface, priority 73). Token-driven + RTL-safe.
 */

:root {
	--rh-star-on: #f5a623;
	--rh-star-off: #d7dbe2;
}

/* ===== Section heading ================================================ */

.rh-reviews__heading {
	margin: 0 0 1rem;
	font-size: var(--wp--preset--font-size--md, 1.125rem);
	font-weight: var(--rh-fw-strong);
	color: var(--wp--preset--color--contrast, #0f1115);
}

/* Empty-state CTA: inline (not the full-width summary button). */
.rh-reviews__empty-cta {
	width: auto;
	align-self: center;
	margin-block-start: 0.75rem;
	padding-inline: 1.5rem;
}

/* ===== Two-column body: main (list) column ============================ */
/* The summary card is the side column (product-reviews.css gives it
   grid-column:1 + sticky); this wrapper is the main column holding the list.
   min-width:0 lets it shrink inside the grid instead of overflowing. */

.rh-reviews__main {
	min-width: 0;
}

@media (min-width: 900px) {
	.rh-reviews__main {
		grid-column: 2;
	}
}

/* ===== Star bar (percentage fill — exact for fractional averages) ====== */

.rh-stars {
	position: relative;
	display: inline-block;
	line-height: 1;
	font-size: 1rem;
	white-space: nowrap;
	vertical-align: middle;
}

.rh-stars__row {
	display: block;
	letter-spacing: 0.08em;
}

.rh-stars__row--bg {
	color: var(--rh-star-off);
}

.rh-stars__row--on {
	position: absolute;
	inset-block-start: 0;
	inset-inline-start: 0;
	overflow: hidden;
	color: var(--rh-star-on);
	/* width is set inline (the fill %); clip from the inline-start edge */
}

/* ===== Inline rating (next to the price) =============================== */

.rh-rating-inline {
	display: inline-flex;
	align-items: center;
	gap: 0.375rem;
	font-size: var(--wp--preset--font-size--sm, 0.875rem);
	color: var(--wp--preset--color--text-muted, #5b6271);
}

.rh-rating-inline__star {
	color: var(--rh-star-on);
	font-size: 0.95rem;
	line-height: 1;
}

.rh-rating-inline__avg {
	font-weight: var(--rh-fw-strong);
	color: var(--wp--preset--color--contrast, #0f1115);
}

.rh-rating-inline__count {
	color: var(--wp--preset--color--text-muted, #5b6271);
}

.rh-rating-inline--empty {
	opacity: 0.85;
}

/* ===== Rating breakdown bars (summary card) =========================== */

.rh-rvbars {
	list-style: none;
	margin: 0.75rem 0 0;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 0.3rem;
}

.rh-rvbars__row {
	display: grid;
	grid-template-columns: 2.25rem 1fr 1.75rem;
	align-items: center;
	gap: 0.5rem;
	font-size: 0.8rem;
	color: var(--wp--preset--color--text-muted, #5b6271);
}

.rh-rvbars__star {
	display: inline-flex;
	align-items: center;
	gap: 0.15rem;
	white-space: nowrap;
}

.rh-rvbars__star-ico {
	color: var(--rh-star-on);
}

.rh-rvbars__track {
	position: relative;
	height: 0.5rem;
	border-radius: 999px;
	background: var(--wp--preset--color--border, #e2e4e9);
	overflow: hidden;
}

.rh-rvbars__fill {
	position: absolute;
	inset-block: 0;
	inset-inline-start: 0;
	border-radius: 999px;
	background: var(--rh-star-on);
}

.rh-rvbars__num {
	text-align: start;
	font-variant-numeric: tabular-nums;
}

/* ===== List state (loading / empty / error) =========================== */

.rh-reviews__state {
	margin: 0.5rem 0;
	font-size: var(--wp--preset--font-size--sm, 0.875rem);
	color: var(--wp--preset--color--text-muted, #5b6271);
	text-align: center;
}

.rh-reviews__state:empty {
	display: none;
}

/* ===== Review-card photos (JS-rendered cards reuse .rh-reviews__card) == */

.rh-reviews__card-photos {
	display: flex;
	flex-wrap: wrap;
	gap: 0.4rem;
	margin-block-start: 0.5rem;
}

.rh-reviews__photo {
	width: 56px;
	height: 56px;
	border-radius: 0.5rem;
	overflow: hidden;
	border: 1px solid var(--wp--preset--color--border, #e2e4e9);
	background: var(--wp--preset--color--base, #fff);
	padding: 0;
	cursor: zoom-in;
	flex: 0 0 auto;
}

.rh-reviews__photo img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

/* ===== Submit form dialog ============================================= */

.rh-rvform {
	width: min(540px, calc(100vw - 2rem));
	max-height: calc(100vh - 2rem);
	border: none;
	border-radius: 1rem;
	padding: 0;
	background: var(--wp--preset--color--base, #fff);
	color: var(--wp--preset--color--contrast, #0f1115);
	box-shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
	overflow: auto;
}

.rh-rvform::backdrop {
	background: rgba(15, 17, 21, 0.55);
}

.rh-rvform__form {
	padding: 1.1rem 1.25rem 1.35rem;
}

.rh-rvform__head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin-block-end: 0.75rem;
}

.rh-rvform__title {
	margin: 0;
	font-size: var(--wp--preset--font-size--md, 1.125rem);
	font-weight: var(--rh-fw-strong);
}

.rh-rvform__close {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 34px;
	height: 34px;
	border: none;
	border-radius: 50%;
	background: var(--wp--preset--color--border, #eef0f3);
	color: var(--wp--preset--color--contrast, #0f1115);
	cursor: pointer;
}

.rh-rvform__close:hover {
	background: #dfe3ea;
}

/* Gate / done notices */
.rh-rvform__gate,
.rh-rvform__done {
	text-align: center;
	padding: 1rem 0.5rem 0.5rem;
}

.rh-rvform__gate-text {
	margin: 0 0 0.75rem;
	color: var(--wp--preset--color--text-muted, #5b6271);
}

.rh-rvform__login {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: var(--wp--custom--button--h--md, 44px);
	padding: 0 1.25rem;
	border-radius: 0.625rem;
	background: var(--wp--preset--color--primary, #0a66c2);
	color: #fff;
	font-weight: var(--rh-fw-strong);
	text-decoration: none;
}

/* Star input */
.rh-rvform__rating {
	display: inline-flex;
	flex-direction: row;
	gap: 0.2rem;
	margin-block-end: 0.85rem;
}

.rh-rvform__star {
	border: none;
	background: none;
	padding: 0 0.05rem;
	font-size: 1.9rem;
	line-height: 1;
	cursor: pointer;
	color: var(--rh-star-off);
	transition: color 0.08s ease;
}

.rh-rvform__star.is-on {
	color: var(--rh-star-on);
}

/* Text fields */
.rh-rvform__input,
.rh-rvform__textarea {
	width: 100%;
	box-sizing: border-box;
	border: 1px solid var(--wp--preset--color--border, #e2e4e9);
	border-radius: 0.625rem;
	padding: 0.7rem 0.85rem;
	font: inherit;
	color: inherit;
	background: var(--wp--preset--color--base, #fff);
	margin-block-end: 0.7rem;
}

.rh-rvform__textarea {
	resize: vertical;
	min-height: 6rem;
}

.rh-rvform__input:focus,
.rh-rvform__textarea:focus {
	outline: none;
	border-color: var(--wp--preset--color--primary, #0a66c2);
	box-shadow: 0 0 0 3px rgba(109, 189, 186, 0.15);
}

/* Photos */
.rh-rvform__photos {
	margin-block-end: 0.85rem;
}

.rh-rvform__photo-add {
	display: inline-flex;
	align-items: center;
	gap: 0.4rem;
	padding: 0.5rem 0.85rem;
	border: 1px dashed var(--wp--preset--color--primary, #0a66c2);
	border-radius: 0.625rem;
	color: var(--wp--preset--color--primary, #0a66c2);
	font-size: 0.85rem;
	font-weight: var(--rh-fw-strong);
	cursor: pointer;
	background: rgba(109, 189, 186, 0.04);
}

.rh-rvform__previews {
	display: flex;
	flex-wrap: wrap;
	gap: 0.45rem;
	margin-block-start: 0.6rem;
}

.rh-rvform__preview {
	position: relative;
	width: 64px;
	height: 64px;
	border-radius: 0.5rem;
	overflow: hidden;
	border: 1px solid var(--wp--preset--color--border, #e2e4e9);
}

.rh-rvform__preview img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.rh-rvform__preview-rm {
	position: absolute;
	inset-block-start: 2px;
	inset-inline-end: 2px;
	width: 20px;
	height: 20px;
	border: none;
	border-radius: 50%;
	background: rgba(15, 17, 21, 0.7);
	color: #fff;
	font-size: 13px;
	line-height: 20px;
	text-align: center;
	cursor: pointer;
	padding: 0;
}

.rh-rvform__hint {
	margin: 0.5rem 0 0;
	font-size: 0.75rem;
	color: var(--wp--preset--color--text-muted, #5b6271);
}

/* Anonymous-submission checkbox */
.rh-rvform__anon {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	margin-block-end: 0.85rem;
	font-size: 0.85rem;
	color: var(--wp--preset--color--text, #1a1d23);
	cursor: pointer;
}

.rh-rvform__anon input {
	width: 16px;
	height: 16px;
	flex: 0 0 auto;
	accent-color: var(--wp--preset--color--primary, #0a66c2);
	cursor: pointer;
}

/* Message + submit */
.rh-rvform__msg {
	margin: 0 0 0.6rem;
	padding: 0.55rem 0.75rem;
	border-radius: 0.5rem;
	font-size: 0.85rem;
}

.rh-rvform__msg.is-error {
	background: #fdecec;
	color: #b3261e;
}

.rh-rvform__msg.is-success {
	background: #e7f6ec;
	color: #1f7a3d;
}

.rh-rvform__submit {
	width: 100%;
	min-height: var(--wp--custom--button--h--md, 46px);
	border: none;
	border-radius: 0.7rem;
	background: var(--wp--preset--color--primary, #0a66c2);
	color: #fff;
	font-weight: var(--rh-fw-strong);
	font-size: 0.95rem;
	cursor: pointer;
}

.rh-rvform__submit:disabled {
	opacity: 0.6;
	cursor: default;
}

/* ===== Photo lightbox (built lazily by rh-reviews.js) ================= */

.rh-rvlightbox {
	width: min(92vw, 900px);
	max-height: 92vh;
	border: none;
	border-radius: 0.75rem;
	padding: 0;
	background: #000;
	overflow: hidden;
}

.rh-rvlightbox::backdrop {
	background: rgba(0, 0, 0, 0.85);
}

.rh-rvlightbox__img {
	display: block;
	width: 100%;
	max-height: 92vh;
	object-fit: contain;
	margin: 0 auto;
}

.rh-rvlightbox__close {
	position: absolute;
	inset-block-start: 10px;
	inset-inline-end: 14px;
	width: 38px;
	height: 38px;
	border: none;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.18);
	color: #fff;
	font-size: 22px;
	cursor: pointer;
}

.rh-rvlightbox__nav {
	position: absolute;
	inset-block-start: 50%;
	transform: translateY(-50%);
	width: 44px;
	height: 44px;
	border: none;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.18);
	color: #fff;
	font-size: 24px;
	cursor: pointer;
}

.rh-rvlightbox__nav--prev {
	inset-inline-start: 12px;
}

.rh-rvlightbox__nav--next {
	inset-inline-end: 12px;
}
