/* =========================================================
   DAN MAGICAL TOURS — Gallery page (galerie.html) — filter row, masonry grid, lightbox
   Loaded by that page only.
   ========================================================= */
/* ---- Gallery page ---- */
.gallery-page { padding-top: 0; }

.gallery-filter-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 40px 0 48px;
}
.gallery-filter-btn {
  padding: 8px 22px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  border: 1px solid rgba(247,237,218,0.15);
  border-radius: 2px;
  transition: all var(--t-base);
  cursor: pointer;
  background: none;
  font-family: var(--font-body);
}
/* 30 real pixels tall under the global zoom — too small to hit reliably. */
@media (pointer: coarse) {
  .gallery-filter-btn { min-height: calc(40px / var(--ui-scale, 1)); }
}
.gallery-filter-btn:hover,
.gallery-filter-btn.active {
  color: var(--off-white);
  border-color: var(--gold);
  background: rgba(200,136,26,0.08);
}

/* ---- Photo grid ----
   Masonry rather than a uniform crop: a gallery's whole job is showing the
   photographs, and a 4:3 box cuts the top off a portrait and the sides off
   a panorama. Each tile spans as many 8px rows as its own proportions need.

   The span is computed from the width and height recorded in
   js/gallery-data.js, not from the loaded image, so the column reserves the
   right space before the picture arrives and the page never jumps. */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  grid-auto-rows: 8px;
  column-gap: 12px;
  row-gap: 0;                 /* the row gap is each tile's bottom margin,
                                 so it can be part of the span arithmetic */
}
button.gallery-item {
  grid-row: span var(--span, 30);
  margin-bottom: 12px;
  position: relative;
  overflow: hidden;
  padding: 0;
  width: 100%;
  background: none;
  border: none;
  border-radius: 3px;
  aspect-ratio: auto;         /* the row span sets the height here */
  /* Lets the browser skip painting tiles far off screen. With 203 of them
     that is the difference between a smooth page and a stuttering one. */
  content-visibility: auto;
  contain-intrinsic-size: auto 320px;
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.6s var(--ease-out), transform 0.6s var(--ease-out);
}
button.gallery-item.in { opacity: 1; transform: none; }
button.gallery-item:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }
button.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.7s var(--ease-out);
}
button.gallery-item:hover img { transform: scale(1.06); }

/* A hairline that only appears under the pointer, so 203 tiles do not read
   as 203 boxes when you are just scrolling past them. */
.gallery-item::after {
  content: "";
  position: absolute;
  inset: 0;
  border: 1px solid transparent;
  border-radius: 3px;
  pointer-events: none;
  transition: border-color 0.35s ease;
}
.gallery-item:hover::after { border-color: rgba(var(--gold-rgb) / 0.55); }

/* The caption is decoration: the same text is on the button's aria-label
   and in the lightbox, where it is always readable. */
.gallery-item-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: flex;
  align-items: flex-end;
  padding: 14px;
  background: linear-gradient(to top, rgba(12,8,2,0.82) 0%, rgba(12,8,2,0.25) 40%, transparent 65%);
  opacity: 0;
  transition: opacity 0.35s ease;
}
.gallery-item:hover .gallery-item-overlay,
.gallery-item:focus-visible .gallery-item-overlay { opacity: 1; }
.gallery-item-overlay span {
  color: var(--warm);
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  transform: translateY(6px);
  transition: transform 0.35s var(--ease-out);
}
.gallery-item:hover .gallery-item-overlay span,
.gallery-item:focus-visible .gallery-item-overlay span { transform: none; }

.gallery-count {
  margin-left: auto;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

@media (prefers-reduced-motion: reduce) {
  button.gallery-item { opacity: 1; transform: none; transition: none; }
  button.gallery-item img { transition: none; }
}

/* ---- Lightbox ---- */
.lightbox {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(12,8,2,0.96);
  align-items: center;
  justify-content: center;
  flex-direction: column;
}
.lightbox.open { display: flex; }
.lightbox-img-wrap {
  position: relative;
  max-width: 90vw;
  max-height: 80vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.lightbox-img {
  max-width: 90vw;
  max-height: 78vh;
  object-fit: contain;
  display: block;
}
.lightbox-caption {
  color: var(--off-white);
  font-size: 0.82rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-top: 16px;
  text-align: center;
  opacity: 0.7;
}
.lightbox-counter {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  margin-top: 8px;
}
.lightbox-close {
  position: absolute;
  top: 24px;
  right: 28px;
  color: var(--off-white);
  font-size: 1.4rem;
  opacity: 0.7;
  cursor: pointer;
  transition: opacity var(--t-fast);
  z-index: 10;
}
.lightbox-close:hover { opacity: 1; }
.lightbox-prev,
.lightbox-next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  color: var(--off-white);
  font-size: 1.4rem;
  opacity: 0.6;
  cursor: pointer;
  padding: 20px;
  transition: opacity var(--t-fast);
  z-index: 10;
}
.lightbox-prev { left: 16px; }
.lightbox-next { right: 16px; }
.lightbox-prev:hover,
.lightbox-next:hover { opacity: 1; }

/* One column on a phone: two 170px tiles work, but one full-width tile
   actually shows the photograph. */
@media (max-width: 480px) {
  .gallery-grid { grid-template-columns: 1fr; }
}
