/* ============================================
   MOREL CONSTRUCCIONES — Galería
   ============================================ */

.gallery {
  background: var(--color-bg-2);
  position: relative;
}
.gallery::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--color-border-gold), transparent);
}

/* Filtros */
.gallery-filters {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  justify-content: center;
  margin-bottom: var(--space-10);
}

.filter-btn {
  padding: var(--space-2) var(--space-5);
  font-size: var(--text-sm);
  font-weight: 400;
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  transition: all var(--duration-base) var(--ease-out);
}
.filter-btn:hover {
  color: var(--color-text);
  border-color: var(--color-border-gold);
}
.filter-btn.active {
  background: var(--color-gold);
  color: var(--color-black);
  border-color: var(--color-gold);
  font-weight: 500;
}

/* Carousel Wrapper */
.gallery-carousel-wrap {
  position: relative;
  width: 100%;
  padding: 0 var(--space-12);
}

/* Nav Buttons */
.gallery-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-lg);
  cursor: pointer;
  z-index: 10;
  transition: all var(--duration-base) var(--ease-out);
}
.gallery-nav:hover {
  background: var(--color-gold);
  color: var(--color-black);
  border-color: var(--color-gold);
}
.gallery-nav.prev { left: 0; }
.gallery-nav.next { right: 0; }

@media (max-width: 768px) {
  .gallery-carousel-wrap { padding: 0 var(--space-2); }
  .gallery-nav { display: none; } /* Hide buttons on mobile, rely on swipe */
}

/* Grid / Carousel */
.gallery-grid {
  display: flex;
  gap: var(--space-6);
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  padding: var(--space-6) 0 var(--space-10) 0;
  -ms-overflow-style: none;
  scrollbar-width: none;
}
.gallery-grid::-webkit-scrollbar {
  display: none;
}

.gallery-item {
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  flex: 0 0 80%;
  max-width: 500px;
  aspect-ratio: 4/3;
  scroll-snap-align: center;
  background: var(--color-surface);
  cursor: pointer;
  transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.5s ease, opacity 0.5s ease;
  transform: scale(0.85);
  opacity: 0.5;
}

@media (min-width: 768px) {
  .gallery-item {
    flex: 0 0 45%;
  }
}
@media (min-width: 1024px) {
  .gallery-item {
    flex: 0 0 35%;
  }
}

.gallery-item.active-slide {
  transform: scale(1.05);
  opacity: 1;
  box-shadow: 0 20px 40px rgba(0,0,0,0.6);
  z-index: 2;
}

.gallery-item.hidden {
  display: none !important;
}

.gallery-item img,
.gallery-item video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--duration-slow) var(--ease-out);
}

.gallery-item video {
  pointer-events: none; /* Prevent controls from intercepting clicks in the grid */
}

.gallery-item.active-slide:hover img { transform: scale(1.05); }

.gallery-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.8) 0%, transparent 60%);
  opacity: 0;
  transition: opacity var(--duration-base);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: var(--space-6);
}
.gallery-item.active-slide:hover .gallery-overlay { opacity: 1; }

.gallery-caption {
  font-size: var(--text-base);
  color: var(--color-white);
  font-weight: 500;
}
.gallery-tag {
  font-size: var(--text-xs);
  color: var(--color-gold);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: var(--space-1);
}

/* Placeholder cuando no hay imagen */
.gallery-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  color: var(--color-text-dim);
  font-size: var(--text-sm);
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-md);
}

/* Lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0,0,0,0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--duration-base) var(--ease-out);
}
.lightbox.open {
  opacity: 1;
  pointer-events: all;
}

.lightbox-img-wrap {
  max-width: 90vw;
  max-height: 85vh;
  text-align: center;
}
.lightbox-img-wrap img,
.lightbox-img-wrap video {
  max-width: 100%;
  max-height: 80vh;
  border-radius: var(--radius-md);
  object-fit: contain;
}
.lightbox-caption {
  margin-top: var(--space-3);
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}

.lightbox-close,
.lightbox-prev,
.lightbox-next {
  position: absolute;
  color: var(--color-white);
  font-size: var(--text-2xl);
  padding: var(--space-3);
  transition: color var(--duration-fast);
  line-height: 1;
}
.lightbox-close { top: var(--space-6); right: var(--space-6); font-size: 2rem; }
.lightbox-prev  { left: var(--space-6); top: 50%; transform: translateY(-50%); }
.lightbox-next  { right: var(--space-6); top: 50%; transform: translateY(-50%); }
.lightbox-close:hover,
.lightbox-prev:hover,
.lightbox-next:hover { color: var(--color-gold); }

@media (max-width: 900px) {
  .gallery-grid { grid-template-columns: repeat(2, 1fr); }
  .gallery-item:nth-child(4),
  .gallery-item:nth-child(7) {
    grid-column: span 1;
    aspect-ratio: 4/3;
  }
}
@media (max-width: 520px) {
  .gallery-grid { grid-template-columns: 1fr; }
}
