/* Page transitions (pt.js): the hold under a cover transition's colour, and the three two-page transitions, drawn by
   the browser's cross-page View Transitions. Both pages opt in; the head's inline script skips the browser's own
   crossfade unless pt.js chose one of these three (it adds the type: pt-cube, pt-cube-down, pt-window, pt-stack). */

/* a cover transition is arriving: the page waits unseen on the cover's colour (set on <html>) until pt.js covers it */
html.pt-hold body { opacity: 0 !important; }

@view-transition { navigation: auto; }

/* shared: the two snapshots move as one piece each, no crossfade blending */
html:active-view-transition-type(pt-cube, pt-cube-down, pt-window, pt-stack)::view-transition { background: #0b0b0c; }
html:active-view-transition-type(pt-cube, pt-cube-down, pt-window, pt-stack)::view-transition-group(root) { animation: none; }
html:active-view-transition-type(pt-cube, pt-cube-down, pt-window, pt-stack)::view-transition-old(root),
html:active-view-transition-type(pt-cube, pt-cube-down, pt-window, pt-stack)::view-transition-new(root) { mix-blend-mode: normal; opacity: 1; backface-visibility: hidden; }

/* 3D cube (Osmo): the two pages are faces of a cube half a screen deep; it pulls back, turns a quarter, comes forward */
html:active-view-transition-type(pt-cube)::view-transition-old(root) { animation: pt-cube-old 1.3s cubic-bezier(0.625, 0.05, 0, 1) both; }
html:active-view-transition-type(pt-cube)::view-transition-new(root) { animation: pt-cube-new 1.3s cubic-bezier(0.625, 0.05, 0, 1) both; }
html:active-view-transition-type(pt-cube-down)::view-transition-old(root) { animation: pt-cube-old-d 1.3s cubic-bezier(0.625, 0.05, 0, 1) both; }
html:active-view-transition-type(pt-cube-down)::view-transition-new(root) { animation: pt-cube-new-d 1.3s cubic-bezier(0.625, 0.05, 0, 1) both; }
@keyframes pt-cube-old {
  0% { transform: perspective(1600px) translateZ(0) translateZ(-50vh) rotateX(0deg) translateZ(50vh); }
  40% { transform: perspective(1600px) translateZ(-45vh) translateZ(-50vh) rotateX(30deg) translateZ(50vh); }
  100% { transform: perspective(1600px) translateZ(0) translateZ(-50vh) rotateX(90deg) translateZ(50vh); }
}
@keyframes pt-cube-new {
  0% { transform: perspective(1600px) translateZ(0) translateZ(-50vh) rotateX(-90deg) translateZ(50vh); }
  40% { transform: perspective(1600px) translateZ(-45vh) translateZ(-50vh) rotateX(-60deg) translateZ(50vh); }
  100% { transform: perspective(1600px) translateZ(0) translateZ(-50vh) rotateX(0deg) translateZ(50vh); }
}
@keyframes pt-cube-old-d {
  0% { transform: perspective(1600px) translateZ(0) translateZ(-50vh) rotateX(0deg) translateZ(50vh); }
  40% { transform: perspective(1600px) translateZ(-45vh) translateZ(-50vh) rotateX(-30deg) translateZ(50vh); }
  100% { transform: perspective(1600px) translateZ(0) translateZ(-50vh) rotateX(-90deg) translateZ(50vh); }
}
@keyframes pt-cube-new-d {
  0% { transform: perspective(1600px) translateZ(0) translateZ(-50vh) rotateX(90deg) translateZ(50vh); }
  40% { transform: perspective(1600px) translateZ(-45vh) translateZ(-50vh) rotateX(60deg) translateZ(50vh); }
  100% { transform: perspective(1600px) translateZ(0) translateZ(-50vh) rotateX(0deg) translateZ(50vh); }
}

/* masked window (Osmo): the next page rises in a rounded window that opens to the full screen, the old one lifts,
   grows and darkens behind it */
html:active-view-transition-type(pt-window)::view-transition-old(root) { animation: pt-win-old 1.2s cubic-bezier(0.625, 0.05, 0, 1) both; }
html:active-view-transition-type(pt-window)::view-transition-new(root) { animation: pt-win-new 1.2s cubic-bezier(0.625, 0.05, 0, 1) both; }
@keyframes pt-win-old { from { transform: none; filter: brightness(1); } to { transform: translateY(-10vh) scale(1.2); filter: brightness(0.8); } }
@keyframes pt-win-new {
  from { transform: translateY(50%); clip-path: inset(50% round 48px); }
  83% { transform: translateY(0); }
  to { transform: translateY(0); clip-path: inset(0% round 0px); }
}

/* stacked cards (Osmo): both pages become rounded cards, the old one on top with a blue card under its edge; it
   drops away, and the next one grows up to the full screen */
html:active-view-transition-type(pt-stack)::view-transition-old(root) { z-index: 2; animation: pt-stack-old 1.8s linear both; }
html:active-view-transition-type(pt-stack)::view-transition-new(root) { z-index: 1; animation: pt-stack-new 1.8s linear both; }
@keyframes pt-stack-old {
  0% { transform: none; border-radius: 0; box-shadow: 0 0 0 0 #2E46E6; animation-timing-function: cubic-bezier(0.87, 0, 0.13, 1); }
  40% { transform: translateY(6%) scale(0.95); border-radius: 18px; box-shadow: 0 34px 0 -14px #2E46E6; animation-timing-function: cubic-bezier(0.625, 0.05, 0, 1); }
  100% { transform: translateY(135%) scale(0.95); border-radius: 18px; box-shadow: 0 34px 0 -14px #2E46E6; }
}
@keyframes pt-stack-new {
  0% { transform: scale(0.8); border-radius: 18px; }
  45% { transform: scale(0.8); border-radius: 18px; animation-timing-function: cubic-bezier(0.87, 0, 0.13, 1); }
  92% { transform: scale(1); border-radius: 18px; }
  100% { transform: scale(1); border-radius: 0; }
}
