/* ============================================
   GALLERY PAGE — Moloney Contractors
   ============================================ */

/* ---------- Gallery hero (compact) ---------- */
.gallery-hero {
  position: relative;
  padding: 160px var(--pad) 40px;
  display: flex;
  align-items: flex-end;
  overflow: visible;
}

.gallery-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 60% 80% at 20% 80%, rgba(232, 154, 60, 0.12) 0%, transparent 60%),
    radial-gradient(ellipse 40% 50% at 80% 30%, rgba(255, 122, 24, 0.08) 0%, transparent 60%);
  pointer-events: none;
}

.gallery-hero-content {
  position: relative;
  max-width: var(--max);
  width: 100%;
  margin: 0 auto;
}

.gallery-hero .hero-title {
  font-size: clamp(2rem, 5vw, 4.2rem);
  margin-bottom: 20px;
}

.gallery-hero .hero-sub {
  margin-bottom: 0;
  max-width: 50ch;
}

/* ---------- Nav active state ---------- */
.nav-active {
  color: var(--ink) !important;
  background: rgba(255, 255, 255, 0.06);
}

/* ---------- Filter pills ---------- */
.gallery-filters {
  position: sticky;
  top: 90px;
  z-index: 40;
  padding: 0 var(--pad);
  margin-bottom: 48px;
}

.filters-inner {
  max-width: var(--max);
  margin: 0 auto;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 14px 18px;
  background: rgba(12, 12, 13, 0.75);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  width: fit-content;
}

.filter-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: 999px;
  font-family: var(--f-body);
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--ink-mute);
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.35s var(--ease);
  white-space: nowrap;
}

.filter-pill:hover {
  color: var(--ink-soft);
  background: rgba(255, 255, 255, 0.04);
}

.filter-pill.active {
  color: var(--bg-0);
  background: var(--orange);
  border-color: var(--orange);
  font-weight: 700;
}

.filter-pill.active:hover {
  background: var(--orange-hot);
}

.filter-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.filter-pill.active .filter-dot {
  background: var(--bg-0);
}

.filter-count {
  font-family: var(--f-mono);
  font-size: 0.7rem;
  opacity: 0.6;
}

.filter-pill.active .filter-count {
  opacity: 0.8;
}

/* ---------- Masonry grid ---------- */
.gallery-page {
  padding: 20px var(--pad) clamp(60px, 8vw, 100px);
  max-width: var(--max);
  margin: 0 auto;
}

.masonry {
  columns: 3;
  column-gap: 16px;
}

.masonry-item {
  position: relative;
  break-inside: avoid;
  margin-bottom: 16px;
  border-radius: 16px;
  overflow: hidden;
  cursor: pointer;
  background: var(--bg-1);
  isolation: isolate;
  transition: transform 0.5s var(--ease), opacity 0.5s var(--ease);
}

.masonry-item.hidden {
  display: none;
}

.masonry-item img {
  width: 100%;
  height: auto;
  display: block;
  transition: transform 1s var(--ease), filter 0.6s var(--ease);
  filter: brightness(0.88) saturate(0.95);
}

.masonry-item:hover img {
  transform: scale(1.06);
  filter: brightness(1) saturate(1.05);
}

/* Overlay caption */
.item-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 24px 20px;
  background: linear-gradient(180deg,
    transparent 40%,
    rgba(0, 0, 0, 0.3) 65%,
    rgba(0, 0, 0, 0.85) 100%);
  opacity: 0;
  transition: opacity 0.45s var(--ease);
}

.masonry-item:hover .item-overlay {
  opacity: 1;
}

.item-overlay .mono {
  color: var(--orange);
  font-size: 0.65rem;
  letter-spacing: 0.12em;
  margin-bottom: 6px;
}

.item-title {
  font-family: var(--f-display);
  font-size: 1.1rem;
  letter-spacing: -0.015em;
  line-height: 1.2;
}

.item-detail {
  font-size: 0.82rem;
  color: var(--ink-soft);
  margin-top: 3px;
}

/* ---------- Lightbox ---------- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.4s var(--ease), visibility 0.4s;
}

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

.lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(5, 5, 5, 0.92);
  backdrop-filter: blur(40px) saturate(120%);
  -webkit-backdrop-filter: blur(40px) saturate(120%);
}

.lightbox-stage {
  position: relative;
  max-width: 90vw;
  max-height: 82vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox-img {
  max-width: 100%;
  max-height: 82vh;
  object-fit: contain;
  border-radius: 12px;
  box-shadow:
    0 40px 100px -30px rgba(0, 0, 0, 0.8),
    0 0 0 1px rgba(255, 255, 255, 0.06);
  transform: scale(0.92);
  transition: transform 0.5s var(--ease);
}

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

.lightbox-close {
  position: absolute;
  top: 24px;
  right: 24px;
  z-index: 102;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(16px);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink);
  cursor: pointer;
  transition: background 0.3s, transform 0.3s var(--ease);
}

.lightbox-close:hover {
  background: rgba(255, 255, 255, 0.15);
  transform: rotate(90deg);
}

.lightbox-prev,
.lightbox-next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 102;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(16px);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink);
  cursor: pointer;
  transition: background 0.3s, transform 0.3s var(--ease);
}

.lightbox-prev { left: 24px; }
.lightbox-next { right: 24px; }

.lightbox-prev:hover,
.lightbox-next:hover {
  background: rgba(255, 255, 255, 0.14);
}

.lightbox-prev:hover { transform: translateY(-50%) translateX(-3px); }
.lightbox-next:hover { transform: translateY(-50%) translateX(3px); }

.lightbox-caption {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 102;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 22px;
  background: rgba(12, 12, 13, 0.7);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  white-space: nowrap;
  max-width: 90vw;
}

.lightbox-caption-text {
  font-size: 0.9rem;
  color: var(--ink-soft);
  overflow: hidden;
  text-overflow: ellipsis;
}

.lightbox-counter {
  color: var(--orange);
  font-size: 0.72rem;
  flex-shrink: 0;
}

/* ---------- Gallery CTA ---------- */
.gallery-cta {
  padding: 0 var(--pad) clamp(60px, 8vw, 100px);
  max-width: 1000px;
  margin: 0 auto;
}

.gallery-cta-inner {
  padding: clamp(36px, 5vw, 56px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 40px;
  flex-wrap: wrap;
  position: relative;
  overflow: hidden;
}

.gallery-cta-inner::after {
  content: "";
  position: absolute;
  top: -80px;
  right: -80px;
  width: 300px;
  height: 300px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(232, 154, 60, 0.25), transparent 65%);
  filter: blur(30px);
  z-index: -1;
}

.gallery-cta-text .h2 {
  font-size: clamp(1.6rem, 3vw, 2.4rem);
  margin-bottom: 10px;
}

.gallery-cta-text p {
  color: var(--ink-soft);
  font-size: 1rem;
}

.gallery-cta-actions {
  display: flex;
  gap: 12px;
  flex-shrink: 0;
}

/* ---------- Scroll reveal for gallery items ---------- */
.masonry-item {
  opacity: 0;
  transform: translateY(30px);
}

.masonry-item.in {
  opacity: 1;
  transform: none;
  transition: opacity 0.7s var(--ease), transform 0.7s var(--ease);
}

/* ---------- Responsive ---------- */
@media (max-width: 980px) {
  .masonry {
    columns: 2;
  }

  .gallery-hero {
    padding-top: 130px;
    padding-bottom: 60px;
  }

  .gallery-filters {
    top: 76px;
  }

  .gallery-cta-inner {
    flex-direction: column;
    text-align: center;
    align-items: center;
  }

  .gallery-cta-actions {
    flex-direction: column;
    width: 100%;
  }

  .gallery-cta-actions .btn {
    justify-content: center;
  }
}

@media (max-width: 560px) {
  .masonry {
    columns: 1;
  }

  .gallery-hero {
    padding-top: 110px;
    padding-bottom: 40px;
  }

  .gallery-hero .hero-title {
    font-size: clamp(1.8rem, 8vw, 2.8rem);
  }

  .gallery-filters {
    top: 68px;
    margin-bottom: 32px;
  }

  .filters-inner {
    padding: 10px 12px;
    gap: 6px;
    width: 100%;
    justify-content: center;
  }

  .filter-pill {
    padding: 8px 14px;
    font-size: 0.8rem;
  }

  .lightbox-prev { left: 12px; width: 44px; height: 44px; }
  .lightbox-next { right: 12px; width: 44px; height: 44px; }
  .lightbox-close { top: 16px; right: 16px; width: 42px; height: 42px; }

  .lightbox-caption {
    bottom: 16px;
    padding: 10px 16px;
    gap: 12px;
  }

  .lightbox-caption-text {
    font-size: 0.8rem;
  }
}
