/* Reviews ----------------------------------------------------------------
   Everything the shop draws about customer reviews: the form an order's
   buyer fills in, the stars that show a rating, and the review lists (the
   product's block, /reviews, the Opinie section). The one accent is the
   star gold; the rest sits on the surfaces every other card uses.

   The star picker is five radios written five first, laid out in reverse,
   so a checked radio lights its own label and every label after it in the
   markup — which on screen are the stars before it. Hovering previews the
   same way. Each star is a 42px target, enough for a thumb. */

.review-page {
  max-width: 40rem;
  padding-block: var(--space-8) var(--space-12);
}

.review-form,
.review-notice {
  display: grid;
  gap: var(--space-6);
}

.review-notice {
  justify-items: start;
}

.review-form__lede,
.review-block__hint {
  color: var(--ink-soft);
}

.review-block {
  display: grid;
  gap: var(--space-4);
  padding-top: var(--space-6);
  border-top: 1px solid var(--line);
}

.review-rating {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2) var(--space-4);
}

.review-rating__label {
  font-weight: 700;
}

/* The picker. */
.stars-input {
  display: inline-flex;
  flex-direction: row-reverse;
  justify-content: flex-end;
  gap: var(--space-1);
  margin: 0;
  padding: 0;
  border: 0;
}

.stars-input input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.stars-input label {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  color: var(--line-strong);
  cursor: pointer;
}

.stars-input .icon {
  width: 32px;
  height: 32px;
  fill: currentcolor;
  stroke: none;
}

.stars-input input:checked ~ label,
.stars-input label:hover,
.stars-input label:hover ~ label {
  color: var(--accent-gold-deep);
}

.stars-input input:focus-visible + label {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}

.stars-input[aria-invalid="true"] label {
  color: color-mix(in srgb, var(--danger) 45%, transparent);
}

/* A shown rating. */
.stars {
  display: inline-flex;
  gap: 2px;
  vertical-align: -0.15em;
}

.stars__star {
  position: relative;
  display: inline-grid;
  color: var(--line-strong);
}

.stars__star .icon {
  fill: currentcolor;
  stroke: none;
}

.stars__star.is-on {
  color: var(--accent-gold-deep);
}

/* A half star is a grey star with a gold one over it, cut at the middle. */
.stars__fill {
  position: absolute;
  inset: 0 50% 0 0;
  display: grid;
  overflow: hidden;
  color: var(--accent-gold-deep);
}

/* One order line on the form. */
.review-line {
  display: grid;
  gap: var(--space-4);
  padding: var(--space-4);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.review-line__head {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr);
  gap: var(--space-3);
  align-items: center;
}

.review-line__name {
  margin: 0;
  font-weight: 700;
}

.review-line__variant {
  margin: 0;
  color: var(--ink-muted);
  font-size: var(--text-sm);
}

.review-line__body {
  display: grid;
  gap: var(--space-4);
}

.review-line:has(.review-line__skip input:checked) .review-line__body {
  display: none;
}

.review-line:has(.review-line__skip input:checked) {
  opacity: 0.6;
}

/* The field only a bot fills in. */
.review-trap {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

@media (prefers-reduced-motion: no-preference) {
  .stars-input label {
    transition: color 0.12s ease;
  }
}

/* The product's rating in its buy box, a link down to the block. */
.product-rating {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  color: var(--ink);
  font-weight: 700;
  text-decoration: none;
}

.product-rating__count {
  color: var(--ink-muted);
  font-weight: 400;
  text-decoration: underline;
}

/* The product's reviews: the score and the bars beside the list on a
   desktop, above it on a phone. */
.reviews-block {
  display: grid;
  gap: var(--space-5);
  scroll-margin-top: var(--space-16);
}

.reviews-summary {
  display: grid;
  gap: var(--space-5);
  padding: var(--space-5);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

@media (min-width: 640px) {
  .reviews-summary { grid-template-columns: auto minmax(0, 1fr); align-items: center; }
}

.reviews-summary__score {
  display: grid;
  justify-items: start;
  gap: var(--space-1);
  color: var(--ink-soft);
}

.reviews-summary__avg {
  font-family: var(--font-heading);
  font-size: var(--text-4xl);
  font-weight: 700;
  line-height: 1;
  color: var(--ink);
}

.reviews-dist {
  display: grid;
  gap: var(--space-1);
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
}

.reviews-dist__row {
  display: grid;
  grid-template-columns: 3.5ch minmax(0, 1fr) 3ch;
  gap: var(--space-2);
  align-items: center;
}

.reviews-dist__bar {
  width: 100%;
  height: 8px;
}

.reviews-dist__n { text-align: right; color: var(--ink-muted); }

.reviews-list {
  display: grid;
  gap: var(--space-3);
  margin: 0;
  padding: 0;
  list-style: none;
}

.review-item {
  display: grid;
  gap: var(--space-2);
  padding: var(--space-4);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.review-item__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-3);
}

.review-item__verified {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  color: var(--success);
  font-size: var(--text-xs);
}

.review-item__meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-3);
  color: var(--ink-muted);
  font-size: var(--text-sm);
}

.review-item__text {
  margin: 0;
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.reviews-how {
  color: var(--ink-muted);
  font-size: var(--text-sm);
}

/* The shop's reviews in a section and on /reviews: a grid of cards, or a
   strip that scrolls sideways with the next card peeking in. */
.reviews-section { display: grid; gap: var(--space-4); }

.reviews-grid {
  display: grid;
  gap: var(--space-3);
}

@media (min-width: 640px) {
  .reviews-grid { grid-template-columns: repeat(auto-fill, minmax(18rem, 1fr)); }
}

.reviews-strip {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(16rem, 80%);
  gap: var(--space-3);
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  padding-bottom: var(--space-2);
}

@media (min-width: 640px) {
  .reviews-strip { grid-auto-columns: minmax(18rem, 1fr); }
}

.reviews-strip > * { scroll-snap-align: start; }

.review-item__rate {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
}
