.gallery-block,
.gallery-menu {
  --gallery-gap: var(--awa-space, 1rem);
  --gallery-radius: var(--bs-border-radius-lg, 0.75rem);
  --gallery-border: var(--bs-border-color, rgba(128, 128, 128, 0.35));
  --gallery-bg: var(--color-background, var(--bs-body-bg, Canvas));
  --gallery-surface: var(--color-surface, var(--bs-tertiary-bg, var(--gallery-bg)));
  --gallery-text: var(--color-foreground, var(--theme-text, var(--bs-body-color, CanvasText)));
  --gallery-muted: var(--color-muted, var(--theme-muted, var(--bs-secondary-color, color-mix(in srgb, var(--gallery-text) 72%, transparent))));
  --gallery-accent: var(--bs-link-color, currentColor);
  --gallery-control-bg: color-mix(in srgb, var(--gallery-surface) 88%, var(--gallery-text) 12%);
  color: var(--gallery-text);
}

.gallery-block *,
.gallery-menu * {
  box-sizing: border-box;
}

.theme-dark .gallery-block,
.theme-dark .gallery-menu {
  --gallery-bg: var(--color-background, var(--theme-background, var(--awa-color-background, #15181c)));
  --gallery-surface: var(--color-surface, var(--theme-surface, var(--awa-color-surface, #24282e)));
  --gallery-text: var(--color-foreground, var(--theme-foreground, var(--awa-color-foreground, #f5f7fa)));
  --gallery-muted: var(--color-muted, var(--theme-muted, var(--awa-color-muted, #c4cad1)));
  --gallery-accent: var(--color-accent, var(--theme-accent, var(--awa-color-accent, #9ec5fe)));
  --gallery-border: var(--color-border, var(--theme-border, var(--awa-color-border, rgba(255, 255, 255, 0.28))));
  --gallery-control-bg: color-mix(in srgb, var(--gallery-surface) 90%, var(--gallery-text) 10%);
}

.gallery-slideshow {
  position: relative;
}

.gallery-slides {
  position: relative;
  display: grid;
  overflow: hidden;
  border-radius: var(--gallery-radius);
  background: var(--gallery-bg);
}

.gallery-slide {
  grid-area: 1 / 1;
  min-width: 0;
  margin: 0;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateX(100%);
  transition: opacity 450ms ease, transform 450ms ease, visibility 0s linear 450ms;
}

.gallery-slide[hidden] {
  display: block;
}

.gallery-slide.is-active {
  z-index: 1;
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateX(0);
  transition-delay: 0s;
}

.gallery-slide.is-preparing {
  visibility: visible;
  transition: none;
}

.gallery-slide.is-from-left {
  transform: translateX(-100%);
}

.gallery-slide.is-from-right {
  transform: translateX(100%);
}

.gallery-slide.is-leaving-left,
.gallery-slide.is-leaving-right {
  z-index: 1;
  opacity: 1;
  visibility: visible;
  transition-delay: 0s;
}

.gallery-slide.is-leaving-left {
  transform: translateX(-100%);
}

.gallery-slide.is-leaving-right {
  transform: translateX(100%);
}

.gallery-block[data-gallery-effect="fade"] .gallery-slide {
  transform: none;
}

.gallery-block[data-gallery-effect="fade"] .gallery-slide.is-leaving-left,
.gallery-block[data-gallery-effect="fade"] .gallery-slide.is-leaving-right {
  opacity: 0;
}

.gallery-slide img {
  display: block;
  width: 100%;
  max-height: min(72vh, 48rem);
  object-fit: contain;
  background: var(--gallery-bg);
}

.gallery-caption {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  align-items: baseline;
  padding: 0.85rem 1rem;
  border-top: 1px solid var(--gallery-border);
}

.gallery-caption-title {
  color: var(--gallery-text);
  font-weight: 700;
}

.gallery-caption-credit {
  color: var(--gallery-muted);
  font-size: 0.9em;
}

.gallery-caption-credit-label {
  color: color-mix(in srgb, var(--gallery-muted) 82%, transparent);
  font-size: 0.875em;
}

.gallery-arrow {
  position: absolute;
  top: 50%;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border: 1px solid var(--gallery-border);
  border-radius: 999rem;
  color: var(--gallery-text);
  background: var(--gallery-control-bg);
  font-size: 2rem;
  line-height: 1;
  transform: translateY(-50%);
  cursor: pointer;
}

.gallery-arrow-glyph {
  display: block;
  line-height: 1;
  transform: translateY(-0.06em);
}

.gallery-arrow:hover,
.gallery-arrow:focus-visible {
  color: var(--gallery-accent);
  background: color-mix(in srgb, var(--gallery-control-bg) 82%, var(--gallery-accent) 18%);
  border-color: currentColor;
}

.gallery-arrow:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 2px;
}

.gallery-arrow--prev {
  left: 1rem;
}

.gallery-arrow--next {
  right: 1rem;
}

.gallery-dots {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  padding: 0.9rem 0 0;
}

.gallery-browser-panel[hidden] {
  display: none;
}

.gallery-dot {
  width: 0.7rem;
  height: 0.7rem;
  padding: 0;
  border: 1px solid var(--gallery-border);
  border-radius: 999rem;
  background: transparent;
  cursor: pointer;
}

.gallery-dot.is-active,
.gallery-dot:hover,
.gallery-dot:focus-visible {
  background: var(--gallery-accent);
  border-color: var(--gallery-accent);
}

.gallery-menu-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: stretch;
  margin: 0;
  padding: 0;
  list-style: none;
}

.gallery-menu {
  display: block;
  width: 100%;
  margin-block-start: clamp(1.5rem, 4vw, 3rem);
}

.gallery-menu-link {
  display: inline-flex;
  gap: 0.65rem;
  align-items: center;
  min-height: 100%;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--gallery-border);
  border-radius: var(--gallery-radius);
  color: var(--gallery-text);
  background: var(--gallery-surface);
  text-decoration: none;
  font: inherit;
  text-align: inherit;
  cursor: pointer;
}

.gallery-menu-link:hover,
.gallery-menu-link:focus-visible,
.gallery-menu-item.is-active .gallery-menu-link {
  color: var(--gallery-accent);
  border-color: currentColor;
}

.gallery-menu-thumb {
  flex: 0 0 auto;
  width: 4rem;
  height: 3rem;
  overflow: hidden;
  border: 1px solid var(--gallery-border);
  border-radius: calc(var(--gallery-radius) * 0.7);
  background: var(--gallery-bg);
}

.gallery-menu-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.gallery-menu-thumb--placeholder {
  background: color-mix(in srgb, var(--gallery-muted) 12%, transparent);
}

.gallery-menu-title {
  font-weight: 700;
}

.gallery-menu--cover_thumbnails .gallery-menu-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(13rem, 18rem));
  gap: clamp(1rem, 2.5vw, 1.5rem);
  align-items: stretch;
  width: 100%;
}

.gallery-menu--cover_thumbnails .gallery-menu-item {
  min-width: 0;
}

.gallery-menu--cover_thumbnails .gallery-menu-link {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  align-items: stretch;
  width: 100%;
  min-height: 0;
  padding: 0.75rem;
}

.gallery-menu--cover_thumbnails .gallery-menu-thumb {
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 3;
}

.gallery-menu--cover_thumbnails .gallery-menu-title {
  text-align: center;
  overflow-wrap: anywhere;
}

@media (max-width: 36rem) {
  .gallery-menu--cover_thumbnails .gallery-menu-list {
    grid-template-columns: minmax(0, 1fr);
  }

  .gallery-arrow {
    width: 2.35rem;
    height: 2.35rem;
  }

  .gallery-arrow--prev {
    left: 0.5rem;
  }

  .gallery-arrow--next {
    right: 0.5rem;
  }

  .gallery-caption {
    padding: 0.75rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .gallery-slide {
    transition-duration: 0.01ms;
  }
}
