/*
 * Bodylet AI: motion
 *
 * Rules of the house:
 *   1. Animate transform and opacity only (plus canvas drawing).
 *   2. Nothing moves unless it explains something or rewards attention.
 *   3. prefers-reduced-motion gets a still, complete page.
 *   4. Without JavaScript everything is visible: the hidden start state of a
 *      reveal only applies under html.bl-js, which reveal.js sets.
 *
 * Durations and easings are tokens (--bl-dur-*, --bl-ease-*).
 */

/* ── Reveal on scroll (driven by reveal.js) ─────────────────────────────── */

.bl-js .bl-reveal {
  opacity: 0;
  transform: translate3d(0, var(--bl-reveal-y, 18px), 0);
  transition:
    opacity var(--bl-dur-4) var(--bl-ease-out) var(--bl-reveal-delay, 0ms),
    transform var(--bl-dur-5) var(--bl-ease-out) var(--bl-reveal-delay, 0ms);
}

.bl-js .bl-reveal.is-visible {
  opacity: 1;
  transform: none;
}

.bl-js .bl-reveal--fade {
  --bl-reveal-y: 0px;
}

.bl-js .bl-reveal--scale {
  transform: scale(0.97);
}

/* ── Keyframes ──────────────────────────────────────────────────────────── */

@keyframes bl-fade-in {
  from {
    opacity: 0;
  }
}

@keyframes bl-fade-up {
  from {
    opacity: 0;
    transform: translate3d(0, 14px, 0);
  }
}

@keyframes bl-float {
  0%,
  100% {
    transform: translate3d(0, calc(var(--bl-float, 6px) * -1), 0);
  }

  50% {
    transform: translate3d(0, var(--bl-float, 6px), 0);
  }
}

@keyframes bl-breathe {
  0%,
  100% {
    opacity: var(--bl-breathe-min, 0.55);
  }

  50% {
    opacity: 1;
  }
}

@keyframes bl-spin {
  to {
    transform: rotate(1turn);
  }
}

/* A ring that grows and fades: presence, a pulse leaving a source. */
@keyframes bl-ripple {
  0% {
    opacity: 0.8;
    transform: scale(0.35);
  }

  100% {
    opacity: 0;
    transform: scale(1.5);
  }
}

/* ── Utilities ──────────────────────────────────────────────────────────── */

.bl-anim-float {
  animation: bl-float var(--bl-float-dur, 7s) var(--bl-ease-in-out) infinite;
}

.bl-anim-breathe {
  animation: bl-breathe var(--bl-breathe-dur, 4s) ease-in-out infinite;
}

.bl-anim-spin {
  animation: bl-spin 0.9s linear infinite;
}

/* Sections that are off screen can stop their CSS animations: lifecycle.js
   toggles .is-offscreen on elements registered with pauseWhenHidden(). */
.is-offscreen,
.is-offscreen * {
  animation-play-state: paused !important;
}

/* ── Reduced motion ─────────────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  .bl-js .bl-reveal,
  .bl-js .bl-reveal.is-visible {
    opacity: 1;
    transform: none;
    transition: none;
  }

  .bl-anim-float,
  .bl-anim-breathe,
  .bl-anim-spin {
    animation: none;
  }

  html {
    scroll-behavior: auto !important;
  }
}
