/* Cross-document view transitions between the mode apps.
   Browsers without support just do a normal page load. */

@view-transition { navigation: auto; }

#switcher        { view-transition-name: switcher; }
.mode-indicator  { view-transition-name: mode-indicator; }
main             { view-transition-name: app; }

/* Nav stays put; only the indicator moves. */
::view-transition-group(mode-indicator) {
  animation-duration: 0.45s;
  animation-timing-function: cubic-bezier(0.65, 0, 0.35, 1);
}

/* Arriving from the intro (no nav on the root page): slide the nav down. */
::view-transition-new(switcher):only-child {
  animation: nav-drop 0.45s ease 0.15s both;
}

/* Default (no direction known): crossfade with a slight scale. */
::view-transition-old(app) { animation: app-out 0.3s ease both; }
::view-transition-new(app) { animation: app-in 0.4s ease both; }

/* Direction-aware slides between modes. */
html:active-view-transition-type(forward)::view-transition-old(app) { animation: slide-out-left 0.45s cubic-bezier(0.65, 0, 0.35, 1) both; }
html:active-view-transition-type(forward)::view-transition-new(app) { animation: slide-in-right 0.45s cubic-bezier(0.65, 0, 0.35, 1) both; }
html:active-view-transition-type(back)::view-transition-old(app)    { animation: slide-out-right 0.45s cubic-bezier(0.65, 0, 0.35, 1) both; }
html:active-view-transition-type(back)::view-transition-new(app)    { animation: slide-in-left 0.45s cubic-bezier(0.65, 0, 0.35, 1) both; }

/* Intro → dev: the boot box (#intro-box on the root page) morphs into the
   terminal panel. Only named during that transition, so the panel doesn't
   animate separately from the page on normal mode switches. */
html:active-view-transition-type(intro) #panel { view-transition-name: panel; }
::view-transition-group(panel) {
  animation-duration: 0.6s;
  animation-timing-function: cubic-bezier(0.65, 0, 0.35, 1);
}

@keyframes nav-drop        { from { transform: translateY(-100%); opacity: 0; } }
@keyframes app-out         { to   { opacity: 0; transform: scale(0.98); } }
@keyframes app-in          { from { opacity: 0; transform: scale(1.02); } }
@keyframes slide-out-left  { to   { transform: translateX(-30%); opacity: 0; } }
@keyframes slide-in-right  { from { transform: translateX(30%);  opacity: 0; } }
@keyframes slide-out-right { to   { transform: translateX(30%);  opacity: 0; } }
@keyframes slide-in-left   { from { transform: translateX(-30%); opacity: 0; } }

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