/*
 * School Content – slideshow (DOM contract: AGENT_TASKS.md §2).
 * Everything is scoped to .scc-slideshow. Without JavaScript the first slide is shown (the other
 * slides carry the hidden attribute); controls and thumbnails appear once media/js/slideshow.js
 * set data-scc-ready. Images are never scaled above their natural size (--scc-w / --scc-h).
 */
.scc-slideshow {
  position: relative;
  box-sizing: border-box;
  max-width: 100%;
  margin: 1.5rem 0;
}

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

.scc-slideshow__main {
  position: relative;
}

.scc-slideshow__stage {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  width: 100%;
  aspect-ratio: var(--scc-ratio, 1.5);
  max-height: var(--scc-max-height, 640px);
  overflow: hidden;
  background: var(--scc-bg, #111827);
  touch-action: pan-y;
}

.scc-slideshow__slide {
  position: relative;
  grid-area: 1 / 1;
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  min-height: 0;
  margin: 0;
  padding: 0;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.4s ease, transform 0.4s ease, visibility 0s linear 0.4s;
}

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

.scc-slideshow__slide.is-active {
  opacity: 1;
  visibility: visible;
  transition-delay: 0s;
}

/* Slide transition: neighbours wait outside the stage. */
.scc-slideshow[data-transition="slide"] .scc-slideshow__slide {
  opacity: 1;
  transform: translateX(100%);
}

.scc-slideshow[data-transition="slide"] .scc-slideshow__slide.is-before {
  transform: translateX(-100%);
}

.scc-slideshow[data-transition="slide"] .scc-slideshow__slide.is-active {
  transform: none;
}

.scc-slideshow[data-transition="slide"]:dir(rtl) .scc-slideshow__slide {
  transform: translateX(-100%);
}

.scc-slideshow[data-transition="slide"]:dir(rtl) .scc-slideshow__slide.is-before {
  transform: translateX(100%);
}

.scc-slideshow[data-transition="slide"]:dir(rtl) .scc-slideshow__slide.is-active {
  transform: none;
}

.scc-slideshow[data-transition="none"] .scc-slideshow__slide {
  transition: none;
}

.scc-slideshow__image {
  display: block;
  width: 100%;
  height: 100%;
  max-width: var(--scc-w, 100%);
  max-height: var(--scc-h, 100%);
  object-fit: contain;
  object-position: var(--scc-position, center);
  -webkit-user-drag: none;
  user-select: none;
}

.scc-slideshow--fit-cover .scc-slideshow__image {
  object-fit: cover;
}

.scc-slideshow__caption {
  position: absolute;
  inset-inline: 0;
  bottom: 0;
  padding: 0.6rem 1rem;
  background: rgba(0, 0, 0, 0.72);
  color: #fff;
  font-size: 0.95rem;
  line-height: 1.4;
}

.scc-slideshow__caption a {
  color: #fff;
  text-decoration: underline;
}

/* Controls */
.scc-slideshow__prev,
.scc-slideshow__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-slideshow__prev {
  inset-inline-start: 0.5rem;
}

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

.scc-slideshow__prev:hover,
.scc-slideshow__next:hover {
  background: #000;
}

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

.scc-slideshow__play {
  position: absolute;
  top: 0.5rem;
  inset-inline-end: 0.5rem;
  z-index: 2;
  min-height: 2.25rem;
  margin: 0;
  padding: 0.25rem 0.9rem;
  border: 2px solid #fff;
  border-radius: 999px;
  background: rgba(17, 24, 39, 0.82);
  color: #fff;
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
}

.scc-slideshow__play:hover {
  background: #000;
}

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

.scc-slideshow__prev:focus-visible,
.scc-slideshow__next:focus-visible,
.scc-slideshow__play:focus-visible,
.scc-slideshow__thumb:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 0;
  box-shadow: 0 0 0 6px #1d4ed8;
}

/* Thumbnails */
.scc-slideshow__thumbs {
  position: relative;
  display: flex;
  gap: 0.5rem;
  padding: 0.5rem 0.4rem 0.6rem;
  overflow-x: auto;
}

.scc-slideshow__thumb {
  flex: 0 0 auto;
  width: 5rem;
  height: 3.5rem;
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 3px solid transparent;
  border-radius: 2px;
  background: #111827;
  cursor: pointer;
  opacity: 0.7;
}

.scc-slideshow__thumb:hover {
  opacity: 1;
}

.scc-slideshow__thumb[aria-current="true"] {
  border-color: #1d4ed8;
  box-shadow: inset 0 0 0 2px #fff;
  opacity: 1;
}

.scc-slideshow__thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}

/* Live region: visually hidden */
.scc-slideshow__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-slideshow:not([data-scc-ready]) .scc-slideshow__prev,
.scc-slideshow:not([data-scc-ready]) .scc-slideshow__next,
.scc-slideshow:not([data-scc-ready]) .scc-slideshow__play,
.scc-slideshow:not([data-scc-ready]) .scc-slideshow__thumbs {
  display: none;
}

@media (prefers-reduced-motion: reduce) {
  .scc-slideshow__slide {
    transition: none;
  }
}

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

  .scc-slideshow__thumb[aria-current="true"] {
    border-color: Highlight;
  }
}
