/*
 * «نقد و بررسی‌ها» — the reviews section of a product page, and the stars beside the product title.
 *
 * Hairlines, not boxes: the notes are separated by 1px rules so the section reads like a guest book rather than a
 * grid of cards. The stars are two stacked rows — an empty one and a filled one clipped to the rating — so half a
 * star is exactly half, in both directions.
 */

/* =========================================================
   Stars
   ========================================================= */
.stars { position: relative; display: inline-flex; inline-size: max-content; vertical-align: middle; --star: 16px; }
.stars__track, .stars__fill { display: flex; gap: 3px; }
.stars__track { color: var(--border); }
.stars__fill {
  position: absolute; inset-block-start: 0; inset-inline-start: 0; overflow: hidden;
  color: var(--text); inline-size: calc(var(--stars, 0) / 5 * 100%);
}
.stars svg { inline-size: var(--star); block-size: var(--star); flex: none; fill: currentColor; }
.stars--sm { --star: 15px; }
.stars--md { --star: 18px; }
.stars--lg { --star: 24px; }
.stars--lg .stars__track, .stars--lg .stars__fill { gap: 5px; }

/* The one moment of motion in the section: the average fills once, when it comes into view. */
@media (prefers-reduced-motion: no-preference) {
  .review-summary .stars--lg .stars__fill { inline-size: calc(var(--stars, 0) / 5 * 100% * var(--lit, 1)); transition: inline-size var(--dur-slow, 420ms) var(--ease-out, ease); }
}

/* =========================================================
   Beside the product title
   ========================================================= */
.product-rating { display: flex; align-items: center; gap: var(--space-2); margin: 0; font-size: var(--text-small); }
.product-rating__value { font-weight: 600; }
.product-rating__link { color: var(--text-muted); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 0.4em; }
.product-rating__link:hover { color: var(--text); }

/* =========================================================
   The section
   ========================================================= */
.reviews { max-inline-size: var(--container-narrow, 880px); margin-block-start: var(--space-12); padding-block-start: var(--space-8); border-block-start: 1px solid var(--divider); }
.reviews__head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: var(--space-3) var(--space-5); margin-block-end: var(--space-6); }
.reviews__title { margin: 0; font-size: var(--text-h3); font-weight: 600; line-height: var(--lh-h3); }
.reviews__write { flex: none; }

/* Summary: the average on one side, how the ratings fall on the other. */
.review-summary {
  display: grid; gap: var(--space-5) var(--space-8); margin-block-end: var(--space-8);
  padding: var(--space-6); border: 1px solid var(--border); background: var(--bg-raised);
}
.review-summary__score { display: grid; justify-items: center; gap: var(--space-2); text-align: center; }
.review-summary__average { display: flex; align-items: baseline; gap: var(--space-2); margin: 0; }
.review-summary__number { font-size: clamp(2.5rem, 6vw, 3.25rem); font-weight: 200; line-height: 1.1; }
.review-summary__of { font-size: var(--text-caption); color: var(--text-muted); }
.review-summary__count { margin: 0; font-size: var(--text-caption); line-height: var(--lh-caption); color: var(--text-muted); }

.review-spread { list-style: none; display: grid; gap: var(--space-2); margin: 0; padding: 0; min-inline-size: 0; max-inline-size: 380px; }
.review-spread__row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: var(--space-3); font-size: var(--text-caption); color: var(--text-muted); }
.review-spread__stars { white-space: nowrap; }
.review-spread__track { block-size: 5px; background: color-mix(in oklab, var(--text) 9%, transparent); }
.review-spread__fill { display: block; block-size: 100%; inline-size: calc(var(--value, 0) * 100%); background: var(--text); }
.review-spread__count { min-inline-size: 2ch; text-align: end; font-variant-numeric: normal; }
.review-spread__row.is-empty .review-spread__count { opacity: 0.55; }

@media (min-width: 768px) {
  .review-summary { grid-template-columns: minmax(0, auto) minmax(0, 1fr); align-items: center; justify-content: start; }
  .review-summary__score { justify-items: start; text-align: start; padding-inline-end: var(--space-8); border-inline-end: 1px solid var(--divider); }
  .review-summary__average { justify-content: start; }
}

/* =========================================================
   The notes
   ========================================================= */
.reviews-list { list-style: none; margin: 0; padding: 0; }
.review-item { padding-block: var(--space-6); border-block-start: 1px solid var(--divider); }
.review-item:first-child { padding-block-start: 0; border-block-start: 0; }
.review-item__body { display: grid; gap: var(--space-3); }
.review-item__head { display: flex; align-items: flex-start; gap: var(--space-3); }
.review-item__mark {
  flex: none; display: grid; place-items: center; inline-size: 40px; block-size: 40px;
  background: var(--bg-sunken); border: 1px solid var(--border); color: var(--text-muted);
  font-size: var(--text-title); font-weight: 500; line-height: 1;
}
.review-item__who { flex: 1; min-inline-size: 0; display: grid; gap: 2px; }
.review-item__line { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1) var(--space-3); }
.review-item__author { margin: 0; font-size: var(--text-body); font-weight: 600; line-height: 1.6; }
.review-item__meta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1) var(--space-3); margin: 0; font-size: var(--text-caption); line-height: var(--lh-caption); color: var(--text-muted); }
.review-item__verified { display: inline-flex; align-items: center; padding-inline: var(--space-3); border-radius: var(--radius-pill); background: var(--success-tint); color: var(--success); font-size: var(--text-micro); line-height: 1.9; }
.review-item__stars { flex: none; }
.review-item__pending { margin: 0; font-size: var(--text-caption); color: var(--warning); }
.review-item__text { max-inline-size: 62ch; font-size: var(--text-body); line-height: var(--lh-body); }
.review-item__text p { margin: 0 0 var(--space-3); }
.review-item__text p:last-child { margin-block-end: 0; }

.reviews__pages ul { list-style: none; display: flex; flex-wrap: wrap; gap: var(--space-2); margin: var(--space-6) 0 0; padding: 0; }
.reviews__pages a, .reviews__pages span { display: inline-flex; align-items: center; min-block-size: 40px; padding-inline: var(--space-4); border: 1px solid var(--border); border-radius: var(--radius-cta); font-size: var(--text-label); }
.reviews__pages .current { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }

/* Nothing written yet. */
.reviews-empty { display: grid; gap: var(--space-2); padding: var(--space-8) var(--space-5); border: 1px dashed var(--border-strong); text-align: center; }
.reviews-empty__title { margin: 0; font-size: var(--text-title); font-weight: 600; line-height: var(--lh-title); }
.reviews-empty__text { margin: 0 auto; max-inline-size: 46ch; font-size: var(--text-small); line-height: var(--lh-small); color: var(--text-muted); }

.reviews-locked { margin-block-start: var(--space-6); padding-block-start: var(--space-5); border-block-start: 1px solid var(--divider); font-size: var(--text-small); line-height: var(--lh-small); color: var(--text-muted); }
.reviews-locked a { color: var(--link); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 0.4em; }

/* =========================================================
   Writing one
   ========================================================= */
.review-form { margin-block-start: var(--space-8); padding: var(--space-6); border: 1px solid var(--border); background: var(--bg-raised); }
.review-form__title { margin: 0 0 var(--space-2); font-size: var(--text-title); font-weight: 600; line-height: var(--lh-title); }
.review-form__lead { margin: 0 0 var(--space-5); max-inline-size: 58ch; font-size: var(--text-small); line-height: var(--lh-small); color: var(--text-muted); }
.review-form__form { display: grid; gap: var(--space-5); max-inline-size: 640px; }
.review-form__field { margin: 0; }
.review-form__field label { font-size: var(--text-label); font-weight: 500; line-height: 1.5; }
.review-form__hint { font-size: var(--text-caption); line-height: var(--lh-caption); color: var(--text-muted); }
.review-form .comment-form-cookies-consent { display: flex; align-items: center; gap: var(--space-3); margin: 0; font-size: var(--text-small); }
.review-form .comment-form-cookies-consent input { inline-size: 20px; block-size: 20px; margin: 0; accent-color: var(--primary); }
.review-form .form-submit { margin: 0; }
.review-form__submit { min-inline-size: 180px; }
.review-form .comment-notes, .review-form .logged-in-as { margin: 0 0 var(--space-4); font-size: var(--text-caption); color: var(--text-muted); }
.review-form .required-field-message { margin: 0; font-size: var(--text-caption); color: var(--text-muted); }

/* Choosing a rating: five radios that look like stars, «۱ ستاره» at the start of the line. */
.review-form__rating { margin: 0; padding: 0; border: 0; }
.review-form__rating legend { padding: 0; margin-block-end: var(--space-2); font-size: var(--text-label); font-weight: 500; }
.rating-input { display: flex; flex-direction: row-reverse; justify-content: flex-end; gap: var(--space-1); }
.rating-input input { position: absolute; inline-size: 1px; block-size: 1px; opacity: 0; pointer-events: none; }
.rating-input label {
  display: grid; place-items: center; inline-size: 44px; block-size: 44px; color: var(--border);
  cursor: pointer; transition: color var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out);
}
.rating-input svg { inline-size: 28px; block-size: 28px; fill: currentColor; }
.rating-input label:hover, .rating-input label:hover ~ label { color: var(--text-muted); }
.rating-input input:checked + label, .rating-input input:checked ~ input + label { color: var(--text); }
.rating-input label:active { transform: scale(0.92); }
.rating-input input:focus-visible + label { outline: 2px solid var(--focus-ring); outline-offset: 2px; }

/* =========================================================
   Small screens
   ========================================================= */
@media (max-width: 640px) {
  .reviews { margin-block-start: var(--space-10); }
  .review-summary, .review-form { padding: var(--space-5); }
  .review-item__head { gap: var(--space-2); }
}
