.az-content-gallery-controls {
  display: flex;
  align-items: center;
  gap: 2px;
  width: max-content;
  margin: 18px auto 8px;
  padding: 2px;
  border: 1px solid var(--az-color-border, #e5e5e5);
  border-radius: 999px;
  background: var(--az-color-surface, #fff);
}

.az-content-gallery-controls button {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--az-color-text, #424242);
  cursor: pointer;
}

.az-content-gallery-controls button::before {
  content: "";
  width: 8px;
  height: 8px;
  border: solid currentColor;
  border-width: 2px 2px 0 0;
  transform: rotate(45deg);
}

.az-content-gallery-controls button:first-child::before {
  transform: rotate(-135deg);
}

.az-content-gallery-controls:dir(rtl) button::before {
  scale: -1 1;
}

@media (hover: hover) {
  .az-content-gallery-controls button:hover {
    background: var(--az-color-page, #f4f6f8);
  }
}

.az-content-gallery-controls button:active {
  background: var(--az-color-primary-soft, #f4f6f8);
}

.az-content-gallery-controls button:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: -3px;
}

.az-content-gallery-controls [role="status"] {
  min-width: 7ch;
  padding-inline: 4px;
  color: var(--az-color-text, #424242);
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1.25;
  text-align: center;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

:is(.gallery, .wp-block-gallery, .blocks-gallery-grid).az-content-gallery-track {
  display: block;
  padding: 0;
  margin: 8px 0 22px;
  list-style: none;
  text-align: center;
}

.az-content-gallery-controls + :is(.gallery, .wp-block-gallery) {
  margin-top: 0;
}

.wp-block-gallery > .blocks-gallery-grid.az-content-gallery-track {
  margin-block: 0;
}

.wp-block-gallery:has(> .blocks-gallery-grid.az-content-gallery-track) > :is(.blocks-gallery-grid, .blocks-gallery-caption) {
  grid-column: 1 / -1;
}

:is(.gallery, .wp-block-gallery, .blocks-gallery-grid).az-content-gallery-track > .az-content-gallery-slide {
  display: block;
  min-width: 100%;
  margin: 0;
  padding: 0;
}

:is(.gallery, .wp-block-gallery, .blocks-gallery-grid).az-content-gallery-track > .az-content-gallery-slide[hidden] {
  display: none;
}

:is(.gallery, .wp-block-gallery, .blocks-gallery-grid).az-content-gallery-track > .az-content-gallery-slide :is(figure, .gallery-icon) {
  display: block;
  margin: 0;
}

:is(.gallery, .wp-block-gallery, .blocks-gallery-grid).az-content-gallery-track .az-content-gallery-slide img {
  display: block;
  width: auto;
  max-width: 100%;
  height: auto;
  max-height: min(65vw, 32rem);
  margin-inline: auto;
  object-fit: contain;
}

:is(.wp-block-gallery, .blocks-gallery-grid).az-content-gallery-track > .az-content-gallery-slide:is(.wp-block-image, .blocks-gallery-item, .blocks-gallery-image) figcaption {
  position: static;
  margin: 8px 0 0;
  padding: 0;
  color: var(--az-color-muted, #555);
  background: none;
  text-shadow: none;
}

.wp-block-gallery.az-content-gallery-track .az-content-gallery-slide.wp-block-image:has(figcaption)::before {
  content: none;
}
