/* SOF-XI ERP shell opening animation — additive only, clean-room.
   Animates ONLY the shell (sidebar, topbar, active non-editor page
   section) on a full page load. It changes NO layout, colour, font,
   size, text, button, or data, and only transform + opacity.
   It runs ONLY when <body> carries "erp-anim-on", which erp-opening.js
   adds after the boot has rendered (see that file). If the JS never
   runs, this file does nothing and the page is exactly as before.
   If this file fails to load, the JS class is harmless.
   NEVER animated: #boot (the loading screen itself), #modalRoot /
   #modalBox, #toastRoot / .toast, #page-editor (the full-window
   document editor), and any non-active page section. Page switches
   after the entrance window do not re-animate: the class is removed
   after settling (see erp-opening.js), so hash-routed switches stay
   instant. No external requests, no third-party fonts. */

:root { --erp-anim-ease: cubic-bezier(0.22, 1, 0.36, 1); }

/* Sidebar first. On desktop the sidebar is in normal flex layout, so
   a rise is safe. On <=860px it is a fixed off-canvas panel whose
   open/close is driven by transform, so there it animates opacity
   ONLY — never transform — so the entrance can never flash the
   sidebar open or fight the .open state. */
body.erp-anim-on #sidebar {
  animation: erp-anim-rise 800ms var(--erp-anim-ease) both;
  animation-delay: 0ms;
}

/* Topbar second. */
body.erp-anim-on #topbar {
  animation: erp-anim-rise 800ms var(--erp-anim-ease) both;
  animation-delay: 200ms;
}

/* Active page content third. Editor excluded by :not(); hidden
   (non-active) sections are display:none in ERP's own CSS and are
   not targeted, so switching pages later cannot re-trigger them. */
body.erp-anim-on main#content > section.page.active:not(#page-editor) {
  animation: erp-anim-rise 800ms var(--erp-anim-ease) both;
  animation-delay: 600ms;
}

@keyframes erp-anim-rise {
  from { opacity: 0; transform: translateY(28px); }
  to { opacity: 1; transform: translateY(0); }
}

/* <=860px: sidebar opacity only (see comment above). Topbar and the
   active section keep the rise — they are in normal flow. */
@media (max-width: 860px) {
  body.erp-anim-on #sidebar {
    animation-name: erp-anim-fade;
  }
}

@keyframes erp-anim-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Reduced motion: no animation at all, page shows instantly. The
   !important rules beat the entrance animations only; they do not
   touch any ERP layout, modal, toast, or editor rule. */
@media (prefers-reduced-motion: reduce) {
  body.erp-anim-on #sidebar,
  body.erp-anim-on #topbar,
  body.erp-anim-on main#content > section.page.active:not(#page-editor) {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
  }
}
