/* ===== GALLERY SECTION - I NOSTRI LAVORI - LIGHT THEME ===== */

/* Inline gallery (inside servizi section) */
.gallery-inline {
  margin-top: var(--space-3xl);
  padding-top: var(--space-2xl);
  border-top: 1px solid var(--color-border-light);
}

/* Standalone section */
.gallery-section {
  background: var(--color-bg-secondary);
  padding: var(--space-3xl) 0;
  position: relative;
}

/* Header */
.gallery-header {
  text-align: center;
  margin-bottom: var(--space-2xl);
}

.gallery-header h2,
.gallery-header h3 {
  font-size: var(--font-size-2xl);
  font-weight: var(--font-weight-bold);
  color: var(--color-text-primary);
  margin-bottom: var(--space-sm);
  font-family: var(--font-heading);
}

.gallery-header p {
  font-size: var(--font-size-base);
  color: var(--color-text-secondary);
  max-width: 50ch;
  margin: 0 auto;
  line-height: var(--line-height-relaxed);
}

/* Grid Layout - Masonry-like with CSS Grid */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-auto-rows: 20rem;
  gap: var(--space-md);
  max-width: 110rem;
  margin: 0 auto;
}

/* Gallery Items */
.gallery-item {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-lg);
  background: var(--color-bg-primary);
  cursor: pointer;
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1),
              box-shadow 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--shadow-sm);
}

.gallery-item:hover {
  box-shadow: var(--shadow-xl);
}

/* No-JS hover transform */
body:not(.js) .gallery-item:hover {
  transform: translateY(-4px);
}

/* JS enabled: hover only after animate-in */
.js .gallery-item.animate-in:hover {
  transform: translateY(-4px);
}

/* Large items span 2 rows */
.gallery-item--large {
  grid-row: span 2;
}

/* Images */
.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.gallery-item:hover img {
  transform: scale(1.05);
}

/* Placeholder for empty items */
.gallery-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  background: linear-gradient(135deg,
    rgba(255, 107, 74, 0.05) 0%,
    rgba(123, 111, 217, 0.05) 100%);
  border: 2px dashed rgba(255, 107, 74, 0.2);
  color: var(--color-text-secondary);
  transition: all 0.3s ease;
}

.gallery-placeholder .material-symbols-outlined {
  font-size: 4rem;
  color: rgba(255, 107, 74, 0.3);
  transition: color 0.3s ease;
}

.gallery-placeholder span:last-child {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  opacity: 0.6;
}

.gallery-item:hover .gallery-placeholder {
  background: linear-gradient(135deg,
    rgba(255, 107, 74, 0.08) 0%,
    rgba(123, 111, 217, 0.08) 100%);
  border-color: rgba(255, 107, 74, 0.4);
}

.gallery-item:hover .gallery-placeholder .material-symbols-outlined {
  color: rgba(255, 107, 74, 0.5);
}

/* Overlay for images - stays dark (overlay on photo) */
.gallery-item::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to top,
    rgba(26, 26, 26, 0.5) 0%,
    transparent 50%);
  opacity: 0;
  transition: opacity 0.4s ease;
  pointer-events: none;
}

.gallery-item:hover::after {
  opacity: 1;
}

/* Tablet: 2 columns */
@media (max-width: 1024px) {
  .gallery-grid {
    grid-template-columns: repeat(2, 1fr);
    grid-auto-rows: 18rem;
    gap: var(--space-sm);
  }

  .gallery-item--large {
    grid-row: span 2;
  }
}

/* Mobile: Single column */
@media (max-width: 768px) {
  .gallery-section {
    padding: var(--space-2xl) 0;
  }

  .gallery-inline {
    margin-top: var(--space-2xl);
    padding-top: var(--space-xl);
  }

  .gallery-header {
    margin-bottom: var(--space-xl);
    padding: 0;
  }

  .gallery-header h2,
  .gallery-header h3 {
    font-size: var(--font-size-xl);
  }

  .gallery-header p {
    font-size: var(--font-size-sm);
  }

  .gallery-grid {
    grid-template-columns: 1fr;
    grid-auto-rows: 16rem;
    gap: var(--space-md);
    padding: 0;
  }

  .gallery-item--large {
    grid-row: span 1;
    height: 22rem;
  }

  .gallery-placeholder .material-symbols-outlined {
    font-size: 3rem;
  }
}

/* Animation on scroll (only with JS) */
.js .gallery-item {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.js .gallery-item.animate-in {
  opacity: 1;
  transform: translateY(0);
}

/* Staggered animation delays */
.js .gallery-item:nth-child(1) { transition-delay: 0.1s; }
.js .gallery-item:nth-child(2) { transition-delay: 0.2s; }
.js .gallery-item:nth-child(3) { transition-delay: 0.3s; }
.js .gallery-item:nth-child(4) { transition-delay: 0.4s; }
.js .gallery-item:nth-child(5) { transition-delay: 0.5s; }
.js .gallery-item:nth-child(6) { transition-delay: 0.6s; }
