/* aligns the carousel with the padded homepage content at desktop and mobile widths. */
body.index .home-carousel {
  box-sizing: border-box;
  width: calc(100% - 2rem);
  max-width: 59rem;
  margin: 0 auto clamp(4.5rem, 8vw, 8rem);
  color: var(--kimi-ivory);
}

/* matches the shared desktop container's width after its existing side padding. */
@media screen and (min-width: 976px) {
  body.index .home-carousel {
    max-width: calc(1500px - 2rem);
  }
}

/* keeps the gallery aligned with the narrowed laptop containers and their unchanged padding. */
@media screen and (min-width: 976px) and (max-width: 1920px) {
  body.index .home-carousel {
    max-width: calc(min(75vw, 1125px) - 2rem);
  }
}

/* prevents theme defaults from exposing inactive slides or hidden controls. */
.home-carousel [hidden] {
  display: none !important;
}

/* overlaps transitioning slides in one clipped frame without adding horizontal page scrolling. */
.home-carousel-slides {
  display: grid;
  overflow: hidden;
}
.home-carousel-slide {
  grid-area: 1 / 1;
  align-self: start;
  min-width: 0;
  margin: 0;
}

/* preserves the existing frame proportions while fitting the entire image or video. */
.home-carousel-media {
  aspect-ratio: 16 / 9;
  width: 100%;
  overflow: hidden;
}
.home-carousel-media img,
.home-carousel-media video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* gives selected slide media a white background without changing their captions. */
.home-carousel-media[data-slide-folder="3"],
.home-carousel-media[data-slide-folder="16"],
.home-carousel-media[data-slide-folder="19"],
.home-carousel-media[data-slide-folder="20"] {
  background-color: #fff;
}

/* displays paired videos side by side within the existing desktop media frame. */
.home-carousel-media-pair {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: minmax(0, 1fr);
  gap: 1rem;
}
.home-carousel-media-pair video {
  min-width: 0;
  min-height: 0;
}

/* stacks paired videos on narrow screens so both sets of native controls remain usable. */
@media screen and (max-width: 600px) {
  .home-carousel-media-pair {
    aspect-ratio: auto;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto;
  }
  .home-carousel-media-pair video {
    aspect-ratio: 16 / 9;
    height: auto;
  }
}

/* places multiline plain-text descriptions beneath the media. */
.home-carousel figcaption {
  padding: 1rem 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.6;
  text-align: center;
}

/* provides legible keyboard-accessible controls on the fluid dark background. */
.home-carousel-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
}
.home-carousel-controls button {
  padding: 0.6rem 1rem;
  border: 1px solid var(--kimi-line);
  border-radius: 999px;
  color: var(--kimi-ivory);
  background: #0b1720;
  cursor: pointer;
}
.home-carousel-controls button:hover,
.home-carousel-controls button:focus-visible {
  outline: 2px solid var(--kimi-cyan-bright);
  outline-offset: 2px;
}

/* keeps localized media errors visible beside the navigation controls. */
.home-carousel-status {
  margin: 1rem 0 0;
  text-align: center;
}
