/* Rediall marketing site: motion for the hairline drawings (.art), driven by
   art-motion.js. Purpose: explanation. Each drawing assembles once when it
   becomes active (Modules) or scrolls into view (How it works): elements
   settle in back to front, accent connectors draw along their path, the
   PAID stamp lands, the trace steps light up in order. Dashed connectors
   then flow slowly while the drawing is on screen; that is the only
   continuous motion. Elements move with the individual `translate` and
   `scale` properties so the SVG `transform` attributes on labels survive.
   Without JS, with reduced motion and in print the drawings stay static and
   complete. --art-base offsets a whole drawing: the hero diagram waits for
   the headline words. Loads after modules.css, before motion.css. */

.hero-art {
  --art-base: 500ms;
}

@keyframes art-in {
  from {
    opacity: 0;
    translate: 0 6px;
  }
}

@keyframes art-draw {
  from {
    stroke-dashoffset: 1;
  }

  to {
    stroke-dashoffset: 0;
  }
}

@keyframes art-stamp {
  from {
    opacity: 0;
    scale: 1.18;
  }

  60% {
    opacity: 1;
    scale: 0.97;
  }
}

@keyframes art-flow {
  to {
    stroke-dashoffset: -12;
  }
}

@keyframes trace-in {
  from {
    opacity: 0.25;
  }
}

/* armed by art-motion.js: hidden until the drawing plays */
.art[data-anim="wait"] svg > *,
.art[data-anim="wait"] .trace span {
  opacity: 0;
}

.art[data-anim="play"] svg > * {
  --delay: calc(var(--art-base, 0ms) + min(var(--k, 0), 40) * 24ms);
  animation: art-in 420ms var(--ease-out) var(--delay) both;
}

/* accent connectors draw along their path (pathLength="1" set in JS) */
.art[data-anim="play"] svg > .a:not(.dash) {
  stroke-dasharray: 1;
  animation:
    art-in 200ms var(--ease-out) var(--delay) both,
    art-draw 700ms var(--ease-in-out) var(--delay) both;
}

/* the PAID stamp lands */
.art[data-anim="play"] svg > .g {
  transform-box: fill-box;
  transform-origin: center;
  animation: art-stamp 520ms var(--ease-out) var(--delay) both;
}

/* dashed connectors flow while the drawing is on screen */
.art[data-anim="play"].is-live svg > .dash {
  animation:
    art-in 420ms var(--ease-out) var(--delay) both,
    art-flow 1.6s linear calc(var(--delay) + 420ms) infinite;
}

/* the trace lights up step by step as the drawing completes */
.art[data-anim="play"] .trace span {
  animation: trace-in 360ms var(--ease-out) both;
}

.art[data-anim="play"] .trace span:nth-child(1) {
  animation-delay: calc(var(--art-base, 0ms) + 300ms);
}

.art[data-anim="play"] .trace span:nth-child(2) {
  animation-delay: calc(var(--art-base, 0ms) + 650ms);
}

.art[data-anim="play"] .trace span:nth-child(3) {
  animation-delay: calc(var(--art-base, 0ms) + 1000ms);
}

.art[data-anim="play"] .trace span:nth-child(4) {
  animation-delay: calc(var(--art-base, 0ms) + 1350ms);
}

/* the hero is on screen at first paint: keep it hidden until art-motion.js
   arms it. If the script never runs, it fades in on its own. */
@media (prefers-reduced-motion: no-preference) {
  .js .hero-art:not([data-anim]) svg > *,
  .js .hero-art:not([data-anim]) .trace span {
    animation: art-in 420ms var(--ease-out) 500ms both;
  }

  /* the hero scene settles in once the headline has started */
  .js .hero-art .rd {
    animation: art-in 420ms var(--ease-out) 500ms both;
  }
}

@media (prefers-reduced-motion: reduce) {
  .art[data-anim] svg > *,
  .art[data-anim] .trace span {
    opacity: 1;
    animation: none;
  }
}

@media print {
  .art[data-anim] svg > *,
  .art[data-anim] .trace span {
    opacity: 1 !important;
    animation: none !important;
  }
}
