/* ============================================
   Gallery Page — Filter & Lightbox Styles
   ============================================ */

/* ── GALLERY SECTION ── */
.gallery-grid-wrapper {
  width: 100%; max-width: none; padding: 0 16px;
  margin-top: 48px;
  overflow: visible;
  display: block;
}

/* ── GALLERY FILTER ── */
.filters {
  display: flex; justify-content: center; gap: 12px; margin: 48px 16px; flex-wrap: wrap;
}
.filter-btn {
  font-size: 0.75rem; font-weight: 500; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--color-slate);
  background: transparent; padding: 12px 24px;
  border: 1.5px solid var(--glass-border); border-radius: 32px;
  cursor: pointer; transition: all 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  white-space: nowrap;
  position: relative;
  overflow: hidden;
}
.filter-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--color-accent);
  transition: all 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  transform: scaleX(0);
  transform-origin: left;
  z-index: -1;
  opacity: 0;
}
.filter-btn:hover::before,
.filter-btn.active::before {
  transform: scaleX(1);
  opacity: 1;
}
.filter-btn:hover {
  background: var(--color-accent); 
  color: var(--white); 
  border-color: var(--color-accent);
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 8px 24px rgba(201, 169, 98, 0.25);
}
.filter-btn.active {
  background: var(--color-accent); 
  color: var(--white); 
  border-color: var(--color-accent);
  box-shadow: 0 8px 24px rgba(201, 169, 98, 0.35);
}

/* ── GALLERY GRID ── */
.gallery-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin: 0 16px;
  width: calc(100% - 32px);
  grid-auto-rows: auto;
  overflow: visible;
}
.gallery-item {
  position: relative;
  aspect-ratio: 4/3;
  overflow: hidden;
  cursor: pointer;
  border-radius: 12px;
  transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  box-shadow: 0 2px 8px rgba(26, 26, 46, 0.1);
  transform-origin: center center;
  transform: perspective(1000px) scale(1);
  background: linear-gradient(135deg, #f0f0f0 0%, #e8e8e8 100%);
  min-height: 200px;
  width: 100%;
}
.gallery-item:hover {
  box-shadow: 0 12px 28px rgba(26, 26, 46, 0.2);
  transform: translateY(-4px);
}
.gallery-item.hidden { display: none; }
.gallery-bg {
  width: 100%;
  height: 100%;
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: linear-gradient(135deg, #f0f0f0 0%, #e8e8e8 100%);
  display: flex;
  align-items: center;
  justify-content: center;
}
.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block !important;
  transition: transform 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94), filter 0.6s ease;
  filter: brightness(1);
  opacity: 1 !important;
  visibility: visible !important;
  will-change: transform;
  max-width: 100%;
  max-height: 100%;
}
.gallery-item img[loading="lazy"] {
  opacity: 1;
}
.gallery-item img:not([src]) {
  opacity: 0.3;
}
.gallery-item:hover img { 
  transform: scale(1.12); 
  filter: brightness(1.05);
}
.gallery-overlay {
  position: absolute; inset: 0;
  background: rgba(26, 26, 46, 0); transition: background 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  display: flex; align-items: center; justify-content: center;
}
.gallery-item:hover .gallery-overlay { 
  background: rgba(26, 26, 46, 0.5); 
}
.gallery-zoom {
  width: 56px; height: 56px;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transform: scale(0.7) rotate(-180deg); 
  transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  font-size: 1.6rem; font-weight: 300; color: var(--white);
  border: 2px solid rgba(255, 255, 255, 0.6); border-radius: 50%;
  background: rgba(26, 26, 46, 0.4); backdrop-filter: blur(6px);
}
.gallery-item:hover .gallery-zoom { 
  opacity: 1; 
  transform: scale(1) rotate(0deg); 
}

/* ── LIGHTBOX ── */
.lightbox {
  display: none; position: fixed; inset: 0; z-index: 9999;
  background: rgba(0, 0, 0, 0.96);
  align-items: center; justify-content: center;
  backdrop-filter: blur(2px);
  animation: fadeIn 0.3s ease;
  opacity: 0;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.lightbox.active { 
  display: flex; 
  opacity: 1;
  animation: fadeIn 0.3s ease forwards;
}
.lightbox-close {
  position: absolute; top: 28px; right: 36px;
  font-size: 2.8rem; color: var(--white); background: none; border: none;
  cursor: pointer; opacity: 0.7; transition: all 0.3s ease; line-height: 1;
}
.lightbox-close:hover { 
  opacity: 1; 
  transform: scale(1.1) rotate(90deg);
}
.lightbox-img-container {
  position: relative; width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
}
.lightbox-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  font-size: 2.2rem; color: var(--white);
  background: rgba(255, 255, 255, 0.08); border: 1px solid rgba(255, 255, 255, 0.15);
  width: 60px; height: 60px; cursor: pointer;
  opacity: 0.6; transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  display: flex; align-items: center; justify-content: center;
  border-radius: 8px;
}
.lightbox-nav:hover {
  opacity: 1; 
  background: rgba(201, 169, 98, 0.25); 
  border-color: rgba(201, 169, 98, 0.4);
  transform: translateY(-50%) scale(1.08);
  box-shadow: 0 0 20px rgba(201, 169, 98, 0.3);
}
.lightbox-prev { left: 32px; }
.lightbox-next { right: 32px; }
.lightbox-img {
  max-width: 90vw; max-height: 85vh; object-fit: contain;
  border-radius: 2px; 
  animation: slideIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  opacity: 1;
  transition: opacity 0.3s ease;
}
.lightbox-img.loading {
  opacity: 0.5;
}
@keyframes slideIn { 
  from { 
    opacity: 0; 
    transform: scale(0.95) translateY(20px); 
  } 
  to { 
    opacity: 1; 
    transform: scale(1) translateY(0); 
  } 
}
.lightbox-info {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.95), rgba(0,0,0,0.7), transparent);
  padding: 60px 36px 28px;
  display: flex; justify-content: space-between; align-items: flex-end;
  animation: slideUp 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94) 0.1s backwards;
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(30px); }
  to { opacity: 1; transform: translateY(0); }
}
.lightbox-counter {
  font-size: 0.75rem; color: rgba(255, 255, 255, 0.8); letter-spacing: 0.15em;
  text-transform: uppercase;
  transition: all 0.3s ease;
}
.lightbox-category {
  font-size: 0.9rem; color: var(--color-accent); font-weight: 400;
  letter-spacing: 0.1em;
  transition: all 0.3s ease;
}
.lightbox-thumbs {
  position: absolute; bottom: 28px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 8px; max-width: 80vw; overflow-x: auto;
  padding-bottom: 8px; scroll-behavior: smooth;
  animation: slideUp 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94) 0.2s backwards;
}
.lightbox-thumbs::-webkit-scrollbar {
  height: 4px;
}
.lightbox-thumbs::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.3); border-radius: 4px;
  transition: all 0.3s ease;
}
.lightbox-thumbs::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.5);
}
.lightbox-thumb {
  width: 56px; height: 42px; border-radius: 4px; overflow: hidden;
  cursor: pointer; opacity: 0.6; transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.1);
  flex-shrink: 0;
}
.lightbox-thumb img {
  width: 100%; height: 100%; object-fit: cover;
  transition: all 0.3s ease;
}
.lightbox-thumb:hover {
  opacity: 0.85;
  transform: scale(1.05);
}
.lightbox-thumb.active {
  opacity: 1; 
  border-color: var(--color-accent);
  box-shadow: 0 0 12px rgba(201, 169, 98, 0.4), inset 0 0 8px rgba(201, 169, 98, 0.2);
}

/* ── RESPONSIVE ── */
@media (max-width: 1400px) {
  .gallery-grid { grid-template-columns: repeat(4, 1fr); gap: 14px; }
}
@media (max-width: 1200px) {
  .gallery-grid { grid-template-columns: repeat(3, 1fr); gap: 14px; }
}
@media (max-width: 900px) {
  .gallery-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; margin: 0 12px; width: calc(100% - 24px); }
  .gallery-grid-wrapper { padding: 0 12px; }
  .filters { gap: 10px; margin: 40px 12px; }
  .filter-btn { padding: 10px 20px; font-size: 0.7rem; }
  .lightbox-nav { width: 52px; height: 52px; font-size: 1.8rem; }
  .lightbox-prev { left: 20px; }
  .lightbox-next { right: 20px; }
}
@media (max-width: 768px) {
  .gallery-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 0 10px; width: calc(100% - 20px); }
  .gallery-item { min-height: 180px !important; }
  .gallery-item img { object-fit: cover; }
  .gallery-grid-wrapper { padding: 0 10px; }
  .filters { margin: 36px 10px; gap: 8px; }
  .filter-btn { padding: 9px 16px; font-size: 0.65rem; }
}
@media (max-width: 640px) {
  .gallery-grid { grid-template-columns: 1fr; gap: 10px; margin: 0 8px; width: calc(100% - 16px); }
  .gallery-item { min-height: 280px !important; }
  .gallery-item img { width: 100% !important; height: 100% !important; display: block !important; object-fit: cover; }
  .gallery-bg { display: flex !important; width: 100% !important; height: 100% !important; }
  .gallery-grid-wrapper { padding: 0 8px; margin-top: 32px; }
  .filters { margin: 32px 8px; gap: 6px; }
  .filter-btn { padding: 8px 14px; font-size: 0.6rem; }
  .lightbox-img { max-width: 95vw; max-height: 80vh; }
  .lightbox-nav { width: 48px; height: 48px; font-size: 1.6rem; }
  .lightbox-prev { left: 12px; }
  .lightbox-next { right: 12px; }
  .lightbox-close { top: 20px; right: 20px; font-size: 2.2rem; }
  .lightbox-info { padding: 32px 20px 20px; }
  .lightbox-thumbs { max-width: 90vw; }
}
@media (max-width: 480px) {
  .gallery-grid { grid-template-columns: 1fr; gap: 8px; margin: 0 6px; width: calc(100% - 12px); }
  .gallery-item { min-height: 240px !important; }
  .gallery-item img { width: 100% !important; height: 100% !important; display: block !important; opacity: 1 !important; visibility: visible !important; object-fit: cover; }
  .gallery-bg { display: flex !important; width: 100% !important; height: 100% !important; }
  .gallery-grid-wrapper { padding: 0 6px; margin-top: 24px; }
  .filters { margin: 24px 6px; gap: 4px; }
  .filter-btn { padding: 7px 12px; font-size: 0.55rem; }
}

/* ── ANIMATION & TRANSITIONS ── */
@supports (animation: none) {
  .gallery-item {
    animation: slideUp 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94) 0.1s backwards;
    opacity: 0;
  }
  
  @keyframes slideUp {
    0% {
      opacity: 0;
      transform: translateY(40px);
    }
    100% {
      opacity: 1;
      transform: translateY(0);
    }
  }
  
  @keyframes fadeInScale {
    0% {
      opacity: 0;
      transform: scale(0.92);
    }
    100% {
      opacity: 1;
      transform: scale(1);
    }
  }
  
  @keyframes floatUp {
    0%, 100% {
      transform: translateY(0px);
    }
    50% {
      transform: translateY(-8px);
    }
  }
  
  /* Staggered animation delays for cascade effect */
  .gallery-item:nth-child(1) { animation-delay: 0s; }
  .gallery-item:nth-child(2) { animation-delay: 0.08s; }
  .gallery-item:nth-child(3) { animation-delay: 0.16s; }
  .gallery-item:nth-child(4) { animation-delay: 0.24s; }
  .gallery-item:nth-child(5) { animation-delay: 0.16s; }
  .gallery-item:nth-child(6) { animation-delay: 0.24s; }
  .gallery-item:nth-child(7) { animation-delay: 0.32s; }
  .gallery-item:nth-child(8) { animation-delay: 0.4s; }
  .gallery-item:nth-child(n+9) { animation-delay: 0.48s; }
  
  /* Scroll-triggered animations */
  .gallery-item.in-view {
    animation: slideUp 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
  }
  
  .gallery-item.in-view img {
    animation: fadeInScale 1s cubic-bezier(0.34, 1.56, 0.64, 1) 0.2s forwards;
  }
}

/* ── PARALLAX SCROLL EFFECT ── */
.gallery-item {
  transform-origin: center;
  will-change: transform, opacity;
}

.gallery-item img {
  will-change: transform;
}

/* ── FILTER ANIMATION ── */
.gallery-item.hidden {
  animation: fadeOut 0.4s ease-out forwards;
}

@keyframes fadeOut {
  from {
    opacity: 1;
    transform: scale(1);
  }
  to {
    opacity: 0;
    transform: scale(0.95);
  }
}

.gallery-item:not(.hidden) {
  animation: fadeInScale 0.5s ease-out forwards;
}

/* ── SMOOTH FILTER TRANSITIONS ── */
.filters {
  animation: slideDown 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94) 0.1s backwards;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ── ACCESSIBILITY ── */
.gallery-item:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* ── PRINT STYLES ── */
@media print {
  .gallery-grid { display: none; }
  .filters { display: none; }
}
