/* =====================================================
   ROB TRACY STUDIOS — Masonry Gallery
   Inspired by ritavega.com
   ===================================================== */

/* ── Gallery header ── */
.gallery-header {
  padding: calc(var(--nav-h) + 48px) var(--gutter) 32px;
  display: flex;
  align-items: baseline;
  gap: 20px;
  flex-wrap: wrap;
}

.gallery-site-title {
  font-family: var(--font-head);
  font-size: clamp(1.6rem, 3vw, 2.6rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  text-transform: uppercase;
  color: var(--dark);
  line-height: 1;
}

.gallery-site-sub {
  font-size: 0.7rem;
  font-weight: 400;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--mid-gray);
}

.gallery-book-btn {
  display: inline-flex;
  align-items: center;
  padding: 8px 18px;
  background: none;
  border: 1.5px solid var(--dark);
  border-radius: 100px;
  font-family: var(--font-body);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--dark);
  text-decoration: none;
  margin-left: auto;
  transition: background 0.22s ease, color 0.22s ease;
}

.gallery-book-btn:hover {
  background: var(--dark);
  color: #fff;
}

/* ── Masonry grid ── */
.masonry-gallery {
  column-count: 3;
  column-gap: 4px;
  padding: 0 var(--gutter) clamp(60px, 8vw, 100px);
}

/* ── Each item ── */
.m-item {
  break-inside: avoid;
  margin-bottom: 4px;
  position: relative;
  overflow: hidden;
  display: block;
  cursor: pointer;

  /* entry state — revealed by JS */
  opacity: 0;
  transform: translateY(16px);
  transition:
    opacity 0.55s cubic-bezier(0.25, 0, 0, 1),
    transform 0.55s cubic-bezier(0.25, 0, 0, 1);
}

.m-item.visible {
  opacity: 1;
  transform: translateY(0);
}

/* filtering — hide/show */
.m-item.filtered-out {
  display: none;
}

.m-item img {
  width: 100%;
  height: auto;
  display: block;
  transition: transform 0.7s cubic-bezier(0.25, 0, 0, 1);
  will-change: transform;
}

.m-item:hover img {
  transform: scale(1.035);
}

/* Category caption — appears on hover */
.m-item figcaption {
  position: absolute;
  bottom: 12px;
  left: 14px;
  font-size: 0.6rem;
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: #fff;
  background: rgba(0,0,0,0.45);
  padding: 4px 10px;
  border-radius: 2px;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: none;
  backdrop-filter: blur(4px);
}

.m-item:hover figcaption {
  opacity: 1;
  transform: translateY(0);
}

/* ── Filter bar (below gallery header) ── */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 var(--gutter) 28px;
  flex-wrap: wrap;
}

.filter-link {
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #555;
  background: none;
  border: none;
  padding: 9px 16px;
  cursor: pointer;
  border-radius: 2px;
  border-bottom: 2px solid transparent;
  transition: color 0.2s ease, border-color 0.2s ease;
}

.filter-link:hover { color: var(--dark); }

.filter-link.active {
  color: var(--dark);
  background: none;
  border-bottom-color: var(--dark);
}

/* ── Lightbox ── */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
}

.lightbox.open {
  opacity: 1;
  pointer-events: all;
}

.lb-overlay {
  position: absolute;
  inset: 0;
  background: rgba(8, 8, 8, 0.94);
  cursor: pointer;
}

.lb-container {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  transform: scale(0.97);
  transition: transform 0.35s cubic-bezier(0.25, 0, 0, 1);
  max-width: 92vw;
  max-height: 92vh;
}

.lightbox.open .lb-container {
  transform: scale(1);
}

.lb-img {
  max-width: 90vw;
  max-height: 84vh;
  object-fit: contain;
  display: block;
  border-radius: 2px;
}

.lb-close {
  position: absolute;
  top: -44px;
  right: 0;
  color: rgba(255,255,255,0.65);
  font-size: 1.8rem;
  line-height: 1;
  transition: color 0.2s;
  cursor: pointer;
  background: none;
  border: none;
}

.lb-close:hover { color: #fff; }

.lb-nav {
  display: flex;
  align-items: center;
  gap: 32px;
}

.lb-arrow {
  color: rgba(255,255,255,0.55);
  font-size: 1.4rem;
  cursor: pointer;
  background: none;
  border: none;
  transition: color 0.2s, transform 0.2s;
  padding: 6px 12px;
  line-height: 1;
}

.lb-arrow:hover {
  color: #fff;
  transform: scale(1.15);
}

.lb-counter {
  font-size: 0.65rem;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.4);
  min-width: 60px;
  text-align: center;
}

.lb-cat {
  font-size: 0.6rem;
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.3);
  text-align: center;
  margin-top: 4px;
}

/* ── Responsive ── */
@media (max-width: 1100px) {
  .masonry-gallery { column-count: 3; }
}

@media (max-width: 900px) {
  .masonry-gallery { column-count: 2; }
}

@media (max-width: 768px) {
  .gallery-header  { flex-direction: column; gap: 6px; }
  /* Move book btn inline below subtitle on mobile */
  .gallery-book-btn { margin-left: 0; align-self: flex-start; }
  /* Bigger lightbox arrows for thumbs */
  .lb-arrow { font-size: 1.8rem; padding: 10px 18px; }
  .lb-nav { gap: 20px; }
}

@media (max-width: 480px) {
  .masonry-gallery { column-count: 1; }
  /* Hide book btn on very small screens — mobile bar handles it */
  .gallery-book-btn { display: none; }
}
