/* Batch SEA-1: the moves between the sign-in pages and the console. The console's part of the contract
   Jesse approved (MuirwaveHome/docs/TRANSITIONS.md; mockups/transitions/moves.css, sections 0, 1, 2, 4, 5
   and 6). School's rules are left out: they name classes (.bar, .foot) the console uses for other things.
   Linked from <head> by the signed-out pages and the console's main page; moves.js sets the types. */
@view-transition { navigation: auto; }

.mw-sea { view-transition-name: sea; }
body.signed-out .card { view-transition-name: console-card; }

@keyframes move-out-up   { 55% { opacity: 0.22; } to { opacity: 0; transform: translateY(-44px); } }
@keyframes move-out-down { 55% { opacity: 0.22; } to { opacity: 0; transform: translateY(52px); } }
@keyframes move-in-down  { from { opacity: 0; transform: translateY(-44px); } }
@keyframes move-sea-away { to   { transform: translateY(-104%); } }
@keyframes move-sea-back { from { transform: translateY(-104%); } }
@keyframes arrive-surface { from { opacity: 0; transform: translateY(14px); } }

/* Between two signed-out pages the sea is the same sea at the same moment: the still gives way at once. */
::view-transition-old(sea), ::view-transition-new(sea) { animation-duration: 140ms; animation-timing-function: linear; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: 320ms; animation-timing-function: ease; }

/* Signing in: the card is left behind above, the surface rises off the top of the window and the lit water
   dims into the console's dark, which Surfacing (surfacing.js) takes over. */
::view-transition-old(console-card):only-child { animation: 220ms cubic-bezier(0.4, 0, 1, 1) both move-out-up; }
::view-transition-old(sea):only-child { animation: 460ms cubic-bezier(0.5, 0, 0.85, 0.55) both move-sea-away; }
:root:active-view-transition-type(dive)::view-transition-old(root),
:root:active-view-transition-type(dive)::view-transition-new(root) {
  animation-duration: 520ms;
  animation-timing-function: cubic-bezier(0.4, 0, 0.6, 1);
}

/* Signing out: the console sinks away, the surface comes back down and the card settles under it. */
:root:active-view-transition-type(surface)::view-transition-old(root) { animation: 220ms cubic-bezier(0.4, 0, 1, 1) both move-out-down; }
:root:active-view-transition-type(surface)::view-transition-new(root) { animation-delay: 110ms; }
::view-transition-new(sea):only-child { animation: 560ms cubic-bezier(0.16, 1, 0.3, 1) both move-sea-back; }
::view-transition-new(console-card):only-child { animation: 440ms cubic-bezier(0.16, 1, 0.3, 1) 160ms both move-in-down; }

/* A blur behind a named element is painted with the page, so it would stay as a pane after the card had gone:
   while a move runs the card is plain dark glass. */
:root.moving body.signed-out .card { -webkit-backdrop-filter: none; backdrop-filter: none; background-color: rgb(8 15 27 / 0.9); }
:root:active-view-transition body.signed-out .card { -webkit-backdrop-filter: none; backdrop-filter: none; background-color: rgb(8 15 27 / 0.9); }

/* Arriving any other way, the card surfaces into place, once. */
@media (prefers-reduced-motion: no-preference) {
  :root:not(.moved) body.signed-out .card { animation: arrive-surface 680ms cubic-bezier(0.16, 1, 0.3, 1) 60ms backwards; }
}
@media (prefers-reduced-motion: reduce) {
  @view-transition { navigation: none; }
}
