/* GoMathy V17 — cours plus denses sans modifier le contenu ni l'ordre pédagogique.
   Objectif : les petites cartes occupent l'espace réellement disponible au lieu de
   réserver des colonnes vides. Les grandes sections du cours restent dans leur ordre. */

/* Les blocs "Définitions / propriétés / formules" n'ont en pratique que 1 ou 2 cartes.
   L'ancienne règle V35 réservait pourtant 3 colonnes, d'où les grands trous. */
.course-theme-maths .math-depth-grid,
.course-theme-maths .gomathy-math-depth-grid-v35 {
  display:grid!important;
  grid-template-columns:repeat(auto-fit,minmax(360px,1fr))!important;
  align-items:start!important;
  gap:.78rem!important;
}
.course-theme-maths .math-depth-grid>.math-depth-card,
.course-theme-maths .gomathy-math-depth-grid-v35>.math-depth-card {
  min-width:0!important;
  width:100%!important;
  height:auto!important;
  align-self:start!important;
}

/* Quand il n'y a qu'une carte, elle utilise toute la largeur. Son contenu textuel
   se redistribue lui-même en colonnes lisibles au lieu de produire une longue bande vide. */
.course-theme-maths .math-depth-grid>.math-depth-card:only-child,
.course-theme-maths .gomathy-math-depth-grid-v35>.math-depth-card:only-child {
  grid-column:1/-1!important;
}
.course-theme-maths .math-depth-grid>.math-depth-card:only-child>ul,
.course-theme-maths .gomathy-math-depth-grid-v35>.math-depth-card:only-child>ul {
  display:grid!important;
  grid-template-columns:repeat(auto-fit,minmax(420px,1fr))!important;
  column-gap:1.8rem!important;
  row-gap:.34rem!important;
}

/* Même logique pour les autres petites grilles des cours de maths :
   auto-fit supprime les pistes vides tout en conservant l'ordre DOM. */
.course-theme-maths .math-depth-methods,
.course-theme-maths .math-depth-mastery,
.course-theme-maths .math-depth-objectives ul,
.course-theme-maths .course-unified-body .gomathy-course-method-list,
.course-theme-maths .course-unified-wide-card .gomathy-course-vocab-grid {
  grid-template-columns:repeat(auto-fit,minmax(300px,1fr))!important;
  align-items:start!important;
}

/* Les petits blocs clés restent compacts : une seule entrée prend la largeur,
   deux entrées se répartissent naturellement sans créer de colonne fantôme. */
.course-theme-maths .gomathy-course-keypoints,
.course-theme-maths .gomathy-course-practice-list {
  grid-template-columns:repeat(auto-fit,minmax(280px,1fr))!important;
  align-items:start!important;
}

/* Les exemples internes ne doivent jamais être étirés à la hauteur de leur voisin. */
.course-theme-maths .math-depth-examples,
.course-theme-maths .course-unified-example-grid,
.course-theme-maths .course-unified-final-grid {
  align-items:start!important;
}
.course-theme-maths .math-depth-examples>article,
.course-theme-maths .course-unified-example-grid>* ,
.course-theme-maths .course-unified-final-grid>* {
  align-self:start!important;
  min-height:0!important;
}

/* Tablettes : deux blocs lisibles si la largeur le permet, sinon une seule colonne. */
@media(max-width:900px){
  .course-theme-maths .math-depth-grid,
  .course-theme-maths .gomathy-math-depth-grid-v35,
  .course-theme-maths .math-depth-methods,
  .course-theme-maths .math-depth-mastery,
  .course-theme-maths .math-depth-objectives ul,
  .course-theme-maths .course-unified-body .gomathy-course-method-list,
  .course-theme-maths .course-unified-wide-card .gomathy-course-vocab-grid,
  .course-theme-maths .gomathy-course-keypoints,
  .course-theme-maths .gomathy-course-practice-list {
    grid-template-columns:repeat(auto-fit,minmax(260px,1fr))!important;
  }
  .course-theme-maths .math-depth-grid>.math-depth-card:only-child>ul,
  .course-theme-maths .gomathy-math-depth-grid-v35>.math-depth-card:only-child>ul {
    grid-template-columns:1fr!important;
  }
}

@media(max-width:620px){
  .course-theme-maths .math-depth-grid,
  .course-theme-maths .gomathy-math-depth-grid-v35,
  .course-theme-maths .math-depth-methods,
  .course-theme-maths .math-depth-mastery,
  .course-theme-maths .math-depth-objectives ul,
  .course-theme-maths .course-unified-body .gomathy-course-method-list,
  .course-theme-maths .course-unified-wide-card .gomathy-course-vocab-grid,
  .course-theme-maths .gomathy-course-keypoints,
  .course-theme-maths .gomathy-course-practice-list {
    grid-template-columns:1fr!important;
  }
}
