.gallery-section {
  scroll-margin-top: 96px;
  background: var(--light-bg);
}

.gallery-carousel-shell {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  gap: 10px;
  margin: 2rem 0;
  max-width: 100%;
}

.gallery-carousel-viewport {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

/* Carrusel horizontal: una fila desplazable */
.gallery-section .gallery-grid {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  gap: 12px;
  margin: 0;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x mandatory;
  scroll-padding-inline: 8px;
  padding: 4px 4px 14px;
  scrollbar-width: thin;
}

.gallery-section .gallery-grid::-webkit-scrollbar {
  height: 8px;
}

.gallery-section .gallery-grid::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 999px;
}

.gallery-section .gallery-grid .gallery-item {
  flex: 0 0 clamp(220px, 62vw, 300px);
  scroll-snap-align: start;
}

.gallery-carousel-btn {
  flex-shrink: 0;
  align-self: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 2px solid #dee2e6;
  border-radius: 50%;
  background: #fff;
  color: var(--primary-color, #e63946);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
  box-shadow: var(--shadow-sm, 0 2px 8px rgba(0, 0, 0, 0.06));
}

.gallery-carousel-btn:hover {
  border-color: var(--primary-color, #e63946);
  background: #fff;
  box-shadow: var(--shadow-md, 0 4px 14px rgba(0, 0, 0, 0.1));
}

.gallery-carousel-btn:focus-visible {
  outline: 3px solid var(--primary-color, #e63946);
  outline-offset: 2px;
}

@media (max-width: 479px) {
  .gallery-carousel-btn {
    width: 40px;
    height: 40px;
    font-size: 1.2rem;
  }

  .gallery-carousel-shell {
    gap: 6px;
  }
}

.gallery-item {
  margin: 0;
  border-radius: var(--radius-md);
  overflow: hidden;
  position: relative;
  cursor: pointer;
  transition: transform 0.25s, box-shadow 0.25s;
}

.gallery-item:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}

.gallery-item:focus-visible {
  outline: 3px solid var(--primary-color);
  outline-offset: 2px;
}

.gallery-item img {
  width: 100%;
  height: 200px;
  object-fit: cover;
  display: block;
}

.gallery-item[data-category="cliente"] img,
.gallery-item[data-category="logistica"] img,
.gallery-item[data-category="fabrica"] img,
.gallery-item[data-category="inspeccion"] img {
  height: min(260px, 42vw);
}

@media (min-width: 768px) {
  .gallery-item[data-category="cliente"] img,
  .gallery-item[data-category="logistica"] img,
  .gallery-item[data-category="fabrica"] img,
  .gallery-item[data-category="inspeccion"] img {
    height: 240px;
  }
}

.gallery-item figcaption {
  display: none;
}

.gallery-lightbox figcaption:empty {
  display: none;
}

.gallery-item.is-hidden {
  display: none;
}

.gallery-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-bottom: 1rem;
}

.filter-btn {
  padding: 8px 16px;
  border: 2px solid #dee2e6;
  background: #fff;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-base);
}

.filter-btn:hover,
.filter-btn:focus-visible {
  border-color: var(--primary-color);
  color: var(--primary-color);
}

.filter-btn.active {
  background: var(--primary-color);
  border-color: var(--primary-color);
  color: #fff;
}

.gallery-lightbox {
  position: fixed;
  inset: 0;
  z-index: 12000;
  background: rgba(0, 0, 0, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}

.gallery-lightbox.is-open {
  opacity: 1;
  pointer-events: auto;
}

.gallery-lightbox img {
  max-width: 100%;
  max-height: 85vh;
  border-radius: 8px;
}

.gallery-lightbox figcaption {
  color: #fff;
  text-align: center;
  margin-top: 12px;
  max-width: 600px;
}

.gallery-lightbox-close {
  position: absolute;
  top: 20px;
  right: 24px;
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: #fff;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 24px;
  cursor: pointer;
}

.gallery-lightbox-close:focus-visible {
  outline: 2px solid #fff;
}
