/* =========================================================
   Reviews Pager (one-row sliding window)
   - Desktop: 3 cards visible
   - <=991:   2 cards visible
   - <=599:   1 card visible
   Notes:
   - JS advances by a "page" (3/2/1), but clamps the final step so you
     never see an empty slot on the last view.
========================================================= */

/*
  IMPORTANT:
  The “Read more” modal clones .review-card into <dialog id="reviewModal">,
  which sits outside .reviews-pager in the DOM.
  Any CSS variables used by stars/avatars must exist on BOTH the widget root
  and the modal so the clone looks identical.
*/


/* Performance: keep below-the-fold widget from costing initial paint/layout */
.reviews-pager{
  content-visibility: auto;
  contain: layout paint style;
  contain-intrinsic-size: 600px;
}

:where(.reviews-pager, #reviewModal) {
  /*
    CSS variables are intentionally NOT hard-set here.
    This makes all widget "knobs" fully overridable from Bricks Custom CSS.
    Defaults live as fallbacks in each var(--x, fallback) usage below.
  */
}

.reviews-pager {
  position: relative;
}

/* No-FOUC even before JS runs */
.reviews-pager:not([data-ready="1"]) {
  visibility: hidden;
}

/* viewport: can be visible (shadows can render) */
.reviews-pager__viewport {
  overflow: visible;
}

/* mask: does the clipping for off-screen pages + shadow padding */
.reviews-pager__mask {
  overflow: hidden;
  padding: var(--rp-shadow-pad, 12px);
  border-radius: var(--rp-radius, 0px);
  box-sizing: border-box;
}

/* sliding track (cards are direct children; no page wrappers) */
.reviews-pager__track {
  display: grid;
  grid-auto-flow: column;
  grid-auto-rows: auto;
  align-items: stretch;
  gap: var(--rp-gap, 25px);
  will-change: transform;
  transform: translate3d(0, 0, 0);
  transition: transform 360ms ease;
}

/* 3 visible columns by default */
.reviews-pager__track {
  grid-auto-columns: calc((100% - (var(--rp-gap, 25px) * 2)) / 3);
}

@media (max-width: 991px) {
  .reviews-pager__track {
    grid-auto-columns: calc((100% - var(--rp-gap, 25px)) / 2);
  }
}


@media (max-width: 799px) {
  /* Tablet & mobile preferred fallbacks (still overridable via CSS variables) */
  .reviews-pager__pagination {
    gap: var(--rp-dot-gap, 8px);
  }
  .reviews-pager__dot {
    width: var(--rp-dot, 8px);
    height: var(--rp-dot, 8px);
  }
  .review-card__avatar {
    width: var(--rp-avatar-size, 45px);
    height: var(--rp-avatar-size, 45px);
  }
  .review-card__avatar--fallback {
    font-size: var(--rp-avatar-font, 24px);
  }
}

@media (max-width: 599px) {
  .reviews-pager__track {
    grid-auto-columns: 100%;
  }
}

.reviews-pager__track .review-card {
  height: 100%;
  min-height: var(--rp-card-min-h, auto);
  contain: paint;
}

/* Nav */
.reviews-pager__nav {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: var(--rp-page-gap, 20px);
}

.reviews-pager__prev,
.reviews-pager__next {
  cursor: pointer;
}

/* Pagination dots */
.reviews-pager__pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--rp-dot-gap, 11px);
  flex: 1 1 auto;
}

@media (max-width: 639px) {
  .reviews-pager__pagination {
    display: none;
  }
}

.reviews-pager__dot {
  width: var(--rp-dot, 11px);
  height: var(--rp-dot, 11px);
  border: 0;
  border-radius: 999px;
  background: var(--rp-dot-inactive, var(--neutral-l-10));
  cursor: pointer;
}

.reviews-pager__dot[aria-current="true"] {
  background: var(--rp-dot-active, var(--primary));
}



/* =========================================================
   Review text clamping (desktop/tablet/mobile)
========================================================= */

.review-card__text {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  overflow: hidden;
  -webkit-line-clamp: var(--rp-clamp-desktop, 5);
}

@media (max-width: 767px) {
  .review-card__text {
    -webkit-line-clamp: var(--rp-clamp-tablet, 6);
  }
}

@media (max-width: 478px) {
  .review-card__text {
    -webkit-line-clamp: var(--rp-clamp-mobile, 8);
  }
}

/* Paragraph spacing for real <p> tags from Rich Text */
.review-card__text p,
#reviewModal .review-card__text p {
  margin-top: 0;
  margin-bottom: 1.15em;
}

.review-card__text > :first-child,
#reviewModal .review-card__text > :first-child {
  margin-top: 0;
}

.review-card__text > :last-child,
#reviewModal .review-card__text > :last-child {
  margin-bottom: 0;
}

/* =========================================================
   Modal: show ONLY the review-card (no white frame)
========================================================= */

#reviewModal {
  background: transparent;
  border: 0;
  box-shadow: none;

  width: 100%;
  max-width: min(720px, calc(100vw - 34px));

  padding: 0;
  overflow: visible;
}

#reviewModal::backdrop {
  background: rgba(0, 0, 0, 0.55);
}

.review-modal__box {
  position: relative;
  display: flex;
  justify-content: center;
  background: transparent;
  padding: 0;
  border-radius: 0;
}

.review-modal__content {
  width: 100%;
  overflow: visible;
}

.review-modal__close {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 10;

  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;

  border: 1px solid rgba(0, 0, 0, 0.08);
  background: rgba(255, 255, 255, 0.96);
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.18);
  color: inherit;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  -webkit-appearance: none;
  appearance: none;
}

.review-modal__close:focus-visible {
  outline: none;
}

@media (max-width: 478px) {
  .review-modal__close {
    width: 40px;
    height: 40px;
    border-radius: 8px;
  }
}

#reviewModal.has-scrollbar .review-modal__close {
  right: calc(10px + var(--modal-scrollbar-offset, var(--sbw, 18px)));
}

#reviewModal .review-card__text {
  line-height: 1.5;
  white-space: normal;
}

#reviewModal .review-card__text.is-unclamped {
  display: block;
  overflow: visible;
  -webkit-line-clamp: unset;
}

#reviewModal .review-card--modal {
  width: 100%;
  max-height: min(75vh, 680px);
  overflow: auto;
  background: var(--white);
  -webkit-overflow-scrolling: touch;
}

/* Read more button */
.review-card__more {
  cursor: pointer;
  display: none;
}

.review-card__more:hover {
  text-decoration: underline;
}

.review-card__more.is-visible {
  display: inline;
}

/* ---------- Avatar (image + fallback letter) ---------- */

.review-card__avatar {
  width: var(--rp-avatar-size, 50px);
  height: var(--rp-avatar-size, 50px);
  border-radius: 999px;
  overflow: hidden;
  position: relative;
  flex: 0 0 auto;

  display: flex;
  align-items: center;
  justify-content: center;
}

.review-card__avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* fallback layer (single source of truth) */
.review-card__avatar-fallback {
  position: absolute;
  inset: 0;

  display: grid;
  place-items: center;

  font-family: "Google Sans", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  font-weight: 400;
  font-size: var(--rp-avatar-font, 28px);
  line-height: 1;
  text-transform: uppercase;
  color: var(--av-text, #fff);

  background: hsl(
    calc(var(--av-h, 210deg) + var(--av-hshift, 0deg))
    var(--av-s, 65%)
    var(--av-l, 48%)
  );

  opacity: 0;
  transition: opacity 120ms ease;
  pointer-events: none;
}

/* Optional “optical” nudge knob (moves ONLY the letter, not the circle) */
.review-card__avatar-letter {
  display: block;
  transform: translateY(var(--rp-avatar-nudge, 1px));
}

/* ---------------------------------------------------------
   Reviewer name: prevent wrapping
   Why: a single long name wrapping to 2 lines can increase the
   grid row height, which then makes other cards appear to have
   extra blank space under the "Read more" link.
   --------------------------------------------------------- */
.review-card__meta{
  min-width: 0; /* required for text-overflow in flex layouts */
}

.review-card__name{
  display: block;      /* enables ellipsis */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

@supports (background: oklch(0.62 0.14 200)) {
  .review-card__avatar-fallback {
    background: oklch(
      var(--av-L, 0.62)
      var(--av-C, 0.20)
      calc(var(--av-h, 210deg) + var(--av-hshift, 0deg))
    );
  }
}

/* 3-state */
.review-card__avatar.has-image .review-card__avatar-img { display: block; }
.review-card__avatar.is-loading .review-card__avatar-img,
.review-card__avatar.is-fallback .review-card__avatar-img { display: none; }

.review-card__avatar.is-loading .review-card__avatar-fallback { opacity: 0; }
.review-card__avatar.is-fallback .review-card__avatar-fallback { opacity: 1; }

.review-card__avatar.is-loading { background: rgba(0,0,0,0.08); }


/* Modal safety net:
   If a cached avatar image finishes before listeners attach during clone->dialog,
   the avatar can get stuck in is-loading (grey). In the modal, show the fallback letter
   instead of an empty grey circle so the UI never looks broken.
*/
#reviewModal .review-card__avatar.is-loading .review-card__avatar-fallback { opacity: 1; }

/* =========================================================
   Stars (1–5) — size + color controls
   - Keep data-rating="1".."5" on .review-card__stars
   - Set size via:  .reviews-pager{ --star-size: 22px; }
   - Set color via: .reviews-pager{ --star-color: var(--primary); }
   Notes:
   - We use width = height * ratio, so each rating SVG keeps correct width.
========================================================= */
:where(.reviews-pager, #reviewModal) {
  /*
    CSS variables are intentionally NOT hard-set here.
    This makes all widget "knobs" fully overridable from Bricks Custom CSS.
    Defaults live as fallbacks in each var(--x, fallback) usage below.
  */
}

.review-card__stars{
  display: inline-block;
  height: var(--star-size, 23px);
  width: calc(var(--star-size, 23px) * var(--rp-star-ar, 5.6842105263));
  flex: 0 0 auto;
  background-color: var(--star-color, #ffd64f);

  -webkit-mask-repeat: no-repeat;
  -webkit-mask-position: left center;
  -webkit-mask-size: contain;
          mask-repeat: no-repeat;
          mask-position: left center;
          mask-size: contain;

  /* default to 5 stars if data-rating is missing */
  -webkit-mask-image: var(--rp-stars-5, url("./stars/5-stars.svg"));
          mask-image: var(--rp-stars-5, url("./stars/5-stars.svg"));
}

.review-card__stars[data-rating="5"]{
  --rp-star-ar: 5.6842105263;
  -webkit-mask-image: var(--rp-stars-5, url("./stars/5-stars.svg"));
          mask-image: var(--rp-stars-5, url("./stars/5-stars.svg"));
}
.review-card__stars[data-rating="4"]{
  --rp-star-ar: 4.5263157895;
  -webkit-mask-image: var(--rp-stars-4, url("./stars/4-stars.svg"));
          mask-image: var(--rp-stars-4, url("./stars/4-stars.svg"));
}
.review-card__stars[data-rating="3"]{
  --rp-star-ar: 3.3684210526;
  -webkit-mask-image: var(--rp-stars-3, url("./stars/3-stars.svg"));
          mask-image: var(--rp-stars-3, url("./stars/3-stars.svg"));
}
.review-card__stars[data-rating="2"]{
  --rp-star-ar: 2.2105263158;
  -webkit-mask-image: var(--rp-stars-2, url("./stars/2-stars.svg"));
          mask-image: var(--rp-stars-2, url("./stars/2-stars.svg"));
}
.review-card__stars[data-rating="1"]{
  --rp-star-ar: 1.0526315789;
  -webkit-mask-image: var(--rp-stars-1, url("./stars/1-stars.svg"));
          mask-image: var(--rp-stars-1, url("./stars/1-stars.svg"));
}