/* Unified motion system: subtle cockpit motion, page reveal, and interaction feedback. */

:root {
  --motion-fast: 160ms;
  --motion-mid: 360ms;
  --motion-slow: 680ms;
  --motion-stagger: 34ms;
  --ease-cockpit: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-snap: cubic-bezier(0.34, 1.56, 0.64, 1);
}

html {
  scroll-behavior: smooth;
}

body::after {
  content: "";
  position: fixed;
  inset: -20%;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 18% 24%, rgba(255, 198, 90, 0.12), transparent 24%),
    radial-gradient(circle at 82% 12%, rgba(71, 215, 255, 0.1), transparent 22%),
    radial-gradient(circle at 76% 88%, rgba(57, 214, 163, 0.06), transparent 24%);
  opacity: 0.42;
  transform: translate3d(0, 0, 0) scale(1);
  animation: cockpitAmbient 18s ease-in-out infinite alternate;
}

body.dashboard-page::after {
  display: none;
}

/*
 * The application shell must never become a transformed containing block.
 * Fixed drawers and backdrops are rendered below it and must stay anchored to
 * the viewport, even after a route transition has completed.
 */
.main-content {
  animation: none;
  transform: none;
}

.main-content.motion-page-ready .page-header,
.main-content.motion-page-ready .board-home-header {
  animation: headerDockIn 520ms var(--ease-cockpit) both;
}

.motion-reveal {
  opacity: 0;
  filter: none;
  transform: translate3d(0, 12px, 0) scale(0.992);
  transition:
    opacity var(--motion-slow) var(--ease-cockpit),
    filter var(--motion-slow) var(--ease-cockpit),
    transform var(--motion-slow) var(--ease-cockpit);
  transition-delay: calc(var(--motion-index, 0) * var(--motion-stagger));
  will-change: opacity, transform, filter;
}

.motion-reveal.is-visible {
  opacity: 1;
  filter: none;
  transform: translate3d(0, 0, 0) scale(1);
}

.board-slide-stack {
  scroll-behavior: auto;
}

.board-slide {
  opacity: 0.82;
  transform: translate3d(0, 0, 0) scale(0.992);
  transition:
    opacity 520ms var(--ease-cockpit),
    transform 520ms var(--ease-cockpit),
    filter 520ms var(--ease-cockpit);
}

.board-slide.is-active,
.board-slide:only-child {
  opacity: 1;
  transform: translate3d(0, 0, 0) scale(1);
}

.board-slide-indicator {
  position: relative;
  overflow: hidden;
  opacity: 1;
  filter: none;
  transform: translate3d(0, 0, 0);
  transition:
    transform var(--motion-mid) var(--ease-cockpit),
    border-color var(--motion-mid) ease,
    background var(--motion-mid) ease,
    box-shadow var(--motion-mid) ease;
}

.board-slide-indicator::after {
  content: "";
  position: absolute;
  inset: auto 12px 8px;
  height: 2px;
  border-radius: 999px;
  background: linear-gradient(90deg, transparent, var(--amber), var(--cyan), transparent);
  opacity: 0;
  transform: translateX(-36%);
}

.board-slide-indicator:hover {
  transform: translateY(-2px);
}

.board-slide-indicator.active {
  animation: activeSlideBreath 3.2s ease-in-out infinite;
}

.board-slide-indicator.active::after {
  opacity: 0.88;
  animation: indicatorSweep 2.6s linear infinite;
}

.nav-item,
.ui-chip-button,
.ui-filter-chip,
.export-button,
.rule-link-button,
.mobile-back-button,
.stat-card-button,
.board-module-actions button,
.board-module-actions a {
  transition-timing-function: var(--ease-cockpit);
}

.nav-item:active,
.ui-chip-button:active,
.ui-filter-chip:active,
.export-button:active,
.rule-link-button:active,
.stat-card-button:active {
  transform: translate3d(0, 1px, 0) scale(0.985);
}

.autoscroll-status {
  position: relative;
  overflow: hidden;
}

.autoscroll-status.active::before {
  content: "";
  width: 7px;
  height: 7px;
  margin-right: 7px;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 0 0 rgba(255, 198, 90, 0.36);
  animation: statusDotPulse 1.4s ease-out infinite;
}

.app-loading-state {
  position: relative;
  overflow: hidden;
}

.app-loading-state::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(110deg, transparent 0 35%, rgba(255, 255, 255, 0.055) 45%, transparent 58% 100%);
  transform: translateX(-110%);
  animation: loadingSweep 1.8s ease-in-out infinite;
}

.app-spinner,
.spinner {
  animation: spinnerOrbit 900ms linear infinite;
}

.ui-card-interactive,
.stat-card-button,
.board-panel,
.board-kpi-card,
.board-signal-card,
.board-recent-card,
.board-risk-card,
.board-repeat-card,
.board-innovation-project-card,
.board-skill-profile,
.member-subtable,
.workload-audit-card {
  transform: translate3d(0, 0, 0);
  transition:
    transform var(--motion-mid) var(--ease-cockpit),
    border-color var(--motion-mid) ease,
    background var(--motion-mid) ease,
    box-shadow var(--motion-mid) ease;
}

.ui-card-interactive:hover,
.stat-card-button:hover,
.board-panel:hover,
.board-kpi-card:hover,
.board-signal-card:hover,
.board-recent-card:hover,
.board-risk-card:hover,
.board-repeat-card:hover,
.board-innovation-project-card:hover,
.board-skill-profile:hover,
.member-subtable:hover,
.workload-audit-card:hover {
  transform: translate3d(0, -3px, 0);
}

.dashboard-detail-drawer.is-open,
.modal-card,
.modal-dialog-card,
.mobile-nav-drawer.open {
  animation: overlayRiseIn 320ms var(--ease-cockpit) both;
}

.timeline-item,
.ui-timeline-item {
  transition:
    transform var(--motion-mid) var(--ease-cockpit),
    border-color var(--motion-mid) ease,
    background var(--motion-mid) ease,
    box-shadow var(--motion-mid) ease;
}

.timeline-item:hover,
.ui-timeline-item:hover {
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.16);
}

.stat-value,
.breakdown-score,
.board-module-metric strong,
.board-kpi-value,
.board-comparison-item strong {
  animation: numberSettle 520ms var(--ease-snap) both;
}

body.dashboard-page .main-content,
body.dashboard-page .main-content.motion-page-ready .page-header,
body.dashboard-page .main-content.motion-page-ready .board-home-header,
body.dashboard-page .motion-reveal,
body.dashboard-page .motion-reveal.is-visible,
body.dashboard-page .board-slide,
body.dashboard-page .board-slide-indicator,
body.dashboard-page .board-slide-indicator.active,
body.dashboard-page .board-slide-indicator.active::after,
body.dashboard-page .board-module,
body.dashboard-page .stat-value,
body.dashboard-page .breakdown-score,
body.dashboard-page .board-module-metric strong,
body.dashboard-page .board-kpi-value,
body.dashboard-page .board-comparison-item strong {
  animation: none !important;
  transition-duration: 0.01ms !important;
}

body.dashboard-page .board-carousel-frame--next .board-slide,
body.dashboard-page .board-carousel-frame--prev .board-slide,
body.dashboard-page .board-slide.is-leaving-next,
body.dashboard-page .board-slide.is-leaving-prev {
  animation: none !important;
}

@keyframes cockpitAmbient {
  0% { transform: translate3d(-1.5%, -1%, 0) scale(1); opacity: 0.58; }
  100% { transform: translate3d(1.5%, 1%, 0) scale(1.04); opacity: 0.82; }
}

@keyframes pageShellIn {
  from { opacity: 0; transform: translate3d(0, 8px, 0); }
  to { opacity: 1; transform: translate3d(0, 0, 0); }
}

@keyframes headerDockIn {
  from { opacity: 0; transform: translate3d(0, -10px, 0); }
  to { opacity: 1; transform: translate3d(0, 0, 0); }
}

@keyframes activeSlideBreath {
  0%, 100% { box-shadow: 0 16px 36px rgba(255, 198, 90, 0.08); }
  50% { box-shadow: 0 20px 46px rgba(255, 198, 90, 0.2); }
}

@keyframes indicatorSweep {
  0% { transform: translateX(-70%); opacity: 0; }
  20% { opacity: 0.9; }
  100% { transform: translateX(70%); opacity: 0.25; }
}

@keyframes statusDotPulse {
  0% { box-shadow: 0 0 0 0 rgba(255, 198, 90, 0.38); }
  100% { box-shadow: 0 0 0 9px rgba(255, 198, 90, 0); }
}

@keyframes loadingSweep {
  0% { transform: translateX(-110%); }
  100% { transform: translateX(110%); }
}

@keyframes spinnerOrbit {
  to { transform: rotate(360deg); }
}

@keyframes overlayRiseIn {
  from { opacity: 0; transform: translate3d(0, 14px, 0) scale(0.985); }
  to { opacity: 1; transform: translate3d(0, 0, 0) scale(1); }
}

@keyframes numberSettle {
  from { opacity: 0; transform: translate3d(0, 7px, 0) scale(0.96); }
  to { opacity: 1; transform: translate3d(0, 0, 0) scale(1); }
}

@keyframes boardSlideInNext {
  from { opacity: 0; transform: translate3d(46px, 0, 0) scale(0.992); }
  to { opacity: 1; transform: translate3d(0, 0, 0); }
}

@keyframes boardSlideInPrev {
  from { opacity: 0; transform: translate3d(-46px, 0, 0) scale(0.992); }
  to { opacity: 1; transform: translate3d(0, 0, 0); }
}

@keyframes boardSlideOutNext {
  from { opacity: 1; transform: translate3d(0, 0, 0) scale(1); }
  to { opacity: 0; transform: translate3d(-34px, 0, 0) scale(0.992); }
}

@keyframes boardSlideOutPrev {
  from { opacity: 1; transform: translate3d(0, 0, 0) scale(1); }
  to { opacity: 0; transform: translate3d(34px, 0, 0) scale(0.992); }
}

@keyframes boardSlideFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes boardSlideFadeOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

@supports not (filter: blur(1px)) {
  .motion-reveal {
    filter: none;
  }
}

@media (max-width: 900px) {
  html {
    scroll-behavior: auto;
  }

  body::after {
    animation: none;
    filter: none;
    opacity: 0.22;
  }

  .motion-reveal {
    filter: none;
    transform: translate3d(0, 10px, 0);
    transition-duration: 360ms;
    transition-delay: calc(var(--motion-index, 0) * 18ms);
  }

  .board-slide,
  .board-slide.is-active {
    opacity: 1;
    transform: none;
  }

  .board-slide-indicator.active {
    animation: none;
  }
}

/* Performance: animations and glass effects disabled globally */
html {
  scroll-behavior: auto;
}

*,
*::before,
*::after {
  animation-duration: 0.01ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.01ms !important;
}

* {
  backdrop-filter: none !important;
}

body::after {
  display: none;
}

/* Restore loading indicators */
.app-spinner,
.spinner {
  animation-duration: 900ms !important;
  animation-iteration-count: infinite !important;
}
.app-loading-state::after {
  animation-duration: 1.8s !important;
  animation-iteration-count: infinite !important;
}

/* Dense pages should not reflow every frame while the sidebar changes state. */
.sidebar,
.main-content,
.main-content.sidebar-collapsed {
  transition: none !important;
}

/* Restore only compositor-friendly feedback for interactive controls and overlays. */
.nav-item,
.ui-chip-button,
.ui-filter-chip,
.board-slide-indicator,
.mobile-bottom-nav button,
.dashboard-detail-drawer,
.mobile-nav-drawer,
.modal-card {
  transition:
    transform 150ms ease,
    opacity 150ms ease,
    color 150ms ease,
    background-color 150ms ease,
    border-color 150ms ease !important;
}

.nav-item:active,
.ui-chip-button:active,
.ui-filter-chip:active,
.mobile-bottom-nav button:active {
  transform: scale(0.98);
}

@media (prefers-reduced-motion: reduce) {
  .nav-item,
  .ui-chip-button,
  .ui-filter-chip,
  .board-slide-indicator,
  .mobile-bottom-nav button,
  .dashboard-detail-drawer,
  .mobile-nav-drawer,
  .modal-card,
  .board-slide {
    animation: none !important;
    transition: none !important;
  }

  .nav-item:active,
  .ui-chip-button:active,
  .ui-filter-chip:active,
  .mobile-bottom-nav button:active {
    transform: none !important;
  }
}

body.dashboard-page .board-slide.is-leaving-next {
  animation-name: boardSlideOutNext !important;
  animation-duration: 220ms !important;
  animation-timing-function: cubic-bezier(0.55, 0, 1, 0.45) !important;
  animation-fill-mode: both !important;
  animation-iteration-count: 1 !important;
}

body.dashboard-page .board-slide.is-leaving-prev {
  animation-name: boardSlideOutPrev !important;
  animation-duration: 220ms !important;
  animation-timing-function: cubic-bezier(0.55, 0, 1, 0.45) !important;
  animation-fill-mode: both !important;
  animation-iteration-count: 1 !important;
}
