/*
 * Page turns and dialogs, only for those who have not asked the OS to reduce motion. Pages slide in
 * from the right like a notebook leaf; public/js/page-turn.js marks going back so they slide the
 * other way. Browsers without cross-document view transitions just switch pages as before.
 */
@media (prefers-reduced-motion: no-preference) {
  @view-transition {
    navigation: auto;
  }

  main {
    view-transition-name: page;
  }

  /* The tab bar stays put while the page under it turns. */
  .tabbar {
    view-transition-name: tabbar;
  }

  ::view-transition-old(tabbar),
  ::view-transition-new(tabbar) {
    animation: none;
  }

  ::view-transition-old(page) {
    animation: page-out-left 260ms ease-in both;
  }

  ::view-transition-new(page) {
    animation: page-in-right 320ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
  }

  html:active-view-transition-type(back)::view-transition-old(page) {
    animation-name: page-out-right;
  }

  html:active-view-transition-type(back)::view-transition-new(page) {
    animation-name: page-in-left;
  }

  @keyframes page-in-right {
    from {
      opacity: 0;
      translate: 40% 0;
    }
  }

  @keyframes page-out-left {
    to {
      opacity: 0;
      translate: -25% 0;
    }
  }

  @keyframes page-in-left {
    from {
      opacity: 0;
      translate: -40% 0;
    }
  }

  @keyframes page-out-right {
    to {
      opacity: 0;
      translate: 25% 0;
    }
  }

  .dialog[open] {
    animation: dialog-pop-up 360ms cubic-bezier(0.34, 1.56, 0.64, 1) both;
  }

  .dialog[open]::backdrop {
    animation: backdrop-fade-in 200ms ease-out both;
  }

  @keyframes dialog-pop-up {
    from {
      opacity: 0;
      translate: 0 3rem;
    }
  }

  @keyframes backdrop-fade-in {
    from {
      opacity: 0;
    }
  }
}
