/* =============================================================
   PORTFOLIO CASAMB - CSS DEFINITIVO COMPLETO
   ============================================================= */

/* 1. LAYOUT GENERALE E TITOLO */
.portfolio-page-header {
  text-align: center;
  padding: 40px 0 20px;
}

.portfolio-title {
  font-size: 2.5rem;
  font-weight: 800;
  text-transform: uppercase;
  color: #1a1a1a;
  margin-bottom: 30px;
}

/* 2. FILTRI (BARRA ORIZZONTALE E BOTTONI) */
/* 1. Il wrapper crea lo spazio relativo per le sfumature */
.filter-wrapper {
  position: relative;
  width: 100%;
  max-width: 1200px;
  margin: 30px auto;
}

/* 2. Sfumature ai lati (gradienti) */
.filter-wrapper::before,
.filter-wrapper::after {
  content: "";
  position: absolute;
  top: 0;
  width: 50px;
  height: 100%;
  z-index: 2;
  pointer-events: none; /* Permette di cliccare i bottoni sotto la sfumatura */
}

.filter-wrapper::before {
  left: 0;
  background: linear-gradient(to right, rgba(255,255,255,0.9), transparent);
}

.filter-wrapper::after {
  right: 0;
  background: linear-gradient(to left, rgba(255,255,255,0.9), transparent);
}

/* 3. Il contenitore di scroll - IL VERO FIX */
/* Stile per il trascinamento */
.filter-scroll-container {
  cursor: pointer;
  user-select: none; /* Impedisce di selezionare il testo dei bottoni mentre trascini */
  -webkit-user-select: none;
  scrollbar-width: none; /* Nasconde scrollbar su Firefox */
  display: block;
  overflow-x: auto;
  width: 100%;
}

.filter-scroll-container.dragging {
  cursor: grabbing;
}

.filter-scroll-container a {
  user-drag: none; /* Impedisce il trascinamento nativo dell'immagine/link */
  -webkit-user-drag: none;
}

/* Sfumature (Verifica che abbiano pointer-events: none) */
.filter-wrapper::before,
.filter-wrapper::after {
  content: "";
  position: absolute;
  top: 0;
  width: 60px;
  height: 100%;
  z-index: 5;
  pointer-events: none; /* FONDAMENTALE: permette di cliccare attraverso la sfumatura */
}

.filter-wrapper::before {
  left: 0;
  background: linear-gradient(to right, #fff, rgba(255,255,255,0));
}

.filter-wrapper::after {
  right: 0;
  background: linear-gradient(to left, #fff, rgba(255,255,255,0));
}
.filter-scroll-container::-webkit-scrollbar {
  display: none; /* Nasconde scrollbar su Chrome/Safari */
}

/* 4. La nav - Cambiato justify-content */
.project-filter-nav {
  display: flex !important;
  flex-wrap: nowrap !important; /* Impedisce l'andata a capo */
  gap: 12px;
  padding: 20px 40px; /* Padding laterale per non far finire i bottoni contro il bordo */
  border-top: 1px solid #eee;
  border-bottom: 1px solid #eee;

  /* FIX PER SCROLL: Se il contenuto è meno largo del monitor, lo centra.
     Se è più largo, permette lo scroll partendo da sinistra. */
  width: max-content;
  margin: 0 auto;
  min-width: 100%;
}

/* 5. I Bottoni */
.filter-btn {
  flex: 0 0 auto !important; /* Impedisce il rimpicciolimento */
  white-space: nowrap !important;
  padding: 10px 24px !important;
  background: #f5f5f5 !important;
  color: #333 !important;
  border-radius: 50px !important;
  font-size: 14px !important;
  font-weight: 600 !important;
  text-decoration: none !important;
}

.filter-btn.active {
  background: #222 !important;
  color: #fff !important;
}

/* 3. GRIGLIA MASONRY */
.progetti-masonry-wrapper {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  grid-auto-rows: 10px; /* Base per il calcolo JS */
  gap: 0 30px;
  align-items: start;
}

.masonry-item {
  grid-row-end: span 30; /* Fallback iniziale */
  margin-bottom: 30px;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

/* Classe aggiunta dallo script JS una volta calcolata l'altezza */
.masonry-item.is-ready {
  opacity: 1;
  transform: translateY(0);
}

/* 4. CARD E CONTENUTI */
.masonry-card-link {
  display: block;
  text-decoration: none !important;
  color: inherit !important;
}

.masonry-media {
  overflow: hidden;
  border-radius: 6px;
}

.masonry-media img {
  width: 100%;
  height: auto;
  display: block;
  transition: transform 0.5s ease;
}

/* Asimmetria forzata ( Pinterest feel ) */
.masonry-item:nth-child(odd) .masonry-media img { aspect-ratio: 1 / 1.2; object-fit: cover; }
.masonry-item:nth-child(even) .masonry-media img { aspect-ratio: 1 / 0.9; object-fit: cover; }

.masonry-card-link:hover .masonry-media img {
  transform: scale(1.05);
}

.masonry-content {
  padding: 20px 0;
}

.m-type {
  display: block;
  font-size: 10px;
  font-weight: 700;
  color: #b19470;
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-bottom: 8px;
}

.m-title {
  font-size: 1.4rem;
  margin: 0 0 10px;
  color: #1a1a1a;
}

.m-excerpt {
  font-size: 0.95rem;
  line-height: 1.6;
  color: #666;
}

/* 5. PAGINAZIONE */
.progetti-pagination {
  margin: 50px 0;
  text-align: center;
}

.progetti-pagination a, .progetti-pagination span {
  padding: 12px 20px;
  border: 1px solid #eee;
  margin: 0 4px;
  text-decoration: none;
  color: #333;
}

.progetti-pagination .current {
  background: #222;
  color: #fff;
}

/* 6. RESPONSIVE MOBILE */
@media (max-width: 768px) {
  .project-filter-nav {
    justify-content: flex-start; /* Permette lo swipe a sinistra */
    padding-left: 20px;
    padding-right: 20px;
  }

  .progetti-masonry-wrapper {
    grid-template-columns: 1fr;
    gap: 0;
  }
}