/* ordo-motion.css — "Toolpath" motion layer (pairs with ordo-motion.js).
   The studio's printer, everywhere: filament trail, clicks that print a tiny
   part, X-ray infill under the cursor, headings that lay down layer lines,
   a hot end riding the scroll bar and a print bed running in the footer.
   Loaded after ordo.css. Reduced motion: nothing hidden, nothing moves. */

/* ─── Filament trail ─────────────────────────────────────── */
.m-trail { position: fixed; inset: 0; z-index: 45; width: 100%; height: 100%; pointer-events: none; }

/* ─── Click: a tiny part prints where you press ──────────── */
.m-part { position: fixed; z-index: 46; width: 30px; height: 22px; margin: -21px 0 0 -15px; pointer-events: none; display: flex; flex-direction: column-reverse; align-items: center; gap: 1.5px; }
.m-part i { display: block; height: 3.5px; border-radius: 2px; background: var(--coral); transform-origin: 0 50%; transform: scaleX(0); animation: mLayer .16s steps(5, jump-end) forwards, mCool .5s .16s forwards; }
.m-part i:nth-child(1) { width: 30px; }
.m-part i:nth-child(2) { width: 24px; animation-delay: .15s, .31s; }
.m-part i:nth-child(3) { width: 18px; animation-delay: .3s, .46s; }
.m-part i:nth-child(4) { width: 10px; animation-delay: .45s, .61s; }
.m-part.is-done { animation: mEject .45s var(--ease) forwards; }
@keyframes mLayer { to { transform: scaleX(1); } }
@keyframes mCool { from { background: #ffd2c4; } to { background: var(--teal2); } }
.m-part.is-light i { animation-name: mLayer, mCoolLight; }
@keyframes mCoolLight { from { background: #ffd2c4; } to { background: var(--ivory); } }
@keyframes mEject { to { opacity: 0; translate: 0 -10px; } }

/* ─── X-ray infill under the cursor ──────────────────────
   Hovering an image reveals the part's insides: rectilinear infill inside a
   coral wall, in a lens that follows the pointer (--mx/--my set by JS).
   A child span, because [data-print] already owns ::after for the nozzle. */
.m-xray { position: relative; }
.m-lens {
  position: absolute; inset: 0; z-index: 2; pointer-events: none; border-radius: inherit;
  background:
    radial-gradient(circle 74px at var(--mx, 50%) var(--my, 50%), transparent 70px, rgba(232, 137, 115, .95) 71px 72.5px, transparent 73.5px),
    repeating-linear-gradient(45deg, rgba(251, 249, 243, .62) 0 1px, transparent 1px 9px),
    repeating-linear-gradient(-45deg, rgba(251, 249, 243, .62) 0 1px, transparent 1px 9px),
    rgba(15, 58, 61, .34);
  -webkit-mask: radial-gradient(circle 74px at var(--mx, 50%) var(--my, 50%), #000 calc(100% - 1px), transparent);
          mask: radial-gradient(circle 74px at var(--mx, 50%) var(--my, 50%), #000 calc(100% - 1px), transparent);
  opacity: 0; scale: .9; transition: opacity .35s var(--ease), scale .5s var(--ease-out);
}
.m-xray.is-xray .m-lens { opacity: 1; scale: 1; }

/* ─── Headings lay down three layer lines ──────────────────
   Skipped where a .sub line follows too closely to fit them. */
.js .h2[data-split] { position: relative; }
.js .h2[data-split]:not(:has(+ .sub))::after {
  content: ""; position: absolute; left: 2px; bottom: -14px; width: 54px; height: 10px; pointer-events: none;
  background:
    linear-gradient(var(--coral), var(--coral)) 0 100% / 0 2.5px no-repeat,
    linear-gradient(rgba(232, 137, 115, .65), rgba(232, 137, 115, .65)) 0 calc(100% - 3.75px) / 0 2.5px no-repeat,
    linear-gradient(rgba(232, 137, 115, .35), rgba(232, 137, 115, .35)) 0 0 / 0 2.5px no-repeat;
}
.js .h2[data-split].is-in::after { animation: mLines .9s steps(18, jump-end) .5s forwards; }
@keyframes mLines {
  33.3% { background-size: 100% 2.5px, 0 2.5px, 0 2.5px; }
  66.6% { background-size: 100% 2.5px, 74% 2.5px, 0 2.5px; }
  100% { background-size: 100% 2.5px, 74% 2.5px, 46% 2.5px; }
}

/* ─── Hot end riding the scroll progress bar ─────────────── */
.site-header::after {
  content: ""; position: absolute; bottom: -4px; left: clamp(0px, calc(var(--progress, 0) * 100% - 4px), calc(100% - 8px)); width: 8px; height: 8px;
  border-radius: 50%; background: #ffe1d6; box-shadow: 0 0 0 2px var(--coral), 0 0 14px 3px rgba(232, 137, 115, .65);
  opacity: 0; transition: opacity .3s; pointer-events: none;
}
.site-header.is-scrolled::after { opacity: 1; animation: mHot 1.4s ease-in-out infinite; }
@keyframes mHot { 50% { box-shadow: 0 0 0 2px var(--coral), 0 0 22px 6px rgba(232, 137, 115, .4); } }

/* ─── Hero frames tilt toward the cursor (--rx/--ry set by JS) ── */
.m-tilt { transform: perspective(1200px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)); transition: transform .7s var(--ease-out); }
.is-tracking .m-tilt { transition-duration: .18s; }

/* ─── Print bed in the footer ────────────────────────────── */
.m-bed { position: relative; } /* parts stand on the footer-base rule below */
.m-bed canvas { display: block; width: 100%; height: 104px; }
.m-bed-label {
  position: absolute; right: 0; top: 0; margin: 0;
  font: 500 .72rem/1.4 ui-monospace, "SF Mono", Menlo, Consolas, monospace; letter-spacing: .02em; color: rgba(245, 241, 232, .5);
}
.m-bed-label b { color: var(--coral); font-weight: 500; }
@media (max-width: 520px) { .m-bed canvas { height: 84px; } .m-bed-label { position: static; margin-bottom: 6px; } }

/* ─── Reduced motion: everything settled, nothing moving ─── */
@media (prefers-reduced-motion: reduce) {
  .m-trail, .m-part, .m-lens, .site-header::after { display: none; }
  .js .h2[data-split]::after, .js .h2[data-split].is-in::after { animation: none; background-size: 100% 2.5px, 74% 2.5px, 46% 2.5px; }
  .m-tilt { transform: none; }
}
@media print { .m-trail, .m-part, .m-bed { display: none; } }
