/* 4 kolonner (desktop) / 2 (tablet ≤1024) / 1 (mobil ≤640) + CSS lightbox */

.gal-wrap {
  --gal-gap: 20px;
  --gal-radius: 12px;
  --gal-max: 1280px;

  width: min(100%, var(--gal-max));
  margin-inline: auto;
  padding-inline: clamp(8px, 2vw, 16px);
}

/* Grid */
.gal-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--gal-gap);
}
@media (max-width: 1024px) {
  .gal-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (max-width: 640px) {
  .gal-grid {
    grid-template-columns: 1fr;
  }
}

/* Kort + billede */
.gal-item {
  position: relative;
  margin: 0;
  border-radius: var(--gal-radius);
  overflow: hidden;
  background: #fff;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}
.gal-link {
  display: block;
}
.gal-img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 4/3;
  object-fit: cover;
}
.gal-cap {
  font-size: 0.95rem;
  color: #4b5563;
  margin: 10px 12px 12px;
  line-height: 1.45;
}

/* Anchors (forhindrer hop/scroll) */
.gal-anchor {
  position: fixed;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  overflow: hidden;
}

/* KUN når lightbox er aktiv (target inde i overlay) låser vi scroll */
html:has(.gal-overlay .gal-anchor:target),
body:has(.gal-overlay .gal-anchor:target) {
  overflow: hidden;
}

/* Overlay (default skjult) – vises når den indeholder :target */
.gal-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(16px, 3vw, 32px);
  background: rgba(8, 10, 14, 0.82);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);

  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.gal-overlay:has(.gal-anchor:target) {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* Slide (kun aktiv slide er synlig/klikbar) */
.gal-slide {
  position: absolute;
  inset: auto;
  display: grid;
  justify-items: center;
  gap: 12px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
}
.gal-slide:has(.gal-anchor:target) {
  opacity: 1;
  pointer-events: auto;
}

.gal-overlay-img {
  max-width: min(92vw, 1400px);
  max-height: 82vh;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: calc(var(--gal-radius) + 4px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55);
}
.gal-lightbox-cap {
  color: #eaeaea;
  text-align: center;
  max-width: 92vw;
}

/* Luk (X) */
.gal-close {
  position: fixed;
  top: 14px;
  right: 16px;
  width: clamp(44px, 7vw, 72px);
  height: clamp(44px, 7vw, 72px);
  border-radius: 999px;
  background: rgba(17, 17, 22, 0.55);
  display: grid;
  place-items: center;
  text-decoration: none;
}
.gal-close::before {
  content: "";
  width: clamp(18px, 3vw, 26px);
  height: clamp(18px, 3vw, 26px);
  background: #fff;
  -webkit-mask: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z" fill="%23000"/></svg>')
    center/contain no-repeat;
  mask: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z" fill="%23000"/></svg>')
    center/contain no-repeat;
}

/* Pile */
.gal-nav {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  width: clamp(44px, 7vw, 72px);
  height: clamp(44px, 7vw, 72px);
  border-radius: 999px;
  background: rgba(17, 17, 22, 0.55);
  display: grid;
  place-items: center;
  text-decoration: none;
}
.gal-nav::before {
  content: "";
  width: clamp(18px, 3vw, 26px);
  height: clamp(18px, 3vw, 26px);
  background: #fff;
  -webkit-mask: var(--ico) center/contain no-repeat;
  mask: var(--ico) center/contain no-repeat;
}
.gal-left {
  left: clamp(10px, 2vw, 20px);
  --ico: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M15.41 7.41 10.83 12l4.58 4.59L14 18l-6-6 6-6z" fill="%23000"/></svg>');
}
.gal-right {
  right: clamp(10px, 2vw, 20px);
  --ico: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M8.59 16.59 13.17 12 8.59 7.41 10 6l6 6-6 6z" fill="%23000"/></svg>');
}

/* Dark mode */
@media (prefers-color-scheme: dark) {
  .gal-item {
    background: #0f1115;
  }
  .gal-cap {
    color: #c9d1d9;
  }
}
