/* ─────────────────────────────────────────
   GALLERY.CSS — animated filter reflow + staggered reveal
   Q.C Bodies Landing Page
───────────────────────────────────────── */

.gallery {
  padding: 7rem 3rem;
  background: var(--steel);
  position: relative;
  overflow: hidden;
}

.gallery::before {
  content: '';
  position: absolute;
  bottom: -150px; left: -150px;
  width: 500px; height: 500px;
  background: radial-gradient(circle, rgba(232,160,32,0.06) 0%, transparent 70%);
  pointer-events: none;
}

.gallery-inner {
  max-width: var(--max-width);
  margin: 0 auto;
}

/* ── HEADER ── */
.gallery-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 2rem;
  margin-bottom: 2rem;
}

.gallery-header-left { max-width: 480px; }

/* ── FILTER TABS ── */
.gallery-filters {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 2rem;
}

.filter-btn {
  font-family: var(--font-ui);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--muted);
  background: transparent;
  border: 1px solid rgba(255,255,255,0.08);
  padding: 7px 18px;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, background 0.2s, transform 0.2s;
}

.filter-btn:hover {
  color: var(--white);
  border-color: rgba(255,255,255,0.25);
  transform: translateY(-2px);
}

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

/* ── GRID with reflow animation ── */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-auto-rows: 280px;
  gap: 8px;
}

/* Bento pattern repeats every 7 items */
.gallery-item:nth-child(7n+1) { grid-column: 1; }
.gallery-item:nth-child(7n+2) { grid-column: 2; }
.gallery-item:nth-child(7n+3) { grid-column: 3; grid-row: span 2; }
.gallery-item:nth-child(7n+4) { grid-column: 1; }
.gallery-item:nth-child(7n+5) { grid-column: 2; }
.gallery-item:nth-child(7n+6) { grid-column: 1 / span 2; }
.gallery-item:nth-child(7n+7) { grid-column: 3; }

/* ── EACH ITEM ── */
.gallery-item {
  position: relative;
  overflow: hidden;
  cursor: pointer;
  background: var(--mid);
  transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1),
              opacity 0.4s ease,
              filter 0.4s ease;
  transform-style: preserve-3d;
}

/* Staggered entrance animation on scroll */
.gallery-item.reveal-item {
  opacity: 0;
  transform: translateY(40px) scale(0.92);
}

.gallery-item.reveal-item.visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

/* Filtered-out state — shrink and fade */
.gallery-item.is-hidden {
  opacity: 0;
  transform: scale(0.7);
  filter: blur(4px);
  pointer-events: none;
}

.gallery-item.is-match {
  opacity: 1;
  transform: scale(1);
  filter: blur(0);
}

.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.6s ease;
  pointer-events: none;
}

.gallery-item:hover img { transform: scale(1.08); }

/* Overlay */
.gallery-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to top,
    rgba(10,10,10,0.88) 0%,
    rgba(10,10,10,0.1) 50%,
    transparent 100%
  );
  opacity: 0;
  transition: opacity 0.35s;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 1.4rem;
  pointer-events: none;
}

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

/* Accent top line on hover */
.gallery-item::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent2), var(--accent));
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.4s ease;
  z-index: 2;
  pointer-events: none;
}

.gallery-item:hover::before { transform: scaleX(1); }

.overlay-type {
  font-family: var(--font-ui);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 4px;
}

.overlay-title {
  font-family: var(--font-display);
  font-size: 1.3rem;
  letter-spacing: 0.04em;
  color: var(--white);
  line-height: 1.1;
}

/* Expand icon */
.gallery-item::after {
  content: '+';
  position: absolute;
  top: 1rem; right: 1rem;
  width: 32px; height: 32px;
  background: var(--accent);
  color: var(--black);
  font-size: 1.3rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: scale(0.7) rotate(-45deg);
  transition: opacity 0.3s, transform 0.3s;
  z-index: 2;
  pointer-events: none;
}

.gallery-item:hover::after { opacity: 1; transform: scale(1) rotate(0deg); }

/* ── LIGHTBOX ── */
.lightbox {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.95);
  z-index: 9999;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.lightbox.open { display: flex; animation: lightbox-in 0.3s ease; }

@keyframes lightbox-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.lightbox img {
  max-width: 90vw;
  max-height: 85vh;
  object-fit: contain;
  box-shadow: 0 0 80px rgba(232,160,32,0.15);
  animation: lightbox-img-in 0.35s ease;
}

@keyframes lightbox-img-in {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.lightbox-close {
  position: fixed;
  top: 1.5rem; right: 1.5rem;
  width: 44px; height: 44px;
  background: var(--accent);
  color: var(--black);
  font-size: 1.4rem;
  font-weight: 700;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  transition: transform 0.2s;
}

.lightbox-close:hover { transform: scale(1.1) rotate(90deg); }

.lightbox-prev,
.lightbox-next {
  position: fixed;
  top: 50%; transform: translateY(-50%);
  background: rgba(232,160,32,0.15);
  border: 1px solid rgba(232,160,32,0.3);
  color: var(--accent);
  font-size: 1.5rem;
  width: 48px; height: 48px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, transform 0.2s;
  z-index: 10000;
}

.lightbox-prev { left: 1.5rem; }
.lightbox-next { right: 1.5rem; }
.lightbox-prev:hover { background: rgba(232,160,32,0.3); transform: translateY(-50%) scale(1.1) translateX(-3px); }
.lightbox-next:hover { background: rgba(232,160,32,0.3); transform: translateY(-50%) scale(1.1) translateX(3px); }

/* ── CTA ── */
.gallery-cta {
  margin-top: 2.5rem;
  text-align: center;
}

.gallery-cta a {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-ui);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  text-decoration: none;
  border: 1px solid rgba(232,160,32,0.3);
  padding: 13px 32px;
  transition: background 0.2s, border-color 0.2s, transform 0.2s;
}

.gallery-cta a:hover {
  background: rgba(232,160,32,0.08);
  border-color: var(--accent);
  transform: translateY(-2px);
}

/* ── RESPONSIVE ── */
@media (max-width: 900px) {
  .gallery-grid {
    grid-template-columns: repeat(2, 1fr);
    grid-auto-rows: 220px;
  }
  .gallery-item:nth-child(n) { grid-column: auto !important; grid-row: auto !important; }
}

@media (max-width: 580px) {
  .gallery { padding: 4rem 1.5rem; }
  .gallery-grid {
    grid-template-columns: 1fr 1fr;
    grid-auto-rows: 160px;
  }
  .gallery-item:nth-child(n) { grid-column: auto !important; grid-row: auto !important; }
}

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