@view-transition {
  navigation: auto;
}

@media (min-width: 721px) and (prefers-reduced-motion: no-preference) {
  html:active-view-transition-type(chef-module-switch) {
    --module-switch-duration: 300ms;
    --module-switch-ease: cubic-bezier(.25, .72, .3, 1);
  }

  html:active-view-transition-type(chef-module-switch) .app-layout > .sidebar {
    view-transition-name: chef-module-rail;
  }
  html:active-view-transition-type(chef-module-switch) .erp-sidebar,
  html:active-view-transition-type(chef-module-switch) .module-panel {
    view-transition-name: chef-module-panel;
  }
  html:active-view-transition-type(chef-module-switch) .erp-brand-header,
  html:active-view-transition-type(chef-module-switch) .module-brand-header {
    view-transition-name: chef-module-brand;
  }

  /* Keep the destination page at its final layout throughout the transition. */
  html:active-view-transition-type(chef-module-switch)::view-transition-old(root) { display: none; }
  html:active-view-transition-type(chef-module-switch)::view-transition-new(root) { animation: none; }

  ::view-transition-group(chef-module-rail),
  ::view-transition-group(chef-module-panel),
  ::view-transition-group(chef-module-brand) {
    animation-duration: var(--module-switch-duration);
    animation-timing-function: var(--module-switch-ease);
  }

  ::view-transition-new(chef-module-panel) {
    animation: chef-module-reveal var(--module-switch-duration) var(--module-switch-ease) both;
  }
  ::view-transition-old(chef-module-panel) {
    animation: chef-module-retract var(--module-switch-duration) var(--module-switch-ease) both;
  }
  /* Both modules share the same logo header now: keep it perfectly still. */
  ::view-transition-old(chef-module-brand) { display: none; }
  ::view-transition-new(chef-module-brand) { animation: none; }
}

@keyframes chef-module-reveal {
  from { clip-path: inset(0 100% 0 0); }
  to { clip-path: inset(0); }
}
@keyframes chef-module-retract {
  from { clip-path: inset(0); }
  to { clip-path: inset(0 100% 0 0); }
}

/* Phone: switching between Gestão Chef and ERP slides the content like a new screen,
   while the top bar and the bottom bar stay put and just cross fade. */
@media (max-width: 720px) and (prefers-reduced-motion: no-preference) {
  html:active-view-transition-type(chef-module-slide) {
    --module-slide-duration: 340ms;
    --module-slide-ease: cubic-bezier(.22, 1, .36, 1);
  }
  html:active-view-transition-type(chef-module-slide) .topbar { view-transition-name: chef-mobile-topbar; }
  html:active-view-transition-type(chef-module-slide) .bottom-nav { view-transition-name: chef-mobile-bottombar; }

  ::view-transition-group(chef-mobile-topbar),
  ::view-transition-group(chef-mobile-bottombar) { animation-duration: 200ms; }

  html:active-view-transition-type(to-erp)::view-transition-old(root) { animation: chef-slide-out-left var(--module-slide-duration) var(--module-slide-ease) both; }
  html:active-view-transition-type(to-erp)::view-transition-new(root) { animation: chef-slide-in-right var(--module-slide-duration) var(--module-slide-ease) both; }
  html:active-view-transition-type(to-chef)::view-transition-old(root) { animation: chef-slide-out-right var(--module-slide-duration) var(--module-slide-ease) both; }
  html:active-view-transition-type(to-chef)::view-transition-new(root) { animation: chef-slide-in-left var(--module-slide-duration) var(--module-slide-ease) both; }
  /* The incoming screen sits on top with a soft edge shadow. */
  html:active-view-transition-type(chef-module-slide)::view-transition-new(root) { z-index: 1; box-shadow: 0 0 24px #2021242e; }

  /* Fallback for browsers without page transitions: dim while the other module loads. */
  html.chef-module-leaving body { opacity: .55; transition: opacity .18s ease; }
}

@keyframes chef-slide-in-right { from { transform: translateX(100%); } }
@keyframes chef-slide-in-left { from { transform: translateX(-100%); } }
@keyframes chef-slide-out-left { to { transform: translateX(-28%); opacity: .6; } }
@keyframes chef-slide-out-right { to { transform: translateX(28%); opacity: .6; } }
