/* Gallery-specific styles */

/* Gallery Hero */
.gallery-hero {
  padding: clamp(2rem, 4vh, 4rem) 0;
  text-align: center;
}

.gallery-header {
  max-width: 800px;
  margin: 0 auto 3rem;
}

.gallery-header h1 {
  font-size: clamp(2.5rem, 5vw, 4rem);
  margin-bottom: 1.5rem;
}

/* Gallery Filters */
.gallery-filters {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 2rem;
}

.filter-btn {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius);
  font: 500 0.9rem var(--font-sans);
  cursor: pointer;
  transition: var(--transition-base);
  position: relative;
  overflow: hidden;
}

.filter-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--gradient-accent);
  opacity: 0;
  transition: var(--transition-base);
  z-index: -1;
}

.filter-btn:hover,
.filter-btn.active {
  color: var(--text);
  border-color: var(--accent);
  transform: translateY(-2px);
}

.filter-btn.active::before {
  opacity: 1;
}

.filter-btn.active {
  color: white;
  box-shadow: var(--shadow-glow);
}

/* Gallery Grid - Modern Masonry */
.gallery-section {
  padding-top: 0;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
  align-items: start;
}

.gallery-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  position: relative;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

.gallery-item::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.1), transparent 60%);
  opacity: 0;
  transition: all 0.4s ease;
  z-index: 1;
}

.gallery-item:hover {
  transform: translateY(-12px) scale(1.02);
  border-color: var(--accent);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15), 0 0 0 1px var(--accent);
}

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

.gallery-item.hidden {
  opacity: 0;
  transform: scale(0.8);
  pointer-events: none;
}

.gallery-image {
  width: 100%;
  height: auto;
  min-height: 200px;
  object-fit: cover;
  transition: all 0.4s ease;
  filter: brightness(1) saturate(1);
  position: relative;
}

.gallery-item:hover .gallery-image {
  filter: brightness(1.1) saturate(1.1);
}

/* Masonry Heights for Visual Interest */
.gallery-item:nth-child(4n+1) .gallery-image {
  height: 260px;
}

.gallery-item:nth-child(4n+2) .gallery-image {
  height: 320px;
}

.gallery-item:nth-child(4n+3) .gallery-image {
  height: 240px;
}

.gallery-item:nth-child(4n+4) .gallery-image {
  height: 300px;
}

/* Additional variety */
.gallery-item:nth-child(7n+1) .gallery-image {
  height: 380px;
}

.gallery-item:nth-child(11n+1) .gallery-image {
  height: 220px;
}

/* Loading State */
.gallery-loading {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 4rem 0;
  color: var(--text-dim);
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top: 3px solid var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Image Modal */
.image-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: var(--transition-base);
}

.image-modal.active {
  opacity: 1;
  visibility: visible;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.9);
  backdrop-filter: blur(10px);
}

.modal-content {
  position: relative;
  max-width: 95vw;
  max-height: 95vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-close {
  position: absolute;
  top: -3rem;
  right: 0;
  background: none;
  border: none;
  color: white;
  font-size: 2rem;
  cursor: pointer;
  z-index: 10;
  padding: 0.5rem;
  transition: var(--transition-base);
}

.modal-close:hover {
  color: var(--accent-light);
  transform: scale(1.1);
}

.modal-prev,
.modal-next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0, 0, 0, 0.7);
  border: 1px solid var(--border);
  color: white;
  font-size: 2rem;
  cursor: pointer;
  padding: 1rem;
  border-radius: var(--radius);
  transition: var(--transition-base);
  z-index: 10;
}

.modal-prev {
  left: -4rem;
}

.modal-next {
  right: -4rem;
}

.modal-prev:hover,
.modal-next:hover {
  background: var(--accent);
  border-color: var(--accent);
  transform: translateY(-50%) scale(1.1);
}

.modal-image-container {
  background: transparent;
  border: none;
  border-radius: var(--radius-lg);
  overflow: hidden;
  max-width: 100%;
  max-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

#modal-image {
  width: auto;
  height: auto;
  max-width: 90vw;
  max-height: 85vh;
  object-fit: contain;
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.modal-info {
  display: none; /* Hidden for clean visual focus */
}

/* Active nav link */
.nav a.active {
  color: var(--accent-light);
  font-weight: 600;
}

.nav a.active::before {
  width: 100%;
  background: var(--accent);
}

/* Responsive Design */
@media (max-width: 768px) {
  .gallery-grid {
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 0.75rem;
  }
  
  .gallery-item:hover {
    transform: translateY(-6px) scale(1.01);
  }
  
  /* Normalize heights on mobile */
  .gallery-item .gallery-image {
    height: 280px !important;
  }
  
  .gallery-filters {
    gap: 0.5rem;
  }
  
  .filter-btn {
    padding: 0.625rem 1.25rem;
    font-size: 0.85rem;
  }
  
  .modal-prev {
    left: -2rem;
  }
  
  .modal-next {
    right: -2rem;
  }
  
  .modal-prev,
  .modal-next {
    font-size: 1.5rem;
    padding: 0.75rem;
  }
}

@media (max-width: 480px) {
  .gallery-grid {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.5rem;
  }
  
  .gallery-item .gallery-image {
    height: 240px !important;
  }
  
  .gallery-filters {
    flex-direction: column;
    align-items: center;
  }
  
  .filter-btn {
    min-width: 180px;
    padding: 0.75rem 1rem;
  }
  
  .modal-prev,
  .modal-next {
    display: none; /* Hide nav buttons on very small screens */
  }
  
  #modal-image {
    max-width: 95vw;
    max-height: 80vh;
  }
}

/* Animation stagger for gallery items */
.gallery-item:nth-child(1) { animation-delay: 0s; }
.gallery-item:nth-child(2) { animation-delay: 0.1s; }
.gallery-item:nth-child(3) { animation-delay: 0.2s; }
.gallery-item:nth-child(4) { animation-delay: 0.3s; }
.gallery-item:nth-child(5) { animation-delay: 0.4s; }
.gallery-item:nth-child(6) { animation-delay: 0.5s; }

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
  .gallery-item,
  .filter-btn,
  .modal-prev,
  .modal-next {
    transition: none;
  }
  
  .loading-spinner {
    animation: none;
  }
}
