/*
 * Testimonial carousel (testimonials block, carousel style), out of
 * about.css so a carousel on any page links only this. Head, by class
 * prefix "carousel" (peanut_scoped_css()), right after about.css.
 */

@layer blocks {
  /* One slide per view in a scroll-snap track. The track scrolls inside its own box, so
     the page never scrolls sideways. Without JS the scrollbar shows (the
     only cue that it scrolls); once motion.js shows the arrows and dots
     (.is-ready) the scrollbar hides. The dots are a pagination control,
     not buttons in the .btn sense: 12px marks inside 44px targets. */
  .carousel {
    max-width: 48rem;
    margin-inline: auto;
  }

  /* positioned, so the slides measure their offsetLeft from the track (motion.js) */
  .carousel__track {
    position: relative;
    display: grid;
    grid-auto-columns: 100%;
    grid-auto-flow: column;
    gap: var(--space-4);
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x mandatory;
    border-radius: var(--radius-sm);
  }

  .carousel.is-ready .carousel__track {
    scrollbar-width: none;
  }

  .carousel.is-ready .carousel__track::-webkit-scrollbar {
    display: none;
  }

  .carousel__track:focus-visible {
    outline: 3px solid var(--focus-ring);
    outline-offset: 4px;
  }

  .carousel__slide {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-3);
    margin: 0;
    padding: var(--space-5) var(--space-4);
    border: var(--border);
    border-radius: var(--radius-sm);
    background: var(--color-white);
    color: var(--color-ink);
    text-align: center;
    scroll-snap-align: start;
  }

  .carousel__slide .testimonial__avatar {
    width: 7rem;
    height: 7rem;
    border: var(--border);
  }

  .carousel__slide .testimonial__quote {
    max-width: 36rem;
    font-family: var(--font-heading);
    font-size: var(--step-2);
    font-weight: var(--weight-heading);
    line-height: 1.4;
    text-wrap: balance;
  }

  .carousel__slide .testimonial__quote > p::before {
    content: "\201C";
  }

  .carousel__slide .testimonial__quote > p::after {
    content: "\201D";
  }

  /* Phones: the dots get their own centered row and Previous and Next sit
     under them (in one row the three were wider than a 390 px screen and
     the page scrolled sideways once the controls appeared); one row from
     40rem */
  .carousel__controls:not([hidden]) {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    margin-block-start: var(--space-3);
  }

  .carousel__dots {
    display: flex;
    flex-basis: 100%;
    justify-content: center;
    order: -1;
  }

  @media (min-width: 40rem) {
    .carousel__dots {
      flex-basis: auto;
      order: 0;
    }
  }

  .carousel__dot {
    display: grid;
    place-items: center;
    width: 2.75rem;
    height: 2.75rem;
    padding: 0;
    border: 0;
    background: none;
    cursor: pointer;
  }

  .carousel__dot::before {
    content: "";
    width: 0.75rem;
    height: 0.75rem;
    border: var(--border);
    border-radius: 50%;
  }

  .carousel__dot[aria-current="true"]::before {
    background: var(--color-ink);
  }

  .carousel__dot:focus-visible {
    outline: 3px solid var(--focus-ring);
    outline-offset: -6px;
  }

  @media print {
    .carousel__track {
      display: block;
      overflow: visible;
    }

    .carousel__slide + .carousel__slide {
      margin-block-start: var(--space-3);
    }
  }
}
