/* Case to case: the page lifts into a sheet, washes out, swaps with the next
   sheet waiting at the edge, and the new sheet settles before its content
   fades in. Types are set by case-transition.js; other navigations keep the
   site's default crossfade and the gallery card morph. */
:root{--sheet-scale:.88;--sheet-edge:18px;--sheet-radius:18px;--sheet-time:1.3s}
@media(max-width:700px){:root{--sheet-scale:.9;--sheet-edge:10px;--sheet-radius:14px;--sheet-time:1.15s}}

/* The poster travels inside its sheet instead of morphing on its own, and the
   fixed chrome holds still while the pages move underneath it. */
html.case-sheet .case-poster .card-face{view-transition-name:none}
html.case-sheet .floating-nav{view-transition-name:case-nav}
html.case-sheet .theme-corner{view-transition-name:case-theme}

html:active-view-transition-type(case-next,case-prev)::view-transition{background:#0c0a09}
html:active-view-transition-type(case-next,case-prev)::view-transition-old(root),
html:active-view-transition-type(case-next,case-prev)::view-transition-new(root){
  mix-blend-mode:normal;animation-duration:var(--sheet-time);animation-timing-function:linear;animation-fill-mode:both;
  transform-origin:50% 50%;overflow:clip
}
html:active-view-transition-type(case-next)::view-transition-old(root){animation-name:sheet-out-left}
html:active-view-transition-type(case-next)::view-transition-new(root){animation-name:sheet-in-right}
html:active-view-transition-type(case-prev)::view-transition-old(root){animation-name:sheet-out-right}
html:active-view-transition-type(case-prev)::view-transition-new(root){animation-name:sheet-in-left}

/* 0-22% lift into a sheet. 22-50% drift and wash out. 50-72% the swap.
   72-100% the new sheet settles to full bleed and full colour. */
@keyframes sheet-out-left{
  0%{transform:none;border-radius:0;filter:none;opacity:1;animation-timing-function:cubic-bezier(.55,0,.25,1)}
  22%{transform:scale(var(--sheet-scale));border-radius:var(--sheet-radius);filter:none;animation-timing-function:cubic-bezier(.45,0,.9,.45)}
  50%{transform:translateX(-3%) scale(var(--sheet-scale));filter:grayscale(1) brightness(.75);animation-timing-function:cubic-bezier(.25,.85,.25,1)}
  72%{transform:translateX(calc(-50% - 50% * var(--sheet-scale) + var(--sheet-edge))) scale(var(--sheet-scale));border-radius:var(--sheet-radius);filter:grayscale(1) brightness(.5);opacity:1}
  100%{transform:translateX(calc(-50% - 50% * var(--sheet-scale) + var(--sheet-edge))) scale(var(--sheet-scale));border-radius:var(--sheet-radius);filter:grayscale(1) brightness(.5);opacity:0}
}
@keyframes sheet-in-right{
  0%,22%{transform:translateX(calc(50% + 50% * var(--sheet-scale) - var(--sheet-edge))) scale(var(--sheet-scale));border-radius:var(--sheet-radius);filter:grayscale(1) brightness(.5);animation-timing-function:cubic-bezier(.45,0,.9,.45)}
  50%{transform:translateX(calc(47% + 50% * var(--sheet-scale) - var(--sheet-edge))) scale(var(--sheet-scale));filter:grayscale(1) brightness(.6);animation-timing-function:cubic-bezier(.25,.85,.25,1)}
  72%{transform:scale(var(--sheet-scale));border-radius:var(--sheet-radius);filter:grayscale(1) brightness(.85);animation-timing-function:cubic-bezier(.3,0,.15,1)}
  100%{transform:none;border-radius:0;filter:none}
}
@keyframes sheet-out-right{
  0%{transform:none;border-radius:0;filter:none;opacity:1;animation-timing-function:cubic-bezier(.55,0,.25,1)}
  22%{transform:scale(var(--sheet-scale));border-radius:var(--sheet-radius);filter:none;animation-timing-function:cubic-bezier(.45,0,.9,.45)}
  50%{transform:translateX(3%) scale(var(--sheet-scale));filter:grayscale(1) brightness(.75);animation-timing-function:cubic-bezier(.25,.85,.25,1)}
  72%{transform:translateX(calc(50% + 50% * var(--sheet-scale) - var(--sheet-edge))) scale(var(--sheet-scale));border-radius:var(--sheet-radius);filter:grayscale(1) brightness(.5);opacity:1}
  100%{transform:translateX(calc(50% + 50% * var(--sheet-scale) - var(--sheet-edge))) scale(var(--sheet-scale));border-radius:var(--sheet-radius);filter:grayscale(1) brightness(.5);opacity:0}
}
@keyframes sheet-in-left{
  0%,22%{transform:translateX(calc(-50% - 50% * var(--sheet-scale) + var(--sheet-edge))) scale(var(--sheet-scale));border-radius:var(--sheet-radius);filter:grayscale(1) brightness(.5);animation-timing-function:cubic-bezier(.45,0,.9,.45)}
  50%{transform:translateX(calc(-47% - 50% * var(--sheet-scale) + var(--sheet-edge))) scale(var(--sheet-scale));filter:grayscale(1) brightness(.6);animation-timing-function:cubic-bezier(.25,.85,.25,1)}
  72%{transform:scale(var(--sheet-scale));border-radius:var(--sheet-radius);filter:grayscale(1) brightness(.85);animation-timing-function:cubic-bezier(.3,0,.15,1)}
  100%{transform:none;border-radius:0;filter:none}
}

/* The new sheet arrives with its title; the rest of the opening follows once
   it has settled. Backwards fill only, so scroll reveals keep their own state. */
@keyframes sheet-content-in{from{opacity:0;transform:translateY(14px)}to{opacity:1;transform:none}}
html.case-sheet-in .case-opening>div:first-child>.mono,
html.case-sheet-in .case-opening-aside,
html.case-sheet-in .case-feature{animation:sheet-content-in .6s cubic-bezier(.2,.8,.2,1) backwards}
html.case-sheet-in .case-opening>div:first-child>.mono{animation-delay:calc(var(--sheet-time) * .78)}
html.case-sheet-in .case-opening-aside{animation-delay:calc(var(--sheet-time) * .78 + 90ms)}
html.case-sheet-in .case-feature{animation-delay:calc(var(--sheet-time) * .78 + 180ms)}

@media(prefers-reduced-motion:reduce){
  html.case-sheet-in .case-opening>div:first-child>.mono,html.case-sheet-in .case-opening-aside,html.case-sheet-in .case-feature{animation:none}
}
