/*
 * Reviews: [gyla_reviews] shortcode (inc/reviews.php). Without JS a swipe row.
 * reviews.js adds .is-ready (text clamp) and, when the row is longer than the screen,
 * .is-looping (endless slow scroll, copies of the cards, controls and progress bar).
 * Paragraph classes are written as p.class to outrank Astra's `.entry-content p` margin.
 */

.gyla-reviews {
  background: var(--gyla-color-surface-soft);
}

/* Phones and tablets: controls under the cards. Desktop: next to the heading. */
.gyla-reviews__inner {
  display: grid;
  grid-template-areas:
    "header header"
    "track track"
    "progress controls";
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 20px;
}

.gyla-reviews__header {
  grid-area: header;
  max-width: 760px;
  margin-bottom: 40px;
}

.gyla-reviews__header h2 {
  margin: 0;
  color: var(--gyla-color-ink);
  font-size: var(--gyla-text-h2);
  line-height: 1.15;
}

/* Link to /atsiliepimai/. `a.` outranks Astra's `a:focus` colour. */
a.gyla-reviews__all {
  display: inline-block;
  margin-top: 16px;
  color: var(--gyla-color-teal-strong);
  font-size: var(--gyla-text-small);
  font-weight: 700;
  line-height: 1.4;
  text-decoration: underline;
  text-underline-offset: 3px;
}

a.gyla-reviews__all:hover,
a.gyla-reviews__all:focus {
  color: var(--gyla-color-teal-stronger);
}

/* Bleeds to the screen edges so the next card peeks in as a swipe hint. */
.gyla-reviews__track {
  grid-area: track;
  min-width: 0;
  margin: 0 -20px;
  overflow-x: auto;
  container-type: inline-size;
  scroll-snap-type: x mandatory;
  scroll-padding-inline: 20px;
  scrollbar-width: none;
}

.gyla-reviews__track::-webkit-scrollbar {
  display: none;
}

/* The loop scrolls pixel by pixel; snapping would pull it back to a card edge. */
.gyla-reviews.is-looping .gyla-reviews__track {
  scroll-snap-type: none;
}

.gyla-reviews__list {
  display: flex;
  gap: 16px;
  width: max-content;
  margin: 0;
  padding: 0 20px;
  list-style: none;
}

.gyla-review {
  display: flex;
  flex: 0 0 min(82cqi, 360px);
  flex-direction: column;
  gap: 20px;
  box-sizing: border-box;
  margin: 0;
  padding: 28px 24px;
  background: #ffffff;
  border: 1px solid var(--gyla-color-border);
  border-radius: 20px;
  scroll-snap-align: start;
}

.gyla-review.is-clone {
  display: none;
}

.gyla-reviews.is-looping .gyla-review.is-clone {
  display: flex;
}

.gyla-review__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.gyla-review__rating {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  color: var(--gyla-color-orange-strong);
}

.gyla-review__star {
  display: flex;
}

.gyla-review__star svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

.gyla-review__star.is-empty {
  color: var(--gyla-color-border);
}

.gyla-review__score {
  margin-left: 6px;
  color: var(--gyla-color-ink);
  font-size: var(--gyla-text-title);
  font-weight: 700;
  line-height: 1;
}

.gyla-review__platform {
  color: var(--gyla-color-text-muted);
  font-size: var(--gyla-text-caption);
  font-weight: 600;
  line-height: 1.3;
}

p.gyla-review__text {
  margin: 0;
  color: var(--gyla-color-text);
  font-size: var(--gyla-text-body);
  line-height: 1.65;
}

.gyla-reviews.is-ready .gyla-review__text {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 6;
  line-clamp: 6;
}

.gyla-reviews.is-ready .gyla-review.is-expanded .gyla-review__text {
  display: block;
  overflow: visible;
}

/* Text button; Astra styles every <button> as a filled theme button. */
.gyla-review__more {
  align-self: flex-start;
  margin: -8px 0 0;
  padding: 0;
  color: var(--gyla-color-teal-strong);
  font-family: inherit;
  font-size: var(--gyla-text-small);
  font-weight: 700;
  line-height: 1.4;
  text-decoration: underline;
  text-underline-offset: 3px;
  background: none;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  cursor: pointer;
}

.gyla-review__more:hover,
.gyla-review__more:focus {
  color: var(--gyla-color-teal-stronger);
  background: none;
}

.gyla-review__more[hidden] {
  display: none;
}

.gyla-review__author {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: auto;
  padding-top: 20px;
  border-top: 1px solid var(--gyla-color-border);
}

.gyla-review__avatar {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  color: var(--gyla-color-ink);
  font-size: var(--gyla-text-small);
  font-weight: 700;
  line-height: 1;
  background: var(--gyla-color-orange);
  border-radius: 50%;
}

p.gyla-review__name {
  margin: 0;
  color: var(--gyla-color-ink);
  font-size: var(--gyla-text-body);
  font-weight: 700;
  line-height: 1.4;
}

/* Position in the row; decoration only. */
.gyla-reviews__progress {
  grid-area: progress;
  height: 4px;
  margin-top: 28px;
  overflow: hidden;
  background: var(--gyla-color-border);
  border-radius: 2px;
}

.gyla-reviews__progress span {
  display: block;
  height: 100%;
  background: var(--gyla-color-orange);
  transform: scaleX(0);
  transform-origin: left;
}

.gyla-reviews__controls {
  display: flex;
  grid-area: controls;
  gap: 8px;
  margin-top: 28px;
}

.gyla-reviews__progress[hidden],
.gyla-reviews__controls[hidden] {
  display: none;
}

/* Round icon buttons; every state is set because Astra styles <button> and its hover/focus. */
.gyla-reviews__button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  width: 48px;
  height: 48px;
  padding: 0;
  color: var(--gyla-color-ink);
  background: #ffffff;
  border: 1px solid var(--gyla-color-border-strong);
  border-radius: 50%;
  box-shadow: none;
  cursor: pointer;
  transition:
    background-color 200ms ease,
    border-color 200ms ease,
    color 200ms ease;
}

.gyla-reviews__button:focus {
  color: var(--gyla-color-ink);
  background: #ffffff;
}

.gyla-reviews__button:hover,
.gyla-reviews__button:focus-visible {
  color: #ffffff;
  background: var(--gyla-color-teal-strong);
  border-color: var(--gyla-color-teal-strong);
}

.gyla-reviews__button[hidden] {
  display: none;
}

.gyla-reviews__button svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

.gyla-reviews__toggle {
  margin-right: 8px;
}

.gyla-reviews__icon-play,
.gyla-reviews.is-paused .gyla-reviews__icon-pause {
  display: none;
}

.gyla-reviews.is-paused .gyla-reviews__icon-play {
  display: block;
}

/* Variant: white background (.gyla-reviews--white) next to light grey sections; cards turn grey */

.gyla-reviews--white {
  background: #ffffff;
}

.gyla-reviews--white .gyla-review {
  background: var(--gyla-color-surface-soft);
}

@media (prefers-reduced-motion: reduce) {
  .gyla-reviews__button {
    transition: none;
  }
}

@media (min-width: 901px) {
  .gyla-reviews__inner {
    grid-template-areas:
      "header controls"
      "track track"
      "progress progress";
  }

  .gyla-reviews__controls {
    align-self: end;
    margin: 0 0 40px;
  }

  .gyla-reviews__track {
    margin: 0;
  }

  /* Cards fade in and out at the container edges instead of being cut off. */
  .gyla-reviews.is-looping .gyla-reviews__track {
    mask-image: linear-gradient(to right, transparent, #000 32px, #000 calc(100% - 32px), transparent);
  }

  .gyla-reviews__list {
    gap: 24px;
    padding: 0;
  }

  .gyla-review {
    flex-basis: calc((100cqi - 48px) / 3);
    padding: 32px;
  }
}
