/* Build up · Scroll Story Kit
   Static (no JS, reduced motion): the assembled product (lamp lit) beside a numbered parts list.
   Motion: the section pins for --sk-build-len of scroll. The product starts as an exploded view, each part pulled
   away from its place with a number tag, over a dashed outline of the finished shape. Part by part (one step each)
   the pieces slide home while the list lights the part being fitted and ticks off the ones before it; when the
   last part lands the light comes on. Each part's offset is set in the markup (--dx, --dy, --rot). */
.sk-build { --sk-build-len: 440vh; --sk-build-n: 6; }
.sk-build-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); gap: clamp(28px, 5vw, 72px); align-items: center; }
.sk-build-art { margin: 0; }
.sk-build-art svg { display: block; width: 100%; max-width: 560px; height: auto; margin: 0 auto; }
.sk-build-ghost, .sk-build-tag { display: none; }
.sk-build-list { display: grid; margin: 28px 0 0; padding: 0; list-style: none; counter-reset: sk-build; }
.sk-build-item { counter-increment: sk-build; position: relative; padding: 12px 0 12px 48px; border-top: 1px solid var(--sk-line); }
.sk-build-item:last-child { border-bottom: 1px solid var(--sk-line); }
.sk-build-item::before { content: counter(sk-build); position: absolute; left: 0; top: 11px; width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%; background: var(--sk-sunk); color: var(--sk-ink); font: 700 .875rem/1 var(--sk-font-mono); transition: background-color var(--sk-step) var(--sk-ease), color var(--sk-step) var(--sk-ease), box-shadow var(--sk-step) var(--sk-ease); }
.sk-build-item strong { display: block; font-size: 1.0625rem; line-height: 1.35; }
.sk-build-item span { display: block; margin-top: 2px; color: var(--sk-ink-2); font-size: .9375rem; line-height: 1.45; }

/* motion */
:root.sk-on .sk-build {
  --b: clamp(0, (var(--sk-p) * var(--sk-build-n) - var(--sk-build-n) + .3) / .25, 1); /* the light, once the last part is home */
  height: var(--sk-build-len); padding: 0;
}
:root.sk-on .sk-build-pin { position: sticky; top: 0; height: 100vh; height: 100svh; display: grid; align-items: center; padding: 0 var(--sk-gutter); }
:root.sk-on .sk-build-grid { width: 100%; grid-template-columns: minmax(0, .85fr) minmax(0, 1.15fr); }
:root.sk-on .sk-build-art svg { overflow: visible; width: auto; max-width: 100%; max-height: min(600px, 82vh); max-height: min(600px, 82svh); }
:root.sk-on .sk-build-ghost { display: inline; }
:root.sk-on .sk-build-ghost > g { opacity: calc(.9 - .9 * var(--e)); } /* each outline fades as its part lands */
:root.sk-on .sk-build-ghost * { fill: none; stroke: var(--sk-line-strong); stroke-width: 2; stroke-dasharray: 5 7; opacity: 1; }
:root.sk-on .sk-build-ghost circle[r="8"], :root.sk-on .sk-build-ghost circle[r="11"] { display: none; }
:root.sk-on .sk-build-part, :root.sk-on .sk-build-ghost > g {
  --t: clamp(0, (var(--sk-p) * var(--sk-build-n) - var(--i) - .1) / .7, 1); /* this part's own share of its step */
  --e: calc(var(--t) * (2 - var(--t)));                                        /* eased out, so each part settles */
}
:root.sk-on .sk-build-part {
  transform-box: fill-box; transform-origin: center;
  transform: translate(calc(var(--dx) * (1 - var(--e)) * 1px), calc(var(--dy) * (1 - var(--e)) * 1px)) rotate(calc(var(--rot) * (1 - var(--e)) * 1deg));
}
:root.sk-on .sk-build-tag { display: inline; opacity: calc(1 - var(--e)); }
:root.sk-on .sk-build-beam { opacity: calc(.22 * var(--b)); }
:root.sk-on .sk-build-pool { opacity: calc(.4 * var(--b)); }
:root.sk-on .sk-build-list { margin-top: 26px; }
:root.sk-on .sk-build-item { --on: 0; padding: 10px 0 10px 46px; }
:root.sk-on .sk-build-item strong { opacity: calc(.5 + .5 * var(--on)); transition: opacity var(--sk-step) var(--sk-ease); }
:root.sk-on .sk-build-item span { max-height: calc(var(--on) * 3em); opacity: var(--on); overflow: clip; transition: max-height var(--sk-step) var(--sk-ease), opacity var(--sk-step) var(--sk-ease); }

/* the part being fitted (data-sk-step from core/sk-scroll.js) and the ones already home */
:root.sk-on .sk-build:not([data-sk-step]) .sk-build-item:nth-child(1),
:root.sk-on .sk-build[data-sk-step="0"] .sk-build-item:nth-child(1),
:root.sk-on .sk-build[data-sk-step="1"] .sk-build-item:nth-child(2),
:root.sk-on .sk-build[data-sk-step="2"] .sk-build-item:nth-child(3),
:root.sk-on .sk-build[data-sk-step="3"] .sk-build-item:nth-child(4),
:root.sk-on .sk-build[data-sk-step="4"] .sk-build-item:nth-child(5),
:root.sk-on .sk-build[data-sk-step="5"] .sk-build-item:nth-child(6),
:root.sk-on .sk-build[data-sk-step="6"] .sk-build-item:nth-child(7),
:root.sk-on .sk-build[data-sk-step="7"] .sk-build-item:nth-child(8) { --on: 1; }
:root.sk-on .sk-build:not([data-sk-step]) .sk-build-item:nth-child(1)::before,
:root.sk-on .sk-build[data-sk-step="0"] .sk-build-item:nth-child(1)::before,
:root.sk-on .sk-build[data-sk-step="1"] .sk-build-item:nth-child(2)::before,
:root.sk-on .sk-build[data-sk-step="2"] .sk-build-item:nth-child(3)::before,
:root.sk-on .sk-build[data-sk-step="3"] .sk-build-item:nth-child(4)::before,
:root.sk-on .sk-build[data-sk-step="4"] .sk-build-item:nth-child(5)::before,
:root.sk-on .sk-build[data-sk-step="5"] .sk-build-item:nth-child(6)::before,
:root.sk-on .sk-build[data-sk-step="6"] .sk-build-item:nth-child(7)::before,
:root.sk-on .sk-build[data-sk-step="7"] .sk-build-item:nth-child(8)::before { background: var(--sk-surface); box-shadow: inset 0 0 0 3px var(--sk-accent); }
:root.sk-on .sk-build[data-sk-step="1"] .sk-build-item:nth-child(-n+1)::before,
:root.sk-on .sk-build[data-sk-step="2"] .sk-build-item:nth-child(-n+2)::before,
:root.sk-on .sk-build[data-sk-step="3"] .sk-build-item:nth-child(-n+3)::before,
:root.sk-on .sk-build[data-sk-step="4"] .sk-build-item:nth-child(-n+4)::before,
:root.sk-on .sk-build[data-sk-step="5"] .sk-build-item:nth-child(-n+5)::before,
:root.sk-on .sk-build[data-sk-step="6"] .sk-build-item:nth-child(-n+6)::before,
:root.sk-on .sk-build[data-sk-step="7"] .sk-build-item:nth-child(-n+7)::before { background: var(--sk-ink); color: var(--sk-paper); }

@media (max-width: 760px) {
  :root.sk-on .sk-build-pin { align-items: start; padding-top: 14px; }
  :root.sk-on .sk-build-grid { grid-template-columns: minmax(0, 1fr); gap: 6px; }
  :root.sk-on .sk-build-art { order: -1; }
  :root.sk-on .sk-build-art svg { height: 36vh; height: 36svh; }
  :root.sk-on .sk-build-copy .sk-kicker { display: none; }
  :root.sk-on .sk-build-copy .sk-h2 { font-size: clamp(1.5rem, 1rem + 3vw, 2rem); }
  :root.sk-on .sk-build-list { margin-top: 12px; }
  :root.sk-on .sk-build-item { padding: 7px 0 7px 40px; }
  :root.sk-on .sk-build-item::before { top: 6px; width: 26px; height: 26px; font-size: .8125rem; }
}
@media (prefers-reduced-motion: reduce) {
  .sk-build-item::before, .sk-build-item strong, .sk-build-item span { transition: none !important; }
}
