/* 
   Perla Nera - Portfolio CSS
   CSS dedicato per la pagina "I Nostri Lavori"
   Aprile 2025
*/

:root {
    --gold: #d4af37;
    --dark-gold: #b08f26;
    --black: #171717;
    --dark-gray: #333;
    --medium-gray: #777;
    --light-gray: #f5f5f5;
    --white: #ffffff;
    --transition: all 0.3s ease;
}

/* ========== HERO SEZIONE PORTFOLIO ========== */
.hero-portfolio {
    height: 60vh;
    position: relative;
    overflow: hidden;
    background-color: var(--black);
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    margin-bottom: 4rem;
}

.hero-portfolio::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('images/portfolio-hero.jpg');
    background-size: cover;
    background-position: center;
    opacity: 0.4;
    z-index: 1;
}

.hero-content {
    position: relative;
    z-index: 2;
    max-width: 800px;
    padding: 0 20px;
}

.hero-portfolio h1 {
    font-size: 3.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--gold);
}

.hero-portfolio p {
    font-size: 1.2rem;
    max-width: 600px;
    margin: 0 auto;
}

.hero-portfolio .hero-overlay {
    background: linear-gradient(to top, var(--black) 5%, transparent 100%);
    opacity: 0.8;
}

.hero-portfolio:after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 5px;
    background: linear-gradient(90deg, transparent, var(--gold), transparent);
}

.hero-portfolio .subtitle {
    color: var(--gold-light);
    font-size: clamp(1.1rem, 3vw, 1.3rem);
    font-weight: 300;
    margin-top: 15px;
}

/* ========== INTRO SEZIONE ========== */
.portfolio-intro {
    text-align: center;
    max-width: 800px;
    margin: 0 auto 50px;
    padding: 0 20px;
}

.portfolio-tagline {
    color: var(--gold-light);
    font-family: 'Playfair Display', serif;
    font-style: italic;
    font-size: 1.2rem;
    margin-bottom: 20px;
  font-family: 'Playfair Display', serif;
  font-style: italic;
  font-size: 1.2rem;
  margin-bottom: 20px;
}

/* ========== SISTEMA DI FILTRI ========== */
.filter-container {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 15px;
  margin: 0 auto 50px;
  max-width: 900px;
  padding: 0 20px;
}

.filter-btn {
  padding: 10px 22px;
  background: rgba(203, 161, 53, 0.05);
  color: var(--gold-light);
  border: 1px solid rgba(203, 161, 53, 0.2);
  border-radius: 30px;
  font-family: 'Poppins', sans-serif;
  font-weight: 400;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.filter-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent);
  transition: left 0.6s ease;
}

.filter-btn:hover::before {
  left: 100%;
}

.filter-btn:hover, .filter-btn:focus {
  background: rgba(203, 161, 53, 0.15);
  transform: translateY(-3px);
  box-shadow: 0 4px 10px rgba(0,0,0,0.2);
  outline: none;
}

.filter-btn.active {
  background: var(--gold);
  color: var(--black);
  font-weight: 500;
  box-shadow: 0 5px 15px rgba(203, 161, 53, 0.3);
}

/* ========== GRIGLIA PROGETTI ========== */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
  gap: 50px;
  margin: 0 auto;
  padding: 0 20px;
  max-width: 1400px;
}

.gallery-item {
  position: relative;
  overflow: hidden;
  border-radius: 5px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  display: flex;
  flex-direction: column;
  background-color: white;
}

.gallery-item:hover {
  transform: translateY(-5px);
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.15);
}

.gallery-category {
  position: absolute;
  top: 15px;
  left: 15px;
  background-color: var(--gold);
  color: var(--black);
  padding: 5px 12px;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: 3px;
  z-index: 10;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.gallery-content {
  padding: 20px;
}

.gallery-title {
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 10px;
  color: var(--black);
}

.gallery-desc {
  font-size: 0.95rem;
  color: var(--medium-gray);
  line-height: 1.5;
}

/* Before-After Container */
.ba-container {
  position: relative;
  width: 100%;
  height: 350px;
  overflow: hidden;
  cursor: col-resize;
  border-radius: 6px 6px 0 0;
  box-shadow: 0 0 15px rgba(0, 0, 0, 0.2);
  user-select: none; /* Impedisce la selezione del testo durante il drag */
  touch-action: none; /* Migliora il supporto mobile */
}

.img-before,
.img-after {
  position: absolute;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  top: 0;
  margin: 0;
  max-width: none;
  pointer-events: none; /* Impedisce problemi con eventi touch/mouse */
}

.img-before {
  left: 0;
  clip-path: polygon(0 0, 50% 0, 50% 100%, 0 100%);
  z-index: 1;
}

.img-after {
  right: 0;
  clip-path: polygon(50% 0, 100% 0, 100% 100%, 50% 100%);
  z-index: 2;
}

.slider-handle {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 3px;
  background: var(--gold);
  transform: translateX(-50%);
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease; /* Smooth color transition */
}

.ba-container.active .slider-handle {
  background: var(--dark-gold); /* Cambia colore durante il trascinamento */
}

.slider-handle::before {
  content: "";
  height: 40px;
  width: 40px;
  background: var(--gold);
  border-radius: 50%;
  border: 3px solid white;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
  transition: all 0.2s ease;
}

.ba-container.active .slider-handle::before {
  transform: scale(1.1); /* Leggermente più grande durante trascinamento */
  background: var(--dark-gold);
}

.ba-container::before,
.ba-container::after {
  position: absolute;
  top: 15px;
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  z-index: 4;
  opacity: 0.9;
  transition: opacity 0.3s ease;
}

.ba-container::before {
  content: "Prima";
  left: 15px;
  background: var(--black);
  color: var(--gold);
  border: 1px solid var(--gold);
}

.ba-container::after {
  content: "Dopo";
  right: 15px;
  background: var(--gold);
  color: var(--black);
}

.ba-container:hover::before,
.ba-container:hover::after {
  opacity: 1;
}

/* Migliorie per dispositivi mobili */
@media (max-width: 768px) {
  .ba-container {
    height: 250px;
  }
  
  .slider-handle::before {
    height: 32px;
    width: 32px;
  }
  
  .ba-container::before,
  .ba-container::after {
    padding: 4px 8px;
    font-size: 10px;
  }
}

@media (max-width: 480px) {
  .ba-container {
    height: 200px;
  }
  
  .slider-handle::before {
    height: 28px;
    width: 28px;
  }
}

/* Immagine before/after */
.ba-container {
  position: relative;
  width: 100%;
  height: 0;
  padding-bottom: 75%; /* Aspect ratio 4:3 */
  overflow: hidden;
}

.img-before, .img-after {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.7s cubic-bezier(0.33, 1, 0.68, 1);
}

.img-after {
  clip-path: polygon(50% 0, 100% 0, 100% 100%, 50% 100%);
}

.slider-handle {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 4px;
  background: var(--gold);
  transform: translateX(-50%);
  z-index: 10;
  pointer-events: none;
}

.slider-handle:after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 40px;
  height: 40px;
  background: var(--gold);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 10px rgba(0,0,0,0.5);
}

.slider-handle:before {
  content: '↔';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: var(--black);
  font-size: 1.2rem;
  font-weight: bold;
  z-index: 11;
}

.gallery-item:hover .img-before,
.gallery-item:hover .img-after {
  transform: scale(1.05);
}

/* Contenuti della gallery */
.gallery-content {
  padding: 20px;
  background-color: rgba(11, 11, 11, 0.9);
  border-top: 1px solid rgba(203, 161, 53, 0.2);
}

.gallery-title {
  color: var(--gold);
  font-size: 1.3rem;
  margin: 0 0 10px;
  font-family: 'Playfair Display', serif;
}

.gallery-desc {
  color: rgba(255,255,255,0.9);
  font-size: 0.9rem;
  margin: 0;
  line-height: 1.4;
  font-family: 'Poppins', sans-serif;
  font-weight: 300;
}

/* Category badge */
.gallery-category {
  position: absolute;
  top: 15px;
  right: 15px;
  background-color: rgba(11, 11, 11, 0.8);
  color: var(--gold);
  font-size: 0.8rem;
  padding: 6px 12px;
  border-radius: 20px;
  z-index: 10;
  font-family: 'Poppins', sans-serif;
  font-weight: 400;
  border: 1px solid rgba(203, 161, 53, 0.3);
  box-shadow: 0 3px 10px rgba(0,0,0,0.2);
  transition: all 0.3s ease;
}

.gallery-item:hover .gallery-category {
  background-color: var(--gold);
  color: var(--black);
}

/* ========== SEPARATORE VISIVO ========== */
.section-separator {
  position: relative;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(203, 161, 53, 0.2), transparent);
  margin: 80px auto;
  width: 80%;
}

.section-separator::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 10px;
  height: 10px;
  background-color: var(--gold);
  border-radius: 50%;
}

/* ========== CTA SECTION ========== */
.portfolio-cta {
  text-align: center;
  margin: 60px auto;
  max-width: 800px;
  padding: 0 20px;
}

.portfolio-cta h3 {
  font-size: 1.8rem;
  margin-bottom: 25px;
}

.portfolio-cta p {
  margin-bottom: 30px;
  font-size: 1.1rem;
}

.cta-button {
  display: inline-block;
  padding: 15px 35px;
  background: var(--gold);
  color: var(--black);
  font-weight: 500;
  border-radius: 3px;
  overflow: hidden;
  transition: all 0.4s ease;
  box-shadow: 0 5px 15px rgba(0,0,0,0.2);
  font-family: 'Poppins', sans-serif;
  text-decoration: none;
  position: relative;
}

.cta-button:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 25px rgba(0,0,0,0.3);
}

.cta-button::after {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
  transition: left 0.7s ease;
}

.cta-button:hover::after {
  left: 100%;
}

/* ========== MEDIA QUERIES ========== */
@media (max-width: 992px) {
  .gallery-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .hero-portfolio {
    height: 50vh;
  }
  
  .page-section {
    padding: 60px 0;
  }
  
  .filter-container {
    gap: 10px;
  }
  
  .filter-btn {
    font-size: 0.9rem;
    padding: 8px 18px;
  }
  
  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 25px;
  }
  
  .gallery-title {
    font-size: 1.2rem;
  }
  
  .gallery-desc {
    font-size: 0.85rem;
  }
}

@media (max-width: 576px) {
  .hero-portfolio {
    height: 40vh;
  }
  
  .filter-container {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
  
  .filter-btn {
    width: 100%;
    text-align: center;
    font-size: 0.85rem;
    padding: 10px;
  }
  
  .gallery-grid {
    grid-template-columns: 1fr;
    max-width: 450px;
    margin-left: auto;
    margin-right: auto;
  }
  
  .portfolio-cta h3 {
    font-size: 1.5rem;
  }
  
  .portfolio-cta p {
    font-size: 1rem;
  }
}
