/* deck: the pinned how-it-works stack. Safe to ship. */
/* ==========================================================================
   PINNED DECK — three pages that land on the same mark and turn over
   --------------------------------------------------------------------------
   All three cards share ONE sticky top, so card 3 lands exactly where card 2
   landed and where card 1 landed — no drift, no gap, no jump. The card being
   covered is driven by --recede (0 → 1, written by deck.js): it scales back,
   lifts, and its copy dims away before the incoming edge crosses it. Without
   JS, or with reduced motion, the stack still works — it simply does not
   recede. The rail and the deck start on the same mark and leave together.
   ========================================================================== */
@media (min-width:901px){
  .rail-steps{list-style:none;padding-left:0}
  #how.how-pinned{
    --card-top:108px;                     /* the one landing mark */
    --card-pad:clamp(34px,3.6vw,54px);
    --card-h:min(72vh,600px);
  }
  #how.how-pinned .wrap{
    display:grid;
    grid-template-columns:minmax(0,.92fr) minmax(0,1.08fr);
    column-gap:clamp(32px,5vw,72px);
    row-gap:0;
    align-items:start;
  }
  /* both columns hang from the same mark, and both release at the same scroll */
  #how.how-pinned .how-rail{
    grid-column:1;grid-row:1 / span 2;
    position:sticky;
    top:var(--card-top);
  }
  #how.how-pinned .steps--stack{grid-column:2;grid-row:1 / span 2;max-width:none;align-self:start}
  /* the rail is trimmed to the deck's height so both columns release together */
  #how.how-pinned .how-rail .section-head{margin-bottom:26px}
  #how.how-pinned .how-rail > p:last-child{margin-top:18px;margin-bottom:0}

  .steps--stack{
    display:block;margin:0;
    counter-reset:deck;
  }
  /* in-flow tail (not padding): sticky is clipped to the content box, so the
     hold after the last card has to be content, otherwise card 3 slides out
     the moment it lands — the old "it spaces out again" jump. */
  .steps--stack::after{content:"";display:block;height:clamp(40px,6vh,70px)}
  .steps--stack .step{
    counter-increment:deck;
    position:sticky;
    top:var(--card-top);
    min-height:var(--card-h);
    display:flex;
    flex-direction:column;
    justify-content:flex-start;
    background:var(--cream-3);
    border:1px solid var(--rule);
    border-top:2px solid var(--gold);
    border-radius:var(--r);
    padding:var(--card-pad);
    margin:0;
    overflow:hidden;
    box-shadow:0 -34px 64px -44px rgba(34,32,28,.6),
               0 34px 70px -50px rgba(34,32,28,.6);
    transform:scale(calc(1 - var(--recede,0) * .035));
    transform-origin:50% 0;
    will-change:transform;
  }
  .steps--stack .step:nth-of-type(1){z-index:1}
  .steps--stack .step:nth-of-type(2){z-index:2}
  .steps--stack .step:nth-of-type(3){z-index:3}

  /* the card's copy recedes with the card — it is never sliced at full weight */
  .steps--stack .step > *:not(.ghost){
    /* readable until the edge reaches the copy band, gone before it can cut it */
    opacity:clamp(0, calc((.50 - var(--recede,0)) / .20), 1);
    transform:translateY(calc(var(--recede,0) * -18px));
  }
  /* the card itself sinks toward the page ground as it is covered, so the
     incoming edge passes over tone, never over a line of dark type */
  .steps--stack .step::after{
    content:"";position:absolute;inset:0;background:var(--cream-2);
    opacity:clamp(0, calc((var(--recede,0) - .12) * 1.5), .72);pointer-events:none;
  }
  /* the ghost numeral is what the incoming edge is allowed to cut.
     It lives on an aria-hidden span so AT never reads a stray number. */
  .steps--stack .step .ghost{
    position:absolute; right:var(--card-pad); bottom:calc(var(--card-pad) * .55);
    pointer-events:none; user-select:none;
  }
  .steps--stack .step .ghost::before{
    content:counter(deck,decimal-leading-zero);
    font-family:var(--serif); font-weight:400;
    font-size:clamp(84px,9.5vw,136px); line-height:.8; letter-spacing:-.04em;
    color:rgba(139,107,48,.11);
  }

  .steps--stack .step h3{font-size:clamp(25px,2.5vw,34px);margin:18px 0 14px;max-width:20ch}
  .steps--stack .step .num{display:block;color:var(--gold-text);letter-spacing:.18em;font-size:12px}
  .steps--stack .step .small{max-width:44ch;font-size:15.5px;line-height:1.66}

  /* the rail carries a quiet three-step marker so the stack always shows its depth */
  .rail-steps{list-style:none;margin:18px 0 0;padding:0;display:grid;gap:19px}
  .rail-steps li{
    position:relative;display:grid;grid-template-columns:34px 1fr;align-items:baseline;
    font-size:13.5px;color:var(--ink-soft);letter-spacing:.02em;
    opacity:.78;   /* 2.12:1 was unreadable; 0.78 keeps the depth and clears AA */
    transition:opacity 420ms var(--ease-out);
  }
  .rail-steps li::after{
    content:"";position:absolute;left:0;right:0;bottom:-9px;height:1px;background:var(--gold);
    transform:scaleX(0);transform-origin:left center;
    transition:transform 560ms var(--ease-out);
  }
  .rail-steps li span{font-family:var(--sans);font-size:11.5px;letter-spacing:.16em;color:var(--gold-text)}
  .rail-steps li.is-active{opacity:1}
  .rail-steps li.is-active::after{transform:scaleX(1)}

  @media (prefers-reduced-motion: reduce){
    /* no motion, but the covered card still dims: an opaque card with the next
       one sliding over it cuts its own copy in half. Dimming is not motion. */
    .steps--stack .step{transform:none!important}
    .steps--stack .step > *{transform:none!important}
    .rail-steps li{opacity:.78}
    .rail-steps li::after{transform:scaleX(1)}
  }
}
@media (max-width:900px){
  .steps--stack .step{position:static;top:auto}
  .steps--stack .step .ghost{display:none}
}

/* paged media resolves sticky to static — lay the deck out as a plain list */
@media print{
  .steps--stack::after{display:none!important}
  .steps--stack .step{position:static!important;transform:none!important;min-height:0!important;
    break-inside:avoid;box-shadow:none!important}
  .steps--stack .step::after{display:none!important}
  .steps--stack .step > *:not(.ghost){opacity:1!important;transform:none!important}
  .steps--stack .step .ghost{display:none!important}
  #how.how-pinned .how-rail{position:static!important}
}

/* keep the lab badge from covering content on phones */
@media (max-width:600px){
  body{padding-bottom:46px}
  body::after{left:8px;bottom:8px;font-size:9px;padding:6px 10px;letter-spacing:.1em}
}
