[data-image-gallery] {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  max-width: none;
  max-height: none;
  margin: 0;
  border: 0;
  padding: 0;
  background: transparent;
  color: #fff;
  overflow: hidden;
}

[data-image-gallery][open] {
  display: grid;
  place-items: center;
}

[data-image-gallery]::backdrop {
  background: rgb(0 0 0 / .6);
}

[data-image-gallery] > img {
  display: block;
  width: auto;
  height: auto;
  max-width: 80vw;
  max-height: 90vh;
  background: #fff;
  object-fit: contain;
  box-shadow: 0 0 50px rgb(0 0 0 / .75);
}

[data-gallery-close], [data-gallery-previous], [data-gallery-next] {
  position: absolute;
  z-index: 1;
  display: grid;
  place-items: center;
  min-width: 44px;
  min-height: 44px;
  border: 0;
  padding: 0;
  background: var(--theme-gallery-control-background, var(--primary, #333));
  color: var(--theme-gallery-control-copy, #fff);
  cursor: pointer;
}

[data-gallery-close]:is(:hover, :focus-visible), [data-gallery-previous]:is(:hover, :focus-visible), [data-gallery-next]:is(:hover, :focus-visible) {
  background: var(--theme-gallery-control-hover, var(--primary-hover, #333));
  color: var(--theme-gallery-control-hover-copy, var(--theme-gallery-control-copy, #fff));
}

[data-gallery-close] {
  top: 40px;
  right: 40px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 0;
}

[data-gallery-close]::before, [data-gallery-close]::after {
  position: absolute;
  top: 20%;
  bottom: 20%;
  left: 50%;
  width: 2px;
  margin-left: -1px;
  background: currentColor;
  content: "";
  transform: rotate(45deg);
}

[data-gallery-close]::after {
  transform: rotate(-45deg);
}

[data-gallery-close]:is(:hover, :focus-visible) {
  background: var(--theme-gallery-close-hover, var(--theme-gallery-control-hover, var(--primary-hover, #333)));
  color: var(--theme-gallery-close-hover-copy, var(--theme-gallery-control-hover-copy, var(--theme-gallery-control-copy, #fff)));
}

[data-gallery-previous], [data-gallery-next] {
  top: 50%;
  width: var(--theme-gallery-arrow-width, 60px);
  height: var(--theme-gallery-arrow-height, 120px);
  border-radius: var(--theme-gallery-arrow-radius, 0);
  background: var(--theme-gallery-arrow-background, var(--theme-gallery-control-background, var(--primary, #333)));
  color: var(--theme-gallery-arrow-copy, var(--theme-gallery-control-copy, #fff));
  transform: translateY(-50%);
  font-size: 0;
}

[data-gallery-previous]:is(:hover, :focus-visible), [data-gallery-next]:is(:hover, :focus-visible) {
  background: var(--theme-gallery-arrow-hover, var(--theme-gallery-control-hover, var(--primary-hover, #333)));
  color: var(--theme-gallery-control-hover-copy, var(--theme-gallery-arrow-copy, var(--theme-gallery-control-copy, #fff)));
}

[data-gallery-previous] {
  left: 40px;
}

[data-gallery-next] {
  right: 40px;
}

[data-gallery-previous]::before, [data-gallery-next]::before {
  display: var(--theme-gallery-triangle-display, inline-block);
  border: var(--theme-gallery-arrow-border, 16px solid transparent);
  font-family: var(--theme-gallery-arrow-font, Arial, sans-serif);
  font-size: var(--theme-gallery-arrow-font-size, 0);
  line-height: 1;
}

[data-gallery-previous]::before {
  border-left: 0;
  border-right-color: #fff;
  content: var(--theme-gallery-prev-glyph, "");
}

[data-gallery-next]::before {
  border-right: 0;
  border-left-color: #fff;
  content: var(--theme-gallery-next-glyph, "");
}

[data-gallery-previous] > svg, [data-gallery-next] > svg {
  display: var(--theme-gallery-chevron-display, none);
  width: 17px;
  height: 21px;
  margin: auto;
  fill: none;
  stroke: currentColor;
  stroke-linecap: square;
  stroke-width: 3;
}

[data-gallery-next] > svg {
  transform: scaleX(-1);
}

[data-gallery-pagination] {
  position: absolute;
  bottom: 60px;
  left: 50%;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  max-width: calc(100vw - 32px);
  padding: var(--theme-gallery-navigation-padding, 5px);
  border-radius: 20px;
  background: rgb(0 0 0 / .5);
  transform: translateX(-50%);
}

[data-gallery-pagination] button {
  flex: none;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: 50%;
  padding: 0;
  background: transparent;
  color: #fff;
  font-size: 0;
  cursor: pointer;
}

[data-gallery-pagination] button::before {
  box-sizing: border-box;
  width: 14px;
  height: 14px;
  border: 1px solid #fff;
  border-radius: 50%;
  content: "";
}

[data-gallery-pagination] button[aria-current]::before {
  border-color: var(--theme-gallery-navigation-active, var(--theme-gallery-control-background, var(--primary, #333)));
  background: var(--theme-gallery-navigation-active, var(--theme-gallery-control-background, var(--primary, #333)));
}

[data-image-gallery] :is(button, a):focus-visible {
  outline: 2px solid #fff;
  outline-offset: 3px;
}

[data-image-gallery][aria-busy="true"]::after {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  margin: -10px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 40px #000;
  content: "";
  animation: gallery-loading .5s ease infinite;
}

@keyframes gallery-loading {
  from, to {
    opacity: .5;
    transform: scale(.75);
  }

  50% {
    opacity: 1;
    transform: scale(1);
  }
}

@supports (height: 100dvh) {
  [data-image-gallery] {
    height: 100dvh;
  }

  [data-image-gallery] > img {
    max-height: 90dvh;
  }
}

[data-image-gallery][data-dialog-embedded] > img {
  max-height: 90%;
}

@media (max-width: 660px) {
  [data-gallery-close] {
    top: 20px;
    right: 20px;
  }

  [data-gallery-previous], [data-gallery-next] {
    width: var(--theme-gallery-mobile-arrow-width, 44px);
    height: var(--theme-gallery-mobile-arrow-height, 60px);
  }

  [data-gallery-previous] {
    left: 20px;
  }

  [data-gallery-next] {
    right: 20px;
  }

  [data-gallery-pagination] {
    bottom: 20px;
  }
}

@media (max-width: 320px) {
  [data-gallery-previous] {
    left: 0;
  }

  [data-gallery-next] {
    right: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  [data-image-gallery]::after {
    animation: none;
  }
}
