/**
 * Dernières études de cas AB - Divi 5 custom module
 *
 * Rend N cards (2 colonnes chacune, org à gauche, étude à droite).
 * 3 variantes visuelles hardcodées qui cyclent via .ab-latest-cs__card--v1/v2/v3
 * (le PHP calcule variant = (index % 3) + 1).
 *
 * Variantes :
 *   v1 : org rouge (gauche)  + étude noire  (droite)
 *   v2 : étude noire (gauche) + org blanche (droite)
 *   v3 : org rouge (gauche)  + étude blanche (droite)
 */

.ab-latest-cs {
  --ab-rouge: #F62E02;
  --ab-blanc: #FCFBF7;
  --ab-noir:  #222222;

  --ab-latest-cs-col-padding: 48px;
  --ab-latest-cs-gap: 0;

  /* Le contenu textuel (col--study) reste dans un container centré de 1400px
     max, alors que la col avec le logo/image peut bleeder jusqu'au bord du
     viewport. */
  --ab-latest-cs-content-max: 1400px;
  --ab-latest-cs-outer-gutter: max(var(--ab-latest-cs-col-padding), calc((100vw - var(--ab-latest-cs-content-max)) / 2 + var(--ab-latest-cs-col-padding)));

  box-sizing: border-box;
  display: block;
  width: 100%;
}

.ab-latest-cs__inner {
  display: flex;
  flex-direction: column;
  gap: var(--ab-latest-cs-gap);
  width: 100%;
}

.ab-latest-cs__empty {
  padding: 32px;
  font-family: 'Host Grotesk', sans-serif;
  color: #666;
  text-align: center;
}

/* ============ CARD ============
   Grid 2 cols, align-items: stretch (default) → les 2 cols ont TOUJOURS la
   même hauteur. Cette hauteur est poussée par le contenu de col--study,
   chaque card est donc indépendante des autres. */
.ab-latest-cs__card {
  display: grid;
  grid-template-columns: 1fr 1fr;
  width: 100%;
  overflow: hidden;
  box-sizing: border-box;
}

.ab-latest-cs__col {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: var(--ab-latest-cs-col-padding);
  box-sizing: border-box;
  min-width: 0;
  position: relative;
}

/* ============ COL ORG ============
   Grid 2 rows 1fr 1fr → chaque row = 50% de la hauteur de col--org.
   Comme col--org hérite la hauteur de la card (poussée par col--study),
   les 2 rows sont toujours 50/50 de la card.
   min-height: 0 + overflow: hidden sur les enfants pour empêcher leur
   contenu min-content de casser la répartition. */
.ab-latest-cs__col--org {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: 1fr 1fr;
  padding: 0;
  gap: 0;
  overflow: hidden;
  min-height: 0;
  min-width: 0;
}

.ab-latest-cs__org-top {
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: var(--ab-latest-cs-col-padding);
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  justify-self: stretch;
  align-self: stretch;
}

.ab-latest-cs__org-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 60px;
}

.ab-latest-cs__org-logo-img {
  max-width: 70%;
  max-height: 140px;
  height: auto;
  width: auto;
  display: block;
  object-fit: contain;
}

.ab-latest-cs__org-logo-placeholder {
  font-family: 'PP Fragment Sans', 'PP Fragment', sans-serif;
  font-size: 32px;
  font-weight: 400;
  opacity: 0.4;
}

.ab-latest-cs__org-secteur {
  font-family: 'Host Grotesk', sans-serif;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
}

.ab-latest-cs__org-secteur::before,
.ab-latest-cs__org-secteur::after {
  content: '';
  display: block;
  width: 24px;
  height: 1px;
  background: currentColor;
  opacity: 0.6;
}

.ab-latest-cs__org-image {
  min-height: 0;
  min-width: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: rgba(0, 0, 0, 0.05);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  box-sizing: border-box;
  justify-self: stretch;
  align-self: stretch;
}

.ab-latest-cs__org-image-placeholder {
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, rgba(0, 0, 0, 0.08), rgba(0, 0, 0, 0.02));
}

/* ============ COL STUDY ============ */
.ab-latest-cs__col--study {
  gap: 20px;
}

/* v1 & v3 : col--study visuellement à DROITE (grille LTR).
   Le padding-right pousse le contenu à l'intérieur du 1400px centré. */
.ab-latest-cs__card--v1 .ab-latest-cs__col--study,
.ab-latest-cs__card--v3 .ab-latest-cs__col--study {
  padding-right: var(--ab-latest-cs-outer-gutter);
}

/* v2 : col--study visuellement à GAUCHE (grille rtl swap).
   La side "outer" est la gauche du viewport → padding-left. */
.ab-latest-cs__card--v2 .ab-latest-cs__col--study {
  padding-left: var(--ab-latest-cs-outer-gutter);
}

.ab-latest-cs__study-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  width: 100%;
}

.ab-latest-cs__stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex-shrink: 0;
}

.ab-latest-cs__stat-value {
  font-family: 'PP Fragment Sans', 'PP Fragment', sans-serif;
  font-size: 68px;
  font-weight: 400;
  line-height: 1;
  letter-spacing: -0.02em;
}

.ab-latest-cs__stat-value sup {
  font-size: 0.4em;
  vertical-align: top;
  font-weight: 400;
  position: relative;
  top: 0.6em;
}

.ab-latest-cs__stat-label {
  font-family: 'Host Grotesk', sans-serif;
  font-size: 14px;
  font-weight: 400;
}

.ab-latest-cs__study-icon {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex: 1;
  max-height: 100px;
  min-width: 0;
}

.ab-latest-cs__study-icon img {
  max-width: 100%;
  max-height: 100px;
  height: auto;
  width: auto;
  object-fit: contain;
  display: block;
}

.ab-latest-cs__study-icon-placeholder {
  width: 140px;
  height: 80px;
  border: 1px dashed currentColor;
  opacity: 0.3;
  border-radius: 8px;
}

.ab-latest-cs__study-title {
  font-family: 'PP Fragment Sans', 'PP Fragment', sans-serif;
  font-size: 32px;
  font-weight: 400;
  line-height: 1.15;
  margin: 0;
}

.ab-latest-cs__study-mandat {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.ab-latest-cs__pill {
  display: inline-flex;
  align-items: center;
  padding: 8px 16px;
  border-radius: 6px;
  font-family: 'Host Grotesk', sans-serif;
  font-size: 12px;
  font-weight: 500;
  background-color: var(--ab-blanc);
  color: var(--ab-noir);
  border: 1px solid rgba(0, 0, 0, 0.08);
}

.ab-latest-cs__study-description {
  font-family: 'Host Grotesk', sans-serif;
  font-size: 15px;
  line-height: 1.55;
  margin: 0;
  max-width: 92%;
}

.ab-latest-cs__cta {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-family: 'Host Grotesk', sans-serif;
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  color: inherit;
  padding-top: 16px;
  align-self: flex-end;
  transition: gap 200ms ease;
}

.ab-latest-cs__cta:hover .ab-latest-cs__cta-arrow {
  transform: translateX(4px);
}

.ab-latest-cs__cta-arrow {
  transition: transform 200ms ease;
  display: inline-flex;
  align-items: center;
  font-size: 18px;
  line-height: 1;
}

/* ============ VARIANTES ============
   Les couleurs des textes sont FORCÉES en !important pour battre tout preset
   Divi que l'utilisateur pourrait appliquer sur les fonts. On force sur les
   éléments texte spécifiques (pas un * universel) pour laisser la pill et
   les icônes gérer leur propre color. */

/* --- Variante 1 : org rouge (gauche) + étude noire (droite) --- */
.ab-latest-cs__card--v1 .ab-latest-cs__col--org {
  background-color: var(--ab-rouge);
  color: var(--ab-blanc);
}
.ab-latest-cs__card--v1 .ab-latest-cs__col--study {
  background-color: var(--ab-noir);
  color: var(--ab-blanc);
}
.ab-latest-cs__card--v1 .ab-latest-cs__org-secteur,
.ab-latest-cs__card--v1 .ab-latest-cs__stat-value,
.ab-latest-cs__card--v1 .ab-latest-cs__stat-label,
.ab-latest-cs__card--v1 .ab-latest-cs__study-title,
.ab-latest-cs__card--v1 .ab-latest-cs__study-description,
.ab-latest-cs__card--v1 .ab-latest-cs__cta {
  color: var(--ab-blanc) !important;
}

/* --- Variante 2 : étude noire (gauche) + org blanche (droite) ---
   Swap visuel via direction rtl (l'ordre DOM garde org d'abord). */
.ab-latest-cs__card--v2 {
  direction: rtl;
}
.ab-latest-cs__card--v2 > .ab-latest-cs__col {
  direction: ltr;
}
.ab-latest-cs__card--v2 .ab-latest-cs__col--org {
  background-color: var(--ab-blanc);
  color: var(--ab-noir);
}
.ab-latest-cs__card--v2 .ab-latest-cs__col--study {
  background-color: var(--ab-noir);
  color: var(--ab-blanc);
}
.ab-latest-cs__card--v2 .ab-latest-cs__org-secteur {
  color: var(--ab-noir) !important;
}
.ab-latest-cs__card--v2 .ab-latest-cs__stat-value,
.ab-latest-cs__card--v2 .ab-latest-cs__stat-label,
.ab-latest-cs__card--v2 .ab-latest-cs__study-title,
.ab-latest-cs__card--v2 .ab-latest-cs__study-description,
.ab-latest-cs__card--v2 .ab-latest-cs__cta {
  color: var(--ab-blanc) !important;
}

/* --- Variante 3 : org rouge (gauche) + étude blanche (droite) --- */
.ab-latest-cs__card--v3 .ab-latest-cs__col--org {
  background-color: var(--ab-rouge);
  color: var(--ab-blanc);
}
.ab-latest-cs__card--v3 .ab-latest-cs__col--study {
  background-color: var(--ab-blanc);
  color: var(--ab-noir);
}
.ab-latest-cs__card--v3 .ab-latest-cs__org-secteur {
  color: var(--ab-blanc) !important;
}
.ab-latest-cs__card--v3 .ab-latest-cs__stat-value,
.ab-latest-cs__card--v3 .ab-latest-cs__stat-label,
.ab-latest-cs__card--v3 .ab-latest-cs__study-title,
.ab-latest-cs__card--v3 .ab-latest-cs__study-description,
.ab-latest-cs__card--v3 .ab-latest-cs__cta {
  color: var(--ab-noir) !important;
}
/* Pill v3 : fond noir, texte blanc (contraste sur fond blanc de la col--study) */
.ab-latest-cs__card--v3 .ab-latest-cs__pill {
  background-color: var(--ab-noir) !important;
  border-color: var(--ab-noir);
  color: var(--ab-blanc) !important;
}

/* --- Pill v1/v2 : fond blanc, texte noir --- */
.ab-latest-cs__card--v1 .ab-latest-cs__pill,
.ab-latest-cs__card--v2 .ab-latest-cs__pill {
  background-color: var(--ab-blanc) !important;
  color: var(--ab-noir) !important;
}

/* ============ RESPONSIVE ============ */
@media (max-width: 980px) {
  .ab-latest-cs {
    --ab-latest-cs-col-padding: 32px;
  }
  .ab-latest-cs__stat-value {
    font-size: 56px;
  }
  .ab-latest-cs__study-title {
    font-size: 26px;
  }
}

@media (max-width: 767px) {
  .ab-latest-cs {
    --ab-latest-cs-col-padding: 24px;
  }
  .ab-latest-cs__card {
    grid-template-columns: 1fr;
  }
  /* Empile en mobile : org toujours en haut, étude toujours en bas. */
  .ab-latest-cs__card--v2 {
    direction: ltr;
  }
  /* Sur mobile la col--study prend toute la largeur, pas de gouttière 1400. */
  .ab-latest-cs__card--v1 .ab-latest-cs__col--study,
  .ab-latest-cs__card--v2 .ab-latest-cs__col--study,
  .ab-latest-cs__card--v3 .ab-latest-cs__col--study {
    padding-left: var(--ab-latest-cs-col-padding);
    padding-right: var(--ab-latest-cs-col-padding);
  }
  .ab-latest-cs__stat-value {
    font-size: 48px;
  }
  .ab-latest-cs__study-title {
    font-size: 22px;
  }
  .ab-latest-cs__study-description {
    max-width: 100%;
    font-size: 14px;
  }
  /* Sur mobile la col--org devient natural : row logo à hauteur du contenu,
     row image à hauteur ratio 16/10. Plus de 50/50 auto puisque la card est
     empilée en 1 col et n'a plus de hauteur poussée par la col d'à côté. */
  .ab-latest-cs__col--org {
    grid-template-rows: auto auto;
  }
  .ab-latest-cs__org-top {
    height: auto;
    min-height: 200px;
  }
  .ab-latest-cs__org-image {
    height: auto;
    aspect-ratio: 16 / 10;
  }
}
