/* Galleria - DESKTOP */
.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 20px;
  max-width: 1200px;
  margin: 0 auto 5px;
  padding: 0 15px;
  justify-content: center;
}

.gallery-item {
  position: relative;
  overflow: hidden;
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  background-color: #f5f5f5;
  height: 200px; /* Desktop */
}

.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.4s ease;
}

.gallery-item:hover {
  transform: scale(1.01);
  box-shadow: 0 10px 20px rgba(0,0,0,0.3);
}

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

/* Overlay carosello */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0,0,0,0.95);
  justify-content: center;
  align-items: center;
  z-index: 10000;
}

.modal img {
  max-width: 90%;
  max-height: 80%;
  object-fit: contain;
  border-radius: 10px;
}

/* Chiudi overlay */
.close {
  position: absolute;
  top: 20px;
  right: 30px;
  font-size: 3rem;
  color: #fff;
  cursor: pointer;
  background-color: rgba(0,0,0,0.5);
  border-radius: 50%;
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10001;
  transition: background 0.3s;
}

.close:hover {
  background-color: rgba(255,255,255,0.3);
  color: #fff;
}

/* MOBILE */
@media (max-width: 768px) {
  h1 {
    font-size: 2rem;
  }
  
  .gallery {
    grid-template-columns: 1fr;
    gap: 25px;
    padding: 0 20px;
    max-width: 500px;
  }
  
  .gallery-item {
    height: 250px;
    width: 100%;
    border-radius: 12px;
  }
  
  /* FIX MODALE MOBILE - CENTRATURA PERFETTA */
  .modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.98);
    justify-content: center;
    align-items: center;
    z-index: 10000;
    padding: 0; /* RIMOSSO IL PADDING CHE ROMPEVA */
  }
  
  .modal img {
    max-width: 95%;
    max-height: 90vh;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 8px;
    margin: 0; /* RIMOSSO MARGIN */
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%); /* CENTRATURA ASSOLUTA */
  }
  
  .close {
    position: absolute;
    top: 20px;
    right: 20px;
    font-size: 2.2rem;
    width: 44px;
    height: 44px;
    background-color: rgba(0,0,0,0.7);
    border: 2px solid rgba(255,255,255,0.3);
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
  }
}

@media (max-width: 480px) {
  .gallery {
    gap: 20px;
    padding: 0 15px;
  }
  
  .gallery-item {
    height: 220px;
  }
  
  .modal img {
    max-height: 85vh;
  }
  
  .close {
    top: 15px;
    right: 15px;
    width: 40px;
    height: 40px;
    font-size: 2rem;
  }
}