/* ==========================================================
   Widget Bloc Histoire — V4.1
   - Frise centrée
   - Flèches absolues à droite, alignées sur la ligne du rail
   - Barre de progression pilotée en JS
   - SVG via mask-image (fallback texte si pas de SVG)
========================================================== */

/* --------- Core / variables --------- */
.we-bh{
  /* Slides */
  --slide-w: 42vw;
  --peek-pad: 10vw;
  --track-gap: 150px;

  /* Carte */
  --gap: 0px;
  --radius: 0;
  --shadow: 0 8px 24px rgba(0,0,0,.06);

  /* Frise / Rail */
  --rail-w: min(900px, 70vw);
  --rail-color: #E5E7EB;
  --bar-color: #0E2E4C;
  --rail-height: 2px;
  --rail-offset-y: 18px;     /* distance rail depuis le haut de .we-bh-timeline */

  /* Flèches */
  --nav-bw: 2px;
  --nav-color: #01234F;
  --nav-bg: transparent;
  --nav-bg-hover: #01234F;
  --nav-icon-hover: #fff;
  --nav-h: 40px;             /* hauteur du bouton */
  --nav-w: 60px;             /* largeur du bouton */
  --nav-gap: 16px;           /* écart entre les 2 flèches */

  /* NB: les variables --we-bh-arrow-* sont posées par Elementor sur l’élément */
  width: 100%;
  max-width: none;

  /* Ajustement fin lu par le JS pour le centrage des slides */
  --center-offset: -150px;
}

/* --------- Viewport & Track --------- */
.we-bh-viewport{
  position: relative;
  overflow: hidden;
  padding-inline: var(--peek-pad);
}
.we-bh-track{
  display: inline-flex;
  gap: var(--track-gap);
  will-change: transform;
}

/* --------- Slides --------- */
.we-bh-slide{
  width: var(--slide-w);
  transition: transform .35s ease, opacity .25s ease, filter .25s ease;
  transform-origin: center;
  opacity: .95;
}
.we-bh-slide.is-active{ opacity: 1; }

/* ==========================================================
   Carte : image fixe 230x300 + contenu
========================================================== */
.we-bh-card,
.we-bh-card--right{
  display: grid;
  align-items: stretch;
  gap: var(--gap);
  grid-template-columns: 230px 1fr; /* image fixe 230px */
  padding: clamp(12px, 1.5vw, 18px);
}

/* force image à gauche / texte à droite */
.we-bh-card--right .we-bh-media{ order: 1 !important; }
.we-bh-card--right .we-bh-content{ order: 2 !important; }

/* Image 230x300 */
.we-bh-media{
  width: 230px;
  height: 300px;
  border-radius: 0;
  overflow: hidden;
  box-shadow: var(--shadow);
  background:#f2f4f7;
}
.we-bh-media img{
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: 0;
}

/* Contenu (avec bordure haute) */
.we-bh-content{
  position: relative;
  padding: 20px;
  border-radius: 0;
  background:#fff;
  box-shadow: var(--shadow);
  border-top: 4px solid #01234F;
  max-width: 640px;
}

/* Typo */
.we-bh-year{
  font-size: 18px;
  font-weight: 700;
  margin: 0 0 12px;
  color: #0E2E4C;
}
.we-bh-points{
  margin: 0;
  padding-left: 1.1em;
  display: grid;
  gap: .35em;
  color: #243B53;
}

/* ==========================================================
   Frise centrée + Barre de progression (pilotée en JS)
========================================================== */

/* BOTTOM : frise centrée ; flèches absolues pour ne pas affecter la grille */
.we-bh-bottom{
  position: relative; /* référentiel des flèches */
  display: grid;
  grid-template-columns: 1fr var(--rail-w) 1fr; /* [esp] [FRISE] [esp] -> frise bien centrée */
  align-items: start;
  margin-top: clamp(20px, 2.4vw, 32px);
}

/* --- Frise (dates) --- */
.we-bh-timeline{
  grid-column: 2;
  width: var(--rail-w);
  max-width: 100%;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 80px;
  padding: var(--rail-offset-y) 0 0;
  margin: 0 auto;
  position: relative;

  overflow-x: auto;
  overflow-y: visible;

  /* Variables pilotées par le JS */
  --progress-left: 0px;     /* offset du bord gauche du rail */
  --progress-width: 0px;    /* longueur de la barre bleue */
}

/* rail gris (pleine largeur de la timeline) */
.we-bh-timeline::before{
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: var(--rail-height);
  background: var(--rail-color);
  border-radius: var(--rail-height);
  pointer-events: none;
  z-index: 0;
}

/* barre bleue : démarre à --progress-left et s'étend sur --progress-width */
.we-bh-timeline::after{
  content: "";
  position: absolute;
  top: 0;
  left: var(--progress-left, 0px);
  width: var(--progress-width, 0px);
  height: var(--rail-height);
  background: var(--bar-color);
  border-radius: var(--rail-height);
  pointer-events: none;
  z-index: 1;
}

/* dates */
.we-bh-timeline li{
  list-style: none;
  margin-top: 6px;
  padding-top: calc(6px + var(--rail-height));
  color:#64748B;
  font-weight:600;
  white-space:nowrap;
  cursor:pointer;
  outline:none;
}
.we-bh-timeline li.is-active{ color:#0E2E4C; }

.we-bh-timeline::-webkit-scrollbar{ display:none; }

/* ==========================================================
   Flèches : absolues à droite, sur la ligne du rail
========================================================== */

/* on place les deux boutons en absolu à droite du conteneur .we-bh-bottom */
.we-bh-prev,
.we-bh-next{
  position: absolute;
  right: 0;
  top: calc(
    var(--rail-offset-y)
    - (var(--nav-h) / 2)
    + (var(--rail-height) / 2)
  );
  width: var(--nav-w);
  height: var(--nav-h);
  border-radius: 999px;
  border: var(--nav-bw) solid var(--nav-color);
  background: var(--nav-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--nav-color);
  font-size: 16px;
  cursor: pointer;
  transition: background .25s ease, color .25s ease, transform .1s ease, border-color .25s ease;
  padding: 0;
  z-index: 2; /* au-dessus de la frise */
  margin-right: 20px; 
}

/* décale "précédent" à gauche de "suivant" */
.we-bh-prev{ right: calc(var(--nav-w) + var(--nav-gap)); }

.we-bh-nav:hover{
  background: var(--nav-bg-hover);
  color: var(--nav-icon-hover);
}
.we-bh-nav:active{ transform: scale(.98); }

/* Icône : fallback texte par défaut */
.we-bh-nav .we-bh-ico{
  display: inline-block;
  line-height: 1;
}

/* Si des SVG ont été fournis (classes posées côté PHP/JS), on les applique en masque */
.we-bh.has-prev-svg .we-bh-prev .we-bh-ico,
.we-bh.has-next-svg .we-bh-next .we-bh-ico{
  width: var(--we-bh-arrow-size, 24px);
  height: var(--we-bh-arrow-size, 24px);
  text-indent: -9999px;
  background: var(--we-bh-arrow-color, currentColor);
  -webkit-mask-repeat:no-repeat; mask-repeat:no-repeat;
  -webkit-mask-position:center;  mask-position:center;
  -webkit-mask-size:contain;     mask-size:contain;
}
.we-bh.has-prev-svg .we-bh-prev .we-bh-ico{
  -webkit-mask-image: var(--we-bh-arrow-prev, none);
          mask-image: var(--we-bh-arrow-prev, none);
}
.we-bh.has-next-svg .we-bh-next .we-bh-ico{
  -webkit-mask-image: var(--we-bh-arrow-next, none);
          mask-image: var(--we-bh-arrow-next, none);
}

/* ==========================================================
   MOBILE (≤ 900px)
========================================================== */
@media (max-width: 900px){
  .we-bh{
    --slide-w: 98vw;
    --peek-pad: 2vw;
    --track-gap: 16px;
    --center-offset: 0px;
    --rail-w: min(520px, 86vw);
    --nav-w: 46px;
    --nav-h: 46px;
  }

  /* on repasse en flex ; flèches reviennent dans le flux */
  .we-bh-bottom{
    display: flex !important;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin-top: 16px;
  }
  .we-bh-prev, .we-bh-next{
    position: static;  /* annule l’absolu desktop */
    order: 2;
    margin-left: 0;
    margin-right: 0;
    width: var(--nav-w);
    height: var(--nav-h);
    border-radius: 50%;
    font-size: 18px;
    align-self: center;
    top: 0;
  }

  .we-bh-timeline{
    order: 1;
    width: var(--rail-w);
    max-width: 100%;
    gap: 28px;
    font-size: 14px;
    margin-top: 12px;
    margin-bottom: 48px;
  }

  .we-bh-card,
  .we-bh-card--right{
    grid-template-columns: 1fr;
    justify-items: center;
  }
  .we-bh-media{
    width: 250px !important;
    height: 130px !important;
    margin-inline: auto;
    border-radius: 0 !important;
  }
  .we-bh-media img{ border-radius: 0 !important; }
  .we-bh-content{
    width: 250px !important;
    margin-top: 0;
    padding-top: 0;
  }
}

/* Ultra-étroit (≤ 480px) */
@media (max-width: 480px){
  .we-bh{ --slide-w: 96vw; }
  .we-bh-timeline{ max-width: 480px; gap: 20px; font-size: 13px; }
  .we-bh-nav{ width: var(--nav-w); font-size: 17px; }
}
