/* ===== TIMELINE — Bloc-type CSS (chargé dynamiquement) ===== */

.timeline-section__x-deco {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  opacity: 0.06;
  pointer-events: none;
  z-index: 0;
  display: flex;
  align-items: center;
  will-change: transform;
}

.timeline-section__x-deco svg {
  height: 100%;
  width: auto;
  display: block;
}

.timeline-section__x-deco svg path {
  fill: var(--accent);
  stroke: none;
}

.timeline-section {
  background: var(--bg-cream);
  color: var(--text-dark);
  padding: 0;
  overflow: visible;
}

.timeline-outer {
  height: 400vh;
  position: relative;
}

.timeline-sticky {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.timeline-section__header {
  text-align: center;
  padding-top: 3rem;
  margin-bottom: 1rem;
  flex-shrink: 0;
}

.timeline-section__header .split-section__label {
  justify-content: center;
  margin-bottom: 1rem;
}

.timeline-viewport {
  position: relative;
  overflow: hidden;
  flex: 1;
  display: flex;
  align-items: center;
}

.timeline-track {
  display: flex;
  align-items: center;
  position: relative;
  width: max-content;
  padding: 160px calc(50vw - 160px);
  will-change: transform;
}

.timeline-track__line {
  position: absolute;
  top: 50%;
  left: calc(50vw);
  right: calc(50vw);
  height: 2px;
  background: rgba(3, 114, 255, 0.15);
  transform: translateY(-50%);
  z-index: 1;
}

.timeline-track__line-progress {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 0;
  background: var(--accent);
}

.timeline-center-line {
  display: none;
}

.timeline-item {
  position: relative;
  flex-shrink: 0;
  width: 320px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.timeline-item__bg-year {
  position: absolute;
  top: 50%;
  left: 50%;
  font-size: clamp(3.5rem, 7vw, 5.5rem);
  font-weight: 700;
  color: rgba(255, 255, 255, 0.7);
  white-space: nowrap;
  pointer-events: none;
  z-index: 0;
  line-height: 1;
  letter-spacing: -0.04em;
  opacity: 0;
}

.timeline-item__dot {
  width: 28px;
  height: 36px;
  position: relative;
  z-index: 2;
  flex-shrink: 0;
  opacity: 0;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='-1 -1 14.8 26'%3E%3Cpath d='M5,24H0l7.7-12.2L.3,0h5l7.4,11.8-7.8,12.2Z' fill='%230372FF' stroke='%23F7F5F2' stroke-width='1.5'/%3E%3C/svg%3E") center/contain no-repeat;
  transition: opacity 0.1s ease, transform 0.1s ease;
}

.timeline-item--top .timeline-item__dot {
  transform: rotate(-90deg) translateX(-50px);
}

.timeline-item--top.tl-visible .timeline-item__dot {
  opacity: 1;
  transform: rotate(-90deg) translateX(0);
  transition: opacity 0.35s ease 0s, transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) 0s;
}

.timeline-item--bottom .timeline-item__dot {
  transform: rotate(90deg) translateX(-50px);
}

.timeline-item--bottom.tl-visible .timeline-item__dot {
  opacity: 1;
  transform: rotate(90deg) translateX(0);
  transition: opacity 0.35s ease 0s, transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) 0s;
}

.timeline-item.tl-visible:hover .timeline-item__dot {
  filter: drop-shadow(0 0 6px rgba(3, 114, 255, 0.5));
}

/* Timeline card with animated border */
.timeline-item__card {
  position: absolute;
  width: 270px;
  height: 270px;
  padding: 2rem;
  border: none;
  border-radius: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: flex-start;
  text-align: left;
  z-index: 1;
  opacity: 0;
  transform: translateX(-50%);
  background-color: transparent;
  background-image:
    linear-gradient(rgba(0,0,0,0.12), rgba(0,0,0,0.12)),
    linear-gradient(rgba(0,0,0,0.12), rgba(0,0,0,0.12)),
    linear-gradient(rgba(0,0,0,0.12), rgba(0,0,0,0.12)),
    linear-gradient(rgba(0,0,0,0.12), rgba(0,0,0,0.12));
  background-position: top center, right center, bottom center, left center;
  background-size: 0% 1px, 1px 0%, 0% 1px, 1px 0%;
  background-repeat: no-repeat;
  transition: opacity 0.1s ease, background-size 0.1s ease, background-color 0.1s ease;
}

.timeline-item.tl-visible .timeline-item__card {
  opacity: 1;
  background-size: 100% 1px, 1px 100%, 100% 1px, 1px 100%;
  background-color: #FFFFFF;
  transition: opacity 0.01s ease 0s, background-size 0.4s ease 0.5s, background-color 0.25s ease 0.75s;
}

.timeline-item__card::after {
  content: '';
  position: absolute;
  width: 1px;
  background: var(--accent);
  left: 50%;
  transform: scaleY(0);
  transition: transform 0.1s ease;
}

.timeline-item.tl-visible .timeline-item__card::after {
  transform: scaleY(1);
  transition: transform 0.25s ease 0.3s;
}

.timeline-item--top .timeline-item__card {
  bottom: calc(100% + 25px);
  left: 50%;
}
.timeline-item--top .timeline-item__card::after {
  top: 100%;
  height: 25px;
  transform-origin: bottom;
}

.timeline-item--bottom .timeline-item__card {
  top: calc(100% + 25px);
  left: 50%;
}
.timeline-item--bottom .timeline-item__card::after {
  bottom: 100%;
  height: 25px;
  transform-origin: top;
}

.timeline-item.tl-visible:hover .timeline-item__card {
  background-image:
    linear-gradient(var(--accent), var(--accent)),
    linear-gradient(var(--accent), var(--accent)),
    linear-gradient(var(--accent), var(--accent)),
    linear-gradient(var(--accent), var(--accent));
  box-shadow: 0 4px 20px rgba(3, 114, 255, 0.1);
}

.timeline-item__year {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--abenex-orange);
  margin-bottom: 0.75rem;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.1s ease;
}

.timeline-item__text {
  font-size: 1rem;
  line-height: 1.7;
  color: var(--text-muted-dark);
  opacity: 0;
  transition: opacity 0.1s ease;
}

.timeline-item__text p { margin: 0; }
.timeline-item__text p + p { margin-top: 0.5rem; }
.timeline-item__text strong { font-weight: 700; color: var(--text-dark); }

.timeline-item.tl-visible .timeline-item__year {
  opacity: 1;
  transition: opacity 0.3s ease 0.9s;
}

.timeline-item.tl-visible .timeline-item__text {
  opacity: 1;
  transition: opacity 0.3s ease 1.05s;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 1024px) {
  .timeline-section .timeline-sticky {
    padding: 2rem;
  }
}

@media (max-width: 768px) {
  /* Timeline verticale en mobile */
  .timeline-outer {
    height: auto;
  }

  .timeline-sticky {
    position: relative;
    height: auto;
    padding: 4rem 1.5rem;
  }

  .timeline-viewport {
    overflow: visible;
  }

  .timeline-track {
    flex-direction: column;
    align-items: flex-start;
    padding: 0 0 0 2rem;
    width: auto;
    transform: none !important;
  }

  .timeline-track__line {
    display: none;
  }

  .timeline-center-line {
    display: none;
  }

  .timeline-item {
    width: 100%;
    flex-direction: row;
    align-items: flex-start;
    padding-left: 2rem;
    margin-bottom: 2rem;
    opacity: 1;
    transform: none;
  }

  .timeline-item__dot {
    position: absolute;
    left: -2rem;
    top: 0.5rem;
    transform: none !important;
    opacity: 1 !important;
  }

  .timeline-item__card {
    position: relative;
    top: auto !important;
    bottom: auto !important;
    left: auto !important;
    transform: none !important;
    width: 100%;
    height: auto;
  }

  .timeline-item__card::after {
    display: none;
  }
}

@media (max-width: 480px) {
  .timeline-section { padding: 4rem 1rem 2rem; }
}

/* Hauteur écran limitée (1280×720, laptops 1366×768) :
   - cartes plus compactes pour tenir dans le sticky 100vh
   - bg-year réduit pour éviter les chevauchements (le JS applique un scale 0.8–2.5)
   `min-width: 769px` pour ne pas écraser le mode mobile vertical. */
@media (max-height: 800px) and (min-width: 769px) {
  .timeline-item__card {
    width: 220px;
    height: 200px;
    padding: 1.25rem;
  }
  .timeline-item--top .timeline-item__card { bottom: calc(100% + 18px); }
  .timeline-item--top .timeline-item__card::after { height: 18px; }
  .timeline-item--bottom .timeline-item__card { top: calc(100% + 18px); }
  .timeline-item--bottom .timeline-item__card::after { height: 18px; }

  .timeline-item__bg-year {
    font-size: clamp(2rem, 4vw, 3rem);
  }
  .timeline-item__year {
    font-size: 1.125rem;
    margin-bottom: 0.5rem;
  }
  .timeline-item__text {
    font-size: 0.875rem;
    line-height: 1.55;
  }
}
