/* Turntable box · Scroll Story Kit
   Static (no JS, reduced motion): the four faces of the package laid flat as a row of cards.
   Motion: the section pins for --sk-turn-len of scroll while a CSS 3D box, tipped a little towards you, turns one
   full circle with --sk-p. It starts on a corner and eases (sin() where supported), so each face holds square to the
   front in the middle of its own step; the faces darken as they turn away (cos() of their angle). The caption under the box names the face in front
   and rolls to the next name at each step. Four faces, by design. */
.sk-turn { --sk-turn-len: 400vh; }
.sk-turn-head { max-width: 640px; }
.sk-turn-stage { margin-top: 44px; }
.sk-turn-faces { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: var(--sk-gap); margin: 0; padding: 0; list-style: none; }
.sk-turn-face { position: relative; display: flex; flex-direction: column; padding: 16px 16px 22px; border-radius: var(--sk-radius-sm); background: var(--sk-surface); box-shadow: inset 0 0 0 1px var(--sk-line), var(--sk-shadow-sm); }
.sk-turn-face:nth-child(1) { --c: var(--sk-accent-3); --k: 0; }
.sk-turn-face:nth-child(2) { --c: var(--sk-accent-2); --k: 1; }
.sk-turn-face:nth-child(3) { --c: var(--sk-accent); --k: 2; }
.sk-turn-face:nth-child(4) { --c: var(--sk-accent-4); --k: 3; }
.sk-turn-art { display: grid; place-items: center; aspect-ratio: 16 / 10; margin-bottom: 18px; border-radius: 8px; background: var(--c); }
.sk-turn-art svg { display: block; width: 72%; height: auto; }
.sk-turn-face .sk-text { margin-top: 8px; font-size: .9375rem; line-height: 1.5; }
.sk-turn-lid, .sk-turn-floor, .sk-turn-caption { display: none; }

/* motion */
:root.sk-on .sk-turn { height: var(--sk-turn-len); padding: 0; }
:root.sk-on .sk-turn-pin { position: sticky; top: 0; height: 100vh; height: 100svh; display: grid; align-items: center; padding: 0 var(--sk-gutter); }
:root.sk-on .sk-turn-grid { width: 100%; display: grid; grid-template-columns: minmax(0, .85fr) minmax(0, 1.15fr); gap: clamp(24px, 5vw, 72px); align-items: center; }
:root.sk-on .sk-turn-stage { --w: min(270px, 50vw, 34vh); --w: min(270px, 50vw, 34svh); --turn: calc(45deg - var(--sk-p) * 360deg); display: grid; justify-items: center; margin: 0; perspective: 1400px; perspective-origin: 50% 20%; }
/* where CSS sin() exists, the turn eases: fastest across each corner, slowest with a face square to the front */
@supports (width: calc(sin(30deg) * 1px)) {
  :root.sk-on .sk-turn-stage { --turn: calc(45deg - (var(--sk-p) * 4 + sin(var(--sk-p) * 1440deg) / 6.2832) * 90deg); }
}
:root.sk-on .sk-turn-box { position: relative; width: var(--w); height: calc(var(--w) * 1.26); margin-top: calc(var(--w) * .3); transform-style: preserve-3d; transform: rotateX(-14deg) rotateY(var(--turn)); }
:root.sk-on .sk-turn-faces { position: absolute; inset: 0; display: block; transform-style: preserve-3d; }
:root.sk-on .sk-turn-face { position: absolute; inset: 0; padding: 8% 8% 9%; border-radius: 3px; box-shadow: inset 0 0 0 1px var(--sk-line); backface-visibility: hidden; transform: rotateY(calc(var(--k) * 90deg)) translateZ(calc(var(--w) / 2)); }
:root.sk-on .sk-turn-face::after { content: ""; position: absolute; inset: 0; border-radius: inherit; background: var(--sk-ink); opacity: 0; opacity: calc(.34 * (1 - cos(var(--turn) + var(--k) * 90deg))); pointer-events: none; }
:root.sk-on .sk-turn-art { aspect-ratio: 5 / 4; margin-bottom: 9%; border-radius: 4px; }
:root.sk-on .sk-turn-face .sk-h3 { font-size: calc(var(--w) * .074); line-height: 1.15; }
:root.sk-on .sk-turn-face .sk-text { margin-top: 6px; font-size: max(12px, calc(var(--w) * .05)); line-height: 1.45; }
:root.sk-on .sk-turn-lid { display: grid; place-items: center; position: absolute; left: 0; top: 0; width: var(--w); height: var(--w); border-radius: 3px; background: var(--sk-surface); box-shadow: inset 0 0 0 1px var(--sk-line); transform: translateY(calc(var(--w) / -2)) rotateX(90deg); }
:root.sk-on .sk-turn-lid svg { width: 64%; height: auto; }
:root.sk-on .sk-turn-floor { display: block; width: calc(var(--w) * 1.7); height: calc(var(--w) * .34); margin-top: calc(var(--w) * -.16); border-radius: 50%; background: radial-gradient(closest-side, color-mix(in srgb, var(--sk-ink) 22%, transparent), transparent); }
:root.sk-on .sk-turn-caption { display: grid; justify-items: center; gap: 12px; margin-top: calc(var(--w) * .1); }
:root.sk-on .sk-turn-names { display: grid; height: 1.5em; overflow: clip; font-size: 1.1875rem; font-weight: 700; line-height: 1.5; }
:root.sk-on .sk-turn-names > div { grid-area: 1 / 1; text-align: center; white-space: nowrap; opacity: 0; transform: translateY(100%); transition: transform 460ms var(--sk-ease), opacity 460ms var(--sk-ease); }
:root.sk-on .sk-turn-names b { margin-right: 8px; font: 700 .875rem/1 var(--sk-font-mono); color: var(--sk-accent-text); }
:root.sk-on .sk-turn-meter { display: block; width: 168px; height: 3px; border-radius: 3px; background: var(--sk-line); overflow: clip; }
:root.sk-on .sk-turn-meter i { display: block; height: 100%; background: var(--sk-accent); transform-origin: 0 50%; transform: scaleX(var(--sk-p)); }

/* the name in front (data-sk-step from core/sk-scroll.js) and the ones already passed */
:root.sk-on .sk-turn:not([data-sk-step]) .sk-turn-names > div:nth-child(1),
:root.sk-on .sk-turn[data-sk-step="0"] .sk-turn-names > div:nth-child(1),
:root.sk-on .sk-turn[data-sk-step="1"] .sk-turn-names > div:nth-child(2),
:root.sk-on .sk-turn[data-sk-step="2"] .sk-turn-names > div:nth-child(3),
:root.sk-on .sk-turn[data-sk-step="3"] .sk-turn-names > div:nth-child(4) { opacity: 1; transform: none; }
:root.sk-on .sk-turn[data-sk-step="1"] .sk-turn-names > div:nth-child(-n+1),
:root.sk-on .sk-turn[data-sk-step="2"] .sk-turn-names > div:nth-child(-n+2),
:root.sk-on .sk-turn[data-sk-step="3"] .sk-turn-names > div:nth-child(-n+3) { transform: translateY(-100%); }

@media (max-width: 760px) {
  :root.sk-on .sk-turn-pin { align-items: start; padding-top: 22px; }
  :root.sk-on .sk-turn-grid { grid-template-columns: minmax(0, 1fr); gap: 0; }
  :root.sk-on .sk-turn-head .sk-kicker { display: none; }
  :root.sk-on .sk-turn-head .sk-h2 { font-size: clamp(1.6rem, 1rem + 3vw, 2.2rem); }
  :root.sk-on .sk-turn-head .sk-lead { margin-top: 10px; font-size: var(--sk-size-body); }
  :root.sk-on .sk-turn-stage { --w: min(214px, 56vw, 30vh); --w: min(214px, 56vw, 30svh); }
  :root.sk-on .sk-turn-names { font-size: 1.0625rem; }
}
@media (prefers-reduced-motion: reduce) {
  .sk-turn-names > div { transition: none !important; }
}
