/* ───────────────────────────────────────────────
   GALLERY — Smart Adaptive Grid
   Images classified as: .gi-wide  .gi-tall  .gi-square
   CSS Grid auto-places them intelligently
   ─────────────────────────────────────────────── */

/* ── COMPACT HERO SECTION (Sync with Products Page) ── */
.gallery-hero.page-hero {
  background: radial-gradient(circle at 20% 50%, rgba(5, 150, 105, 0.15) 0%, transparent 50%),
              linear-gradient(135deg, #022c22 0%, #064e3b 60%, #022c22 100%);
  padding: clamp(100px, 10vw, 130px) 0 clamp(32px, 4vw, 48px);
  min-height: auto;
  height: clamp(230px, 20vw, 280px);
  display: flex;
  align-items: flex-end;
  position: relative;
  overflow: hidden;
  color: white;
}

.hero-grid-bg {
  position: absolute;
  inset: 0;
  background-image: 
    linear-gradient(rgba(255,255,255,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.03) 1px, transparent 1px);
  background-size: 40px 40px;
  mask-image: radial-gradient(circle at 20% 50%, black, transparent 70%);
  pointer-events: none;
  z-index: 1;
}

.radial-glow {
  position: absolute;
  top: 50%;
  left: 20%;
  transform: translate(-50%, -50%);
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(16, 185, 129, 0.1) 0%, transparent 70%);
  pointer-events: none;
  z-index: 1;
}

.gallery-hero .hero-content {
  position: relative;
  z-index: 2;
}

.hero-compact-title {
  font-size: clamp(2.5rem, 5vw, 3.5rem) !important;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 2px !important;
  color: white;
  line-height: 1 !important;
}

.hero-compact-desc {
  font-size: var(--fs-base) !important;
  color: rgba(255, 255, 255, 0.6) !important;
  max-width: 600px !important;
  margin-bottom: 12px !important;
  line-height: 1.4 !important;
}

.hero-tags {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--color-lime);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  font-weight: 600;
}

.gallery-hero .breadcrumb {
  margin-bottom: 12px;
  color: var(--color-lime);
  font-size: 0.8rem;
}
.gallery-hero .breadcrumb a {
  color: white;
  opacity: 0.7;
}

/* ── BASE GRID ── */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-auto-rows: 240px;
  grid-auto-flow: dense;
  gap: var(--space-md);
}

/* On small mobile: 1 col, all items uniform */
@media (max-width: 639px) {
  .gallery-grid {
    grid-template-columns: 1fr;
    grid-auto-rows: 260px;
  }
  .gi-wide,
  .gi-tall,
  .gi-square {
    grid-column: span 1 !important;
    grid-row:    span 1 !important;
  }
}

/* Tablet: 2 cols */
@media (min-width: 640px) and (max-width: 1099px) {
  .gallery-grid {
    grid-template-columns: repeat(2, 1fr);
    grid-auto-rows: 220px;
  }
  .gi-wide {
    grid-column: span 2;
    grid-row:    span 1;
  }
  .gi-tall {
    grid-column: span 1;
    grid-row:    span 2;
  }
  .gi-square {
    grid-column: span 1;
    grid-row:    span 1;
  }
}

/* Desktop: 3 cols */
@media (min-width: 1100px) and (max-width: 1599px) {
  .gallery-grid {
    grid-template-columns: repeat(3, 1fr);
    grid-auto-rows: 240px;
  }
  .gi-wide {
    grid-column: span 2;
    grid-row:    span 1;
  }
  .gi-tall {
    grid-column: span 1;
    grid-row:    span 2;
  }
  .gi-square {
    grid-column: span 1;
    grid-row:    span 1;
  }
}

/* Large desktop: 4 cols */
@media (min-width: 1600px) {
  .gallery-grid {
    grid-template-columns: repeat(4, 1fr);
    grid-auto-rows: 260px;
  }
  .gi-wide {
    grid-column: span 2;
    grid-row:    span 1;
  }
  .gi-tall {
    grid-column: span 1;
    grid-row:    span 2;
  }
  .gi-square {
    grid-column: span 1;
    grid-row:    span 1;
  }
}

/* ── GALLERY ITEM ── */
.gallery-item {
  border-radius: var(--radius-lg);
  overflow: hidden;
  position: relative;
  cursor: pointer;
  background: var(--color-grid-bg);
  /* height fills the grid row(s) automatically */
}

/* ── IMAGE WRAPPER fills the slot perfectly ── */
.gallery-img-wrap {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
}

.gallery-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
  transition: transform 0.6s cubic-bezier(0.165, 0.84, 0.44, 1);
}

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

/* ── OVERLAY ── */
.gallery-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to top,
    rgba(2, 44, 34, 0.88) 0%,
    rgba(2, 44, 34, 0.35) 45%,
    transparent 100%
  );
  opacity: 0;
  transition: opacity 0.3s ease;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: var(--space-md);
  z-index: 2;
}

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

.gallery-caption {
  color: white;
  font-family: var(--font-display);
  font-size: var(--fs-base);
  font-weight: 700;
  margin-bottom: 4px;
  line-height: 1.25;
}

.gallery-desc-preview {
  color: rgba(255, 255, 255, 0.82);
  font-size: var(--fs-xs);
  line-height: 1.45;
  margin-bottom: 10px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.gallery-cat-tag {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--color-lime);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 500;
}

/* Skeleton pulse for unloaded items */
.skeleton-item {
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 0.35; }
  50%       { opacity: 0.6; }
}

/* ── LIGHTBOX ── */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(2, 44, 34, 0.98);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.lightbox-inner {
  position: relative;
  width: 100%;
  max-width: 1280px;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  padding: 0 var(--container-pad);
  align-items: center;
}

.lightbox-inner img {
  max-width: 100%;
  max-height: 72vh;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: var(--radius-lg);
  box-shadow: 0 40px 100px rgba(0, 0, 0, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.lightbox-caption {
  margin-top: var(--space-5);
  text-align: center;
  max-width: 700px;
  padding: 0 var(--space-4);
}

.lb-title {
  display: block;
  font-family: var(--font-display);
  font-size: var(--fs-xl);
  font-weight: 700;
  color: white;
  margin-bottom: var(--space-2);
  letter-spacing: -0.01em;
}

.lb-desc {
  font-size: var(--fs-sm);
  color: rgba(255, 255, 255, 0.65);
  line-height: 1.65;
}

/* ── LIGHTBOX BUTTON CONTROLS ── */
.lightbox-close {
  position: absolute;
  top: clamp(-56px, -8vw, -68px);
  right: 0;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: white;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 20px;
  transition: all var(--transition-fast);
}

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

.lightbox-nav {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: white;
  width: clamp(44px, 6vw, 60px);
  height: clamp(44px, 6vw, 60px);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 22px;
  transition: all var(--transition-fast);
  z-index: 10;
}

.lightbox-nav:hover {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.3);
  transform: translateY(-50%) scale(1.08);
}

.lightbox-nav.prev { left: clamp(12px, 3vw, 32px); }
.lightbox-nav.next { right: clamp(12px, 3vw, 32px); }

/* Mobile: move nav to bottom */
@media (max-width: 768px) {
  .lightbox-nav {
    top: auto;
    bottom: 24px;
    transform: none;
  }
  .lightbox-nav:hover {
    transform: scale(1.08);
  }
  .lightbox-nav.prev { left: calc(50% - 64px); }
  .lightbox-nav.next { right: calc(50% - 64px); }
  .lightbox-inner {
    padding: 0 20px;
  }
  .lightbox-inner img {
    max-height: 65vh;
  }
  .lightbox-close {
    top: -52px;
    right: 0;
  }
}
