/* ===== GALERÍA ===== */

/* Preview en index.html */
.gallery-preview-section { padding-bottom: 2rem; }

.gallery-preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.gallery-preview-item {
  position: relative;
  aspect-ratio: 1/1;
  overflow: hidden;
  border-radius: 6px;
  cursor: pointer;
  background: var(--color-gray-light);
}

.gallery-preview-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease;
  display: block;
}

.gallery-preview-item:hover img { transform: scale(1.06); }

.gallery-preview-item-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.35);
  opacity: 0;
  transition: opacity 0.3s;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 1.25rem;
}

.gallery-preview-item:hover .gallery-preview-item-overlay { opacity: 1; }

.gallery-preview-cta {
  text-align: center;
  padding-top: 0.5rem;
}

.gallery-preview-cta .btn { gap: 0.5rem; }

/* ── Vista toggle ── */
.gallery-view-toggle {
  display: flex;
  gap: 0.35rem;
}

.view-btn {
  width: 36px;
  height: 36px;
  border: 1.5px solid var(--color-gray-light);
  background: white;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  color: #999;
  transition: all 0.2s;
}

.view-btn.active,
.view-btn:hover {
  background: var(--color-black);
  color: white;
  border-color: var(--color-black);
}

/* ── Grid uniforme ── */
.gallery-grid.uniform {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.75rem;
}

/* ── Grid masonry ── */
.gallery-grid.masonry {
  columns: 2;
  column-gap: 0.75rem;
}

@media (min-width: 640px) {
  .gallery-grid.masonry { columns: 3; }
}
@media (min-width: 1024px) {
  .gallery-grid.masonry { columns: 4; }
}

.gallery-grid.masonry .gallery-item {
  break-inside: avoid;
  margin-bottom: 0.75rem;
  border-radius: 6px;
  overflow: hidden;
}

.gallery-grid.masonry .gallery-item img {
  width: 100%;
  height: auto;
  display: block;
}

/* ── Item ── */
.gallery-item {
  position: relative;
  overflow: hidden;
  border-radius: 6px;
  cursor: pointer;
  background: var(--color-gray-light);
}

.gallery-grid.uniform .gallery-item {
  aspect-ratio: 1/1;
}

.gallery-grid.uniform .gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease;
  display: block;
}

.gallery-grid.masonry .gallery-item img {
  transition: transform 0.4s ease;
}

.gallery-item:hover img { transform: scale(1.04); }

.gallery-item-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.4);
  opacity: 0;
  transition: opacity 0.3s;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 1.5rem;
}

.gallery-item:hover .gallery-item-overlay { opacity: 1; }

.gallery-item-cat {
  position: absolute;
  bottom: 0.5rem;
  left: 0.5rem;
  background: rgba(0,0,0,0.6);
  color: white;
  font-size: 0.65rem;
  padding: 0.15rem 0.45rem;
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ── Lightbox ── */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox[hidden] { display: none; }

.lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.95);
}

.lightbox-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  height: 100%;
  padding: 3rem 4rem;
}

.lightbox-img-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  position: relative;
}

.lightbox-img-wrap img {
  max-width: 100%;
  max-height: 80vh;
  object-fit: contain;
  border-radius: 4px;
  transition: opacity 0.25s ease;
  display: block;
}

.lightbox-loader {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  color: var(--color-gold);
  font-size: 2rem;
}

.lightbox-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: rgba(255,255,255,0.1);
  border: none;
  color: white;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  z-index: 2;
}
.lightbox-close:hover { background: rgba(255,255,255,0.25); }

.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255,255,255,0.1);
  border: none;
  color: white;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  z-index: 2;
}
.lightbox-nav:hover { background: rgba(255,255,255,0.25); }
.lightbox-prev { left: 1rem; }
.lightbox-next { right: 1rem; }

.lightbox-footer {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding-top: 0.75rem;
  color: rgba(255,255,255,0.6);
  font-size: 0.85rem;
}

.lightbox-download {
  color: var(--color-gold);
  font-size: 1rem;
  transition: opacity 0.2s;
}
.lightbox-download:hover { opacity: 0.7; }

@media (max-width: 640px) {
  .lightbox-content { padding: 3rem 1rem 1rem; }
  .lightbox-nav { width: 36px; height: 36px; font-size: 0.9rem; }
  .lightbox-prev { left: 0.25rem; }
  .lightbox-next { right: 0.25rem; }
  .gallery-grid.uniform { grid-template-columns: repeat(2, 1fr); }
}
