/* Madagascar Section */
.madagascar-section {
  height: auto;
  min-height: 100vh;
  padding: 40px 5%;
  background: #0B1F3A;
  display: flex;
  justify-content: center;
}

.madagascar-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  max-width: 1200px;
  width: 100%;
  opacity: 0;
  transform: translateX(-50px);
  transition: opacity 1s ease, transform 1s ease;
}

.madagascar-content.visible {
  opacity: 1;
  transform: translateX(0);
}

.madagascar-text {
  flex: 1;
  min-width: 280px;
  margin-right: 20px;
  padding: 20px;
}

.madagascar-text h2 {
  color: #fff;
  font-size: 32px;
  font-weight: bold;
  margin-bottom: 20px;
  line-height: 1.2;
}

.madagascar-stats {
  display: flex;
  gap: 20px;
  font-size: 16px;
  margin-bottom: 20px;
}

.madagascar-btn {
  display: inline-block;
  padding: 10px 20px;
  border: 1px solid #fff;
  text-decoration: none;
  color: #fff;
  font-weight: bold;
  transition: 0.3s;
}

.madagascar-btn:hover {
  background: #000;
  color: #fff;
}

.madagascar-images {
  position: relative;
  flex: 1;
  height: 80vh;
  min-width: 280px;
  overflow: hidden;
}

.carousel-item {
  position: absolute;
  width: 280px;
  height: 60vh; /* Hauteur maximale pour cohérence */
  transition: all 0.5s ease;
}

.carousel-item img {
  width: 100%;
  height: 100%; /* Occupe toute la hauteur du conteneur */
  object-fit: cover;
  border-radius: 8px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
  transition: transform 0.3s, z-index 0.3s, opacity 0.5s;
}

.carousel-text {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 15px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.8), transparent);
  color: #fff;
  font-size: 16px;
  font-weight: bold;
  text-align: center;
  opacity: 0; /* Masqué par défaut */
  transition: opacity 0.3s ease;
}

.carousel-item[style*="z-index: 3"] .carousel-text {
  opacity: 1; /* Visible uniquement pour l'élément au premier plan */
}

/* Masquer les autres textes explicitement */
.carousel-item:not([style*="z-index: 3"]) .carousel-text {
  opacity: 0 !important;
}

/* Positions initiales des images */
.carousel-item:nth-child(1) {
  top: 10vh;
  left: 0;
  z-index: 3;
}

.carousel-item:nth-child(2) {
  top: 15vh;
  left: 140px;
  z-index: 2;
}

.carousel-item:nth-child(3) {
  top: 20vh;
  left: 240px;
  z-index: 1;
}

.carousel-item:nth-child(4) {
  top: 25vh;
  left: 340px;
  z-index: 0;
}

.carousel-item:nth-child(5) {
  top: 30vh;
  left: 440px;
  z-index: -1;
}

.carousel-item[style*="z-index: -1"] {
  top: 30vh !important;
}

.carousel-item[style*="z-index: -1"] img {
  opacity: 0.5 !important;
}

.carousel-item:hover {
  transform: scale(1.05);
  z-index: 5;
}

.carousel-item:hover img {
  opacity: 1;
}

.carousel-item:hover .carousel-text {
  opacity: 1; /* Affiche le texte au survol */
}

/* Pop-up Overlay */
.popup-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  z-index: 1000;
  justify-content: center;
  align-items: center;
}

.popup-content {
  position: relative;
  background: #fff;
  border-radius: 10px;
  width: 90%;
  max-width: 800px;
  padding: 20px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.popup-close {
  position: absolute;
  top: 10px;
  right: 10px;
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: #333;
}

.popup-card {
  position: relative;
  min-height: 200px;
}

.popup-item {
  display: none;
  flex-direction: row;
  gap: 20px;
  align-items: center;
}

.popup-item.active {
  display: flex;
}

.popup-image img {
  width: 280px;
  height: 280px;
  object-fit: cover;
  border-radius: 8px;
}

.popup-text {
  flex: 1;
}

.popup-text h3 {
  margin-top: 0;
  font-size: 20px;
  color: #333;
}

.popup-text p {
  margin: 10px 0;
  font-size: 14px;
  color: #666;
}

.popup-indicators {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 20px;
}

.indicator {
  width: 10px;
  height: 10px;
  background: #ccc;
  border-radius: 50%;
  cursor: pointer;
  transition: background 0.3s ease;
}

.indicator.active {
  background: #007bff;
}

/* Responsive : Mobile (max-width: 768px) */
@media (max-width: 768px) {

  .madagascar-section {
      padding: 10px 3%;
      height: auto;
      min-height: 45vh;
  }

  .madagascar-content {
      flex-direction: column;
      gap: 20px;
      /* max-width: 600px; */
      width: 100%;
  }

  .madagascar-text {
      margin-right: 0;
      text-align: center;
      padding: 10px;
      width: 100%;
  }

  .madagascar-text h2 {
      font-size: 24px;
      margin-bottom: 15px;
  }

  .madagascar-stats {
      flex-direction: column;
      gap: 10px;
      font-size: 14px;
      margin-bottom: 15px;
  }

  .madagascar-btn {
      padding: 8px 16px;
      font-size: 14px;
  }

  .madagascar-images {
      position: static;
      height: auto;
      display: flex;
      flex-wrap: nowrap;
      overflow-x: auto;
      gap: 10px;
      width: 100%;
      justify-content: flex-start;
      padding: 10px 0;
  }

  .madagascar-images::-webkit-scrollbar {
      display: none;
  }

  .carousel-item {
      position: relative; /* Changé à relative pour ancrer .carousel-text */
      width: 160px;
      height: 200px; /* Hauteur fixe */
      flex-shrink: 0;
  }

  .carousel-item img {
      width: 100%;
      height: 100%;
      border-radius: 8px;
      transform: none !important;
      opacity: 1;
  }

  .carousel-text {
      font-size: 12px;
      padding: 8px;
      opacity: 1; /* Visible pour toutes les images sur mobile */
      background: linear-gradient(to top, rgba(0, 0, 0, 0.8), transparent);
  }

  .carousel-item[style*="z-index"] .carousel-text {
      opacity: 1; /* Pas nécessaire, mais conservé pour compatibilité */
  }

  .popup-content {
      width: 95%;
      padding: 15px;
  }

  .popup-item {
      flex-direction: column;
      text-align: center;
      gap: 10px;
  }

  .popup-image img {
      width: 140px;
      height: 140px;
  }

  .popup-text h3 {
      font-size: 16px;
  }

  .popup-text p {
      font-size: 12px;
  }

  .indicator {
      width: 8px;
      height: 8px;
  }
}

/* Responsive : Tablette (max-width: 1024px) */
/* Responsive : Tablette (max-width: 1024px) */
@media (max-width: 1024px) and (min-width: 769px) {
  .madagascar-section {
    padding: 30px 4%;
    min-height: 45vh;
  }

  .madagascar-content {
    flex-direction: row; /* Rétablir la disposition en ligne pour tablette */
    flex-wrap: wrap;
    gap: 20px;
    align-items: center; /* Aligner en haut pour éviter les décalages */
    justify-content: center;
  }

  .madagascar-text {
    flex: 1;
    margin-right: 20px;
    text-align: left; /* Texte aligné à gauche pour meilleure lisibilité */
    padding: 15px;
    min-width: 300px;
    max-width: 500px;
  }

  .madagascar-text h2 {
    font-size: 28px;
  }

  .madagascar-stats {
    gap: 15px;
    font-size: 16px;
    flex-wrap: wrap; /* Permet aux stats de s'adapter si nécessaire */
  }

  .madagascar-images {
    flex: 1;
    height: 60vh; /* Hauteur cohérente */
    min-width: 300px;
    max-width: 500px;
    position: relative; /* Retour à relative pour le carrousel */
    overflow: hidden; /* Masquer tout débordement */
  }

  .carousel-item {
    position: absolute; /* Repositionnement absolu pour l'effet carrousel */
    width: 280px; /* Taille fixe pour uniformité */
    height: 50vh; /* Hauteur ajustée pour cohérence */
    transition: all 0.5s ease;
  }

  .carousel-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 8px;
    opacity: 1;
  }

  .carousel-text {
    font-size: 14px;
    padding: 10px;
    opacity: 0; /* Masqué par défaut, comme en mode desktop */
    background: linear-gradient(to top, rgba(0, 0, 0, 0.8), transparent);
    transition: opacity 0.3s ease;
  }

  /* Afficher le texte uniquement pour l'élément au premier plan */
  .carousel-item[style*="z-index: 3"] .carousel-text {
    opacity: 1;
  }

  /* Positions initiales des images (comme en desktop) */
  .carousel-item:nth-child(1) {
    top: 5vh;
    left: 0;
    z-index: 3;
  }

  .carousel-item:nth-child(2) {
    top: 10vh;
    left: 140px;
    z-index: 2;
  }

  .carousel-item:nth-child(3) {
    top: 15vh;
    left: 240px;
    z-index: 1;
  }

  .carousel-item:nth-child(4) {
    top: 20vh;
    left: 340px;
    z-index: 0;
  }

  .carousel-item:nth-child(5) {
    top: 25vh;
    left: 440px;
    z-index: -1;
  }

  .carousel-item[style*="z-index: -1"] {
    top: 25vh !important;
    opacity: 0.5;
  }

  .popup-content {
    max-width: 600px;
  }

  .popup-image img {
    width: 200px;
    height: 200px;
  }
}