/* ============================================================
   GALLERY — responsive masonry-style grid with hover effects
   and a full-screen lightbox. Matches the site's dark/gold theme.
   ============================================================ */
.gallery {
  background: var(--black);
  position: relative;
  z-index: 2;
}
.gallery-inner { max-width: 1200px; margin: 0 auto; }

.gallery-head { margin-bottom: 44px; max-width: 640px; }
.gallery-head .section-intro {
  color: var(--grey);
  font-size: 1.02rem;
  line-height: 1.7;
  margin-top: 6px;
}

/* ─── Subjects (albums) ─── */
.gallery-album { margin-bottom: 54px; }
.gallery-album:last-child { margin-bottom: 0; }

.gallery-album-head {
  display: flex;
  align-items: baseline;
  gap: 14px;
  margin-bottom: 18px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.gallery-album-title {
  font-family: 'Barlow', sans-serif;
  font-weight: 800;
  font-size: clamp(1.3rem, 2.6vw, 1.9rem);
  letter-spacing: -0.01em;
  color: var(--white);
  text-transform: uppercase;
}
.gallery-album-count {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 0.8rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--yellow);
  white-space: nowrap;
}

/* ─── Collage mosaic — dense grid, some tiles span extra cells ─── */
.gallery-collage {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-auto-rows: 130px;
  grid-auto-flow: dense;
  gap: 10px;
}
/* Feature tiles create the montage rhythm. Scoped per-collage so every
   subject leads with a hero tile regardless of how many photos it has. */
.gallery-collage .collage-tile:nth-child(6n+1) { grid-column: span 2; grid-row: span 2; }
.gallery-collage .collage-tile:nth-child(6n+4) { grid-row: span 2; }
/* A lone photo shouldn't stretch full-bleed and tiny-tall. */
.gallery-collage[data-count="1"] { grid-template-columns: minmax(0, 520px); grid-auto-rows: 340px; }
.gallery-collage[data-count="1"] .collage-tile { grid-column: auto; grid-row: auto; }

@media (max-width: 900px) {
  .gallery-collage { grid-template-columns: repeat(3, 1fr); grid-auto-rows: 115px; }
}
@media (max-width: 520px) {
  .gallery-collage { grid-template-columns: repeat(2, 1fr); grid-auto-rows: 120px; gap: 8px; }
  .gallery-collage .collage-tile:nth-child(6n+1) { grid-column: span 2; grid-row: span 2; }
  .gallery-collage .collage-tile:nth-child(6n+4) { grid-row: span 1; }
}

.collage-tile {
  position: relative;
  display: block;
  width: 100%; height: 100%;
  padding: 0;
  border: 1px solid rgba(255,255,255,0.06);
  overflow: hidden;
  cursor: pointer;
  background: var(--dark);
  transition: box-shadow 0.35s ease, border-color 0.35s ease, transform 0.35s ease;
}
.collage-tile:hover,
.collage-tile:focus-visible {
  border-color: rgba(245,200,0,0.5);
  box-shadow: 0 14px 34px rgba(0,0,0,0.55);
  z-index: 2;
  outline: none;
}

.collage-tile img {
  display: block;
  width: 100%; height: 100%;
  object-fit: cover;
  transition: transform 0.6s cubic-bezier(0.2, 0.7, 0.2, 1), filter 0.4s ease;
  filter: saturate(0.9) brightness(0.9);
}
.collage-tile:hover img,
.collage-tile:focus-visible img {
  transform: scale(1.08);
  filter: saturate(1.05) brightness(1);
}

/* Gradient + caption overlay revealed on hover */
.collage-tile::after {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.8) 0%, rgba(0,0,0,0) 55%);
  opacity: 0;
  transition: opacity 0.4s ease;
  pointer-events: none;
}
.collage-tile:hover::after,
.collage-tile:focus-visible::after { opacity: 1; }

.collage-cap {
  position: absolute;
  bottom: 0; inset-inline: 0;
  padding: 12px 14px;
  color: #fff;
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 600;
  font-size: 0.92rem;
  letter-spacing: 0.02em;
  line-height: 1.2;
  transform: translateY(10px);
  opacity: 0;
  transition: transform 0.4s ease, opacity 0.4s ease;
  z-index: 1;
  text-align: start;
}
.collage-tile:hover .collage-cap,
.collage-tile:focus-visible .collage-cap { transform: translateY(0); opacity: 1; }

/* A tiny "view" glyph in the corner */
.collage-tile .collage-zoom {
  position: absolute;
  top: 10px; inset-inline-end: 10px;
  width: 30px; height: 30px;
  display: grid; place-items: center;
  font-size: 0.8rem;
  background: rgba(10,10,10,0.6);
  color: var(--yellow);
  border: 1px solid rgba(245,200,0,0.4);
  border-radius: 50%;
  opacity: 0;
  transform: scale(0.8);
  transition: opacity 0.35s ease, transform 0.35s ease;
  z-index: 1;
}
.collage-tile:hover .collage-zoom,
.collage-tile:focus-visible .collage-zoom { opacity: 1; transform: scale(1); }

.gallery-empty, .gallery-error {
  color: var(--grey);
  padding: 40px 0;
  text-align: center;
}
.gallery-error { color: #e0736b; }

/* ─── Lightbox ─── */
.lightbox {
  position: fixed; inset: 0;
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 4vh 4vw;
  background: rgba(5,5,5,0.94);
  backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity 0.3s ease;
}
.lightbox.open { display: flex; opacity: 1; }

.lightbox-figure {
  margin: 0;
  max-width: 100%;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
.lightbox-img {
  max-width: 100%;
  max-height: 82vh;
  object-fit: contain;
  border: 1px solid rgba(255,255,255,0.1);
  box-shadow: 0 24px 70px rgba(0,0,0,0.7);
  animation: lb-in 0.35s cubic-bezier(0.2, 0.7, 0.2, 1);
}
@keyframes lb-in {
  from { opacity: 0; transform: scale(0.96); }
  to   { opacity: 1; transform: scale(1); }
}
.lightbox-cap {
  color: var(--white);
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 1.05rem;
  letter-spacing: 0.03em;
  text-align: center;
  max-width: 70ch;
}

.lightbox-btn {
  position: absolute;
  background: rgba(20,20,20,0.7);
  color: var(--white);
  border: 1px solid rgba(255,255,255,0.15);
  width: 52px; height: 52px;
  display: grid; place-items: center;
  font-size: 1.5rem; line-height: 1;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
  user-select: none;
}
.lightbox-btn:hover { background: var(--yellow); color: var(--black); border-color: var(--yellow); }
.lightbox-close { top: 20px; inset-inline-end: 20px; border-radius: 50%; font-size: 1.3rem; }
.lightbox-prev { inset-inline-start: 18px; top: 50%; transform: translateY(-50%); }
.lightbox-next { inset-inline-end: 18px; top: 50%; transform: translateY(-50%); }
.lightbox-count {
  position: absolute;
  bottom: 22px; inset-inline: 0;
  text-align: center;
  color: var(--grey);
  font-family: 'Barlow Condensed', sans-serif;
  letter-spacing: 0.15em;
  font-size: 0.85rem;
}

/* RTL: flip the nav chevrons so ‹ / › still point the intuitive way */
[dir="rtl"] .lightbox-prev,
[dir="rtl"] .lightbox-next { transform: translateY(-50%) scaleX(-1); }

@media (max-width: 620px) {
  .lightbox-btn { width: 44px; height: 44px; font-size: 1.25rem; }
  .lightbox-prev { inset-inline-start: 8px; }
  .lightbox-next { inset-inline-end: 8px; }
}

/* Respect reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .gallery-item, .gallery-item img, .gallery-cap, .gallery-zoom,
  .lightbox, .lightbox-img { transition: none; animation: none; }
}
