/* ==========================================================================
   Section: testimonials  →  assets/section-testimonials.css
   Figma 1164-3158: 1320 wide inside the page width, 64px below the UGC Gallery. Two 658×658
   squares 4px apart:
     media    #f2f2f2, photo cover-cropped; product tag 24px in from the bottom-left corner;
              72×32 white prev | next box flush in the bottom-right corner
     review   #f6f6f6 with a 1px #e2e2e2 inside stroke, 60px in from the outer edge:
              5 × 16px stars → 80px → 56px avatar → 24px → quote (Heading/H3, 538 wide)
              at the top; name (Heading/H4) → 12px → meta row (Body/M) 61px off the bottom
   The review panel's fill and stroke are one layer behind every slide (the slider's ::before),
   so the reviews fade over each other without their backgrounds covering one another.
   Every review sits in the same grid cell, so the section is as tall as its longest review and
   never jumps while stepping through them.
   Settings — custom properties on .testimonials
     --section-top 64px   --review-inset 60px   --rating-gap 80px   --quote-size 32px
   ========================================================================== */
.testimonials {
  --section-top: 64px;
  --review-inset: clamp(24px, 4.1667vw, 60px);
  --rating-gap: clamp(32px, 5.5556vw, 80px);
  --quote-size: clamp(24px, 2.2223vw, 32px);
  --name-size: clamp(20px, 1.6667vw, 24px);
  --media-bg: var(--color-surface-muted);
  --review-bg: var(--color-surface-tertiary);
  --review-border: var(--color-border-tertiary);
  --grain-opacity: 0.12; /* Figma's Noise effect on the photo (1164-3160), components/media-grain.css */

  padding-top: var(--section-top);
}

/* Desktop: two columns; each review spans both through a subgrid */
.testimonials__slider {
  position: relative;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: 4px;
}

.testimonials__slider::before {
  content: "";
  grid-area: 1 / 2;
  border: 1px solid var(--review-border);
  background: var(--review-bg);
}

.testimonials__slide {
  display: grid;
  grid-area: 1 / 1 / 2 / 3;
  grid-template-columns: subgrid;
  visibility: hidden;
}

.testimonials__slide.is-active,
.testimonials__slide.is-leaving {
  visibility: visible;
}

/* The incoming review is drawn over the one leaving */
.testimonials__slide.is-active {
  z-index: 1;
}

/* ----------------------------------------------------------------- media */
.testimonials__media {
  position: relative;
  overflow: hidden;
  container: testimonial-media / inline-size;
  background: var(--media-bg);
  touch-action: pan-y; /* horizontal swipes reach the slider, vertical ones scroll the page */
}

.testimonials__image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: var(--focal-x, 50%) var(--focal-y, 50%);
  /* --reveal-scale and --drift-x are the slide transition's (testimonials.js) */
  transform: scale(calc(var(--zoom, 1) * var(--reveal-scale, 1)));
  transform-origin: var(--focal-x, 50%) var(--focal-y, 50%);
  translate: var(--drift-x, 0%) 0;
}

.testimonials__product {
  position: absolute;
  bottom: 24px;
  left: 24px;
  z-index: 1;
  max-width: calc(100% - 48px);
}

.testimonials__product .product-tag__info {
  flex: 0 1 200px;
  min-width: 0;
}

/* Too narrow for the tag and the arrows side by side: the tag moves up over the arrows' row */
@container testimonial-media (max-width: 420px) {
  .testimonials__product {
    bottom: 44px;
    left: 12px;
    max-width: calc(100% - 24px);
  }
}

/* ---------------------------------------------------------------- review
   Transparent: the fill and stroke are the slider's ::before. The insets are the 60px Figma
   measures from the outer edge; the 61px at the bottom is Figma's (its author block is 61 tall). */
.testimonials__content {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 24px;
  aspect-ratio: 1; /* the square, but it grows when a long review needs more room */
  padding: var(--review-inset) var(--review-inset) calc(var(--review-inset) + 1px);
  color: var(--color-text-primary);
}

.testimonials__review {
  display: flex;
  flex-direction: column;
  gap: var(--rating-gap);
}

.testimonials__rating {
  display: flex;
  gap: 4px;
  color: var(--color-icon-primary);
}

.testimonials__body {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 24px;
}

.testimonials__avatar {
  position: relative;
  width: 56px;
  height: 56px;
  overflow: hidden;
  border-radius: 50%;
  background: var(--color-white);
}

.testimonials__avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: var(--focal-x, 50%) var(--focal-y, 50%);
  transform: scale(var(--zoom, 1));
  transform-origin: var(--focal-x, 50%) var(--focal-y, 50%);
}

/* Heading/H3: EB Garamond 500 / 1.2. Figma lays each line out on a whole-pixel box (38px at 32px),
   so the line height is rounded the same way. */
.testimonials__quote {
  font-family: var(--font-display);
  font-size: var(--quote-size);
  font-weight: 500;
  line-height: 1.2;
  line-height: round(nearest, var(--quote-size) * 1.2, 1px);
}

.testimonials__author {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
}

/* Heading/H4: EB Garamond 500 24px / 1.2, on Figma's 29px box */
.testimonials__name {
  font-family: var(--font-display);
  font-size: var(--name-size);
  font-weight: 500;
  line-height: 1.2;
  line-height: round(nearest, var(--name-size) * 1.2, 1px);
}

/* Body/M: Inter 400 14px / 1.4, on Figma's 20px box. Two classes: reset.css zeroes list padding
   with ul[role="list"] (0,1,1). */
.testimonials__meta.testimonials__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 0;
  list-style: none;
  color: var(--color-text-secondary);
  font-size: var(--text-body-m-size);
  font-weight: 400;
  line-height: 20px;
}

.testimonials__meta-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.testimonials__meta-item > span {
  width: var(--width-whole-px);
  white-space: nowrap;
}

.testimonials__meta-item .icon {
  color: var(--color-icon-secondary);
}

.testimonials__meta-bar {
  color: var(--color-icon-tertiary);
}

/* ------------------------------------------------------------ navigation
   Figma 1164-3169: 8px padding, [prev] 4 [divider] 4 [next]. An arrow at the end of the list is
   disabled and drawn in the secondary icon colour, as Figma's prev arrow on the first review. */
.testimonials__nav {
  display: flex;
  grid-area: 1 / 1;
  align-self: end;
  justify-self: end;
  z-index: 2;
  gap: 4px;
  padding: 8px;
  background: var(--color-white);
  color: var(--color-icon-tertiary);
}

testimonial-slider:not(:defined) .testimonials__nav {
  visibility: hidden;
}

.testimonials__arrow {
  position: relative;
  color: var(--color-icon-primary);
  transition: color var(--duration-fast) ease;
}

/* 16px icons, 32px targets */
.testimonials__arrow::after {
  content: "";
  position: absolute;
  inset: -8px -4px;
}

.testimonials__arrow .icon {
  transition: transform var(--duration-fast) var(--ease-out);
}

.testimonials__arrow:disabled {
  color: var(--color-icon-secondary);
  cursor: default;
}

@media (hover: hover) {
  .testimonials__arrow:not(:disabled):hover [class*="icon-chevron-left"] {
    transform: translateX(-2px);
  }

  .testimonials__arrow:not(:disabled):hover [class*="icon-chevron-right"] {
    transform: translateX(2px);
  }
}

.testimonials__arrow:focus-visible {
  outline-offset: 4px;
}

/* ------------------------------------------------------------- responsive */

/* Tablet and phone: photo over review, each a full-width row; the arrows stay on the photo */
@media (max-width: 989px) {
  .testimonials__slider {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto;
    row-gap: 4px;
  }

  .testimonials__slider::before {
    grid-area: 2 / 1;
  }

  .testimonials__slide {
    grid-area: 1 / 1 / 3 / 2;
    grid-template-rows: subgrid;
  }

  .testimonials__media {
    aspect-ratio: 1;
  }

  .testimonials__content {
    aspect-ratio: auto;
    gap: 40px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .testimonials__arrow,
  .testimonials__arrow .icon {
    transition: none;
  }
}
