.case-gallery {
  --gallery-line: var(--rule);
  --gallery-focus: var(--green);
  min-width: 0;
}

.case-gallery [hidden] { display: none !important; }

.case-gallery__slide { margin: 0; }

.case-gallery__slide + .case-gallery__slide { margin-top: 1.75rem; }

.case-gallery[data-enhanced] .case-gallery__slide { margin-top: 0; }

.case-gallery__image-link {
  display: block;
  box-sizing: border-box;
  border: 1px solid var(--gallery-line);
  cursor: zoom-in;
  touch-action: pan-y pinch-zoom;
}

.case-gallery__image {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 3 / 2;
  object-fit: contain;
}

@media (prefers-reduced-motion: no-preference) {
  .case-gallery[data-gallery-navigated] [data-gallery-slide]:not([hidden]) [data-gallery-ready] {
    animation: case-gallery-fade-in 180ms ease-in-out;
  }
}

@keyframes case-gallery-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.case-gallery__caption {
  margin-top: 0.65rem;
  font-size: 0.9rem;
  line-height: 1.45;
}

.case-gallery__controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.7rem;
  margin-top: 0.7rem;
}

.case-gallery__button {
  display: inline-grid;
  place-items: center;
  min-width: 44px;
  min-height: 44px;
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--gallery-line);
  border-radius: 999px;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.case-gallery__button[aria-disabled="true"] { color: #6b6b64; cursor: default; }

.case-gallery :is(a, button):focus-visible {
  outline: 2px solid var(--gallery-focus);
  outline-offset: 3px;
}

.case-gallery__counter {
  min-width: 4ch;
  text-align: center;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.case-gallery__sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.case-gallery__dialog {
  box-sizing: border-box;
  max-width: min(96vw, 84rem);
  max-height: 96vh;
  max-height: 96dvh;
  overflow: auto;
  padding: clamp(0.6rem, 2vw, 1.25rem);
  border: 1px solid var(--gallery-line);
  background: var(--paper);
  color: var(--ink);
}

.case-gallery__dialog:not([open]) { display: none; }

.case-gallery__dialog::backdrop { background: rgb(15 18 16 / 83%); }

@media (prefers-reduced-motion: no-preference) {
  .case-gallery__dialog[open]:not([data-gallery-closing]) {
    animation: case-gallery-dialog-in 240ms ease-out both;
  }

  .case-gallery__dialog[open]:not([data-gallery-closing])::backdrop {
    animation: case-gallery-fade-in 240ms ease-out both;
  }

  .case-gallery__dialog[open][data-gallery-closing] {
    animation: case-gallery-dialog-out 220ms ease-in both;
  }

  .case-gallery__dialog[open][data-gallery-closing]::backdrop {
    animation: case-gallery-fade-out 220ms ease-in both;
  }
}

@keyframes case-gallery-dialog-in {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

@keyframes case-gallery-dialog-out {
  from { opacity: 1; transform: none; }
  to { opacity: 0; transform: translateY(8px) scale(0.98); }
}

@keyframes case-gallery-fade-out {
  from { opacity: 1; }
  to { opacity: 0; }
}

.case-gallery__dialog-bar { display: flex; justify-content: end; margin-bottom: 0.5rem; }

.case-gallery__large {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 74vh;
  max-height: 74dvh;
  margin-inline: auto;
}
