/*
 * School Content – carousel (DOM contract: AGENT_TASKS.md §2).
 * Everything is scoped to .scc-carousel. Layout works without JavaScript (the track scrolls and
 * snaps); buttons, dots and the play button appear once media/js/carousel.js set data-scc-ready.
 */
.scc-carousel {
  --scc-pv: var(--scc-per-view, 1);
  --scc-gap-x: var(--scc-gap, 16px);
  position: relative;
  box-sizing: border-box;
  max-width: 100%;
  margin: 1.5rem 0;
}

.scc-carousel *,
.scc-carousel *::before,
.scc-carousel *::after {
  box-sizing: border-box;
}

@media (min-width: 640px) {
  .scc-carousel {
    --scc-pv: var(--scc-per-view-md, 2);
  }
}

@media (min-width: 1024px) {
  .scc-carousel {
    --scc-pv: var(--scc-per-view-lg, 3);
  }
}

.scc-carousel__frame {
  position: relative;
}

.scc-carousel__viewport {
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
}

.scc-carousel[data-scc-ready] .scc-carousel__viewport {
  scrollbar-width: none;
}

.scc-carousel[data-scc-ready] .scc-carousel__viewport::-webkit-scrollbar {
  display: none;
}

/* Two classes on purpose: templates clip lists in articles (Cassiopeia: ".com-content-article ul { overflow: hidden }"),
   which would stop the viewport from scrolling. */
.scc-carousel .scc-carousel__track {
  overflow: visible;
}

.scc-carousel__track {
  display: flex;
  align-items: flex-start;
  gap: var(--scc-gap-x);
  margin: 0;
  padding: 0;
  list-style: none;
}

.scc-carousel__slide {
  flex: 0 0 calc((100% - (var(--scc-pv) - 1) * var(--scc-gap-x)) / var(--scc-pv));
  min-width: 0;
  margin: 0;
  padding: 0;
  list-style: none;
  scroll-snap-align: start;
  scroll-snap-stop: always;
}

.scc-carousel__figure {
  margin: 0;
  padding: 0;
}

.scc-carousel__link {
  display: block;
  color: inherit;
  text-decoration: none;
}

.scc-carousel__image {
  display: block;
  width: 100%;
  height: auto;
  max-width: 100%;
  background: #f3f4f6;
  -webkit-user-drag: none;
  user-select: none;
}

.scc-carousel:not(.scc-carousel--ratio-auto) .scc-carousel__image {
  aspect-ratio: var(--scc-ratio, 1.7778);
  object-fit: contain;
  object-position: var(--scc-position, center);
}

.scc-carousel--fit-cover:not(.scc-carousel--ratio-auto) .scc-carousel__image {
  object-fit: cover;
}

.scc-carousel__caption {
  padding: 0.5rem 0.25rem 0;
  font-size: 0.9rem;
  line-height: 1.4;
}

/* Controls */
.scc-carousel__prev,
.scc-carousel__next {
  position: absolute;
  top: 50%;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  margin: 0;
  padding: 0;
  transform: translateY(-50%);
  border: 2px solid #fff;
  border-radius: 50%;
  background: rgba(17, 24, 39, 0.82);
  color: #fff;
  cursor: pointer;
  line-height: 1;
}

.scc-carousel__prev {
  inset-inline-start: 0.5rem;
}

.scc-carousel__next {
  inset-inline-end: 0.5rem;
}

.scc-carousel__prev:hover,
.scc-carousel__next:hover {
  background: #000;
}

.scc-carousel__prev[aria-disabled="true"],
.scc-carousel__next[aria-disabled="true"] {
  opacity: 0.4;
  cursor: default;
}

.scc-carousel:dir(rtl) .scc-icon {
  transform: scaleX(-1);
}

.scc-carousel__prev:focus-visible,
.scc-carousel__next:focus-visible,
.scc-carousel__dot:focus-visible,
.scc-carousel__play:focus-visible,
.scc-carousel__link:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 0;
  box-shadow: 0 0 0 6px #1d4ed8;
}

.scc-carousel__controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.scc-carousel__dots {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
}

.scc-carousel__dot {
  position: relative;
  width: 1.75rem;
  height: 1.75rem;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
}

.scc-carousel__dot::before {
  content: "";
  position: absolute;
  inset: 0.5rem;
  border: 2px solid currentColor;
  border-radius: 50%;
  background: transparent;
}

.scc-carousel__dot[aria-current="true"]::before {
  background: currentColor;
}

.scc-carousel__dot[hidden] {
  display: none;
}

.scc-carousel__play {
  min-height: 2.25rem;
  margin: 0;
  padding: 0.25rem 0.9rem;
  border: 2px solid currentColor;
  border-radius: 999px;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
}

.scc-carousel__play:hover {
  background: rgba(128, 128, 128, 0.2);
}

.scc-carousel__play[hidden] {
  display: none;
}

/* Live region: visually hidden */
.scc-carousel__status {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* Controls need JavaScript */
.scc-carousel:not([data-scc-ready]) .scc-carousel__prev,
.scc-carousel:not([data-scc-ready]) .scc-carousel__next,
.scc-carousel:not([data-scc-ready]) .scc-carousel__controls {
  display: none;
}

@media (prefers-reduced-motion: reduce) {
  .scc-carousel__viewport {
    scroll-behavior: auto;
  }
}

@media (forced-colors: active) {
  .scc-carousel__prev,
  .scc-carousel__next {
    border-color: ButtonText;
    background: ButtonFace;
    color: ButtonText;
  }

  .scc-carousel__dot::before {
    border-color: ButtonText;
  }

  .scc-carousel__dot[aria-current="true"]::before {
    background: Highlight;
  }
}
