/*! motion-engine v0.1.0 (prototype). Drawing kit and scene behaviour, shared by both sites.
   Default CSS is the composed final frame. Motion applies only under html.motion, which the
   page sets when the visitor allows motion; nothing is hidden without JavaScript. */

/* ---------- Drawing kit ---------- */
.kit { overflow: visible; }
.kit .stroke { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.kit .node { stroke-width: 2.5; }
.kit .orbit, .kit .pulse { transform-box: view-box; }

/* ---------- Scene timing (only when motion is allowed) ---------- */
html.motion [data-scene] .draw {
  stroke-dasharray: 1 1;
  stroke-dashoffset: 1;
}
html.motion [data-scene].is-playing .draw {
  animation: kit-draw var(--d, 900ms) var(--ease-in-out) var(--delay, 0s) both;
}
html.motion [data-scene] .fade { opacity: 0; }
html.motion [data-scene].is-playing .fade {
  animation: kit-fade var(--d, 600ms) var(--ease-out) var(--delay, 0s) forwards;
}
html.motion [data-scene] .rise { opacity: 0; transform: translateY(0.6rem); }
html.motion [data-scene].is-playing .rise {
  animation: kit-rise var(--d, 700ms) var(--ease-out) var(--delay, 0s) forwards;
}
html.motion [data-scene] .ignite { opacity: 0; transform: scale(0.2); transform-box: fill-box; transform-origin: center; }
html.motion [data-scene].is-playing .ignite {
  animation: kit-ignite var(--d, 700ms) var(--ease-out) var(--delay, 0s) forwards;
}
html.motion [data-scene] .slide-l { transform: translateX(-9%); opacity: 0; }
html.motion [data-scene] .slide-r { transform: translateX(9%); opacity: 0; }
html.motion [data-scene].is-playing .slide-l,
html.motion [data-scene].is-playing .slide-r {
  animation: kit-meet var(--d, 1100ms) var(--ease-out) var(--delay, 0s) forwards;
}
/* Continuous turning after the sequence; frozen by the pause control. */
html.motion [data-scene].is-playing .orbit {
  animation: kit-spin var(--orbit) linear var(--delay, 4.6s) infinite;
}
html.motion [data-scene] .after { opacity: 0; }
html.motion [data-scene].is-playing .after {
  animation: kit-fade 500ms var(--ease-out) var(--delay, 4.6s) forwards;
}

html.motion [data-scene].is-playing .orbit.ccw { animation-direction: reverse; }
/* The turning bead is motion only: in a still frame it would read as a stray mark. */
html:not(.motion) .orbit { display: none; }
/* A pulse that travels a path (SMIL); hidden until its scene plays, so it never sits at the origin. */
.moving { opacity: 0; }
html.motion [data-scene].is-playing .moving { opacity: 1; transition: opacity 400ms var(--ease-out) 1.6s; }

@keyframes kit-draw {
  0% { stroke-dashoffset: 1; opacity: 0; }
  1% { opacity: 1; }
  100% { stroke-dashoffset: 0; opacity: 1; }
}
@keyframes kit-fade { to { opacity: 1; } }
@keyframes kit-rise { to { opacity: 1; transform: none; } }
@keyframes kit-ignite {
  0% { opacity: 0; transform: scale(0.2); }
  60% { opacity: 1; transform: scale(1.12); }
  100% { opacity: 1; transform: scale(1); }
}
@keyframes kit-meet { to { transform: none; opacity: 1; } }
@keyframes kit-grow { to { transform: none; } }
@keyframes kit-progress { to { stroke-dashoffset: 0; } }
@keyframes kit-spin { to { transform: rotate(360deg); } }

/* ---------- Pause control ---------- */
html.is-paused *,
html.is-paused *::before,
html.is-paused *::after { animation-play-state: paused !important; }
html:not(.motion) [data-pause] { display: none; }

/* Chapter emphasis is colour, not opacity, so every chapter keeps readable contrast (components.css). */

/* ---------- Handoff between the two sites ---------- */
html.motion.is-leaving main {
  transition: opacity 380ms var(--ease-in-out), transform 380ms var(--ease-in-out), filter 380ms var(--ease-in-out);
  opacity: 0;
  transform: scale(0.985);
  filter: blur(4px);
}
html.motion.is-arriving :target {
  animation: kit-arrive 900ms var(--ease-out) both;
}
@keyframes kit-arrive {
  from { opacity: 0; transform: translateY(1.25rem); filter: blur(6px); }
  to { opacity: 1; transform: none; filter: none; }
}

/* ---------- Variants (pending proposals, shown only on request) ---------- */
.variant-badge {
  position: fixed; inset: auto auto 1rem 1rem; z-index: 50;
  font: 600 0.75rem/1.2 system-ui, sans-serif; letter-spacing: 0.02em;
  padding: 0.45rem 0.7rem; border-radius: 6px;
  background: #fff6c2; color: #3a3000; box-shadow: 0 2px 10px rgb(0 0 0 / 0.18);
}
