/* ==========================================================================
   Reviews — sticky vertical review panel in the right-hand column of the
   single-product page, plus category-loop star ratings.
   Markup: byanh-product-reviews.php (no front-end JS — native scrolling).
   ========================================================================== */

.byanh-shop {
  --byanh-star: #E9A23B;
  --byanh-star-empty: var(--color-line-300);
  --byanh-reviews-pad: var(--space-5);
  /* .site-header is position:sticky at 94px; the panel parks just below it. */
  --byanh-header-h: 94px;
}

/* --- Star glyph ---------------------------------------------------------- */

.byanh-shop .byanh-stars {
  position: relative;
  display: inline-block;
  line-height: 0;
  flex-shrink: 0;
  white-space: nowrap;
}

.byanh-shop .byanh-stars__track,
.byanh-shop .byanh-stars__fill {
  display: block;
  line-height: 0;
  white-space: nowrap;
}

.byanh-shop .byanh-stars__fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--byanh-star-pct, 0%);
  overflow: hidden;
}

.byanh-shop .byanh-stars svg {
  width: 15px;
  height: 15px;
  display: inline-block;
  vertical-align: top;
  fill: var(--byanh-star-empty);
}

.byanh-shop .byanh-stars__fill svg {
  fill: var(--byanh-star);
}

.byanh-shop .byanh-stars--lg svg {
  width: 22px;
  height: 22px;
}

/* --- Category / shop loop: stars under the product-card title ------------- */

.byanh-shop .products .product .byanh-loop-rating {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-5) 0;
  margin: 0;
}

.byanh-shop .products .product .byanh-loop-rating__count {
  font-family: var(--font-body);
  font-size: var(--text-caption-size);
  color: var(--text-muted);
  line-height: 1;
}

/* WooCommerce's own icon-font stars are unhooked in PHP, but a theme or
   plugin re-adding them would double up — keep them out visually too. */
.byanh-shop .products .product .star-rating,
.byanh-shop .products .product .woocommerce-product-rating {
  display: none !important;
}

@media (max-width: 560px) {
  .byanh-shop .products .product .byanh-loop-rating {
    padding: var(--space-2) var(--space-3) 0;
  }

  .byanh-shop .products .product .byanh-stars svg {
    width: 13px;
    height: 13px;
  }
}

/* --- Product page: Description | Reviews two-column ----------------------
   Overrides the 760px single-column rule in byanh-shop-design.css. This
   sheet is enqueued after it, so equal-specificity selectors win here. */

.byanh-shop .product-details-wrap {
  max-width: 760px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
  gap: var(--space-6);
}

/* The second column only exists when the product actually has reviews —
   byanh/product-reviews renders nothing at all otherwise, and a bare
   grid-template-columns would leave a hole beside the Description.
   max-width:none lets the grid fill the whole .container content box. */
.byanh-shop .product-details-wrap:has(.byanh-reviews) {
  max-width: none;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 440px);
}

/* Core's block-layout rule gives every non-first child of a wp-block-group a
   margin-block-start (40px here). Harmless in flow layout, but as grid items
   it pushes the Reviews column a row-gap's worth below the Description. */
.byanh-shop .product-details-wrap > * {
  margin-top: 0;
  margin-block-start: 0;
  min-width: 0;
}

@media (max-width: 1024px) {
  .byanh-shop .product-details-wrap:has(.byanh-reviews) {
    grid-template-columns: minmax(0, 1fr);
    max-width: 760px;
  }
}

/* --- Reviews panel -------------------------------------------------------
   The description column runs thousands of pixels tall, so the panel sticks
   under the site header and caps its own height; the card list scrolls
   inside it rather than the panel trailing a mile of empty column. */

.byanh-shop .byanh-reviews {
  min-width: 0;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: calc(var(--byanh-header-h) + var(--space-5));
  max-height: calc(100vh - var(--byanh-header-h) - var(--space-5) * 2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--surface-card);
  overflow: hidden;
}

.byanh-shop .byanh-reviews__head {
  flex: 0 0 auto;
  padding: var(--byanh-reviews-pad);
  border-bottom: 1px solid var(--border-subtle);
}

.byanh-shop .byanh-reviews__heading {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.05rem;
  line-height: 1.2;
  color: var(--text-primary);
}

.byanh-shop .byanh-reviews__body {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: var(--byanh-reviews-pad);
}

/* --- Rating summary ------------------------------------------------------ */

.byanh-shop .byanh-reviews__summary {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: var(--space-5) var(--space-6);
  padding-bottom: var(--byanh-reviews-pad);
  border-bottom: 1px solid var(--border-subtle);
}

.byanh-shop .byanh-reviews__score {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-2);
  flex-shrink: 0;
}

.byanh-shop .byanh-reviews__avg {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 2.5rem;
  line-height: 1;
  color: var(--text-primary);
}

.byanh-shop .byanh-reviews__count {
  font-size: var(--text-body-sm-size);
  color: var(--text-secondary);
}

.byanh-shop .byanh-reviews__dist {
  display: grid;
  gap: 5px;
  flex: 1 1 auto;
  min-width: 0;
}

.byanh-shop .byanh-reviews__dist-row {
  display: grid;
  grid-template-columns: 30px 1fr 22px;
  align-items: center;
  gap: var(--space-3);
}

.byanh-shop .byanh-reviews__dist-label,
.byanh-shop .byanh-reviews__dist-n {
  font-size: var(--text-caption-size);
  color: var(--text-muted);
  line-height: 1;
}

.byanh-shop .byanh-reviews__dist-n {
  text-align: right;
}

.byanh-shop .byanh-reviews__dist-bar {
  display: block;
  height: 6px;
  border-radius: var(--radius-full);
  background: var(--surface-sunken);
  overflow: hidden;
}

.byanh-shop .byanh-reviews__dist-bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--byanh-star);
}

.byanh-shop .byanh-reviews__preview-note {
  flex: 0 0 auto;
  margin-top: var(--space-4);
  font-size: var(--text-body-sm-size);
  color: var(--color-brown-700);
  background: var(--color-butter-100);
  border: 1px dashed var(--color-butter-300);
  border-radius: var(--radius-sm);
  padding: var(--space-3) var(--space-4);
}

/* --- Vertically scrolling card list -------------------------------------- */

/* Flex, not block: the wrapper's *computed* height stays `auto` even though
   flex gives it a used height, so a percentage height on the list below would
   never resolve and the list would overflow the panel instead of scrolling. */
.byanh-shop .byanh-reviews__list-wrap {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  /* Cancel the panel's padding so the scroll area reaches the panel edges. */
  margin-inline: calc(var(--byanh-reviews-pad) * -1);
  margin-bottom: calc(var(--byanh-reviews-pad) * -1);
}

.byanh-shop .byanh-reviews__list {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  list-style: none;
  margin: 0;
  padding: var(--space-5) var(--byanh-reviews-pad);
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior-y: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--color-line-300) transparent;
}

.byanh-shop .byanh-reviews__list:focus-visible {
  outline: 2px solid var(--brand-primary);
  outline-offset: -2px;
  border-radius: var(--radius-md);
}

.byanh-shop .byanh-reviews__list::-webkit-scrollbar {
  width: 6px;
}

.byanh-shop .byanh-reviews__list::-webkit-scrollbar-track {
  background: transparent;
}

.byanh-shop .byanh-reviews__list::-webkit-scrollbar-thumb {
  background: var(--color-line-300);
  border-radius: var(--radius-full);
}

.byanh-shop .byanh-review-card {
  flex: 0 0 auto;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-5);
  margin: 0;
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-subtle);
}

.byanh-shop .byanh-review-card.is-pending {
  border-style: dashed;
  border-color: var(--color-butter-300);
  background: var(--color-butter-100);
}

.byanh-shop .byanh-review-card__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.byanh-shop .byanh-review-card__pending {
  font-family: var(--font-mono);
  font-size: var(--text-caption-size);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-brown-700);
}

.byanh-shop .byanh-review-card__title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1rem;
  line-height: 1.35;
  color: var(--text-primary);
  margin: 0;
}

.byanh-shop .byanh-review-card__text {
  font-size: var(--text-body-sm-size);
  line-height: var(--text-body-sm-lh);
  color: var(--text-secondary);
}

.byanh-shop .byanh-review-card__text p {
  margin: 0;
}

.byanh-shop .byanh-review-card__text p + p {
  margin-top: var(--space-3);
}

.byanh-shop .byanh-review-card__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border-subtle);
  font-size: var(--text-caption-size);
  color: var(--text-muted);
}

.byanh-shop .byanh-review-card__author {
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--text-primary);
}

.byanh-shop .byanh-review-card__verified {
  color: var(--color-brown-700);
  background: var(--color-peach-100);
  border-radius: var(--radius-full);
  padding: 2px var(--space-2);
  line-height: 1.4;
}

.byanh-shop .byanh-review-card__meta time {
  margin-left: auto;
}

/* --- Stacked layout: no sticky, no height cap, let the list run ---------- */

@media (max-width: 1024px) {
  .byanh-shop .byanh-reviews {
    position: static;
    max-height: none;
  }

  .byanh-shop .byanh-reviews__list {
    flex: 0 1 auto;
    max-height: 620px;
  }
}

@media (max-width: 560px) {
  .byanh-shop .byanh-reviews__summary {
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-4);
  }

  .byanh-shop .byanh-reviews__score {
    flex-direction: row;
    align-items: center;
    gap: var(--space-3);
  }

  .byanh-shop .byanh-reviews__avg {
    font-size: 1.875rem;
  }
}
