.case-gallery {
  display: grid;
  width: 100%;
  max-width: 300px;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
  margin: .75rem 0;
}

.case-gallery-link {
  display: block;
  min-width: 0;
  aspect-ratio: 17 / 12;
  overflow: hidden;
  border: 1px solid rgba(30, 54, 69, .18);
  background: #f5f6f3;
}

.case-gallery-link:focus-visible {
  outline: 2px solid #c9a62d;
  outline-offset: 2px;
}

.case-gallery-link img {
  display: block;
  width: 100%;
  height: 100%;
  aspect-ratio: 17 / 12;
  object-fit: contain;
}

.case-gallery-dialog {
  width: min(94vw, 1100px);
  max-width: calc(100vw - 2rem);
  max-height: calc(100dvh - 2rem);
  margin: auto;
  padding: 0;
  border: 0;
  color: var(--navy, #0f1b2d);
  background: transparent;
  overflow: visible;
}

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

.case-gallery-dialog::backdrop {
  background: rgba(8, 20, 38, .82);
}

.case-gallery-dialog__panel {
  display: grid;
  position: relative;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  gap: .8rem;
  box-sizing: border-box;
  width: 100%;
  height: min(90dvh, 52rem);
  max-height: calc(100dvh - 2rem);
  padding: clamp(1rem, 2vw, 1.5rem);
  border: 1px solid rgba(201, 166, 45, .7);
  background: #fff;
  box-shadow: 0 1.5rem 5rem rgba(0, 0, 0, .28);
}

.case-gallery-dialog__close {
  justify-self: end;
  min-height: 2.25rem;
  padding: .35rem .7rem;
  border: 1px solid rgba(30, 54, 69, .24);
  color: #172d39;
  background: #fff;
  font: inherit;
  cursor: pointer;
}

.case-gallery-dialog__close:focus-visible,
.case-gallery-dialog__previous:focus-visible,
.case-gallery-dialog__next:focus-visible {
  outline: 2px solid #c9a62d;
  outline-offset: 2px;
}

.case-gallery-dialog__image-frame {
  display: flex;
  position: relative;
  align-items: center;
  justify-content: center;
  min-height: 0;
  height: 100%;
  max-height: 100%;
  overflow: hidden;
  background: #f3f4f1;
}

.case-gallery-dialog__image {
  display: block;
  width: 100%;
  max-width: 100%;
  height: 100%;
  max-height: 100%;
  object-fit: contain;
}

.case-gallery-dialog__status {
  position: absolute;
  inset: 50% auto auto 50%;
  max-width: min(90%, 30rem);
  margin: 0;
  color: #40525b;
  text-align: center;
  transform: translate(-50%, -50%);
}

.case-gallery-dialog__status a {
  display: block;
  margin-top: .55rem;
  color: #8a6d00;
  text-decoration: underline;
}

.case-gallery-dialog__caption {
  margin: 0;
  color: #172d39;
  font-family: var(--serif, Georgia, serif);
  font-size: clamp(1rem, 1.7vw, 1.25rem);
  line-height: 1.35;
  text-align: center;
}

.case-gallery-dialog__controls {
  display: flex;
  justify-content: space-between;
  gap: .75rem;
}

.case-gallery-dialog__previous,
.case-gallery-dialog__next {
  flex: 1;
  min-width: 0;
  min-height: 2.35rem;
  padding: .4rem .75rem;
  border: 1px solid rgba(30, 54, 69, .24);
  color: #172d39;
  background: #fff;
  font: inherit;
  cursor: pointer;
  overflow-wrap: anywhere;
}

.case-gallery-dialog__previous:hover,
.case-gallery-dialog__next:hover,
.case-gallery-dialog__close:hover {
  background: #f3f4f1;
}

@media (max-width: 540px) {
  .case-gallery-dialog {
    max-width: calc(100vw - 1rem);
    max-height: calc(100dvh - 1rem);
  }

  .case-gallery-dialog__panel {
    max-height: calc(100dvh - 1rem);
    padding: .7rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .case-gallery-dialog__image {
    transition: none;
  }
}
