/* ==========================================================================
   2357 Photography — gallery.css
   Masonry gallery layout, filter tabs, gallery hover effects, and lightbox.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Filter Bar
   -------------------------------------------------------------------------- */
.filter-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  margin-bottom: clamp(2rem, 4vw, 3rem);
  flex-wrap: wrap;
}

.filter-btn {
  font-family: var(--font-sans);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 0.65em 1.6em;
  cursor: pointer;
  transition:
    color var(--transition-fast),
    border-color var(--transition-fast);
  white-space: nowrap;
}

.filter-btn:hover {
  color: var(--color-accent);
}

.filter-btn.active {
  color: var(--color-accent);
  border-bottom-color: var(--color-accent);
}

/* --------------------------------------------------------------------------
   2. Masonry Gallery Grid
   Technique: CSS column-count. Images flow naturally, preserving aspect ratio.
   JavaScript filtering uses .hidden class to collapse items from the layout.
   -------------------------------------------------------------------------- */
.masonry-grid {
  column-count: 3;
  column-gap: 10px;
}

.gallery-item {
  break-inside: avoid;
  margin-bottom: 10px;
  overflow: hidden;
  cursor: pointer;
  display: block;     /* ensure break-inside works cross-browser */
  position: relative;
}

/* Hidden state for filtered-out items */
.gallery-item.hidden {
  display: none;
}

.gallery-item img {
  width: 100%;
  height: auto;         /* natural aspect ratio — NO cropping */
  display: block;
  transition:
    transform 0.5s ease,
    filter 0.4s ease;
}

.gallery-item:hover img {
  transform: scale(1.03);
  filter: brightness(1.07);
}

/* Optional: subtle overlay on hover to signal clickability */
.gallery-item::after {
  content: '';
  position: absolute;
  inset: 0;
  background-color: rgba(46, 31, 20, 0);
  transition: background-color var(--transition-mid);
  pointer-events: none;
}

.gallery-item:hover::after {
  background-color: rgba(46, 31, 20, 0.08);
}

/* Expand icon on hover */
.gallery-item__expand {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.7);
  opacity: 0;
  background-color: rgba(250, 247, 242, 0.92);
  color: var(--color-text);
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  transition:
    opacity var(--transition-mid),
    transform var(--transition-mid);
  z-index: 2;
  font-size: 1.1rem;
}

.gallery-item:hover .gallery-item__expand {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

/* --------------------------------------------------------------------------
   3. Lightbox
   -------------------------------------------------------------------------- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;

  /* Closed state */
  opacity: 0;
  visibility: hidden;
  background-color: rgba(20, 12, 6, 0.92);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  transition:
    opacity var(--transition-mid),
    visibility var(--transition-mid);
}

.lightbox.active {
  opacity: 1;
  visibility: visible;
}

/* Main image container */
.lightbox__figure {
  position: relative;
  max-width: 92vw;
  max-height: 90vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

#lightbox-img {
  max-width: 92vw;
  max-height: 88vh;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
  box-shadow: 0 8px 48px rgba(0, 0, 0, 0.6);
  transition: opacity 0.25s ease;
}

#lightbox-img.is-loading {
  opacity: 0.4;
}

/* Caption */
.lightbox__caption {
  position: absolute;
  bottom: -2rem;
  left: 0;
  right: 0;
  text-align: center;
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 0.875rem;
  color: rgba(250, 247, 242, 0.6);
}

/* Close button */
.lightbox__close {
  position: fixed;
  top: 1.25rem;
  right: 1.25rem;
  width: 44px;
  height: 44px;
  background: rgba(250, 247, 242, 0.12);
  border: 1px solid rgba(250, 247, 242, 0.25);
  color: #fff;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition:
    background-color var(--transition-fast),
    border-color var(--transition-fast);
  z-index: 10;
}

.lightbox__close:hover {
  background-color: rgba(250, 247, 242, 0.25);
  border-color: rgba(250, 247, 242, 0.5);
}

/* Prev / Next arrows */
.lightbox__prev,
.lightbox__next {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(250, 247, 242, 0.12);
  border: 1px solid rgba(250, 247, 242, 0.22);
  color: #fff;
  font-size: 1.4rem;
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 50%;
  transition:
    background-color var(--transition-fast),
    transform var(--transition-fast);
  z-index: 10;
}

.lightbox__prev {
  left: 1.25rem;
}

.lightbox__next {
  right: 1.25rem;
}

.lightbox__prev:hover {
  background-color: rgba(250, 247, 242, 0.25);
  transform: translateY(-50%) translateX(-2px);
}

.lightbox__next:hover {
  background-color: rgba(250, 247, 242, 0.25);
  transform: translateY(-50%) translateX(2px);
}

/* Image counter */
.lightbox__counter {
  position: fixed;
  bottom: 1.25rem;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-sans);
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  color: rgba(250, 247, 242, 0.5);
  z-index: 10;
  white-space: nowrap;
}

/* --------------------------------------------------------------------------
   4. Featured Grid on Home Page (small gallery section)
   -------------------------------------------------------------------------- */
.featured-grid .gallery-item {
  /* The featured grid uses a CSS grid wrapper — items shouldn't have
     column-break properties applied from masonry context. */
  break-inside: auto;
  margin-bottom: 0;
}

/* --------------------------------------------------------------------------
   5. Gallery section — empty state when filter shows 0 results
   -------------------------------------------------------------------------- */
.gallery-empty {
  display: none;
  text-align: center;
  padding: 4rem 2rem;
  color: var(--color-text-muted);
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 1.2rem;
  grid-column: 1 / -1;
}
