/* ====================================================================
   GALLERY MODULE
   Galería fullscreen inspirada en Snøhetta - overlay, scroll horizontal
   ==================================================================== */

/* ====================================================================
   GALLERY BUTTON (Fixed Lateral)
   ==================================================================== */

.gallery-button {
  position: fixed;
  right: var(--spacing-lg);
  top: 50%;
  transform: translateY(-50%);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 50px;
  height: 50px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 50%;
  cursor: pointer;
  transition: var(--transition);
  font-family: var(--font-montserrat);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--color-text);
}

.gallery-button:hover {
  background: var(--color-border);
  transform: translateY(-50%) scale(1.1);
}

.gallery-button-icon {
  width: 20px;
  height: 20px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Dot icon */
.gallery-button-icon::before {
  content: '';
  width: 6px;
  height: 6px;
  background-color: var(--color-text);
  border-radius: 50%;
  margin-right: 8px;
}

/* ====================================================================
   GALLERY OVERLAY
   ==================================================================== */

.gallery-overlay {
  position: fixed;
  inset: 0;
  background: #000000;
  z-index: 9999;
  display: none;
  opacity: 0;
  transition: opacity 0.4s ease;
}

.gallery-overlay.is-open {
  display: flex;
  opacity: 1;
}

/* Gallery Container */
.gallery-container {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

/* Gallery Scroll Track */
.gallery-track {
  display: flex;
  height: 100%;
  gap: 0;
  scroll-behavior: smooth;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;

  /* Hide scrollbar */
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.gallery-track::-webkit-scrollbar {
  display: none;
}

/* Gallery Items */
.gallery-item {
  flex: 0 0 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  scroll-snap-align: center;
  scroll-snap-stop: always;
}

.gallery-item img {
  max-width: 95vw;
  max-height: 95vh;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
}

.gallery-item video {
  max-width: 95vw;
  max-height: 95vh;
  width: auto;
  height: auto;
  object-fit: contain;
}

/* ====================================================================
   GALLERY CONTROLS
   ==================================================================== */

/* Close Button (Top Left) */
.gallery-close {
  position: absolute;
  top: var(--spacing-lg);
  left: var(--spacing-lg);
  z-index: 10001;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  background: none;
  border: none;
  color: white;
  transition: var(--transition);
}

.gallery-close:hover {
  opacity: 0.7;
}

.gallery-close::before,
.gallery-close::after {
  content: '';
  position: absolute;
  width: 24px;
  height: 2px;
  background-color: white;
}

.gallery-close::before {
  transform: rotate(45deg);
}

.gallery-close::after {
  transform: rotate(-45deg);
}

/* Logo (Top Left, below close) */
.gallery-logo {
  position: absolute;
  top: var(--spacing-lg);
  left: 50%;
  transform: translateX(-50%);
  z-index: 10001;
  font-family: var(--font-montserrat);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: white;
}

.gallery-logo img {
  height: 20px;
  width: auto;
  filter: invert(1) brightness(1.2);
}

/* Navigation Arrows */
.gallery-nav {
  position: absolute;
  top: 50%;
  width: 100%;
  display: flex;
  justify-content: space-between;
  padding: 0 var(--spacing-lg);
  z-index: 10000;
  transform: translateY(-50%);
  pointer-events: none;
}

.gallery-nav button {
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  font-size: 40px;
  padding: 0;
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.5;
  transition: var(--transition);
  pointer-events: all;
}

.gallery-nav button:hover {
  opacity: 1;
}

/* Counter */
.gallery-counter {
  position: absolute;
  bottom: var(--spacing-lg);
  left: var(--spacing-lg);
  z-index: 10001;
  font-family: var(--font-montserrat);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: rgba(255, 255, 255, 0.6);
}

.gallery-counter-current {
  color: white;
  font-weight: 600;
}

/* ====================================================================
   GALLERY LIGHTBOX (Alternative: Modal View)
   ==================================================================== */

.gallery-lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.95);
  z-index: 9999;
  display: none;
  padding: var(--spacing-xl);
  overflow-y: auto;
}

.gallery-lightbox.is-open {
  display: flex;
  align-items: center;
  justify-content: center;
}

.gallery-lightbox-content {
  max-width: 100%;
  max-height: 90vh;
  position: relative;
}

.gallery-lightbox-content img,
.gallery-lightbox-content video {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
}

.gallery-lightbox-caption {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.8), transparent);
  color: white;
  padding: var(--spacing-lg);
  font-size: 14px;
  line-height: 1.5;
}

/* ====================================================================
   GALLERY GRID (Archive Page)
   ==================================================================== */

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: var(--spacing-md);
  margin-top: var(--spacing-xl);
}

.gallery-grid-item {
  position: relative;
  overflow: hidden;
  aspect-ratio: 4 / 3;
  cursor: pointer;
  background: var(--color-border);
}

.gallery-grid-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: var(--transition-slow);
}

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

.gallery-grid-item-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0);
  transition: var(--transition);
  display: flex;
  align-items: flex-end;
  padding: var(--spacing-md);
}

.gallery-grid-item:hover .gallery-grid-item-overlay {
  background: rgba(0, 0, 0, 0.4);
}

.gallery-grid-item-info {
  color: white;
  opacity: 0;
  transition: var(--transition);
}

.gallery-grid-item:hover .gallery-grid-item-info {
  opacity: 1;
}

.gallery-grid-item-title {
  font-family: var(--font-montserrat);
  font-size: 14px;
  font-weight: 600;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.gallery-grid-item-type {
  font-family: var(--font-montserrat);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  opacity: 0.8;
}

/* ====================================================================
   IMAGE LAZY LOADING
   ==================================================================== */

img[loading="lazy"] {
  background: linear-gradient(90deg, var(--color-border) 25%, rgba(0, 0, 0, 0.05) 50%, var(--color-border) 75%);
  background-size: 200% 100%;
  animation: loading 1.5s infinite;
}

@keyframes loading {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* ====================================================================
   RESPONSIVE GALLERY
   ==================================================================== */

@media (max-width: 1024px) {
  .gallery-button {
    width: 40px;
    height: 40px;
    font-size: 10px;
  }

  .gallery-close {
    width: 35px;
    height: 35px;
  }

  .gallery-close::before,
  .gallery-close::after {
    width: 20px;
  }

  .gallery-nav button {
    font-size: 32px;
    width: 45px;
    height: 45px;
  }

  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: var(--spacing-sm);
  }
}

@media (max-width: 768px) {
  .gallery-button {
    width: 35px;
    height: 35px;
    right: var(--spacing-md);
  }

  .gallery-close {
    top: var(--spacing-md);
    left: var(--spacing-md);
  }

  .gallery-overlay {
    padding: 0;
  }

  .gallery-logo {
    display: none;
  }

  .gallery-nav button {
    font-size: 24px;
    width: 40px;
    height: 40px;
    opacity: 0.6;
  }

  .gallery-counter {
    bottom: var(--spacing-md);
    left: var(--spacing-md);
    font-size: 11px;
  }

  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  }
}

@media (max-width: 480px) {
  .gallery-button {
    width: 30px;
    height: 30px;
    right: var(--spacing-sm);
  }

  .gallery-close::before,
  .gallery-close::after {
    width: 16px;
  }

  .gallery-nav {
    padding: 0 var(--spacing-sm);
  }

  .gallery-nav button {
    font-size: 20px;
    width: 35px;
    height: 35px;
  }

  .gallery-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
}
