/**
 * Gallery + lightbox – one component for the feature block ("Bildergalerie + Text")
 * and the escape room pages (template-parts/content/gallery.php, JS in main.js).
 */

/* Gallery: one large + two or three small, opens the lightbox */
.aw-gallery {
  position: relative;
  display: grid;
  grid-template-columns: 2fr 1fr;
  grid-template-rows: repeat(3, 1fr);
  gap: 6px;
  aspect-ratio: 5 / 4;
}
.aw-gallery--wide { aspect-ratio: 16 / 9; }   /* Full width (escape rooms) */
/* Colour glow behind the images */
.aw-gallery::before {
  content: "";
  position: absolute;
  inset: 8% -6% -10% 10%;
  z-index: -1;
  border-radius: 50%;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--c) 45%, transparent), transparent);
  filter: blur(50px);
}
.aw-gallery__item {
  position: relative;
  display: block;
  overflow: hidden;
  border-radius: var(--aw-radius-s);
  background: var(--aw-ink);
  cursor: zoom-in;
}
.aw-gallery__item:first-child { grid-row: 1 / -1; }
.aw-gallery--3 { grid-template-rows: repeat(2, 1fr); }
.aw-gallery--1 { grid-template-columns: 1fr; grid-template-rows: 1fr; }
.aw-gallery__item img {
  width: 100%; height: 100%;
  object-fit: cover;
}
.aw-gallery__item::after {
  content: "";
  position: absolute; left: 0; right: 0; bottom: 0;
  height: 3px;
  background: var(--c);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform var(--aw-dur) var(--aw-ease-out);
}
/* Hover: the photo itself never moves or zooms (no jumps when the lightbox closes).
   A wash in the attraction colour rises from the bottom (as on the room cards), an "enlarge"
   button fades in and the colour line slides in. All fades, nothing scales. */
.aw-gallery__item::before {
  content: "";
  position: absolute; inset: 0;
  z-index: 1;
  background: linear-gradient(0deg, color-mix(in srgb, var(--c) 55%, transparent) 0%, color-mix(in srgb, var(--c) 18%, transparent) 55%, transparent 100%);
  opacity: 0;
  transition: opacity .5s var(--aw-ease-out);
  pointer-events: none;
}
.aw-gallery__zoom {
  position: absolute; left: 50%; top: 50%;
  z-index: 2;
  display: grid; place-items: center;
  width: 48px; height: 48px;
  margin: -24px 0 0 -24px;
  border-radius: 50%;
  background: var(--aw-white);
  color: var(--c);
  box-shadow: 0 0 30px 4px color-mix(in srgb, var(--c) 60%, transparent);
  opacity: 0;
  transition: opacity .4s var(--aw-ease-out);
  pointer-events: none;
}
.aw-gallery__zoom svg { width: 20px; height: 20px; }
.aw-gallery__item::after { z-index: 2; }
@media (hover: hover) {
  /* Not right after the lightbox closes (the mouse rests on a photo then): wait for it to move */
  html:not(.aw-lightbox-closed) .aw-gallery__item:hover :is(.aw-gallery__zoom),
  html:not(.aw-lightbox-closed) .aw-gallery__item:hover::before { opacity: 1; }
  html:not(.aw-lightbox-closed) .aw-gallery__item:hover::after { transform: none; }
}
.aw-gallery__item:focus-visible { outline-offset: -3px; }

/* Entrance: hidden until main.js fades the photos in (Web Animations, see main.js) */
.js .aw-gallery__item:not(.is-in) { opacity: 0; }
.aw-gallery__item:focus-visible :is(.aw-gallery__zoom),
.aw-gallery__item:focus-visible::before { opacity: 1; }

@media (max-width: 900px) {
  /* Mobile: swipeable row, like the v1 carousel. Photos line up with the page edge, the next one peeks in. */
  .aw-gallery {
    display: flex;
    aspect-ratio: auto;
    gap: 8px;
    margin-inline: calc(-1 * var(--aw-gutter));
    padding-inline: var(--aw-gutter);
    scroll-padding-inline: var(--aw-gutter);
    overflow: auto hidden;
    overscroll-behavior-x: contain;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
  }
  .aw-gallery::-webkit-scrollbar { display: none; }
  .aw-gallery::before { display: none; }   /* Blurred glow inside a scrolling row repaints on every swipe */
  .aw-gallery__item { flex: 0 0 86%; aspect-ratio: 5 / 4; scroll-snap-align: start; }
}

/* Lightbox ---------------------------------------------------------------- */
/* A swipe track with all photos of the gallery: swipe or arrows to browse, swipe down,
   Esc, × or a tap beside the photo to close. The photo zooms from / back to its place in the
   gallery, background and buttons fade (all animated in main.js); the page behind is locked. */
html.aw-lightbox-open { overflow: hidden; }
.aw-lightbox {
  --dy: 0px;
  width: 100vw; height: 100dvh;
  max-width: none; max-height: none;
  margin: 0; padding: 0;
  border: 0;
  overflow: hidden;
  overscroll-behavior: contain;
  background: transparent;
  color: var(--aw-white);
}
/* Background and buttons are separate layers, so they can fade while the photo zooms */
.aw-lightbox__bg {
  position: absolute; inset: 0;
  background: rgb(0 0 0 / .94);
  opacity: 0;   /* no CSS transition here: Safari would replay it from 0 when main.js ends the fade-in (a flash) */
}
.aw-lightbox__ui { opacity: 0; }
.aw-lightbox.is-open :is(.aw-lightbox__bg, .aw-lightbox__ui) { opacity: 1; }
.aw-lightbox::backdrop { background: transparent; }
.aw-lightbox[open] { display: block; }
.aw-lightbox__track {
  position: relative;   /* above the background layer */
  display: flex;
  height: 100%;
  overflow: auto hidden;
  overscroll-behavior: contain;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  touch-action: pan-x pinch-zoom;   /* Vertical drags are ours: swipe down closes */
  translate: 0 var(--dy);
  transition: translate .35s var(--aw-ease-out);
}
.aw-lightbox__track::-webkit-scrollbar { display: none; }
.aw-lightbox__slide {
  flex: 0 0 100%;
  display: grid;
  grid-template: minmax(0, 1fr) / minmax(0, 1fr);
  place-items: center;
  padding: 4.5rem 5.5rem;
  scroll-snap-align: center;
  scroll-snap-stop: always;
}
.aw-lightbox__slide img {
  max-width: 100%;
  max-height: 100%;
  width: auto; height: auto;   /* main.js sets the exact size from the photo's proportions */
  border-radius: var(--aw-radius-s);
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
}
.aw-lightbox.is-dragging .aw-lightbox__track { transition: none; }

.aw-lightbox__btn {
  position: absolute;
  z-index: 1;
  display: grid; place-items: center;
  width: 52px; height: 52px;
  border: 1px solid var(--aw-line);
  border-radius: 50%;
  background: rgb(0 0 0 / .5);
  color: var(--aw-white);
  cursor: pointer;
  transition: background var(--aw-dur-fast), color var(--aw-dur-fast), opacity var(--aw-dur-fast);
}
.aw-lightbox__btn svg { width: 22px; height: 22px; }
.aw-lightbox__btn:disabled { opacity: .3; cursor: default; }
@media (hover: hover) {
  .aw-lightbox__btn:not(:disabled):hover { background: var(--aw-white); color: var(--aw-black); }
}
.aw-lightbox__close { top: max(1rem, env(safe-area-inset-top)); right: max(1rem, env(safe-area-inset-right)); }
/* Arrows at the sides, centred on the photo */
.aw-lightbox__prev,
.aw-lightbox__next { top: 50%; translate: 0 -50%; }
.aw-lightbox__prev { left: max(1rem, env(safe-area-inset-left)); }
.aw-lightbox__next { right: max(1rem, env(safe-area-inset-right)); }
.aw-lightbox__count {
  position: absolute; left: 50%; bottom: max(1.5rem, env(safe-area-inset-bottom)); translate: -50% 0;
  color: var(--aw-mute);
  font-size: var(--aw-step--1);
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}
.aw-lightbox--single :is(.aw-lightbox__prev, .aw-lightbox__next, .aw-lightbox__count) { display: none; }

/* Touch screens: swipe instead of arrows, photo uses the full width */
@media (hover: none) and (pointer: coarse), (max-width: 700px) {
  .aw-lightbox__slide { padding: 4.25rem .75rem 4.5rem; }
}
@media (hover: none) and (pointer: coarse) {
  .aw-lightbox__prev, .aw-lightbox__next { display: none; }
}
