/* Reset box-sizing pour tout le site */
*, *::before, *::after {
  box-sizing: border-box;
}

body {
  font-family: 'Poppins', sans-serif;
  background: linear-gradient(
    to bottom,
    #ffffff 0%,
    #ffeeaa 10%,
    #ffeeaa 90%,
    #ffffff 100%
  );
  color: #222;
  margin: 0;
  padding: 0;
}
/* ----------- MAIN ----------- */
.maths-main {
  max-width: 1300px;
  margin: 0 auto;
  padding: 40px 0 40px 0;
}
.maths-main h1 {
  text-align: center;
  font-size: 2.8rem;
  font-weight: 700;
  margin-top: 18px;
  margin-bottom: 12px;
  letter-spacing: 0.5px;
  background: black;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-shadow: 0 2px 4px rgba(141, 141, 141, 0.3);
}

.maths-subtitle {
  text-align: center;
  font-size: 1.25rem;
  color: #555;
  margin-bottom: 38px;
  font-weight: 500;
  max-width: 800px;
  margin-left: auto;
  margin-right: auto;
  line-height: 1.4;
}

/* Grid des cours */
.cours-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 2fr));
  gap: 30px;
  margin-top: 40px;
  padding: 0 20px;
}

/* Cartes individuelles - hauteur uniforme */
.cours-card {
  background: linear-gradient(145deg, hsl(46, 100%, 89%), #fff8cf);
  border-radius: 16px;
  padding: 25px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  transition: all 0.4s cubic-bezier(0.23, 1, 0.32, 1);
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.2);
  display: flex;
  flex-direction: column;
  min-height: 200px; /* Hauteur minimum */
  height: auto; /* Hauteur automatique pour l'accordéon */
}

/* Conteneur de la barre de progression */
.progress-container {
  margin-bottom: 15px;
  position: relative;
  z-index: 2;
}

/* Barre de progression complète */
.progress-bar {
  width: 100%;
  height: 12px;
  background: rgba(255, 255, 255, 0.7);
  border-radius: 15px;
  overflow: hidden;
  box-shadow: 
    inset 0 2px 4px rgba(0, 0, 0, 0.1),
    0 1px 3px rgba(0, 0, 0, 0.1);
  position: relative;
}

/* Remplissage de la barre */
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #ff7b00, #ff9500, #ffab00);
  border-radius: 15px;
  width: 0%;
  transition: width 1.5s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

/* Animation de brillance sur la barre */
.progress-fill::after {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.4),
    transparent
  );
  animation: progressShine 2s ease-in-out infinite;
}

/* Affichage du pourcentage au centre de la barre */
.progress-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 0.75rem;
  font-weight: 700;
  color: #333;
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.8);
  z-index: 3;
  pointer-events: none;
}

@keyframes progressShine {
  0% { left: -100%; }
  50% { left: 100%; }
  100% { left: 100%; }
}

.cours-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg, 
    transparent, 
    rgba(255, 255, 255, 0.3), 
    transparent
  );
  transition: left 0.6s ease;
  z-index: 1;
}

.cours-card:hover::before {
  left: 100%;
}

.cours-card:hover {
  transform: translateY(-8px) scale(1.02);
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.15);
  border-color: rgba(255, 123, 0, 0.3);
}

/* Header de la carte */
.cours-card-header {
  display: flex;
  align-items: center;
  gap: 15px;
  margin-bottom: 15px;
  position: relative;
  z-index: 2;
  flex-shrink: 0;
  min-height: 60px; /* Hauteur minimum pour éviter les variations */
  cursor: pointer;
  user-select: none;
}

/* Flèche de déroulement */
.cours-card-arrow {
  margin-left: auto;
  font-size: 1.2rem;
  color: #ff7b00;
  transition: transform 0.3s ease;
  font-weight: bold;
}

.cours-card-arrow.expanded {
  transform: rotate(180deg);
}

.cours-icon {
  font-size: 2.5rem;
  font-weight: bold;
  color: #ff7b00;
  text-shadow: 0 2px 4px rgba(255, 123, 0, 0.3);
  transition: transform 0.3s ease;
  flex-shrink: 0;
}

.cours-card:hover .cours-icon {
  transform: scale(1.1) rotate(5deg);
}

.cours-card-titre {
  font-size: 1.3rem;
  font-weight: 700;
  color: #2c3e50;
  margin: 0;
  line-height: 1.2;
  word-wrap: break-word;
  overflow-wrap: break-word;
  hyphens: auto;
  flex: 1;
}

/* Description - prend l'espace disponible */
.cours-card-desc {
  color: #666;
  font-size: 0.95rem;
  line-height: 1.4;
  margin-bottom: 20px;
  position: relative;
  z-index: 2;
  flex-grow: 1; /* Prend tout l'espace disponible */
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.cours-card-desc.expanded {
  max-height: 200px; /* Hauteur max quand déroulé */
  opacity: 1;
  margin-bottom: 20px;
}

/* Actions - toujours en bas */
.cours-card-actions {
  display: flex;
  gap: 12px;
  position: relative;
  z-index: 2;
  margin-top: auto; /* Pousse les boutons vers le bas */
  flex-shrink: 0;
}

.btn-cours {
  flex: 1;
  padding: 12px 16px;
  background: linear-gradient(135deg, #ff7b00, #ff9500);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  text-decoration: none;
  text-align: center;
  box-shadow: 0 2px 8px rgba(255, 123, 0, 0.3);
}

.btn-cours:hover {
  background: linear-gradient(135deg, #ff6600, #ff8800);
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(255, 123, 0, 0.4);
}

.btn-cours:active {
  transform: translateY(0);
}

/* Animation au chargement */
.cours-card {
  opacity: 0;
  animation: fadeInUp 0.6s ease forwards;
}

.cours-card:nth-child(1) { animation-delay: 0.1s; }
.cours-card:nth-child(2) { animation-delay: 0.2s; }
.cours-card:nth-child(3) { animation-delay: 0.3s; }
.cours-card:nth-child(4) { animation-delay: 0.4s; }
.cours-card:nth-child(5) { animation-delay: 0.5s; }
.cours-card:nth-child(6) { animation-delay: 0.6s; }
.cours-card:nth-child(7) { animation-delay: 0.7s; }
.cours-card:nth-child(8) { animation-delay: 0.8s; }
.cours-card:nth-child(9) { animation-delay: 0.9s; }
.cours-card:nth-child(10) { animation-delay: 1.0s; }
.cours-card:nth-child(11) { animation-delay: 1.1s; }
.cours-card:nth-child(12) { animation-delay: 1.2s; }
.cours-card:nth-child(13) { animation-delay: 1.3s; }
.cours-card:nth-child(14) { animation-delay: 1.4s; }
.cours-card:nth-child(15) { animation-delay: 1.5s; }
.cours-card:nth-child(16) { animation-delay: 1.6s; }
.cours-card:nth-child(17) { animation-delay: 1.7s; }
.cours-card:nth-child(18) { animation-delay: 1.8s; }

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Responsive */
@media (max-width: 768px) {
  .cours-grid {
    grid-template-columns: 1fr;
    gap: 20px;
    padding: 0 15px;
  }
  
  .cours-card {
    padding: 20px;
    min-height: 180px; /* Hauteur minimum sur mobile */
    height: auto;
  }
  
  .cours-card-titre {
    font-size: 1.2rem;
  }
  
  .cours-icon {
    font-size: 2rem;
  }
  
  .cours-icon {
    font-size: 2rem;
  }
  
  .btn-cours {
    padding: 10px 14px;
    font-size: 0.85rem;
  }

  .progress-container {
    margin-bottom: 12px;
  }

  .progress-bar {
    height: 10px;
  }

  .progress-text {
    font-size: 0.7rem;
  }

  .cours-card-desc {
    font-size: 0.9rem;
    line-height: 1.3;
    max-height: calc(1.3em * 3);
    -webkit-line-clamp: 3;
    line-clamp: 3;
  }
}

@media (min-width: 1300px) {
  .cours-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1800px) {
  .cours-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}