/* =============================================
   SN UFS : FRISE CHRONOLOGIQUE (page « À propos »)
   Modules natifs Divi 5, CSS pur, sans JavaScript.

   Contrat de classes (Visual Builder) :
   - Ligne              : ufs-timeline
   - Chaque colonne     : ufs-timeline__step
   - Module Texte date        : ufs-timeline__year
   - Module En-tête (H3)      : ufs-timeline__content
   - Module Texte description : ufs-timeline__description (facultatif)
   - Colonne mise en valeur   : ufs-timeline__step--highlight

   Chaque colonne est une grille de trois rangées : date / titre / description.
   La ligne passe sous la date ; les dates (une ligne, même typographie)
   ont toutes la même hauteur, donc la ligne reste alignée quelle que soit
   la hauteur des titres ou la présence d'une description.

   Desktop (> 980 px)  : frise horizontale.
   <= 980 px           : frise verticale (seuil natif d'empilement Divi).

   Ligne et points : pseudo-éléments décoratifs des colonnes,
   ignorés par les technologies d'assistance.
   ============================================= */

/* ---------- 1. Variables et ligne Divi ---------- */

.ufs-timeline {
  --ufs-timeline-blue: #21B8ED;
  --ufs-timeline-orange: #F39C12;
  --ufs-timeline-ink: #0F2A36;
  /* #6B7C86 assombri : contraste AA (> 4,5:1) sur #FFFFFF et #F5F7F8. */
  --ufs-timeline-muted: #5E6F79;
  --ufs-timeline-line: #D5DEE3;

  --ufs-timeline-year-size: clamp(2.5rem, 1.25rem + 2.3vw, 3rem);
  --ufs-timeline-title-size: clamp(1.25rem, 1rem + 0.45vw, 1.375rem);
  --ufs-timeline-text-size: clamp(1rem, 0.9rem + 0.3vw, 1.125rem);

  --ufs-timeline-gap: clamp(1.5rem, 3vw, 3rem);       /* entre colonnes (desktop) */
  --ufs-timeline-step-gap: clamp(2rem, 6vw, 3rem);    /* entre étapes (vertical) */
  --ufs-timeline-rail: 2.5rem;                         /* colonne de la ligne (vertical) */
  --ufs-timeline-stroke: 2px;
  --ufs-timeline-dot: 0.875rem;
  --ufs-timeline-dot-highlight: 1.25rem;
  --ufs-timeline-halo: 0.375rem;

  display: grid !important; /* remplace la mise en page float/flex native de la ligne */
  font-family: "Manrope", Arial, sans-serif;
  color: var(--ufs-timeline-ink);
}

/* Le clearfix de la ligne Divi deviendrait un élément de grille parasite. */
.ufs-timeline::before,
.ufs-timeline::after {
  content: none !important;
}

/* Colonnes : largeurs, marges et gouttières Divi neutralisées (Divi les impose en !important). */
.ufs-timeline .ufs-timeline__step {
  position: relative;
  display: grid !important;
  gap: 0 !important;
  float: none;
  width: auto !important;
  max-width: none;
  min-width: 0;
  margin: 0 !important;
  /* L'espace restant ne doit jamais agrandir la rangée de la date. */
  align-content: start;
}

/* Modules Texte et En-tête : marges des gouttières Divi neutralisées. */
.ufs-timeline .ufs-timeline__year,
.ufs-timeline .ufs-timeline__content,
.ufs-timeline .ufs-timeline__description {
  min-width: 0;
  margin: 0 !important;
  overflow-wrap: break-word;
}

/* ---------- 2. Typographie ---------- */

.ufs-timeline .ufs-timeline__year {
  grid-row: 1;
  font-size: var(--ufs-timeline-year-size);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums lining-nums;
  white-space: nowrap; /* hauteur identique d'une colonne à l'autre */
  color: var(--ufs-timeline-ink);
}

/* La date peut être saisie en texte brut, en paragraphe ou en titre : rendu identique. */
.ufs-timeline .ufs-timeline__year :is(p, h1, h2, h3, h4, h5, h6) {
  margin: 0;
  padding: 0;
  font: inherit;
  letter-spacing: inherit;
  color: inherit;
}

.ufs-timeline .ufs-timeline__content {
  grid-row: 2;
  font-size: var(--ufs-timeline-text-size);
  line-height: 1.55;
  color: var(--ufs-timeline-muted);
}

/* Titre : module En-tête Divi 5 (balise h1-h6 choisie dans le module,
   enveloppée par Divi) ou, à défaut, titre saisi dans un module Texte.
   Le sélecteur vise la balise de titre quelle que soit son enveloppe ;
   la colonne intermédiaire passe devant les styles par instance du module
   (ex. .et_pb_heading_0 … h3) sans recourir à !important. */
.ufs-timeline .ufs-timeline__step .ufs-timeline__content :is(h1, h2, h3, h4, h5, h6) {
  margin: 0;
  padding: 0;
  font-family: inherit;
  font-size: var(--ufs-timeline-title-size);
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.01em;
  color: var(--ufs-timeline-ink);
  text-align: inherit;
  text-wrap: balance;
}

/* Titre lié (option « lien » du module En-tête) : même apparence. */
.ufs-timeline .ufs-timeline__content :is(h1, h2, h3, h4, h5, h6) a {
  color: inherit;
}

.ufs-timeline .ufs-timeline__description {
  grid-row: 3;
  padding-top: 0.5rem;
  font-size: var(--ufs-timeline-text-size);
  line-height: 1.55;
  color: var(--ufs-timeline-muted);
}

.ufs-timeline .ufs-timeline__description :is(p, h1, h2, h3, h4, h5, h6) {
  margin: 0;
  padding: 0;
  font: inherit;
  color: inherit;
}

.ufs-timeline .ufs-timeline__content p {
  margin: 0;
  padding: 0;
  font-size: inherit;
  line-height: inherit;
  color: inherit;
}

/* Espacement régulier entre titre et description, quel que soit le balisage. */
.ufs-timeline .ufs-timeline__content :is(h1, h2, h3, h4, h5, h6, p) + :is(h1, h2, h3, h4, h5, h6, p) {
  margin-top: 0.5rem;
}

/* ---------- 3. Mise en valeur (naissance d'UFS) ---------- */

/* Repère non chromatique : date plus appuyée et point plus grand cerclé d'un halo. */
.ufs-timeline .ufs-timeline__step--highlight .ufs-timeline__year {
  font-weight: 800;
}

.ufs-timeline .ufs-timeline__step.ufs-timeline__step--highlight .ufs-timeline__content :is(h1, h2, h3, h4, h5, h6) {
  font-weight: 800;
}

/* ---------- 4. Ligne et points (décoratifs) ---------- */

.ufs-timeline .ufs-timeline__step::before,
.ufs-timeline .ufs-timeline__step::after {
  content: "";
  position: absolute;
  display: block;
  visibility: visible;
  pointer-events: none;
}

/* Ligne : chaque colonne trace son segment, prolongé de la moitié de l'espacement. */
.ufs-timeline .ufs-timeline__step::before {
  z-index: 0;
  background: var(--ufs-timeline-line);
}

/* Point */
.ufs-timeline .ufs-timeline__step::after {
  z-index: 1;
  width: var(--ufs-timeline-dot);
  height: var(--ufs-timeline-dot);
  border-radius: 50%;
  background: var(--ufs-timeline-blue);
  transform: translate(-50%, -50%);
}

.ufs-timeline .ufs-timeline__step--highlight::after {
  width: var(--ufs-timeline-dot-highlight);
  height: var(--ufs-timeline-dot-highlight);
  background: var(--ufs-timeline-orange);
  box-shadow: 0 0 0 var(--ufs-timeline-halo) rgba(243, 156, 18, 0.2);
}

/* ---------- 5. Desktop : frise horizontale ---------- */

@media (min-width: 981px) {
  .ufs-timeline {
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 1fr);
    column-gap: var(--ufs-timeline-gap);
  }

  .ufs-timeline .ufs-timeline__step {
    grid-template-rows: auto auto 1fr;
    text-align: center;
  }

  .ufs-timeline .ufs-timeline__year {
    align-self: end;
    padding-bottom: 1.5rem;
    text-align: center;
  }

  .ufs-timeline .ufs-timeline__content {
    padding-top: 1.75rem;
    text-align: center;
  }

  .ufs-timeline .ufs-timeline__description {
    text-align: center;
  }

  /* Ligne et point posés sur la limite haute de la zone « contenu ». */
  .ufs-timeline .ufs-timeline__step::before,
  .ufs-timeline .ufs-timeline__step::after {
    grid-row: 2 / 3;
    top: 0;
  }

  .ufs-timeline .ufs-timeline__step::before {
    left: calc(var(--ufs-timeline-gap) / -2);
    right: calc(var(--ufs-timeline-gap) / -2);
    height: var(--ufs-timeline-stroke);
    transform: translateY(-50%);
  }

  .ufs-timeline .ufs-timeline__step::after {
    left: 50%;
  }

  /* La ligne commence au premier point… */
  .ufs-timeline .ufs-timeline__step:not(.ufs-timeline__step ~ .ufs-timeline__step)::before {
    left: 50%;
  }

  /* … et s'arrête au dernier. */
  .ufs-timeline .ufs-timeline__step:not(:has(~ .ufs-timeline__step))::before {
    right: 50%;
  }
}

/* ---------- 6. Tablette étroite et mobile : frise verticale ---------- */

@media (max-width: 980px) {
  .ufs-timeline {
    --ufs-timeline-year-size: clamp(2rem, 1.6rem + 1.6vw, 2.5rem);
    /* Centre vertical de la première ligne de la date (line-height 1.1). */
    --ufs-timeline-dot-y: calc(var(--ufs-timeline-year-size) * 0.55);

    grid-template-columns: minmax(0, 1fr);
    row-gap: var(--ufs-timeline-step-gap);
  }

  .ufs-timeline .ufs-timeline__step {
    grid-template-columns: var(--ufs-timeline-rail) minmax(0, 1fr);
    grid-template-rows: auto auto auto;
    column-gap: 1rem !important;
    text-align: left;
  }

  .ufs-timeline .ufs-timeline__year,
  .ufs-timeline .ufs-timeline__content,
  .ufs-timeline .ufs-timeline__description {
    grid-column: 2;
    text-align: left;
  }

  .ufs-timeline .ufs-timeline__year {
    padding-bottom: 0.5rem;
  }

  /* Ligne et point dans la colonne de gauche. */
  .ufs-timeline .ufs-timeline__step::before,
  .ufs-timeline .ufs-timeline__step::after {
    grid-column: 1 / 2;
    left: 50%;
  }

  .ufs-timeline .ufs-timeline__step::before {
    grid-row: 1 / -1;
    top: calc(var(--ufs-timeline-step-gap) / -2);
    bottom: calc(var(--ufs-timeline-step-gap) / -2);
    width: var(--ufs-timeline-stroke);
    transform: translateX(-50%);
  }

  .ufs-timeline .ufs-timeline__step::after {
    grid-row: 1 / 2;
    top: var(--ufs-timeline-dot-y);
  }

  .ufs-timeline .ufs-timeline__step:not(.ufs-timeline__step ~ .ufs-timeline__step)::before {
    top: var(--ufs-timeline-dot-y);
  }

  .ufs-timeline .ufs-timeline__step:not(:has(~ .ufs-timeline__step))::before {
    bottom: auto;
    height: calc(var(--ufs-timeline-step-gap) / 2 + var(--ufs-timeline-dot-y));
  }
}

@media (max-width: 767px) {
  .ufs-timeline {
    --ufs-timeline-rail: 2rem;
  }
}

/* ---------- 7. Contraste élevé (Windows) ---------- */

@media (forced-colors: active) {
  .ufs-timeline .ufs-timeline__step::before,
  .ufs-timeline .ufs-timeline__step::after {
    forced-color-adjust: none;
    background: CanvasText;
  }

  .ufs-timeline .ufs-timeline__step--highlight::after {
    background: Highlight;
    box-shadow: none;
  }
}
