/* ---- Carousel — .carousel (BPDGo#795) ---------------------------------------------------------------------------
   One row of items you cycle by hand; it never moves on its own. The track scrolls sideways and snaps to an item, so a
   swipe or a trackpad moves it. Previous and Next are elevated icon buttons at the row's ends. Each press moves the row
   one item; a button hides at its end (no wrap-around), and both stay hidden while every item fits. carousel.js runs the
   buttons and Left / Right on them. Shown in /styleguide.

   A page lays it out, and nothing more:
   - --carousel-per-view: how many items show at once (default 3). A fraction (1.2) lets the next one peek in. To change
     it with the carousel's width, use an @container query on the carousel's children; the carousel is the container.
   - --carousel-nav-top: where the buttons sit up and down (default the row's middle). --carousel-item-w is one item's
     width, for that.

   The carousel is a size container: it takes its width from where it sits (a block, a grid cell, a stretched flex item)
   and never sizes itself to its items, so don't put it where its width would come from its content.

   Markup: .carousel[data-carousel] > button.icon-btn.carousel__nav.carousel__nav--prev[data-carousel-prev][hidden],
   .carousel__track[data-carousel-track] > items, button…--next[data-carousel-next][hidden]. Label the buttons with what
   they move ("Previous goals"). */
.carousel {
  --carousel-per-view: 3;
  --carousel-gap: 1rem;
  position: relative;
  container-type: inline-size;
}
.carousel > * {
  --carousel-item-w: calc((100cqi - (var(--carousel-per-view) - 1) * var(--carousel-gap)) / var(--carousel-per-view));
}
.carousel__track {
  display: flex; gap: var(--carousel-gap);
  overflow-x: auto; overscroll-behavior-x: contain; scroll-snap-type: x mandatory; scrollbar-width: none;
  /* A scrolling box clips at its padding box. The padding leaves the items' shadow and focus ring room on every side;
     the negative margins take it back, so the items still line up with what's above and below them. The sides' room is
     kept under the gap, so the next item's shadow stays out of sight until it's brought in. */
  --carousel-bleed: max(0.375rem, 4px) /* fixed px: the focus ring's 2px outline + 2px offset, at every Display size */;
  padding: var(--carousel-bleed) var(--carousel-bleed) 1.5rem;
  margin: calc(-1 * var(--carousel-bleed)) calc(-1 * var(--carousel-bleed)) -1.25rem;
  scroll-padding-inline: var(--carousel-bleed);
}
.carousel__track::-webkit-scrollbar { display: none; }
.carousel__track > * { flex: 0 0 var(--carousel-item-w); min-width: 0; scroll-snap-align: start; }
.icon-btn.carousel__nav {
  position: absolute; z-index: 2; top: var(--carousel-nav-top, 50%); transform: translateY(-50%);
  background: var(--md-sys-color-surface-container-lowest); color: var(--md-sys-color-on-surface);
  box-shadow: var(--elev-2);
}
.carousel__nav--prev { inset-inline-start: calc(var(--icon-btn-size) * -0.5); }
.carousel__nav--next { inset-inline-end: calc(var(--icon-btn-size) * -0.5); }
.icon-btn.carousel__nav[hidden] { display: none; }
