/* Testimonial Carousel — see elements/testimonial-carousel.php and _/js/testimonial-carousel.js */
.testimonial-carousel {
  --tc-card-width: 510px;    /* current card */
  --tc-group-width: 918px;   /* all three cards, outer edge to outer edge */
  --tc-active-bg: #1b1d20;
  --tc-side-bg: #212428;
  --tc-side-scale: 0.71;
  --tc-side-opacity: 0.5;
  --tc-arrow-offset: 50px;   /* arrow icon to the edge of the three cards */
  --tc-arrow-pad: 12px;      /* hit area around the arrow icon */
  --tc-arrow-size: 32px;
  --tc-arrow-color: #fff;
  --tc-arrow-hover-color: var(--mor-orange);
  --tc-arrow-shift: 10px;
  --tc-duration: 600ms;      /* read by the JS too */
  --tc-ease: cubic-bezier(0.4, 0, 0.2, 1);

  display: grid;
  grid-template-columns: auto minmax(0, var(--tc-group-width)) auto;
  grid-template-areas: "prev stage next";
  justify-content: center;
  align-items: center;
  column-gap: calc(var(--tc-arrow-offset) - var(--tc-arrow-pad));
  width: 100%;
  overflow-x: clip;
}
.testimonial-carousel *, .testimonial-carousel *::before, .testimonial-carousel *::after { box-sizing: border-box; }

/* ---- arrows ------------------------------------------------------------ */
.testimonial-carousel__arrow {
  position: relative;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--tc-arrow-pad);
  border: 0;
  background: none;
  color: var(--tc-arrow-color);
  cursor: pointer;
  transition: color 250ms var(--tc-ease), transform 250ms var(--tc-ease);
}
.testimonial-carousel__arrow--prev { grid-area: prev; }
.testimonial-carousel__arrow--next { grid-area: next; }

.testimonial-carousel__arrow:hover,
.testimonial-carousel__arrow:focus-visible { color: var(--tc-arrow-hover-color); }
.testimonial-carousel__arrow--prev:hover,
.testimonial-carousel__arrow--prev:focus-visible { transform: translateX(calc(-1 * var(--tc-arrow-shift))); }
.testimonial-carousel__arrow--next:hover,
.testimonial-carousel__arrow--next:focus-visible { transform: translateX(var(--tc-arrow-shift)); }
.testimonial-carousel__arrow:focus-visible { outline: 1px solid currentColor; outline-offset: 2px; }

.testimonial-carousel__arrow-icon {
  display: flex;
  font-size: var(--tc-arrow-size);
  line-height: 1;
}
/* One icon for both arrows: previous is the same icon mirrored */
.testimonial-carousel__arrow--prev .testimonial-carousel__arrow-icon { transform: scaleX(-1); }

.testimonial-carousel__arrow-icon svg {
  width: var(--tc-arrow-size);
  height: auto;
}
/* Any stroked SVG (the default arrow or an uploaded one) follows the arrow color */
.testimonial-carousel__arrow-icon svg[stroke]:not([stroke="none"]),
.testimonial-carousel__arrow-icon svg [stroke]:not([stroke="none"]) {
  stroke: currentColor;
  transition: stroke 250ms var(--tc-ease);
}

/* ---- cards ------------------------------------------------------------- */
/* Every card shares one grid cell, so the stage is as tall as the tallest card.
   The stage spans all three cards and is their size container (cqw below). */
.testimonial-carousel__stage {
  grid-area: stage;
  container-type: inline-size;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  justify-items: center;
  touch-action: pan-y;
}

.testimonial-carousel__card {
  grid-area: 1 / 1;
  /* Side cards' outer edges land on the stage edges: half the stage less half a scaled card */
  --tc-side-x: calc(50cqw - min(var(--tc-card-width), 100cqw) * var(--tc-side-scale) / 2);

  width: var(--tc-card-width);
  max-width: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center; /* cards share the tallest card's height; centre shorter quotes in it */
  margin: 0;
  padding: 48px;
  border-radius: 8px;
  background: var(--tc-active-bg);
  transition:
    transform var(--tc-duration) var(--tc-ease),
    opacity var(--tc-duration) var(--tc-ease),
    background-color var(--tc-duration) var(--tc-ease);
}

.testimonial-carousel__card.is-active {
  z-index: 3;
}

.testimonial-carousel__card.is-prev,
.testimonial-carousel__card.is-next {
  z-index: 2;
  background: var(--tc-side-bg);
  cursor: pointer;
}
.testimonial-carousel__card.is-prev { transform: translateX(calc(-1 * var(--tc-side-x))) scale(var(--tc-side-scale)); }
.testimonial-carousel__card.is-next { transform: translateX(var(--tc-side-x)) scale(var(--tc-side-scale)); }

.testimonial-carousel__card.is-before,
.testimonial-carousel__card.is-after {
  z-index: 1;
  opacity: 0;
  pointer-events: none;
}

.testimonial-carousel__card.is-faded {
  opacity: 0;
  pointer-events: none;
}

/* Off stage: one more slot out, so a card pushed off an edge fades away beyond it and an incoming one fades in from there */
.testimonial-carousel__card.is-before { transform: translateX(calc(-2 * var(--tc-side-x))) scale(calc(var(--tc-side-scale) * 0.8)); }
.testimonial-carousel__card.is-after { transform: translateX(calc(2 * var(--tc-side-x))) scale(calc(var(--tc-side-scale) * 0.8)); }

.testimonial-carousel__card.is-instant,
.testimonial-carousel__card.is-instant .testimonial-carousel__content { transition: none; }

.testimonial-carousel__content {
  text-align: left;
  transition: opacity var(--tc-duration) var(--tc-ease);
}
.testimonial-carousel__card:not(.is-active) .testimonial-carousel__content {
  opacity: var(--tc-side-opacity);
}

.testimonial-carousel__quote {
  margin: 0;
  padding: 0;
  border: 0;
  color: #fff;
  font-family: "Karla", sans-serif;
  font-size: 22px;
  font-style: normal;
  font-weight: 400;
  line-height: 32px;
}

.testimonial-carousel__meta {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  margin-top: 24px;
  text-align: left;
}

.testimonial-carousel__name {
  color: var(--mor-orange);
  font-family: "Karla", sans-serif;
  font-size: 16px;
  font-style: normal;
  font-weight: 700;
  line-height: normal;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.testimonial-carousel__role {
  color: rgba(255, 255, 255, 0.7);
  font-family: "Karla", sans-serif;
  font-size: 16px;
  font-style: normal;
  font-weight: 400;
  line-height: normal;
  letter-spacing: 1px;
}

/* ---- small screens: one card, arrows underneath ------------------------ */
@media (max-width: 767px) {
  .testimonial-carousel {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-areas: "stage stage" "prev next";
    row-gap: 16px;
  }
  .testimonial-carousel__arrow--prev { justify-self: end; }
  .testimonial-carousel__arrow--next { justify-self: start; }

  .testimonial-carousel__card:not(.is-active) {
    opacity: 0;
    pointer-events: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .testimonial-carousel { --tc-duration: 0ms; }
}
