/* =====================================================================
   Gallery — clean masonry, shares the variables/header from site.css.
   ===================================================================== */

/* Header, intro and filters share the homepage's narrow column so the
   header stays identical across pages; only the grid breaks out wider. */

.gallery-intro { margin-bottom: 2rem; }
.gallery-intro h1 {
  font-family: var(--display);
  font-size: clamp(2.4rem, 6vw, 3.4rem);
  font-weight: 400;
  font-style: italic;
  letter-spacing: -0.005em;
  line-height: 1;
  margin-bottom: 0.5rem;
}
.gallery-intro p { color: var(--muted); font-size: 1.02rem; }

/* ── Filters ─────────────────────────────────────────── */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.1rem;
  margin-bottom: 2.2rem;
  padding-bottom: 1.4rem;
  border-bottom: 1px solid var(--line);
}
.f {
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.02em;
  color: var(--muted);
  padding: 0;
  transition: color 0.18s;
}
.f:hover { color: var(--fg); }
.f.active { color: var(--accent); }

/* ── Grid — breaks out wider than the narrow text column ── */
.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem 1.3rem;
  width: min(1080px, 92vw);
  margin-left: calc(50% - min(540px, 46vw));
}
@media (max-width: 820px) { .grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px) { .grid { grid-template-columns: 1fr; } }

.item {
  cursor: pointer;
  display: block;
}
.item.hidden { display: none; }

.media {
  position: relative;
  overflow: hidden;
  border-radius: 5px;
  background: var(--card);
  line-height: 0;
  aspect-ratio: 4 / 5;
}
.item img,
.item video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.6s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.3s;
}
.item:hover img,
.item:hover video { transform: scale(1.04); }

/* video tile */
.item .play {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 2rem;
  color: #fff;
  background: rgba(0, 0, 0, 0.28);
  opacity: 1;
  transition: opacity 0.25s;
  line-height: 1;
}
.item.is-playing .play { opacity: 0; }

/* caption */
.item figcaption {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 0.6rem;
  padding: 0 0.1rem;
}
.item .t { font-size: 0.88rem; font-weight: 500; }
.item .m {
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--faint);
  text-transform: lowercase;
  white-space: nowrap;
}

/* ── Lightbox ────────────────────────────────────────── */
#lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4vmin;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.32s ease, visibility 0.32s ease;
}
#lightbox.open { opacity: 1; visibility: visible; pointer-events: auto; }

#lb-stage {
  max-width: 92vw;
  max-height: 86vh;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: scale(0.97);
  transition: transform 0.36s cubic-bezier(0.22, 1, 0.36, 1);
}
#lightbox.open #lb-stage { transform: scale(1); }
#lb-img, #lb-vid {
  max-width: 92vw;
  max-height: 86vh;
  object-fit: contain;
  display: none;
  border-radius: 5px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.28);
}

#lb-cap {
  position: fixed;
  bottom: 1.5rem;
  left: 0; right: 0;
  text-align: center;
  font-family: var(--mono);
  font-size: 0.74rem;
  color: var(--muted);
  letter-spacing: 0.03em;
}

#lb-close, #lb-prev, #lb-next {
  position: fixed;
  z-index: 2;
  width: 44px; height: 44px;
  display: grid;
  place-items: center;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.4rem;
  cursor: pointer;
  border-radius: 50%;
  transition: color 0.2s, background 0.2s;
}
#lb-close:hover, #lb-prev:hover, #lb-next:hover {
  color: var(--fg);
  background: var(--card);
}
#lb-close { top: 1.4rem; right: 1.6rem; }
#lb-prev  { top: 50%; left: 1.4rem;  transform: translateY(-50%); }
#lb-next  { top: 50%; right: 1.4rem; transform: translateY(-50%); }

@media (max-width: 600px) {
  #lb-prev { left: 0.4rem; }
  #lb-next { right: 0.4rem; }
}
