/* ==========================================================================
   Gallery Filtering & Masonry Grid
   ========================================================================== */
.gallery-filter-panel {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-bottom: 40px;
  flex-wrap: wrap;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-auto-rows: 240px;
  gap: 20px;
}

.gallery-item {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--color-border);
  box-shadow: 0 4px 15px var(--color-shadow);
  cursor: pointer;
  transition: var(--transition-smooth);
}

/* Create masonry effect via row spans */
.gallery-item.span-h {
  grid-column: span 2;
}

.gallery-item.span-v {
  grid-row: span 2;
}

.gallery-item.span-both {
  grid-column: span 2;
  grid-row: span 2;
}

.gallery-img-wrapper {
  width: 100%;
  height: 100%;
  position: relative;
  background: var(--color-navy-light);
}

.gallery-img-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: var(--transition-smooth);
}

.gallery-item:hover .gallery-img-wrapper img {
  transform: scale(1.05);
}

/* Caption overlay details */
.gallery-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  padding: 24px 20px;
  background: rgba(15, 23, 42, 0.9);
  opacity: 0;
  transform: translateY(10px);
  transition: var(--transition-smooth);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.gallery-item:hover .gallery-overlay {
  opacity: 1;
  transform: translateY(0);
}

.gallery-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--color-text-white);
}

.gallery-category {
  font-size: 0.75rem;
  color: var(--color-orange-accent);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

/* ==========================================================================
   Custom Lightbox Modal
   ========================================================================== */
.lightbox-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(2, 6, 23, 0.95);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 1000;
  justify-content: center;
  align-items: center;
}

.lightbox-modal.show {
  display: flex;
}

.lightbox-content-wrapper {
  position: relative;
  max-width: 90%;
  max-height: 80%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.lightbox-image {
  max-width: 100%;
  max-height: 70vh;
  border-radius: 8px;
  border: 1px solid var(--color-border);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8);
  object-fit: contain;
}

.lightbox-caption {
  color: var(--color-text-white);
  font-family: var(--font-headings);
  font-size: 1.2rem;
  font-weight: 600;
  text-align: center;
}

/* Controls */
.lightbox-btn {
  position: absolute;
  color: white;
  font-size: 2.5rem;
  transition: var(--transition-fast);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(8, 15, 37, 0.5);
  border: 1px solid var(--color-border);
}

.lightbox-btn:hover {
  background: var(--color-blue-accent);
  transform: scale(1.05);
}

.lightbox-close {
  top: -60px;
  right: 0;
}

.lightbox-prev {
  left: -80px;
  top: 50%;
  transform: translateY(-50%);
}

.lightbox-next {
  right: -80px;
  top: 50%;
  transform: translateY(-50%);
}

/* ==========================================================================
   Responsive Gallery Page Breakpoints
   ========================================================================== */
@media (max-width: 1024px) {
  .gallery-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .gallery-item.span-h, .gallery-item.span-both {
    grid-column: span 1;
  }
}

@media (max-width: 768px) {
  .lightbox-prev {
    left: 20px;
    top: auto;
    bottom: -60px;
  }

  .lightbox-next {
    right: 20px;
    top: auto;
    bottom: -60px;
  }
  
  .lightbox-close {
    top: -50px;
  }
}

@media (max-width: 640px) {
  .gallery-grid {
    grid-template-columns: 1fr;
    grid-auto-rows: 200px;
  }

  .gallery-item.span-v, .gallery-item.span-both {
    grid-row: span 1;
  }
}
