/**
 * Timeline AB - Divi 5 custom module (parent + child)
 * Layout: 3 colonnes desktop [image | line+bullet | card], reversed swap sides.
 * Mobile (<=767): 2 colonnes [line+bullet | stack image+card], plus concis.
 * Ligne centrale progressive au scroll (--ab-timeline-fill), bullets qui s'activent.
 */

.ab-timeline {
  --ab-timeline-line-active:   #F62E02;
  --ab-timeline-line-inactive: #DAD6C8;
  --ab-timeline-line-width:    2px;
  --ab-timeline-bullet-size:   14px;
  --ab-timeline-item-gap:      80px;
  --ab-timeline-column-gap:    60px;

  --ab-timeline-card-padding:  4rem 2rem;
  --ab-timeline-card-border:   2px;

  --ab-timeline-red:           #F62E02;
  --ab-timeline-white:         #FCFBF7;
  --ab-timeline-dark:          #222222;

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

.ab-timeline__wrapper {
  position: relative;
  width: 100%;
  box-sizing: border-box;
}

/* ---- Ligne centrale ----
   Absolute derrière tout, fill grimpe via --ab-timeline-fill (0% -> 100%).
   Le top et bottom sont calculés en JS pour que la ligne aille précisément du
   centre du premier bullet au centre du dernier bullet. Fallback = 0 avant JS. */
.ab-timeline__line {
  position: absolute;
  top: var(--ab-timeline-line-top, 0px);
  bottom: var(--ab-timeline-line-bottom, 0px);
  left: 50%;
  transform: translateX(-50%);
  width: var(--ab-timeline-line-width);
  pointer-events: none;
  z-index: 0;
}

.ab-timeline__line-track {
  position: relative;
  width: 100%;
  height: 100%;
  background-color: var(--ab-timeline-line-inactive);
  border-radius: 999px;
}

.ab-timeline__line-fill {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: var(--ab-timeline-fill, 0%);
  background-color: var(--ab-timeline-line-active);
  border-radius: 999px;
  transition: height 120ms linear;
}

/* Preview builder: fill à 100% */
.ab-timeline__wrapper.no-js .ab-timeline__line-fill {
  height: 100%;
}

/* ---- Items ---- */
.ab-timeline__items {
  display: flex;
  flex-direction: column;
  gap: var(--ab-timeline-item-gap);
  position: relative;
  z-index: 1;
}

.ab-timeline-item {
  display: block;
}

/* ---- Row (une étape) ----
   Grid 3 colonnes desktop: [image | ligne | card]
   Chaque side prend 1fr, la colonne centrale = column-gap total. */
.ab-timeline-item__row {
  display: grid;
  grid-template-columns: 1fr var(--ab-timeline-column-gap) 1fr;
  align-items: center;
  position: relative;
  min-height: 240px;
}

.ab-timeline-item__side {
  min-width: 0;
  display: flex;
  align-items: center;
}

.ab-timeline-item__side--left {
  grid-column: 1;
  justify-content: flex-end;
}

.ab-timeline-item__side--right {
  grid-column: 3;
  justify-content: flex-start;
}

/* ---- Bullet centré ---- */
.ab-timeline-item__bullet {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: var(--ab-timeline-bullet-size);
  height: var(--ab-timeline-bullet-size);
  border-radius: 50%;
  background-color: var(--ab-timeline-line-inactive);
  z-index: 2;
  transition: background-color 220ms ease;
}

.ab-timeline-item[data-active="1"] .ab-timeline-item__bullet {
  background-color: var(--ab-timeline-line-active);
}

/* ---- Image ---- */
.ab-timeline-item__image-wrap {
  width: 100%;
  max-width: 480px;
  aspect-ratio: 3 / 4;
  overflow: hidden;
  background-color: #EFEDE6;
}

.ab-timeline-item__image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.ab-timeline-item__image--placeholder {
  background: linear-gradient(135deg, #DAD6C8, #EFEDE6);
}

/* ---- Card ---- */
.ab-timeline-item__card {
  width: 100%;
  max-width: 480px;
  padding: var(--ab-timeline-card-padding);
  border: var(--ab-timeline-card-border) solid transparent;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ab-timeline-item__date {
  font-family: 'Host Grotesk', sans-serif;
  font-weight: 400;
  font-size: 18px;
  line-height: 1;
  letter-spacing: 0.02em;
  margin: 0 0 2rem;
}

.ab-timeline-item__title {
  font-family: 'PP Fragment Sans', 'PP Fragment', sans-serif;
  font-weight: 500;
  font-size: 32px;
  line-height: 1.05;
  margin: 0;
}

.ab-timeline-item__description {
  font-family: 'Host Grotesk', sans-serif;
  font-weight: 400;
  font-size: 15px;
  line-height: 1.5;
  margin: 0;
}

/* ---- Variantes de card ---- */
.ab-timeline-item__row--red-filled .ab-timeline-item__card {
  background-color: var(--ab-timeline-red);
  border-color: transparent;
  color: var(--ab-timeline-white);
}
.ab-timeline-item__row--red-filled .ab-timeline-item__date,
.ab-timeline-item__row--red-filled .ab-timeline-item__title,
.ab-timeline-item__row--red-filled .ab-timeline-item__description {
  color: var(--ab-timeline-white);
}

.ab-timeline-item__row--red-outlined .ab-timeline-item__card {
  background-color: transparent;
  border-color: var(--ab-timeline-red);
  color: var(--ab-timeline-red);
}
.ab-timeline-item__row--red-outlined .ab-timeline-item__date,
.ab-timeline-item__row--red-outlined .ab-timeline-item__title,
.ab-timeline-item__row--red-outlined .ab-timeline-item__description {
  color: var(--ab-timeline-red);
}

.ab-timeline-item__row--dark-filled .ab-timeline-item__card {
  background-color: var(--ab-timeline-dark);
  border-color: transparent;
  color: var(--ab-timeline-white);
}
.ab-timeline-item__row--dark-filled .ab-timeline-item__date,
.ab-timeline-item__row--dark-filled .ab-timeline-item__title,
.ab-timeline-item__row--dark-filled .ab-timeline-item__description {
  color: var(--ab-timeline-white);
}

.ab-timeline-item__row--light-outlined .ab-timeline-item__card {
  background-color: transparent;
  border-color: var(--ab-timeline-dark);
  color: var(--ab-timeline-dark);
}
.ab-timeline-item__row--light-outlined .ab-timeline-item__date,
.ab-timeline-item__row--light-outlined .ab-timeline-item__title,
.ab-timeline-item__row--light-outlined .ab-timeline-item__description {
  color: var(--ab-timeline-dark);
}

/* ---- Tablet: colonnes légèrement plus proches ---- */
@media (max-width: 980px) {
  .ab-timeline {
    --ab-timeline-item-gap: 56px;
    --ab-timeline-column-gap: 32px;
  }
  .ab-timeline-item__row {
    min-height: 200px;
  }
  .ab-timeline-item__title {
    font-size: 26px;
  }
  .ab-timeline-item__image-wrap {
    max-width: 320px;
  }
  .ab-timeline-item__card {
    max-width: 320px;
    padding: 20px 24px;
  }
}

/* ---- Mobile (<= 767px) : timeline gauche + stack image+card à droite ---- */
@media (max-width: 767px) {
  .ab-timeline {
    --ab-timeline-item-gap: 40px;
  }

  .ab-timeline__line {
    left: 16px;
    transform: none;
  }

  /* Grid 2 colonnes x 3 rangées.
     Row 2 = un mini row (0 hauteur + row-gap 8px de chaque côté) où le bullet
     tombe en align-self: center → pile centré entre image et card. */
  .ab-timeline-item__row {
    grid-template-columns: 32px 1fr;
    grid-template-rows: auto 0 auto;
    align-items: stretch;
    min-height: 0;
    row-gap: 8px;
    column-gap: 8px;
  }

  /* Bullet remis en flow (grid child), pas d'absolute sur mobile */
  .ab-timeline-item__bullet {
    position: relative;
    top: auto;
    left: auto;
    transform: none;
    grid-column: 1;
    grid-row: 2;
    justify-self: center;
    align-self: center;
  }

  .ab-timeline-item__side {
    grid-column: 2;
    justify-content: flex-start;
    display: block;
  }

  /* Default: image (left side) row 1, card (right side) row 3 */
  .ab-timeline-item__side--left  { grid-row: 1; }
  .ab-timeline-item__side--right { grid-row: 3; }

  /* Reversed: on garde toujours image en haut sur mobile */
  .ab-timeline-item__row--reversed .ab-timeline-item__side--left  { grid-row: 3; }
  .ab-timeline-item__row--reversed .ab-timeline-item__side--right { grid-row: 1; }

  .ab-timeline-item__image-wrap {
    max-width: none;
    width: 100%;
    aspect-ratio: 16 / 10;
  }

  .ab-timeline-item__card {
    max-width: none;
    width: 100%;
    padding: 20px 24px;
  }

  .ab-timeline-item__title {
    font-size: 24px;
  }
}
