.reference-card {
  position: relative;
  cursor: pointer;
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}

.reference-card::after {
  content: "Bildergalerie öffnen  →";
  display: inline-flex;
  align-items: center;
  position: absolute;
  right: 24px;
  bottom: 18px;
  color: #0874c9;
  font-size: .88rem;
  font-weight: 800;
}

.reference-card:hover,
.reference-card:focus-visible {
  transform: translateY(-3px);
  border-color: #87bee7;
  box-shadow: 0 16px 42px rgba(0, 45, 90, .13);
  outline: none;
}

.reference-card > div {
  padding-bottom: 38px;
}

body.gallery-open {
  overflow: hidden;
}

.product-gallery {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(5, 20, 34, .84);
  backdrop-filter: blur(8px);
}

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

.product-gallery__dialog {
  position: relative;
  width: min(1060px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  padding: 28px;
  border-radius: 22px;
  background: #fff;
  box-shadow: 0 28px 80px rgba(0, 0, 0, .35);
}

.product-gallery__header {
  padding-right: 52px;
}

.product-gallery__header h2 {
  margin: 0 0 5px;
  font-size: clamp(1.55rem, 3vw, 2.3rem);
}

.product-gallery__counter {
  margin: 0 0 18px;
  color: #66717d;
}

.product-gallery__close {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: #e9f3fa;
  color: #045b9e;
  font-size: 1.8rem;
  line-height: 1;
  cursor: pointer;
}

.product-gallery__stage {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 430px;
  overflow: hidden;
  border-radius: 16px;
  background: #edf3f7;
}

.product-gallery__main {
  display: block;
  width: 100%;
  max-height: 62vh;
  object-fit: contain;
}

.product-gallery__nav {
  position: absolute;
  top: 50%;
  width: 46px;
  height: 46px;
  transform: translateY(-50%);
  border: 0;
  border-radius: 50%;
  background: rgba(4, 91, 158, .9);
  color: #fff;
  font-size: 1.65rem;
  cursor: pointer;
}

.product-gallery__prev { left: 14px; }
.product-gallery__next { right: 14px; }

.product-gallery__thumbs {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 104px;
  gap: 10px;
  margin-top: 16px;
  padding: 4px 2px 8px;
  overflow-x: auto;
}

.product-gallery__thumb {
  padding: 3px;
  border: 3px solid transparent;
  border-radius: 11px;
  background: #fff;
  cursor: pointer;
}

.product-gallery__thumb[aria-current="true"] {
  border-color: #0874c9;
}

.product-gallery__thumb img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: 6px;
  object-fit: cover;
}

@media (max-width: 650px) {
  .reference-card::after {
    position: static;
    margin: 12px 20px 20px;
  }

  .reference-card > div { padding-bottom: 0; }
  .product-gallery { padding: 0; }
  .product-gallery__dialog {
    width: 100%;
    max-height: 100vh;
    min-height: 100vh;
    padding: 20px 14px;
    border-radius: 0;
  }
  .product-gallery__stage { min-height: 300px; }
  .product-gallery__thumbs { grid-auto-columns: 84px; }
}
