/* STILE HERO SECTION */

.hero-section {
  position: relative;
  width: 100%;
  height: 100vh;
  overflow: hidden;
}

.hero-background {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: none;
}

.hero-background::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5); /* Regola l'opacity come preferisci */
  z-index: 2;
}

.hero-background iframe,
.hero-background video {
  position: absolute;
  top: 50%;
  left: 50%;
  min-width: 100%;
  min-height: 100%;
  width: auto;
  height: auto;
  transform: translate(-50%, -50%);
  object-fit: cover;
}

.hero-content {
  display: flex;
  flex-direction: row;
  align-items: flex-end;
}

.hero-content p {
  width: 30% !important;
}

/* Responsive Adjustments */
@media (max-width: 768px) {
  .hero-content {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
  }

  .hero-content p {
    width: 100% !important;
  }
}

/* STILE CHI SIAMO SECTION */
.card {
  border-radius: none !important;
  border-radius: 0 !important;
}
.contenitore-card {
  padding: 30px;
}

.valori-section {
  justify-content: center !important;
}

.valori-section .card {
  width: 370px;
  height: 370px;
  border: none;
  background-color: var(--bs-primary);
  border-radius: none !important;
}

.valori-section .card-icon {
  width: 105.168px;
  height: 105.168px;
  background-color: var(--bs-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
}

.valori-section .card-icon img {
  max-width: 60%;
  max-height: 60%;
}

/* ==============================
   GRUPPO ACCORDION
   ============================== */

.gruppo-accordion {
  display: flex;
  flex-wrap: nowrap;
  width: 100%;
  height: 580px;
  overflow: hidden;
  margin-bottom: 50px !important;
}

/* Wrapper per gestire i bordi (fix doppie linee) */
.servizio-wrapper {
  display: flex;
  border: 1px solid var(--bs-neutral);
  border-left: none; /* Evita doppio bordo tra i blocchi */
}

/* Mantiene bordo sinistro solo sul primo */
.gruppo-accordion .servizio-wrapper:first-child {
  border-left: 1px solid var(--bs-neutral);
}

/* ==============================
   TAB SERVIZIO
   ============================== */

.servizio-tab {
  width: 140px;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  cursor: pointer;
  padding: 1rem 0.5rem;
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
  padding-bottom: 118px; /* spazio per il quadrato */
  background-color: white;
  transition: all 0.3s ease-in-out;
}

/* Numero e titolo */
.numero {
  padding-top: 30px;
  writing-mode: horizontal-tb;
  font-weight: 400 !important;
  font-size: 30px;
  margin-bottom: 1rem;
  transition: color 0.3s ease-in-out;
}

.titolo-vertical {
  writing-mode: vertical-rl;
  letter-spacing: normal !important;
  transform: rotate(180deg);
  font-size: 30px !important;
  text-align: start;
  transition: margin-bottom 0.3s ease-in-out, color 0.3s ease-in-out;
  text-transform: none !important;
  font-weight: 400 !important;
  max-height: 60% !important;
  word-wrap: break-word; /* Permette di spezzare le parole */
  overflow-wrap: break-word; /* Fallback per browser più vecchi */
  white-space: normal; /* Permette l'a capo */
  line-height: 1.2; /* Spaziatura tra le righe quando va a capo */
}

.servizio-tab.active .titolo-vertical {
  margin-bottom: 130px;
}

/* Quadrato fondo tab attiva */
.servizio-tab.active::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 118px;
  background-color: var(--bs-primary);
  z-index: 0;
  transition: transform 0.3s ease-in-out;
  transform-origin: bottom;
  transform: scaleY(1);
}

/* Variante secondaria */
.gruppo-accordion-2 .servizio-tab.active::after {
  background-color: var(--bs-secondary);
}

.servizio-tab.active .numero {
  color: var(--bs-primary);
}

.servizio-tab.active .titolo-vertical {
  color: var(--bs-primary);
}

/* Mantiene testo sopra il quadrato */
.servizio-tab * {
  position: relative;
  z-index: 2;
}

/* ==============================
   CONTENUTO
   ============================== */
.servizio-content {
  display: none;
  width: 458px;
  height: 100%;
  padding: 1.5rem;
  overflow-y: auto;
  flex-shrink: 0;
  background-color: white;
  opacity: 0;
  transform: translateX(-20px);
  transition: opacity 0.9s cubic-bezier(0.25, 0.46, 0.45, 0.94),
    transform 0.9s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  padding: 40px !important;
}

.servizio-content.active {
  display: block;
  opacity: 1;
  transform: translateX(0);
  border-left: 1px solid var(--bs-neutral) !important;
}

/* ==============================
   TABLET - ACCORDION IN COLONNA
   ============================== */
@media (min-width: 768px) and (max-width: 1199px) {
  /* Override delle classi Bootstrap per forzare layout in colonna su tablet */
  .hero-content p {
    width: 100% !important;
  }

  .gruppo-accordion {
    height: auto !important;
    flex-direction: column !important;
    width: 100%;
    max-width: 100%;
    overflow: visible;
  }

  .servizio-wrapper {
    flex-direction: column !important;
    width: 100%;
    border: 1px solid var(--bs-neutral);
    border-top: none;
    box-sizing: border-box;
    margin-bottom: 0;
  }

  .gruppo-accordion .servizio-wrapper:first-child {
    border-top: 1px solid var(--bs-neutral);
  }

  /* Tab tablet - layout orizzontale - override Bootstrap */
  .servizio-tab {
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    flex-direction: row !important;
    justify-content: flex-start !important;
    align-items: center !important;
    padding: 20px 15px !important;
    padding-bottom: 20px !important;
    min-height: 60px;
    box-sizing: border-box;
    flex-shrink: 1;
  }

  /* Quadrato piccolo tablet */
  .servizio-tab.active::after {
    width: 16px;
    height: 16px;
    top: 50%;
    left: 15px;
    bottom: auto;
    transform: translateY(-50%);
    border-radius: 2px;
  }

  /* Numero a destra del quadrato */
  .numero {
    margin-left: 40px !important;
    margin-right: 15px !important;
    margin-bottom: 0 !important;
    padding-top: 0 !important;
    writing-mode: horizontal-tb !important;
    font-size: 1rem !important;
    flex-shrink: 0;
    font-weight: bold !important;
  }

  /* Titolo orizzontale - override Bootstrap */
  .titolo-vertical {
    writing-mode: horizontal-tb !important;
    transform: none !important;
    margin-left: 0 !important;
    margin-bottom: 0 !important;
    font-size: 20px !important;
    flex: 1;
    text-align: left;
    font-weight: bold !important;
  }

  /* Contenuto tablet */
  .servizio-content {
    width: 100% !important;
    max-width: 100% !important;
    padding: 20px !important;
    border-left: none !important;
    border-top: 1px solid var(--bs-neutral);
    box-sizing: border-box !important;
    overflow-x: hidden !important;
    word-wrap: break-word;
    transform: translateX(0) !important;
  }

  .servizio-content.active {
    border-left: none !important;
  }
}

/* ==============================
   MOBILE - OTTIMIZZATO
   ============================== */
@media (max-width: 767px) {
  .gruppo-accordion {
    height: auto;
    flex-direction: column;
    width: 100%;
    max-width: 100%;
    overflow: visible;
  }

  /* Wrapper - tutto attaccato senza gap */
  .servizio-wrapper {
    flex-direction: column;
    width: 100%;
    border: 1px solid var(--bs-neutral);
    border-top: none;
    box-sizing: border-box;
    margin-bottom: 0;
  }

  /* Primo wrapper con bordo top */
  .gruppo-accordion .servizio-wrapper:first-child {
    border-top: 1px solid var(--bs-neutral);
  }

  /* Tab mobile - LARGHEZZA RESPONSIVE */
  .servizio-tab {
    width: 100% !important; /* ✅ Larghezza fluida su mobile */
    max-width: 100% !important;
    height: auto !important;
    flex-direction: row !important;
    justify-content: flex-start !important;
    align-items: center !important;
    padding: 20px 15px !important;
    padding-bottom: 20px !important;
    min-height: 60px;
    box-sizing: border-box;
    flex-shrink: 1; /* ✅ Può ridursi se necessario */
  }

  /* Quadrato piccolo mobile */
  .servizio-tab.active::after {
    width: 16px;
    height: 16px;
    top: 50%;
    left: 15px;
    bottom: auto;
    transform: translateY(-50%);
    border-radius: 2px;
  }

  /* Numero a destra del quadrato */
  .numero {
    margin-left: 40px !important;
    margin-bottom: 0 !important;
    padding-top: 0 !important;
    writing-mode: horizontal-tb !important;
    font-size: 1rem !important;
    flex-shrink: 0; /* ✅ Non si comprime */
    font-weight: bold !important;
  }

  /* Titolo orizzontale */
  .titolo-vertical {
    writing-mode: horizontal-tb !important;
    transform: none !important;
    margin-left: 15px !important;
    margin-bottom: 0 !important;
    font-size: 20px !important;
    flex: 1; /* ✅ Prende lo spazio rimanente */
    text-align: left;
    font-weight: bold !important;
  }

  /* Contenuto mobile */
  .servizio-content {
    width: 100% !important;
    max-width: 100% !important;
    padding: 20px !important;
    border-left: none !important;
    border-top: 1px solid var(--bs-neutral);
    box-sizing: border-box !important;
    overflow-x: hidden !important;
    word-wrap: break-word;
    transform: translateX(0) !important; /* ✅ Nessuno spostamento */
  }

  .servizio-content.active {
    border-left: none !important;
  }
}

/* SEZIONE PROGETTI */

.mosaico-container {
  display: flex;
  gap: 0;
  width: 100%;
  height: fit-content;
  min-height: 600px;
}

/* Spazio tra i container */
.mosaico-container + .mosaico-container {
  margin-top: 2rem;
  min-height: auto;
}

.mosaico-column {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: fit-content;
}

.progetto-card {
  overflow: hidden;
  cursor: pointer;
  width: 100%;
  margin: 0;
  padding: 0;
  line-height: 0;
  flex-shrink: 0;
  position: relative;
}

.progetto-card img {
  transition: transform 0.3s ease;
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transform: scale(1.01);
}

.progetto-card:hover img {
  transform: scale(1.05);
}

.progetto-overlay {
  background-color: rgba(0, 0, 0, 0.7);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.progetto-card:hover .progetto-overlay {
  opacity: 1;
}

/* Quadrato colorato animato */
.quadrato-colorato {
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  opacity: 0;
  transition: all 0.4s ease;
  z-index: 1;
}

.progetto-card:hover .quadrato-colorato {
  width: 80px;
  height: 80px;
  opacity: 1;
}

/* Titolo sopra il quadrato */
.progetto-overlay h4 {
  z-index: 2;
}

.quadrato-mobile {
  display: none;
}

/* ========================================
   RESPONSIVE
   ======================================== */

/* Mobile - Hover sempre attivo */
@media (max-width: 768px) {
  .quadrato-desktop {
    display: none;
  }

  .quadrato-mobile {
    display: block;
    width: 50px !important;
    height: 50px !important;
    opacity: 1 !important;
  }

  .mosaico-container {
    flex-direction: column;
    height: auto;
    min-height: auto;
  }

  .paragrafo-progetti {
    width: 100% !important;
  }

  .mosaico-column {
    height: auto;
  }

  .progetto-card {
    height: 300px !important;
  }

  /* Immagine non scala su mobile */
  .progetto-card img,
  .progetto-card:hover img {
    transform: scale(1.01);
  }

  .progetto-overlay {
    opacity: 0;
    transition: opacity 0.3s ease;
  }

  .progetto-card.mobile-overlay-active .progetto-overlay {
    opacity: 1;
  }

  .progetto-card.mobile-overlay-active .quadrato-colorato {
    width: 50px;
    height: 50px;
    opacity: 1;
  }
}

/* Tablet */
@media (min-width: 769px) and (max-width: 1200px) {
  .mosaico-container {
    min-height: 500px;
  }

  .mosaico-container + .mosaico-container {
    min-height: auto;
  }

  .progetto-card:hover .quadrato-colorato {
    width: 70px;
    height: 70px;
  }
}

/* Desktop medio */
@media (min-width: 1200px) and (max-width: 1440px) {
  .mosaico-container {
    min-height: 550px;
  }

  .mosaico-container + .mosaico-container {
    min-height: auto;
  }
}

/* Desktop grande */
@media (min-width: 1441px) {
  .mosaico-container {
    min-height: 600px;
  }

  .mosaico-container + .mosaico-container {
    min-height: auto;
  }
}

/* SEZIONE PARTNER */
.logos-wrapper-container {
  width: 100%;
}

.logos-wrapper {
  display: flex;
  justify-content: start !important;
  align-items: stretch;
  flex-wrap: wrap;
  width: 100%;
  position: relative; /* Aggiunto per gestire i bordi */
}

.logo-flip-box {
  box-sizing: border-box;
  border: 1px solid #000;
  background: #fff;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  padding: 20px 0 !important;
  position: relative; /* Aggiunto per gestire i bordi */
  z-index: 1; /* Assicura che i box siano sopra i bordi */
}

.logo-face {
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 10px;
  box-sizing: border-box;
}

.logo-img {
  max-width: 80%;
  width: auto;
  height: auto;
  object-fit: contain;
  max-height: 90% !important;
}

.logo-flip-inner {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  --pause-start: 75%;
}

.logo-flip-inner.has-multiple {
  animation: flipLogosCycleWithPause cubic-bezier(0.2, 0, 0.2, 1) infinite;
}

/* Face rotations */
.logo-face-0 { transform: rotateX(0deg); }
.logo-face-1 { transform: rotateX(180deg); }
.logo-face-2 { transform: rotateX(360deg); }
.logo-face-3 { transform: rotateX(540deg); }
.logo-face-4 { transform: rotateX(720deg); }
.logo-face-5 { transform: rotateX(900deg); }

@keyframes flipLogosCycleWithPause {
  0% {
    transform: rotateX(0deg);
  }
  75% {
    transform: rotateX(360deg);
  }
  100% {
    transform: rotateX(360deg);
  }
}

/* Desktop (default) */
.logo-flip-box {
  width: 20%;
  height: 140px;
}

/* Rimuove bordi duplicati */
.logo-flip-box {
  border-left: none;
  border-top: none;
}

/* Aggiunge bordi per la prima colonna e prima riga */
.logo-flip-box:nth-child(5n + 1) {
  border-left: 1px solid #000;
}

.logo-flip-box:nth-child(-n + 5) {
  border-top: 1px solid #000;
}

/* Tablet */
@media (min-width: 769px) and (max-width: 1200px) {
  .logos-wrapper {
    flex-direction: column; /* Imposta layout a colonna */
    align-items: stretch;
  }

  .logo-flip-box {
    width: 100%;  /* Larghezza intera */
    height: 150px; /* Aumenta l'altezza */
  }

  .logo-img {
    max-width: 70%; /* Leggermente più grande */
    max-height: 80% !important;
  }

  /* Rimuove bordi duplicati */
  .logo-flip-box {
    border-left: 1px solid #000;
    border-top: none;
    margin-top: -1px; /* Elimina sovrapposizione */
  }

  /* Aggiunge bordo top al primo elemento */
  .logo-flip-box:first-child {
    border-top: 1px solid #000;
    margin-top: 0;
  }
}

/* Mobile */
@media (max-width: 768px) {
  .logos-wrapper {
    flex-direction: column; /* Imposta layout a colonna */
    align-items: stretch;
  }

  .logo-flip-box {
    width: 100%;  /* Larghezza intera */
    height: 180px; /* Aumenta l'altezza */
  }

  .logo-img {
    max-width: 70%; /* Leggermente più grande */
    max-height: 80% !important;
  }

  /* Rimuove bordi duplicati */
  .logo-flip-box {
    border-left: 1px solid #000;
    border-top: none;
    margin-top: -1px; /* Elimina sovrapposizione */
  }

  /* Aggiunge bordo top al primo elemento */
  .logo-flip-box:first-child {
    border-top: 1px solid #000;
    margin-top: 0;
  }
}


/* SEZIONE COLLABORA */
.cta-section {
  width: 100%;
  border-left: none !important;
  border-right: none !important;
}

.cta-container {
  width: 100%;
  padding: 0;
}

/* CTA attaccati tra loro */
.contenitore-interno {
  border: 1px solid var(--bs-neutral);
}
.cta-section .d-flex {
  gap: 0 !important;
}

.contenitore-interno .cta-primary {
  border-right: none !important;
}

/* Responsive */
@media (max-width: 768px) {
  .cta-section {
    padding: 15px 0;
  }

  .cta-section .d-flex {
    flex-direction: column;
    align-items: stretch;
  }
}

@media (min-width: 1900px) {
  .valori-section .card {
    width: 370px !important;
    height: 370px !important;
    border: none;
    background-color: var(--bs-primary);
    border-radius: none !important;
  }
}
