/**
 * Motion & flow — respects prefers-reduced-motion via tokens.css
 */

@keyframes bw-fade-up {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes bw-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes bw-slide-sidebar-in {
  from { transform: translateX(-100%); }
  to { transform: translateX(0); }
}

/* Animate content blocks only — not the full <main> landmark (avoids edge flash on load) */
.bw-stagger > *,
.bw-auth__card,
.bw-auth__info {
  animation: bw-fade-up var(--bw-motion-page, 320ms) var(--bw-ease-theme) both;
}

.bw-auth__info {
  animation-delay: 60ms;
}

.bw-stagger > *:nth-child(1) { animation-delay: 0ms; }
.bw-stagger > *:nth-child(2) { animation-delay: 40ms; }
.bw-stagger > *:nth-child(3) { animation-delay: 80ms; }
.bw-stagger > *:nth-child(4) { animation-delay: 120ms; }
.bw-stagger > *:nth-child(5) { animation-delay: 160ms; }
.bw-stagger > *:nth-child(6) { animation-delay: 200ms; }
.bw-stagger > *:nth-child(n+7) { animation-delay: 240ms; }

.bw-sidebar.is-open {
  animation: bw-slide-sidebar-in var(--bw-motion-med, 240ms) var(--bw-ease-theme);
}

.bw-sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: var(--bw-z-overlay, 190);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--bw-motion-med) var(--bw-ease-theme);
}

.bw-sidebar-overlay.is-visible {
  opacity: 1;
  pointer-events: auto;
}

/* Interactive feedback */
.btn,
.bw-pipeline-nav__item,
.bw-role-card,
.bw-theme-select {
  transition:
    transform var(--bw-motion-fast, 140ms) var(--bw-ease-theme),
    box-shadow var(--bw-motion-fast, 140ms) var(--bw-ease-theme),
    background var(--bw-motion-fast, 140ms) var(--bw-ease-theme),
    color var(--bw-motion-fast, 140ms) var(--bw-ease-theme),
    border-color var(--bw-motion-fast, 140ms) var(--bw-ease-theme);
}

.btn:active:not(:disabled) {
  transform: scale(0.98);
}

.table.bw-table tbody tr {
  transition: background-color var(--bw-motion-fast) var(--bw-ease-theme);
}

.bw-alert {
  animation: bw-fade-in var(--bw-motion-med) var(--bw-ease-theme);
}

/* Reduced motion: instant state changes */
@media (prefers-reduced-motion: reduce) {
  .bw-stagger > *,
  .bw-auth__card,
  .bw-auth__info,
  .bw-sidebar.is-open,
  .bw-alert {
    animation: none !important;
  }

  .btn:active:not(:disabled),
  .bw-role-card:hover,
  .bw-pipeline-card:hover {
    transform: none !important;
  }

  .bw-sidebar-overlay {
    transition: none !important;
  }

  .bw-sidebar,
  .bw-app--with-sidebar,
  .bw-sidebar__collapse-icon {
    transition: none !important;
  }

  /* Theme morph: snap instantly instead of cross-fading surfaces */
  html.bw-theme-animating *,
  html.bw-theme-animating *::before,
  html.bw-theme-animating *::after {
    transition: none !important;
  }
}
