/**
 * Shared Sully pulse loader — linked from index.html before JS and imported via styles.css.
 * Keep HTML preloader and SullyPulseLogo visually in sync.
 */
html,
body {
  margin: 0;
  padding: 0;
}

:root {
  /* Pre-bundle fallback for --background. MUST match the --background tokens
     in styles.css (:root → oklch(1 0 0), .dark → oklch(0.1450 0 0)) exactly.
     A generic fallback like Canvas is a DIFFERENT dark (#121212-ish in
     Chrome), which made the loader visibly shift tone the moment the app
     stylesheet loaded and defined --background (ENG-2946). */
  --sully-loader-fallback-background: light-dark(
    oklch(1 0 0),
    oklch(0.145 0 0)
  );
}

html {
  color-scheme: light dark;
  /* Theme-correct backstop for any frame where no surface has painted yet
     (e.g. the preloader → React handoff). */
  background: var(--background, var(--sully-loader-fallback-background));
}

html.light {
  color-scheme: light;
}

html.dark {
  color-scheme: dark;
}

/* Bootstrap paints the body plain white via an unlayered
   `body { background-color: var(--bs-body-bg) }` rule that beats the app's
   `@layer base` dark body rule (unlayered styles win over layered ones).
   Out-specialize it (0,1,2 vs 0,0,1) so the body is theme-correct and never
   flashes white in dark mode. */
html.light body,
html.dark body {
  background-color: var(--background, var(--sully-loader-fallback-background));
}

@keyframes sully-pulse {
  0%,
  100% {
    opacity: 0.3;
    transform: scale(0.95);
  }

  50% {
    opacity: 1;
    transform: scale(1);
  }
}

/* Duration must match SULLY_PULSE_DURATION_MS (sully-loader.constants.ts)
   and the inline phase-sync script in index.html. */
.sully-pulse-logo {
  display: block;
  width: 64px;
  height: 64px;
  animation: sully-pulse 1.8s ease-in-out infinite;
}

.sully-loading-shell {
  position: fixed;
  inset: 0;
  z-index: 999999;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 0;
  background: var(--background, var(--sully-loader-fallback-background));
}

@keyframes sully-shell-fade-out {
  to {
    opacity: 0;
  }
}

/* Applied to the inert clone SullyLoadingShell leaves behind on unmount so
   every full-screen loader exits with a fade instead of a hard cut. Duration
   must match SULLY_SHELL_EXIT_FADE_MS (sully-loader.constants.ts). An
   animation (not a transition) so it plays from insertion without needing a
   style flush; `forwards` holds opacity 0 until the removal timeout. */
.sully-loading-shell--exit {
  animation: sully-shell-fade-out 160ms ease-out forwards;
  pointer-events: none;
}

/* The HTML preloader precedes #app in the DOM, so with z-index: auto the
   React tree (including the z-indexed Spinner shell) paints above it. The
   preloader is then removed after the app's first paint. */
#preloader.sully-loading-shell {
  z-index: auto;
}
