/* Moving between the pages. Every page shares one background, so nothing flashes, and a page turns a few degrees as it
   leaves or arrives: the next page is the same place, seen from another side. */

html {
  background: var(--editor);
}

/* Browsers that can: a view transition between the two documents. */
@view-transition {
  navigation: auto;
}
::view-transition-old(root) {
  animation: 0.22s cubic-bezier(0.4, 0, 1, 1) both adp-turn-out;
}
::view-transition-new(root) {
  animation: 0.36s cubic-bezier(0.2, 0.7, 0.2, 1) both adp-turn-in;
}
html.back::view-transition-old(root) {
  animation-name: adp-turn-out-back;
}
html.back::view-transition-new(root) {
  animation-name: adp-turn-in-back;
}

/* Every other browser: the page itself turns in once it is drawn, and turns out before it leaves (nav.js). */
html:not(.ready) body {
  opacity: 0;
}
html.ready body {
  animation: 0.36s cubic-bezier(0.2, 0.7, 0.2, 1) backwards adp-turn-in;
}
html.ready.back body {
  animation-name: adp-turn-in-back;
}
html.ready.vt body {
  animation: none;
}
html.leaving body {
  animation: 0.2s cubic-bezier(0.4, 0, 1, 1) forwards adp-turn-out;
}
html.leaving.back body {
  animation-name: adp-turn-out-back;
}

@keyframes adp-turn-out {
  to {
    opacity: 0;
    transform: perspective(1600px) translateX(-14px) rotateY(5deg) scale(0.985);
  }
}
@keyframes adp-turn-in {
  from {
    opacity: 0;
    transform: perspective(1600px) translateX(14px) rotateY(-5deg) scale(0.985);
  }
}
@keyframes adp-turn-out-back {
  to {
    opacity: 0;
    transform: perspective(1600px) translateX(14px) rotateY(-5deg) scale(0.985);
  }
}
@keyframes adp-turn-in-back {
  from {
    opacity: 0;
    transform: perspective(1600px) translateX(-14px) rotateY(5deg) scale(0.985);
  }
}

@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(*),
  ::view-transition-old(*),
  ::view-transition-new(*) {
    animation: none !important;
  }
  html.ready body,
  html.leaving body {
    animation: none;
  }
}
