/* ==========================================================================
   The signal — the site's recurring motion motif (behaviour: assets/js/signal.js)

   It is born where the hands touch in the hero and changes form at four
   moments, each played once when the reader crosses its threshold:
     birth  — a spark runs into "Co robimy" and bursts into the field of dots,
     branch — one pulse runs through the line that joins the capabilities,
     focus  — particles gather into the iris and the eye opens,
     world  — the globe, drawn in dots, rises out of the dark.
   Every state here is opt-in (.is-armed / .is-playing, set by signal.js):
   without JavaScript or with reduced motion the page shows the final state.
   ========================================================================== */

/* Particle stages exist only while a moment plays. */
.signal-canvas {
  position: absolute;
  z-index: -1;
  pointer-events: none;
}

/* ---- Birth: from the hero into "Co robimy" ------------------------------------ */

.intro.is-armed .intro__thread {
  clip-path: inset(0 0 100% 0);
}

.intro.is-armed::before {
  opacity: 0;
}

.intro.is-armed .eyebrow,
.intro.is-armed .section-title,
.intro.is-armed .section-lead {
  opacity: 0;
  transform: translateY(1rem);
}

.intro.is-armed .eyebrow::before {
  transform: scale(0);
}

/* the thread draws itself just ahead of the spark */
.intro.is-playing .intro__thread {
  transition: clip-path var(--signal-thread-duration, 0.5s) cubic-bezier(0.65, 0, 0.35, 1)
    var(--signal-thread-delay, 0s);
}

/* the field of dots takes over from the particles as they land */
.intro.is-playing::before {
  transition: opacity 0.8s ease var(--signal-field-delay, 1.1s);
}

.intro.is-playing .eyebrow,
.intro.is-playing .section-title,
.intro.is-playing .section-lead {
  transition:
    opacity 0.9s cubic-bezier(0.2, 0.7, 0.2, 1),
    transform 0.9s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.intro.is-playing .eyebrow {
  transition-delay: calc(var(--signal-arrive, 0.65s) - 0.1s);
}

.intro.is-playing .section-title {
  transition-delay: calc(var(--signal-arrive, 0.65s) + 0.12s);
}

.intro.is-playing .section-lead {
  transition-delay: calc(var(--signal-arrive, 0.65s) + 0.26s);
}

.intro.is-playing .eyebrow::before {
  animation: signal-pop 0.7s cubic-bezier(0.3, 1.6, 0.5, 1) var(--signal-arrive, 0.65s) both;
}

@keyframes signal-pop {
  from {
    transform: scale(0);
  }
}

/* ---- Branch: one pulse through the capabilities ---------------------------------
   The line joining the icon tiles is laid out by signal.js (--bus-*), so it is
   part of the structure even when nothing moves. */

.services__track {
  position: relative;
}

.signal-bus {
  display: none;
  position: absolute;
  top: var(--bus-top, 0);
  left: calc(var(--bus-x, 0px) - 1px);
  width: 2px;
  height: var(--bus-h, 0);
  background: radial-gradient(circle, rgb(255 255 255 / 0.4) 0 1px, transparent 1.4px) center top / 2px 10px repeat-y;
  pointer-events: none;
}

.services__track.has-bus .signal-bus {
  display: block;
}

/* opaque tiles, so the line passes behind them */
.services__track .service__tile {
  position: relative;
  z-index: 1;
  background: linear-gradient(180deg, #161618, #0e0e0f);
}

/* the bright head of the pulse */
.signal-bus::after {
  content: "";
  position: absolute;
  top: -72px;
  left: -1px;
  width: 4px;
  height: 72px;
  border-radius: 2px;
  background: linear-gradient(to bottom, rgb(242 163 94 / 0), var(--color-accent));
  opacity: 0;
}

.services__track.is-armed .signal-bus {
  clip-path: inset(0 0 100% 0);
}

.services__track.is-playing .signal-bus {
  animation: signal-draw var(--branch-duration, 1.8s) cubic-bezier(0.11, 0, 0.5, 0) both;
}

.services__track.is-playing .signal-bus::after {
  animation:
    signal-pulse-move var(--branch-duration, 1.8s) cubic-bezier(0.11, 0, 0.5, 0) both,
    signal-pulse-fade var(--branch-duration, 1.8s) linear both;
}

/* each tile lights up as the pulse reaches it (delay set by signal.js) */
.services__track.is-playing .service__tile {
  animation: signal-ignite 1.1s cubic-bezier(0.2, 0.7, 0.2, 1) var(--ignite-delay, 0ms);
}

.services__track.is-playing .service__icon {
  animation: signal-ignite-dots 1.1s cubic-bezier(0.2, 0.7, 0.2, 1) var(--ignite-delay, 0ms);
}

@keyframes signal-draw {
  from {
    clip-path: inset(0 0 100% 0);
  }
  to {
    clip-path: inset(0 0 0 0);
  }
}

@keyframes signal-pulse-move {
  from {
    transform: translateY(0);
  }
  to {
    transform: translateY(var(--bus-h, 0));
  }
}

@keyframes signal-pulse-fade {
  0%,
  88% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

@keyframes signal-ignite {
  15% {
    border-color: var(--color-accent);
    box-shadow: 0 0 0 4px var(--color-accent-soft);
  }
}

@keyframes signal-ignite-dots {
  15% {
    fill: var(--color-accent);
  }
}

/* ---- Focus: particles gather and the eye opens -------------------------------- */

.examples__eye {
  position: relative;
}

.examples__eye .signal-canvas {
  z-index: 1;
}

.examples__eye.is-armed .examples__eye-video {
  opacity: 0;
  transform: scale(0.92);
}

.examples__eye.is-playing .examples__eye-video {
  transition:
    opacity 0.9s cubic-bezier(0.2, 0.7, 0.2, 1) var(--signal-open-delay, 0.5s),
    transform 1.2s cubic-bezier(0.2, 0.7, 0.2, 1) var(--signal-open-delay, 0.5s);
}

/* ---- World: the globe rises out of the dark ------------------------------------- */

.world__globe.is-armed .world__video {
  opacity: 0;
  transform: translateY(6%);
}

.world__globe.is-playing .world__video {
  transition:
    opacity 1.6s cubic-bezier(0.2, 0.7, 0.2, 1),
    transform 2.4s cubic-bezier(0.2, 0.7, 0.2, 1);
}

/* ---- Reduced motion: nothing moves; the structure (the line) stays --------------- */

@media (prefers-reduced-motion: reduce) {
  .signal-canvas {
    display: none;
  }

  .services__track.is-playing .signal-bus,
  .services__track.is-playing .signal-bus::after,
  .services__track.is-playing .service__tile,
  .services__track.is-playing .service__icon {
    animation: none;
  }
}
