/* Ouest Intelligence — motion design.
   Un moment fort (les outils qui se relient), trois animations au service du propos.
   Tout est désactivé si l'utilisateur demande moins d'animations (classe .motion absente). */

:root {
  --m-glass: #5b8fd6;
  --m-glass-soft: #a9c4e6;
  --m-porcelain: #f5f8fb;
  --m-night: #0e2c53;
  --m-out: cubic-bezier(0.16, 1, 0.3, 1);
  --m-write: cubic-bezier(0.45, 0.05, 0.55, 0.95);
}

/* Structure (toujours active) */
.hero h1 .h1-line {
  display: block;
}
.hero-handwriting .hw-line {
  display: inline-block;
  font-style: normal;
}

/* ---------- 1. Hero : une entrée, une signature qui s'écrit ---------- */
.motion .hero-photo {
  animation: m-photo 2.8s var(--m-out) both;
  will-change: transform;
}
.motion .hero .eyebrow {
  animation: m-fade 0.7s 0.05s var(--m-out) both;
}
.motion .hero h1 .h1-line {
  overflow: hidden;
  padding-bottom: 0.08em;
  margin-bottom: -0.08em;
}
.motion .hero h1 .h1-line > span {
  display: inline-block;
  animation: m-rise 0.95s var(--m-out) both;
}
.motion .hero h1 .h1-line:nth-child(1) > span {
  animation-delay: 0.12s;
}
.motion .hero h1 .h1-line:nth-child(2) > span {
  animation-delay: 0.24s;
}
.motion .hero-lead {
  animation: m-lift 0.8s 0.42s var(--m-out) both;
}
.motion .hero-actions {
  animation: m-lift 0.8s 0.55s var(--m-out) both;
}
.motion .hero-example-link,
.motion .hero-target {
  animation: m-fade 0.8s 0.7s var(--m-out) both;
}
.motion .hero-handwriting .hw-line {
  clip-path: inset(-20% 100% -30% 0);
  animation: m-write 0.75s var(--m-write) forwards;
}
.motion .hero-handwriting .hw-line:nth-of-type(1) {
  animation-delay: 1s;
}
.motion .hero-handwriting .hw-line:nth-of-type(2) {
  animation-delay: 1.7s;
  animation-duration: 0.95s;
}
.motion .hero-handwriting .hw-line:nth-of-type(3) {
  animation-delay: 2.6s;
  animation-duration: 0.9s;
}
.motion .hero-handwriting .hw-sign {
  clip-path: inset(-20% 100% -40% 0);
  animation: m-write 0.55s 3.55s var(--m-write) forwards;
}
.motion .hero-handwriting .hw-sign:after {
  transform: rotate(-4deg) scaleX(0);
  transform-origin: left center;
  animation: m-underline 0.45s 4.05s var(--m-out) forwards;
}
.motion .photo-note {
  animation: m-fade 1s 1.4s ease both;
}

@keyframes m-photo {
  from {
    transform: scale(1.07);
  }
  to {
    transform: scale(1);
  }
}
@keyframes m-fade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
@keyframes m-rise {
  from {
    transform: translateY(105%);
  }
  to {
    transform: none;
  }
}
@keyframes m-lift {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@keyframes m-write {
  to {
    clip-path: inset(-20% 0 -30% 0);
  }
}
@keyframes m-underline {
  to {
    transform: rotate(-4deg) scaleX(1);
  }
}

/* ---------- 2. Outils : des données dispersées qui se relient ---------- */
.cv-links {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}
.cv-scene.m-live .cv-background {
  opacity: 0;
  transition: opacity 0.6s;
}
.cv-scene.m-live .cv-copy {
  position: relative;
  z-index: 2;
  transition:
    box-shadow 0.5s,
    border-color 0.5s;
}
.cv-scene.m-live .cv-tools {
  position: relative;
  z-index: 1;
}
.cv-scene.m-live .cv-tool {
  background: rgba(255, 255, 255, 0.96);
  transition:
    transform 1.1s var(--m-out),
    opacity 0.9s var(--m-out),
    filter 0.9s var(--m-out),
    border-color 0.3s,
    box-shadow 0.3s;
  transition-delay: var(--m-d, 0s);
}
.cv-scene.m-live .cv-tool img {
  opacity: 1;
}
.cv-scene.m-armed .cv-tool {
  opacity: 0.85;
  filter: grayscale(1) contrast(0.9);
  transform: translate(var(--m-x, 0), var(--m-y, 0)) rotate(var(--m-r, 0));
}
.cv-scene.m-live .cv-tool.is-hot {
  border-color: var(--m-glass);
  box-shadow: 0 0 0 4px rgba(91, 143, 214, 0.12);
}
.cv-scene.m-done .cv-tool {
  transition-delay: 0s;
}
.cv-copy.is-received {
  border-color: #8fb0d6;
  box-shadow:
    0 0 0 5px rgba(91, 143, 214, 0.1),
    0 18px 42px rgba(16, 51, 97, 0.1);
}
.cv-copy.is-complete {
  animation: m-card 1.6s var(--m-out);
}
@keyframes m-card {
  0% {
    box-shadow: 0 14px 36px rgba(16, 51, 97, 0.05);
  }
  35% {
    box-shadow:
      0 0 0 10px rgba(91, 143, 214, 0.14),
      0 22px 50px rgba(16, 51, 97, 0.14);
  }
  100% {
    box-shadow: 0 14px 36px rgba(16, 51, 97, 0.05);
  }
}
.cv-link {
  fill: none;
  stroke: #8fb0d6;
  stroke-width: 1.4;
  stroke-linecap: round;
  opacity: 0.75;
  transition:
    opacity 0.3s,
    stroke-width 0.3s;
}
.cv-link.is-hot {
  opacity: 1;
  stroke-width: 2.2;
  stroke: #6f98cf;
}
.cv-streak {
  fill: none;
  stroke: var(--m-glass);
  stroke-width: 2.4;
  stroke-linecap: round;
}
.cv-pulse {
  fill: #3f73c0;
}
.cv-pulse-halo {
  fill: var(--m-glass);
  opacity: 0.22;
}
.cv-port {
  fill: var(--white);
  stroke: #8fb0d6;
  stroke-width: 1.4;
  transition:
    fill 0.25s,
    stroke 0.25s;
}
.cv-port.is-lit {
  fill: var(--m-glass);
  stroke: var(--m-glass);
}
.cv-port-ring {
  fill: none;
  stroke: var(--m-glass);
  stroke-width: 1.2;
  transform-box: fill-box;
  transform-origin: center;
  animation: m-port 0.7s var(--m-out) forwards;
}
@keyframes m-port {
  from {
    opacity: 0.8;
    transform: scale(1);
  }
  to {
    opacity: 0;
    transform: scale(3.2);
  }
}
@media (min-width: 1101px) {
  .motion .cv-scene {
    column-gap: 68px;
  }
}
@media (min-width: 801px) and (max-width: 1100px) {
  .motion .cv-scene {
    column-gap: 40px;
  }
}

/* ---------- 3. Avant / après : le parcours se déroule ---------- */
.tf-section.m-armed
  :is(.tf-before, .tf-after):not(.m-play)
  :is(
    .tf-manual-steps li,
    .tf-goal,
    .tf-sources li,
    .tf-arrow,
    .tf-agent,
    .tf-agent li,
    .tf-human
  ),
.tf-section.m-armed .tf-result:not(.m-play) {
  opacity: 0;
}
.m-play :is(.tf-goal, .tf-sources li),
.tf-result.m-play {
  animation: m-lift 0.7s var(--m-d, 0s) var(--m-out) both;
}
.tf-before.m-play .tf-manual-steps li {
  animation: m-slide 0.7s var(--m-d, 0s) var(--m-out) both;
}
.tf-after.m-play .tf-arrow {
  animation: m-drop 0.55s var(--m-d, 0s) var(--m-out) both;
}
.tf-after.m-play .tf-agent {
  position: relative;
  overflow: hidden;
  animation: m-open 0.8s var(--m-d, 0s) var(--m-out) both;
}
.tf-after.m-play .tf-agent:after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    100deg,
    transparent 30%,
    rgba(169, 196, 230, 0.28) 50%,
    transparent 70%
  );
  transform: translateX(-120%);
  animation: m-sweep 1.3s calc(var(--m-d, 0s) + 0.5s) ease-in-out both;
  pointer-events: none;
}
.tf-after.m-play .tf-agent li {
  animation: m-slide 0.55s var(--m-d, 0s) var(--m-out) both;
}
.tf-after .tf-sources li {
  transition:
    border-color 0.4s,
    background 0.4s;
}
.tf-after .tf-sources li.is-lit {
  border-color: var(--m-glass);
  background: #eef4fc;
}
.tf-after.m-play .tf-human {
  animation:
    m-lift 0.7s var(--m-d, 0s) var(--m-out) both,
    m-ring 1.8s calc(var(--m-d, 0s) + 0.5s) ease-out both;
}
@keyframes m-slide {
  from {
    opacity: 0;
    transform: translateX(-14px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@keyframes m-drop {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@keyframes m-open {
  from {
    opacity: 0;
    clip-path: inset(0 0 100% 0 round 7px);
  }
  to {
    opacity: 1;
    clip-path: inset(0 0 0 0 round 7px);
  }
}
@keyframes m-sweep {
  to {
    transform: translateX(120%);
  }
}
@keyframes m-ring {
  0% {
    box-shadow: 0 0 0 0 rgba(91, 143, 214, 0.35);
  }
  60% {
    box-shadow: 0 0 0 9px rgba(91, 143, 214, 0);
  }
  100% {
    box-shadow: none;
  }
}

/* ---------- 4. Chiffres réels ---------- */
[data-count] {
  font-variant-numeric: tabular-nums;
}

/* Sécurité : aucune animation si le visiteur l'a demandé */
@media (prefers-reduced-motion: reduce) {
  .cv-links {
    display: none;
  }
  .cv-scene .cv-tool,
  .tf-panel *,
  .tf-panel *:after {
    animation: none !important;
    transition: none !important;
    opacity: 1 !important;
    transform: none !important;
    filter: none !important;
  }
}

/* ---------- 5. Fil conducteur ---------- */
main.has-thread {
  position: relative;
}
.thread {
  position: absolute;
  z-index: 3;
  width: 2px;
  pointer-events: none;
  --thread: #5b8fd6;
  --thread-soft: rgba(91, 143, 214, 0.22);
}
.thread-track,
.thread-fill {
  position: absolute;
  inset: 0;
  border-radius: 2px;
}
.thread-track {
  background: linear-gradient(
    to bottom,
    transparent,
    var(--thread-soft) 40px,
    var(--thread-soft) calc(100% - 40px),
    transparent
  );
}
.thread-fill {
  background: linear-gradient(
    to bottom,
    rgba(91, 143, 214, 0.15),
    var(--thread) 120px
  );
  transform-origin: top;
  transform: scaleY(0);
  will-change: transform;
}
.thread-head {
  position: absolute;
  left: -4px;
  top: -5px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--thread);
  box-shadow:
    0 0 0 5px rgba(91, 143, 214, 0.18),
    0 0 18px rgba(91, 143, 214, 0.55);
  will-change: transform;
  transition: opacity 0.4s;
}
.thread-head.is-idle {
  opacity: 0;
}
.thread-node {
  position: absolute;
  left: -4px;
  top: -5px;
  width: 10px;
  height: 10px;
}
.thread-node i {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--white);
  border: 1.5px solid #a9c4e6;
  transition:
    background 0.35s var(--m-out),
    border-color 0.35s,
    transform 0.5s var(--m-out);
}
.thread-node b {
  position: absolute;
  left: 10px;
  top: 4px;
  width: var(--branch, 20px);
  height: 1.5px;
  background: var(--thread);
  transform-origin: left;
  transform: scaleX(0);
  transition: transform 0.7s 0.1s var(--m-out);
}
.thread-node.is-on i {
  background: var(--thread);
  border-color: var(--thread);
  transform: scale(1.15);
}
.thread-node.is-on b {
  transform: scaleX(1);
}
@media (max-width: 800px) {
  .thread-head {
    left: -3px;
    top: -4px;
    width: 8px;
    height: 8px;
    box-shadow:
      0 0 0 4px rgba(91, 143, 214, 0.18),
      0 0 12px rgba(91, 143, 214, 0.5);
  }
  .thread-node {
    left: -3px;
    top: -4px;
    width: 8px;
    height: 8px;
  }
  .thread-node b {
    left: 8px;
    top: 3.25px;
  }
}

/* ---------- 6. Apparitions au fil du scroll ---------- */
.m-reveal.m-wait {
  opacity: 0;
  transform: translateY(22px);
}
.m-reveal {
  transition:
    opacity 0.8s var(--m-out),
    transform 0.9s var(--m-out);
  transition-delay: calc(var(--m-i, 0) * 90ms);
}
.m-reveal.is-in {
  opacity: 1;
  transform: none;
}
.m-portrait img {
  transition:
    transform 1.4s var(--m-out),
    filter 1.2s var(--m-out);
}
.m-wait .m-portrait,
.m-portrait {
  transition: clip-path 1.1s var(--m-out);
}
.why-head.m-wait .m-portrait {
  clip-path: inset(100% 0 0 0 round 14px);
}
.why-head.m-wait .m-portrait img {
  transform: scale(1.12);
  filter: saturate(0.6);
}
.why-head.is-in .m-portrait {
  clip-path: inset(0 0 0 0 round 14px);
}
.clients-marquee.m-offscreen .clients-track {
  animation-play-state: paused;
}
@media (prefers-reduced-motion: reduce) {
  .thread {
    display: none;
  }
  .m-reveal {
    opacity: 1 !important;
    transform: none !important;
  }
}
