/* Page transitions: moving between pages feels like travelling between galaxies, not a reload.
   The old page drifts away into the dark and fades out; after a beat of empty space the new
   page fades in from the distance, as if arriving at the next galaxy. The top bar and the
   node network stay put, so the network is the space travelled through.
   (Chrome, Edge, Safari: View Transitions. Others: a short fade, see transitions.js.) */
@view-transition { navigation: auto; }

.bar { view-transition-name: wb-bar; }
.progress-rail { view-transition-name: wb-progress; }
.field { view-transition-name: wb-field; }

::view-transition-group(root) { animation-duration: 1.1s; }
::view-transition-old(root) { animation: wb-depart .6s cubic-bezier(.5,0,.75,0) both; }
::view-transition-new(root) { animation: wb-arrive .7s cubic-bezier(.2,.7,.2,1) .4s both; }
/* the bar and the network do not move; the bar's links swap in place */
::view-transition-group(wb-bar), ::view-transition-group(wb-field), ::view-transition-group(wb-progress) { animation: none; }
::view-transition-old(wb-bar), ::view-transition-new(wb-bar) { animation-duration: .3s; }
::view-transition-old(wb-field) { animation: none; opacity: 0; }
::view-transition-new(wb-field) { animation: none; }

/* leaving: the galaxy recedes, dims and dissolves; arriving: the next one comes out of the dark */
@keyframes wb-depart { to { opacity: 0; filter: blur(14px) brightness(1.4); transform: scale(.9); } }
@keyframes wb-arrive { from { opacity: 0; filter: blur(14px) brightness(1.6); transform: scale(1.06); } }

/* the active-page underline: the old one closes, then the new one opens (never two at once) */
html.wb-swap .bar__line { view-transition-name: wb-line-out; }
::view-transition-group(wb-line-in), ::view-transition-group(wb-line-out) { animation: none; }
::view-transition-old(wb-line-out) { animation: wb-line-close .28s cubic-bezier(.4,0,.2,1) both; }
::view-transition-new(wb-line-in) { animation: wb-line-open .45s cubic-bezier(.2,.7,.2,1) .4s both; }
::view-transition-old(wb-line-in), ::view-transition-new(wb-line-out) { display: none; }
@keyframes wb-line-close { to { transform: scaleX(0); opacity: 0; } }
@keyframes wb-line-open { from { transform: scaleX(0); opacity: 0; } }

/* browsers without View Transitions: the same depart and arrive, as plain fades */
html.wb-leaving body { opacity: 0; filter: blur(10px); transform: scale(.94); transition: opacity .3s ease-in, filter .3s ease-in, transform .3s ease-in; }
html.wb-entering body { animation: wb-arrive .6s cubic-bezier(.2,.7,.2,1) both; }

@media (prefers-reduced-motion: reduce) {
  @view-transition { navigation: none; }
  html.wb-entering body { animation: none; }
  html.wb-leaving body { opacity: 1; filter: none; transform: none; }
}
