/* ===== Transitions (View Transitions API; app.js picks the kind; reduced motion gets a plain cut) =====
   cover : the clicked cover glides into place as the contents page's cover; the page around it fades out, then the
           contents page fades in.
   open  : contents → chapter: the chapter slides in from the right as the contents slide away to the left.
   close : chapter → contents: the reverse. */
html[data-flip] header.top{view-transition-name:gw-top}
html[data-flip]::view-transition-group(gw-top){animation:none}

/* cover */
html[data-flip=cover]::view-transition-group(gw-book){animation-duration:.7s;animation-timing-function:cubic-bezier(.22,.68,.18,1);z-index:5}
html[data-flip=cover]::view-transition-old(gw-book),
html[data-flip=cover]::view-transition-new(gw-book){animation-duration:.7s;animation-timing-function:cubic-bezier(.22,.68,.18,1);height:100%;object-fit:cover}
html[data-flip=cover]::view-transition-old(root){animation:gw-fade-out .32s cubic-bezier(.4,0,1,1) both}
html[data-flip=cover]::view-transition-new(root){animation:gw-fade-in .45s .3s cubic-bezier(0,0,.2,1) both}

/* open / close: a smooth sideways slide */
html[data-flip=open]::view-transition-old(root),html[data-flip=open]::view-transition-new(root),
html[data-flip=close]::view-transition-old(root),html[data-flip=close]::view-transition-new(root){
  animation-duration:.55s;animation-timing-function:cubic-bezier(.22,.68,.18,1);animation-fill-mode:both;mix-blend-mode:normal}
html[data-flip=open]::view-transition-old(root){animation-name:gw-out-left}
html[data-flip=open]::view-transition-new(root){animation-name:gw-in-right}
html[data-flip=close]::view-transition-old(root){animation-name:gw-out-right}
html[data-flip=close]::view-transition-new(root){animation-name:gw-in-left}

@keyframes gw-fade-out{to{opacity:0}}
@keyframes gw-fade-in{from{opacity:0}}
@keyframes gw-out-left{to{transform:translateX(-7%);opacity:0}}
@keyframes gw-in-right{from{transform:translateX(7%);opacity:0}}
@keyframes gw-out-right{to{transform:translateX(7%);opacity:0}}
@keyframes gw-in-left{from{transform:translateX(-7%);opacity:0}}

/* Continue: the chapter about to open is marked on the contents page for a moment before the slide */
.bookp .chl li.goto{background:color-mix(in srgb,var(--red) 9%,transparent)!important;border-radius:10px;
  box-shadow:inset 3px 0 0 var(--red);transition:background .4s}
.bookp .chl li.goto .nm{color:var(--red)!important}
