/* Stacking cards · Scroll Story Kit
   Static (no JS, reduced motion): the cards sit in a column, copy beside the picture (picture on top on phones).
   Motion: every card sticks near the top a little lower than the one before; each new card slides up over the
   last, and the cards underneath scale down and dim a step for every card that lands on them. One --sk-p on the
   list drives it all; --sk-stack-n (inline style on the list) must match the number of cards. Up to 6 cards. */
.sk-stack-head { max-width: 760px; }
.sk-stack-list { display: grid; gap: var(--sk-gap); margin: clamp(32px, 5vw, 56px) 0 0; padding: 0; list-style: none; counter-reset: sk-stack; }
.sk-stack-card {
  --i: 0;
  position: relative; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); align-items: stretch;
  border-radius: var(--sk-radius); background: var(--sk-surface); box-shadow: 0 0 0 1px var(--sk-line), var(--sk-shadow);
  counter-increment: sk-stack;
}
.sk-stack-card:nth-child(2) { --i: 1; }
.sk-stack-card:nth-child(3) { --i: 2; }
.sk-stack-card:nth-child(4) { --i: 3; }
.sk-stack-card:nth-child(5) { --i: 4; }
.sk-stack-card:nth-child(6) { --i: 5; }
.sk-stack-copy { display: flex; flex-direction: column; justify-content: center; align-items: flex-start; padding: clamp(24px, 4vw, 52px); }
.sk-stack-copy .sk-h3 { font-size: clamp(1.4rem, 1rem + 1.6vw, 2.2rem); letter-spacing: -0.025em; line-height: 1.1; }
.sk-stack-copy .sk-h3::before { content: counter(sk-stack, decimal-leading-zero); display: block; margin-bottom: 14px; font: 700 var(--sk-size-small)/1 var(--sk-font-mono); letter-spacing: 0; color: var(--sk-accent-text); }
.sk-stack-copy .sk-text { margin-top: 14px; }
.sk-stack-more { display: inline-block; margin-top: 18px; }
.sk-stack-art { display: grid; place-items: center; margin: 10px; min-height: 260px; border-radius: calc(var(--sk-radius) - 6px); overflow: clip; }
.sk-stack-art svg { display: block; width: 100%; max-width: 480px; height: auto; }
.sk-stack-art--teal { background: var(--sk-accent-2); }
.sk-stack-art--ochre { background: var(--sk-accent-3); }
.sk-stack-art--dusk { background: var(--sk-accent-4); }
.sk-stack-art--clay { background: var(--sk-accent); }

@media (max-width: 760px) {
  .sk-stack-card { grid-template-columns: 1fr; }
  .sk-stack-art { order: -1; min-height: 0; margin: 8px 8px 0; }
  .sk-stack-copy { padding: 22px 22px 26px; }
}

/* motion */
:root.sk-on .sk-stack-list {
  --sk-stack-k: .85;       /* scroll between two cards, as a share of the screen height */
  --sk-stack-tail: .35;    /* extra hold once the last card lands, as a share of the screen height */
  --sk-stack-top: max(72px, 11vh);
  --sk-stack-peek: 16px;
  --sk-stack-h: min(520px, 66svh);
  display: flow-root; /* block, not grid: a grid item only sticks inside its own row */
}
:root.sk-on .sk-stack-card {
  /* how many cards lie on top of this one, as a smooth number */
  --d: clamp(0, (var(--sk-p) * (var(--sk-stack-n, 4) * var(--sk-stack-k) + 1 + var(--sk-stack-tail)) - (var(--i) + 1) * var(--sk-stack-k) - .12) / var(--sk-stack-k), var(--sk-stack-n, 4) - 1 - var(--i));
  position: sticky; top: calc(var(--sk-stack-top) + var(--i) * var(--sk-stack-peek));
  height: var(--sk-stack-h);
  margin: 0;
  transform-origin: 50% 0;
  transform: scale(calc(1 - .045 * var(--d)));
}
/* spacing goes above each card and the tail after the last one: a sticky box keeps its whole margin box inside the list, so bottom margins would make cards let go early */
:root.sk-on .sk-stack-card + .sk-stack-card { margin-top: calc(var(--sk-stack-k) * 100vh - var(--sk-stack-h)); }
:root.sk-on .sk-stack-list::after { content: ""; display: block; height: calc((var(--sk-stack-k) + var(--sk-stack-tail)) * 100vh - var(--sk-stack-h)); }
:root.sk-on .sk-stack-card::after { content: ""; position: absolute; inset: 0; border-radius: inherit; background: var(--sk-sunk); opacity: calc(min(.75, var(--d) * .5)); pointer-events: none; }
:root.sk-on .sk-stack-art { min-height: 0; }
:root.sk-on .sk-stack-art svg { width: 92%; height: 92%; max-width: none; }

@media (max-width: 760px) {
  :root.sk-on .sk-stack-list { --sk-stack-peek: 12px; --sk-stack-h: min(540px, 68svh); }
  :root.sk-on .sk-stack-card { grid-template-rows: minmax(0, 1fr) auto; }
  :root.sk-on .sk-stack-copy { padding: 18px 20px 22px; }
  :root.sk-on .sk-stack-copy .sk-h3::before { margin-bottom: 8px; }
  :root.sk-on .sk-stack-copy .sk-text { margin-top: 8px; font-size: .9375rem; }
  :root.sk-on .sk-stack-more { margin-top: 10px; }
}
