/* ==========================================================================
   TYConsulting — Mouvement
   transform / opacity / tracés SVG uniquement ; états masqués seulement sous
   .js ; tout visible sans JavaScript ou après le filet de sécurité
   (.reveal-fallback). Reduced motion : fondus courts conservés, déplacements,
   tracés et boucles supprimés.

   Chaque animation raconte quelque chose :
   - héros : le titre arrive, puis le système d'information passe du désordre au plan ;
   - expertises : le rail s'allume point par point ;
   - offres et méthode : une courbe ascendante qui se trace, les cartes qui la suivent ;
   - icônes dessinées : l'argument s'écrit au moment où on le lit ;
   - champ présélectionné : la page montre ce qu'elle vient de remplir.
   ========================================================================== */

/* -------------------------------------------------------------------------
   1. Héros : texte
   ------------------------------------------------------------------------- */

.js:not(.hero-ready) [data-hero]:not([data-hero="map"]):not(.line) {
  opacity: 0;
}

.js:not(.hero-ready) .hero__title .line__inner {
  transform: translateY(110%);
}

.js:not(.hero-ready) .hero__kicker,
.js:not(.hero-ready) .hero__lead,
.js:not(.hero-ready) .hero__actions,
.js:not(.hero-ready) .repere {
  transform: translateY(14px);
}

.js [data-hero]:not([data-hero="map"]) {
  transition: opacity var(--dur-hero) var(--ease-out), transform var(--dur-hero) var(--ease-out);
}

.js .hero__title .line__inner {
  transition: transform var(--dur-hero) var(--ease-out);
}

.js.hero-ready [data-hero="1"] { transition-delay: 0ms; }
.js.hero-ready [data-hero="2"] .line__inner { transition-delay: 80ms; }
.js.hero-ready [data-hero="3"] .line__inner { transition-delay: 160ms; }
.js.hero-ready [data-hero="4"] .line__inner { transition-delay: 240ms; }
.js.hero-ready [data-hero="5"] { transition-delay: 380ms; }
.js.hero-ready [data-hero="6"] { transition-delay: 460ms; }
.js.hero-ready [data-hero="7"] { transition-delay: 900ms; }
.js.hero-ready [data-hero="8"] { transition-delay: 980ms; }
.js.hero-ready [data-hero="9"] { transition-delay: 1060ms; }
.js.hero-ready [data-hero="10"] { transition-delay: 1140ms; }

/* Cadre de la carte : arrive avec le titre */
.js:not(.hero-ready) .simap {
  opacity: 0;
  transform: translateY(18px) scale(0.98);
}

.js .simap {
  transition: opacity var(--dur-hero) var(--ease-out) 200ms, transform var(--dur-hero) var(--ease-out) 200ms;
}

/* -------------------------------------------------------------------------
   2. Carte du SI : « avant » (html.map-before) → « après » (par défaut)
   Les nœuds glissent vers leur couche, les liens emmêlés s'effacent,
   les flux structurés se tracent, les couches se nomment.
   ------------------------------------------------------------------------- */

.js .simap__node {
  transition: transform var(--dur-map) var(--ease-in-out);
}

.js.map-before .simap__node {
  transform: translate(var(--bx), var(--by)) rotate(var(--br));
}

/* Les nœuds partent dans le désordre, chacun avec un léger décalage */
.js .simap__node:nth-child(2)  { transition-delay: 40ms; }
.js .simap__node:nth-child(3)  { transition-delay: 80ms; }
.js .simap__node:nth-child(4)  { transition-delay: 120ms; }
.js .simap__node:nth-child(5)  { transition-delay: 160ms; }
.js .simap__node:nth-child(6)  { transition-delay: 200ms; }
.js .simap__node:nth-child(7)  { transition-delay: 240ms; }
.js .simap__node:nth-child(8)  { transition-delay: 280ms; }
.js .simap__node:nth-child(9)  { transition-delay: 320ms; }
.js .simap__node:nth-child(10) { transition-delay: 360ms; }

.js .simap__tangle {
  transition: opacity 500ms var(--ease-out);
  opacity: 0;
}

.js.map-before .simap__tangle {
  opacity: 1;
  transition-delay: 300ms;
}

.js .simap__layers {
  transition: opacity 600ms var(--ease-out) 500ms;
  opacity: 1;
}

.js.map-before .simap__layers {
  opacity: 0;
  transition-delay: 0ms;
}

.js .simap__links path {
  stroke-dasharray: 1;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 800ms var(--ease-in-out) 700ms, opacity var(--dur-hover) var(--ease-hover), stroke-width var(--dur-hover) var(--ease-hover);
}

.js .simap__links path:nth-child(2) { transition-delay: 780ms, 0ms, 0ms; }
.js .simap__links path:nth-child(3) { transition-delay: 860ms, 0ms, 0ms; }
.js .simap__links path:nth-child(4) { transition-delay: 940ms, 0ms, 0ms; }
.js .simap__links path:nth-child(5) { transition-delay: 1020ms, 0ms, 0ms; }
.js .simap__links path:nth-child(6) { transition-delay: 1100ms, 0ms, 0ms; }
.js .simap__links path:nth-child(7) { transition-delay: 1180ms, 0ms, 0ms; }
.js .simap__links path:nth-child(8) { transition-delay: 1260ms, 0ms, 0ms; }

.js.map-before .simap__links path {
  stroke-dashoffset: 1;
  transition-delay: 0ms;
  transition-duration: 300ms;
}

/* Survol d'un nœud : ses flux ressortent, les autres s'estompent (dépendances) */
.simap.is-focus .simap__links path {
  opacity: 0.25;
}

.simap.is-focus .simap__links path.is-hot {
  opacity: 1;
  stroke-width: 3;
}

.simap.is-focus .simap__node {
  opacity: 0.45;
  transition: opacity var(--dur-hover) var(--ease-hover), transform var(--dur-map) var(--ease-in-out);
}

.simap.is-focus .simap__node.is-hot {
  opacity: 1;
}

.simap__node.is-hot rect {
  stroke: var(--teal);
}

/* Respiration très lente des flux (données qui circulent), opacité seulement */
.js:not(.map-before) .simap__links path {
  animation: flow-breathe 4200ms ease-in-out 2200ms infinite;
}

.js:not(.map-before) .simap__links path:nth-child(even) {
  animation-delay: 3200ms;
}

@keyframes flow-breathe {
  50% { opacity: 0.6; }
}

.simap.is-focus .simap__links path {
  animation: none;
}

/* -------------------------------------------------------------------------
   3. Apparitions au défilement
   ------------------------------------------------------------------------- */

.js [data-reveal],
.js [data-reveal-group] > * {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity var(--dur-reveal) var(--ease-out), transform var(--dur-reveal) var(--ease-out);
}

.js [data-reveal].is-visible,
.js [data-reveal-group].is-visible > * {
  opacity: 1;
  transform: none;
}

.js [data-reveal-group].is-visible > :nth-child(2) { transition-delay: 70ms; }
.js [data-reveal-group].is-visible > :nth-child(3) { transition-delay: 140ms; }
.js [data-reveal-group].is-visible > :nth-child(4) { transition-delay: 210ms; }
.js [data-reveal-group].is-visible > :nth-child(5) { transition-delay: 280ms; }
.js [data-reveal-group].is-visible > :nth-child(6) { transition-delay: 350ms; }

/* La courbe SVG d'un groupe n'est pas un élément à faire glisser */
.js [data-reveal-group] > svg {
  transform: none;
}

/* Titres de section */
.js [data-reveal] .section__title .line__inner,
.js [data-reveal] .final__title .line__inner {
  transform: translateY(110%);
  transition: transform var(--dur-hero) var(--ease-out) 80ms;
}

.js [data-reveal].is-visible .section__title .line__inner,
.js [data-reveal].is-visible .final__title .line__inner {
  transform: none;
}

/* Icônes qui se dessinent */
.js [data-reveal-group] > * > .icon--lg {
  stroke-dasharray: 90;
  stroke-dashoffset: 90;
  transition: stroke-dashoffset 1100ms var(--ease-in-out) 200ms;
}

.js [data-reveal-group] > * .xp__icon {
  stroke-dasharray: 90;
  stroke-dashoffset: 90;
  transition: stroke-dashoffset 1100ms var(--ease-in-out) 300ms;
}

.js [data-reveal-group].is-visible > * > .icon--lg,
.js [data-reveal-group].is-visible > * .xp__icon {
  stroke-dashoffset: 0;
}

/* Expertises : les points du rail s'allument l'un après l'autre */
.js .xp.is-visible .xp__num {
  border-color: var(--teal);
  background: var(--teal);
  color: var(--navy-900);
}

.js .xp.is-visible > :nth-child(1) .xp__num { transition-delay: 200ms; }
.js .xp.is-visible > :nth-child(2) .xp__num { transition-delay: 320ms; }
.js .xp.is-visible > :nth-child(3) .xp__num { transition-delay: 440ms; }
.js .xp.is-visible > :nth-child(4) .xp__num { transition-delay: 560ms; }
.js .xp.is-visible > :nth-child(5) .xp__num { transition-delay: 680ms; }

/* Offres : la courbe se trace, les points apparaissent avec leur carte */
.js .ladder__path {
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  transition: stroke-dashoffset 1400ms var(--ease-in-out) 100ms;
}

.js .ladder.is-visible .ladder__path {
  stroke-dashoffset: 0;
}

.js .offer__dot {
  transform: scale(0);
  transition: transform 400ms var(--ease-out);
}

.js .ladder.is-visible .offer__dot {
  transform: scale(1);
}

.js .ladder.is-visible > :nth-child(2) .offer__dot { transition-delay: 300ms; }
.js .ladder.is-visible > :nth-child(3) .offer__dot { transition-delay: 600ms; }
.js .ladder.is-visible > :nth-child(4) .offer__dot { transition-delay: 900ms; }
.js .ladder.is-visible > :nth-child(5) .offer__dot { transition-delay: 1200ms; }

/* Méthode : la courbe du projet, liée au défilement quand le navigateur le permet */
.js .method__path {
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  transition: stroke-dashoffset 1600ms var(--ease-in-out) 150ms;
}

.js .method.is-visible .method__path {
  stroke-dashoffset: 0;
}

@supports (animation-timeline: view()) {
  .js .method__path {
    transition: none;
    animation: draw-path linear both;
    animation-timeline: view();
    animation-range: entry 30% cover 55%;
  }

  @keyframes draw-path {
    from { stroke-dashoffset: 1; }
    to   { stroke-dashoffset: 0; }
  }
}

/* Mini-schémas des étapes : se dessinent avec leur carte */
.js .mstep__diagram path {
  stroke-dasharray: 160;
  stroke-dashoffset: 160;
  transition: stroke-dashoffset 1200ms var(--ease-in-out) 300ms;
}

.js .mstep__diagram circle {
  transform: scale(0);
  transform-box: fill-box;
  transform-origin: center;
  transition: transform 400ms var(--ease-out) 500ms;
}

.js .method__steps.is-visible .mstep__diagram path {
  stroke-dashoffset: 0;
}

.js .method__steps.is-visible .mstep__diagram circle {
  transform: scale(1);
}

/* Bandeau final : la courbe du logo se trace */
.js .final__mark path {
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  transition: stroke-dashoffset 1200ms var(--ease-in-out) 200ms;
}

.js .final.is-visible .final__mark path {
  stroke-dashoffset: 0;
}

/* Filet de sécurité */
.js.reveal-fallback [data-reveal],
.js.reveal-fallback [data-reveal-group] > *,
.js.reveal-fallback [data-reveal] .line__inner,
.js.reveal-fallback .repere {
  opacity: 1;
  transform: none;
}

.js.reveal-fallback [data-reveal-group] > * > .icon--lg,
.js.reveal-fallback .xp__icon,
.js.reveal-fallback .ladder__path,
.js.reveal-fallback .method__path,
.js.reveal-fallback .mstep__diagram path,
.js.reveal-fallback .final__mark path {
  stroke-dashoffset: 0;
  animation: none;
}

.js.reveal-fallback .offer__dot,
.js.reveal-fallback .mstep__diagram circle {
  transform: scale(1);
}

/* -------------------------------------------------------------------------
   4. Reduced motion
   ------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .js:not(.hero-ready) [data-hero],
  .js:not(.hero-ready) .hero__title .line__inner,
  .js:not(.hero-ready) .simap,
  .js [data-reveal],
  .js [data-reveal-group] > *,
  .js [data-reveal] .section__title .line__inner,
  .js [data-reveal] .final__title .line__inner {
    transform: none;
  }

  .js [data-hero],
  .js .hero__title .line__inner,
  .js .simap,
  .js [data-reveal],
  .js [data-reveal-group] > *,
  .js [data-reveal] .line__inner,
  .js .simap__tangle,
  .js .simap__layers {
    transition-duration: 200ms;
    transition-delay: 0ms !important;
  }

  /* La carte bascule sans glissement : fondu croisé des deux états */
  .js .simap__node {
    transition: none;
  }

  .js .simap__links path {
    stroke-dashoffset: 0 !important;
    transition: opacity 200ms ease;
    animation: none !important;
  }

  .js.map-before .simap__links path {
    opacity: 0;
  }

  .js [data-reveal-group] > * > .icon--lg,
  .js .xp__icon,
  .js .ladder__path,
  .js .method__path,
  .js .mstep__diagram path,
  .js .final__mark path {
    stroke-dashoffset: 0;
    transition: none;
    animation: none;
  }

  .js .offer__dot,
  .js .mstep__diagram circle {
    transform: scale(1);
    transition: none;
  }

  .js .xp__num {
    transition-delay: 0ms !important;
  }

  .field__input.is-prefilled {
    animation: none;
    box-shadow: 0 0 0 3px rgba(19, 168, 158, 0.3);
  }

  .nav,
  .nav__list li,
  .nav-backdrop {
    transition-duration: 150ms;
    transition-delay: 0ms !important;
  }

  .nav__list li {
    transform: none !important;
  }

  .btn,
  .btn::before,
  .btn__icon,
  .offer,
  .sector,
  .nav__link::after {
    transition-duration: 0ms;
  }
}
