/* Page transitions: moving between pages feels like one site, not a reload.
   The browser keeps the old page on screen, then a lime scan line sweeps down and
   reveals the new page behind it; the top bar and the node network stay put.
   (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; }
.wb-scan { view-transition-name: wb-scan; }

::view-transition-group(root) { animation-duration: .8s; }
::view-transition-old(root) { animation: wb-leave .8s cubic-bezier(.4,0,.2,1) both; }
::view-transition-new(root) { animation: wb-reveal .8s cubic-bezier(.7,0,.2,1) 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; }
::view-transition-old(wb-scan) { display: none; }
::view-transition-new(wb-scan) { animation: none; }

@keyframes wb-leave { to { opacity: .15; filter: blur(10px); transform: scale(.985); } }
@keyframes wb-reveal { from { clip-path: inset(0 0 100% 0); } to { clip-path: inset(0 0 0 0); } }

/* 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) .28s 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; } }

/* the scan line, in step with the reveal */
.wb-scan { position: fixed; inset: 0 0 auto 0; height: 2px; z-index: 9998; pointer-events: none; opacity: 0;
  background: var(--sc-accent, #8fdc5a); box-shadow: 0 0 18px 3px color-mix(in oklab, var(--sc-accent, #8fdc5a) 60%, transparent); }
html.wb-arrive .wb-scan { animation: wb-scan .8s cubic-bezier(.7,0,.2,1) both; }
@keyframes wb-scan { 0% { opacity: 1; transform: translateY(0); } 88% { opacity: 1; } 100% { opacity: 0; transform: translateY(100vh); } }

/* browsers without View Transitions: fade out on leave, fade in on arrival */
html.wb-leaving body { opacity: 0; filter: blur(6px); transition: opacity .22s ease, filter .22s ease; }
html.wb-entering body { animation: wb-enter .45s cubic-bezier(.2,.7,.2,1) both; }
@keyframes wb-enter { from { opacity: 0; transform: translateY(14px); } }

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