.embla {
  max-width: 48rem;
  margin: auto;
  --slide-height: 28rem;
  --slide-spacing: 0;
  --slide-size: 100%;
}

.embla__viewport {
  overflow: hidden;
  border-radius: 1.8rem;
}

.embla__container {
  backface-visibility: hidden;
  display: block;
  position: relative;
  touch-action: pan-y pinch-zoom;
  min-height: var(--slide-height);
  transform: none !important;
}

/* Increase container height when carousel has captions */
.embla[data-has-captions="true"] .embla__container {
  min-height: calc(var(--slide-height) + 6rem);
}

.embla__slide {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  min-height: 100%;
  opacity: 0;
  transition: opacity 0.6s ease-in-out;
  pointer-events: none;
  display: flex;
  flex-direction: column;
}

.embla__slide.is-selected {
  opacity: 1;
  z-index: 1;
  pointer-events: auto;
}

.embla__slide__number {
  box-shadow: inset 0 0 0 0.2rem var(--detail-medium-contrast);
  border-radius: 1.8rem;
  font-size: 4rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  height: var(--slide-height);
  user-select: none;
}

.embla__controls {
  display: grid;
  grid-template-columns: auto 1fr;
  justify-content: space-between;
  gap: 1.2rem;
  margin-top: 1.8rem;
}

.embla__buttons {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.6rem;
  align-items: center;
}

.embla__button {
  -webkit-appearance: none;
  appearance: none;
  background-color: transparent;
  touch-action: manipulation;
  display: inline-flex;
  text-decoration: none;
  cursor: pointer;
  border: 0;
  padding: 0;
  margin: 0;
  box-shadow: inset 0 0 0 0.2rem var(--detail-medium-contrast);
  width: 3.6rem;
  height: 3.6rem;
  z-index: 1;
  border-radius: 50%;
  color: var(--text-body);
  display: flex;
  align-items: center;
  justify-content: center;
}

.embla__button:disabled {
  color: var(--detail-high-contrast);
}

.embla__button__svg {
  width: 35%;
  height: 35%;
}

.embla__play {
  -webkit-appearance: none;
  appearance: none;
  background-color: transparent;
  touch-action: manipulation;
  display: inline-flex;
  text-decoration: none;
  cursor: pointer;
  border: 0;
  padding: 0;
  margin: 0;
  box-shadow: inset 0 0 0 0.2rem var(--detail-medium-contrast);
  border-radius: 1.8rem;
  min-width: 8.4rem;
  height: 3.6rem;
  z-index: 1;
  color: var(--text-body);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.4rem;
}

.embla__slide-container {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  position: relative;
}

/* Image wrapper to contain the image */
.embla__slide figure {
  margin: 0;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  padding: 0.5rem;
}

/* Image styling - ensure contain mode for full visibility */
.embla__slide__img {
  display: block;
  max-width: 100%;
  max-height: calc(var(--slide-height) - 4rem);
  width: auto;
  height: auto;
  margin: 0 auto;
  object-fit: contain;
  cursor: pointer;
}

/* Fill mode: cover - images fill the container and may be cropped */
.embla[data-fill-mode="cover"] .embla__slide__img {
  object-fit: cover;
  width: 100%;
  height: calc(var(--slide-height) - 4rem);
  max-height: none;
}

/* Fit mode: contain - images fit within container (default) */
.embla[data-fill-mode="contain"] .embla__slide__img {
  object-fit: contain;
}

.embla__parallax {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.embla__parallax__layer {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Caption styling - always visible below image */
.embla__slide figcaption {
  color: var(--color-text);
  padding: 0.75rem 1rem;
  font-size: 0.9rem;
  text-align: center;
  line-height: 1.4;
  overflow-wrap: break-word;
  word-wrap: break-word;
  hyphens: auto;
  flex-shrink: 0;
  background: var(--color-bg);
}

.embla__parallax__img {
  opacity: 0;
  transition: opacity 0.2s ease-in-out;
}

.embla__slide--has-target .embla__parallax__img {
  opacity: 1;
}

@media (prefers-color-scheme: dark) {
  .embla__slide figcaption {
    color: var(--color-text);
  }
}