/* ==========================================================================
   Schilderwerken Mattheus - gallery.css
   Staggered bento gallery, lightbox, before/after comparison slider.
   ========================================================================== */

/* ----------------------------------------------------- Staggered gallery */
.gallery {
  display: grid;
  grid-template-columns: 1fr;
  gap: clamp(.6rem, 1.4vw, 1.1rem);
  grid-auto-flow: dense;
}

.gal-item {
  position: relative;
  display: block;
  overflow: hidden;
  background: var(--band);
  border: 0; padding: 0; margin: 0;
  cursor: zoom-in;
  aspect-ratio: 4 / 3;
  width: 100%;
}
.gal-item img {
  width: 100%; height: 100%;
  object-fit: cover;
  filter: saturate(1.03) contrast(1.02) brightness(1.03);
  transition: transform .9s var(--ease-out), filter .5s var(--ease);
}
.gal-item::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(to top, rgba(23, 22, 22, .28), rgba(23, 22, 22, 0) 55%);
  opacity: 0;
  transition: opacity .4s var(--ease);
}
.gal-item:hover img, .gal-item:focus-visible img { transform: scale(1.05); filter: saturate(1.06) contrast(1.03) brightness(1.05); }
.gal-item:hover::after, .gal-item:focus-visible::after { opacity: 1; }

/* The zoom affordance */
.gal-item__zoom {
  position: absolute; z-index: 2;
  right: .75rem; bottom: .75rem;
  width: 40px; height: 40px;
  display: grid; place-items: center;
  background: var(--lime); color: var(--white);
  opacity: 0; transform: translateY(6px) scale(.9);
  transition: opacity .35s var(--ease), transform .35s var(--ease-out);
  pointer-events: none;
}
.gal-item__zoom svg { width: 17px; height: 17px; }
.gal-item:hover .gal-item__zoom, .gal-item:focus-visible .gal-item__zoom {
  opacity: 1; transform: none;
}

/* Rhythm: vary the tiles so the grid never reads as a uniform contact sheet */
@media (min-width: 620px) {
  .gallery { grid-template-columns: repeat(2, 1fr); }
  .gal-item:nth-child(6n + 1) { grid-column: span 2; aspect-ratio: 16 / 9; }
}

@media (min-width: 940px) {
  .gallery { grid-template-columns: repeat(3, 1fr); }
  .gal-item:nth-child(6n + 1) { grid-column: span 2; grid-row: span 2; aspect-ratio: auto; }
  .gal-item:nth-child(6n + 4) { aspect-ratio: 3 / 4; }
  .gal-item:nth-child(6n + 5) { aspect-ratio: 3 / 4; }
}

/* Compact strip variant used on service pages and the home page */
.gal-strip {
  display: grid; gap: clamp(.6rem, 1.4vw, 1.1rem);
  grid-template-columns: repeat(2, 1fr);
}
@media (min-width: 720px) { .gal-strip { grid-template-columns: repeat(4, 1fr); } }
.gal-strip .gal-item { aspect-ratio: 1 / 1; }
@media (min-width: 940px) {
  .gal-strip .gal-item:nth-child(1) { aspect-ratio: 1 / 1; }
}

/* ------------------------------------------------------------- Lightbox */
.lightbox {
  position: fixed; inset: 0;
  z-index: 600;
  background: rgba(23, 22, 22, .93);
  display: grid;
  grid-template-rows: auto 1fr auto;
  opacity: 0; visibility: hidden;
  transition: opacity .35s var(--ease), visibility .35s;
}
.lightbox.is-open { opacity: 1; visibility: visible; }
.lightbox[hidden] { display: none; }
@supports (backdrop-filter: blur(8px)) {
  .lightbox { background: rgba(23, 22, 22, .88); backdrop-filter: blur(10px); }
}

.lightbox__bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem;
  padding: 1rem var(--gutter);
  color: rgba(255,255,255,.7);
  font-size: var(--fs-small);
  font-variant-numeric: tabular-nums;
}
.lightbox__count { letter-spacing: .1em; text-transform: uppercase; font-weight: 600; }

.lightbox__stage {
  position: relative;
  display: grid; place-items: center;
  padding: 0 var(--gutter);
  min-height: 0;
}
.lightbox__stage img {
  max-width: 100%;
  max-height: 100%;
  width: auto; height: auto;
  object-fit: contain;
  box-shadow: 0 24px 70px rgba(0, 0, 0, .45);
  background: var(--band);
}

.lightbox__cap {
  padding: 1rem var(--gutter) calc(1.5rem + env(safe-area-inset-bottom));
  color: rgba(255,255,255,.7);
  font-size: .9375rem;
  text-align: center;
  max-width: 70ch; margin-inline: auto;
}

.lb-btn {
  width: 48px; height: 48px;
  display: inline-grid; place-items: center;
  background: transparent;
  color: var(--white);
  border: 1px solid rgba(255, 255, 255, .3);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all .25s var(--ease);
  flex: none;
}
.lb-btn:hover, .lb-btn:focus-visible { background: var(--lime); border-color: var(--lime); color: var(--white); }
.lb-btn svg { width: 18px; height: 18px; }
.lb-btn[disabled] { opacity: .3; cursor: not-allowed; }
.lb-btn[disabled]:hover { background: transparent; border-color: rgba(255, 255, 255, .3); color: var(--white); }

.lightbox__nav { display: flex; gap: .55rem; }

/* Big side arrows on wide screens */
.lightbox__side {
  position: absolute; top: 50%; transform: translateY(-50%);
  z-index: 3;
  display: none;
}
.lightbox__side--prev { left: calc(var(--gutter) * -1 + .5rem); }
.lightbox__side--next { right: calc(var(--gutter) * -1 + .5rem); }
@media (min-width: 900px) {
  .lightbox__side { display: block; }
  .lightbox__nav { display: none; }
  .lightbox__stage { padding-inline: calc(var(--gutter) + 3.5rem); }
}

/* ----------------------------------------------- Before / after compare */
.compare {
  position: relative;
  width: 100%;
  overflow: hidden;
  background: var(--band);
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
  cursor: ew-resize;
}
.compare img {
  display: block;
  width: 100%; height: 100%;
  object-fit: cover;
  filter: saturate(1.03) contrast(1.02) brightness(1.03);
  pointer-events: none;
}
/* Both layers fill the box exactly, so the two halves stay in register
   whatever the source aspect ratio is. */
.compare__after  { position: absolute; inset: 0; z-index: 1; }
.compare__before {
  position: absolute; inset: 0; z-index: 2;
  /* Revealed from the left, width driven by --pos */
  clip-path: inset(0 calc(100% - var(--pos, 50%)) 0 0);
}
.compare__after img, .compare__before img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
}

/* Draggable handle */
.compare__handle {
  position: absolute; top: 0; bottom: 0; z-index: 4;
  left: var(--pos, 50%);
  width: 3px;
  background: var(--white);
  transform: translateX(-50%);
  pointer-events: none;
}
.compare__grip {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 54px; height: 54px;
  background: var(--white);
  color: var(--ink);
  border-radius: 50%;
  display: grid; place-items: center;
  box-shadow: 0 6px 24px rgba(23, 22, 22, .35);
}
.compare__grip svg { width: 22px; height: 22px; }

/* Native range input sits invisibly on top, so it is keyboard and touch driven */
.compare__range {
  position: absolute; inset: 0; z-index: 5;
  width: 100%; height: 100%;
  margin: 0; padding: 0;
  opacity: 0;
  cursor: ew-resize;
  -webkit-appearance: none; appearance: none;
  background: transparent;
}
.compare__range::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 56px; height: 100vh;
  cursor: ew-resize;
}
.compare__range::-moz-range-thumb {
  width: 56px; height: 100vh;
  border: 0; border-radius: 0;
  cursor: ew-resize;
}
.compare__range:focus-visible ~ .compare__handle .compare__grip {
  outline: 3px solid var(--lime);
  outline-offset: 3px;
}

.compare__tag {
  position: absolute; z-index: 3; bottom: 1rem;
  font-family: var(--font);
  font-size: var(--fs-micro); font-weight: 700;
  letter-spacing: .14em; text-transform: uppercase;
  padding: .45rem .85rem;
  background: rgba(23, 22, 22, .78);
  color: var(--white);
  pointer-events: none;
}
.compare__tag--before { left: 1rem; }
.compare__tag--after { right: 1rem; background: var(--lime); color: var(--white); }

.compare-wrap { position: relative; }
.compare-hint {
  margin-top: .9rem;
  font-size: var(--fs-small);
  color: var(--body);
  display: flex; align-items: center; gap: .5rem;
}
.compare-hint svg { width: 16px; height: 16px; color: var(--lime); flex: none; }

/* Aspect ratios for the two pairs we have */
.compare--4-3 { aspect-ratio: 4 / 3; }
.compare--16-10 { aspect-ratio: 16 / 10; }
@media (max-width: 559px) {
  .compare--16-10 { aspect-ratio: 4 / 3; }
}

/* No-JS: show the "after" image only, nothing broken */
.no-js .compare__before, .no-js .compare__handle, .no-js .compare__range { display: none; }
.no-js .compare-hint { display: none; }
