/* Portfolio: foto's verzameld rond de kop (sectie: gallery) */
.gallery {
  padding-block: calc(var(--section-gap) / 2);
  overflow-x: clip;
}

.gallery-list { list-style: none; margin: 0; padding: 0; }

.gallery-head { text-align: center; }
.gallery-title { font-size: var(--step-l); font-weight: 300; line-height: 1.08; }
.gallery-lede { font-size: var(--step-body); margin-top: 16px; text-wrap: balance; }
.gallery-cta { margin-top: 8px; }
.gallery-cta .link { display: inline-flex; align-items: center; min-height: 44px; }

/* Foto's: vierkante hoeken, geen frames, één behandeling */
.gallery-item { will-change: transform; transform: translate3d(0, var(--gallery-drift, 0px), 0); }
.gallery-open { display: block; overflow: hidden; cursor: zoom-in; transition: transform var(--dur-press) var(--ease); }
.gallery-open img {
  width: 100%; aspect-ratio: 4 / 5; object-fit: cover;
  filter: brightness(.85) contrast(1.05);
  transition: transform .6s var(--ease);
}
.gallery-item--wide .gallery-open img { aspect-ratio: 3 / 2; }
.gallery-open:hover img { transform: scale(1.04); }
.gallery-open:active { transform: scale(.98); }

/* ---------- Telefoon en tablet: stage = de .wrap-breedte, foto's in % daarvan ----------
   (procenten in margin verwijzen naar de breedte van de stage, ook margin-top) */
@media (max-width: 1199.98px) {
  .gallery-stage {
    width: min(100% - 2 * var(--margin), 960px);
    margin-inline: auto;
    display: grid;
    grid-template-columns: 100%;
  }
  .gallery-list { display: contents; }
  .gallery-item {
    grid-column: 1; grid-row: var(--mrow, 3);
    align-self: start;
    width: calc(var(--mw) * 1%);
    margin-left: calc(var(--mx) * 1%);
    margin-top: calc(var(--my) * 1%);
  }
  .gallery-item--desk { display: none; }
  .gallery-head {
    grid-row: 2; grid-column: 1;
    padding-block: 10% 12%;
    position: relative; z-index: 1;
  }
  .gallery-lede { max-width: 30ch; margin-inline: auto; }
}

/* Tablet: kop midden tussen de bovenste twee foto's, de rest in één rij eronder */
@media (min-width: 768px) and (max-width: 1199.98px) {
  .gallery-item {
    grid-row: 2;
    width: calc(var(--tw) * 1%);
    margin-left: calc(var(--tx) * 1%);
    margin-top: calc(var(--ty) * 1%);
  }
  .gallery-item--1,
  .gallery-item--3 { grid-row: 1; }
  .gallery-head {
    grid-row: 1;
    align-self: center; justify-self: center;
    width: 44%;
    padding-block: 0;
  }
}

/* ---------- Desktop: een band van ±1 scherm, cluster rond de kop ---------- */
@media (min-width: 1200px) {
  .gallery-stage {
    /* 1 eenheid = 1px op 1440–1680; kleiner daaronder, tot 1.25px op grote schermen */
    --u: max(min(1px, calc(100vw / 1440)), min(1.25px, calc(100vw / 1680)));
    --uy: min(var(--u), calc(130svh / 1100));
    position: relative;
    width: calc(1440 * var(--u));
    /* Hoogte = onderkant van de laagste foto (nr. 6: top 800, hoogte 210 × 5/4) */
    height: calc(800 * var(--uy) + 264 * var(--u));
    margin-inline: auto;
  }
  .gallery-item {
    position: absolute;
    left: calc(var(--x) * var(--u));
    top: calc(var(--y) * var(--uy));
    width: calc(var(--w) * var(--u));
  }
  .gallery-head {
    position: absolute; z-index: 1;
    left: 50%; top: calc(550 * var(--uy));
    width: max(320px, calc(320 * var(--u)));
    transform: translate(-50%, -50%);
  }
}

/* ---------- Lightbox ---------- */
.gallery-lightbox {
  width: 100%; height: 100%; max-width: none; max-height: none;
  margin: 0; padding: 0; border: 0;
  background: var(--bg); color: var(--ink);
  overflow: hidden;
}
.gallery-lightbox::backdrop { background: var(--bg); }
.gallery-lightbox[open] { display: grid; animation: gallery-fade .24s var(--ease); }
@keyframes gallery-fade { from { opacity: 0; } to { opacity: 1; } }

.gallery-lightbox-figure {
  margin: 0; display: grid; place-items: center;
  width: 100%; height: 100%;
  padding: 80px 96px;
  touch-action: pan-y pinch-zoom;
}
.gallery-lightbox-img {
  max-width: 100%; max-height: calc(100dvh - 160px);
  width: auto; height: auto;
  transition: opacity .2s var(--ease);
}
.gallery-lightbox-img.is-swapping { opacity: 0; }

.gallery-lightbox-count {
  position: absolute; top: var(--margin); left: var(--margin);
  min-height: 48px; display: flex; align-items: center;
  font-size: var(--step-s); color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.gallery-lightbox-btn {
  position: absolute;
  width: 48px; height: 48px; padding: 0; border: 0; border-radius: 0;
  display: grid; place-items: center;
  background: var(--surface); color: var(--ink);
  cursor: pointer;
  transition: background var(--dur-link) var(--ease), transform var(--dur-press) var(--ease);
}
.gallery-lightbox-btn:hover { background: var(--surface-2); }
.gallery-lightbox-btn:active { transform: scale(.97); }
.gallery-lightbox-close { top: var(--margin); right: var(--margin); }
.gallery-lightbox-prev,
.gallery-lightbox-next { top: 50%; margin-top: -24px; }
.gallery-lightbox-prev { left: var(--margin); }
.gallery-lightbox-next { right: var(--margin); }

@media (max-width: 767px) {
  .gallery-lightbox-figure { padding: 80px var(--margin) 96px; }
  .gallery-lightbox-img { max-height: calc(100dvh - 176px); }
  .gallery-lightbox-prev,
  .gallery-lightbox-next { top: auto; bottom: var(--margin); margin-top: 0; }
  .gallery-lightbox-prev { left: calc(50% - 56px); }
  .gallery-lightbox-next { right: calc(50% - 56px); }
}

@media (prefers-reduced-motion: reduce) {
  .gallery-item { transform: none; will-change: auto; }
  .gallery-open:hover img { transform: none; }
}
