/**
 * Contextual Navigation System - Micro-interactions & Animations
 *
 * Premium micro-interactions that make the navigation feel responsive and alive.
 */

/* =============================================================================
   KEYFRAMES
   ============================================================================= */

@keyframes cns-fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes cns-slide-in-from-top {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes cns-slide-in-from-bottom {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes cns-slide-in-from-left {
  from {
    opacity: 0;
    transform: translateX(-8px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes cns-slide-in-from-right {
  from {
    opacity: 0;
    transform: translateX(8px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes cns-scale-in {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes cns-bounce-in {
  0% {
    opacity: 0;
    transform: scale(0.3);
  }
  50% {
    transform: scale(1.05);
  }
  70% {
    transform: scale(0.9);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes cns-pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

@keyframes cns-shimmer {
  0% {
    background-position: -200% 0;
  }
  100% {
    background-position: 200% 0;
  }
}

@keyframes cns-glow {
  0%, 100% {
    box-shadow: 0 0 0 0 var(--ds-primary-alpha-20);
  }
  50% {
    box-shadow: 0 0 0 4px var(--ds-primary-alpha-10);
  }
}

/* =============================================================================
   ANIMATION CLASSES
   ============================================================================= */

.cns-animate-fade-in {
  animation: cns-fade-in 200ms ease-out forwards;
}

.cns-animate-slide-in-top {
  animation: cns-slide-in-from-top 200ms ease-out forwards;
}

.cns-animate-slide-in-bottom {
  animation: cns-slide-in-from-bottom 200ms ease-out forwards;
}

.cns-animate-slide-in-left {
  animation: cns-slide-in-from-left 200ms ease-out forwards;
}

.cns-animate-slide-in-right {
  animation: cns-slide-in-from-right 200ms ease-out forwards;
}

.cns-animate-scale-in {
  animation: cns-scale-in 150ms ease-out forwards;
}

.cns-animate-bounce-in {
  animation: cns-bounce-in 400ms ease-out forwards;
}

.cns-animate-pulse {
  animation: cns-pulse 2s ease-in-out infinite;
}

/* =============================================================================
   LOADING SKELETON
   ============================================================================= */

.cns-skeleton {
  background: linear-gradient(
    90deg,
    var(--ds-subtle) 0%,
    var(--ds-muted) 50%,
    var(--ds-subtle) 100%
  );
  background-size: 200% 100%;
  animation: cns-shimmer 1.5s ease-in-out infinite;
  border-radius: 4px;
}

/* =============================================================================
   INTERACTIVE STATES
   ============================================================================= */

/* Button press effect */
.cns-press-effect {
  transition: transform 150ms ease-out, box-shadow 150ms ease-out;
}

.cns-press-effect:active {
  transform: scale(0.97);
}

/* Hover lift effect */
.cns-hover-lift {
  transition: transform 200ms ease-out, box-shadow 200ms ease-out;
}

.cns-hover-lift:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px var(--ds-shadow-sm);
}

/* Hover glow effect */
.cns-hover-glow {
  transition: box-shadow 200ms ease-out;
}

.cns-hover-glow:hover {
  box-shadow: 0 0 0 3px var(--ds-primary-alpha-20);
}

/* Focus glow animation */
.cns-focus-glow:focus-visible {
  animation: cns-glow 1.5s ease-in-out infinite;
}

/* =============================================================================
   DROPDOWN ANIMATIONS
   ============================================================================= */

.cns-dropdown-content {
  animation: cns-scale-in 150ms ease-out forwards;
  transform-origin: top;
}

.cns-dropdown-item {
  transition: background-color 100ms ease-out, color 100ms ease-out;
}

/* Stagger animation for dropdown items */
.cns-dropdown-item:nth-child(1) { animation-delay: 0ms; }
.cns-dropdown-item:nth-child(2) { animation-delay: 20ms; }
.cns-dropdown-item:nth-child(3) { animation-delay: 40ms; }
.cns-dropdown-item:nth-child(4) { animation-delay: 60ms; }
.cns-dropdown-item:nth-child(5) { animation-delay: 80ms; }
.cns-dropdown-item:nth-child(6) { animation-delay: 100ms; }
.cns-dropdown-item:nth-child(7) { animation-delay: 120ms; }
.cns-dropdown-item:nth-child(8) { animation-delay: 140ms; }

/* =============================================================================
   BREADCRUMB TRANSITIONS
   ============================================================================= */

.cns-breadcrumb-segment {
  transition: color 150ms ease-out;
}

.cns-breadcrumb-chevron {
  transition: transform 200ms ease-out;
}

.cns-breadcrumb-segment[data-state="open"] .cns-breadcrumb-chevron {
  transform: rotate(180deg);
}

/* =============================================================================
   ACTION BAR TRANSITIONS
   ============================================================================= */

.cns-action-bar {
  transition: background-color 200ms ease-out, box-shadow 200ms ease-out;
}

.cns-action-button {
  transition: all 150ms ease-out;
}

.cns-action-button:hover {
  transform: translateY(-1px);
}

.cns-action-button:active {
  transform: translateY(0);
}

/* Selection bar slide in */
.cns-selection-bar {
  animation: cns-slide-in-from-bottom 200ms ease-out forwards;
}

/* =============================================================================
   KPI COUNTER ANIMATION
   ============================================================================= */

.cns-kpi-value {
  transition: all 300ms ease-out;
}

.cns-kpi-value[data-changed="true"] {
  animation: cns-bounce-in 400ms ease-out;
}

/* =============================================================================
   WORKFLOW SUGGESTIONS
   ============================================================================= */

.cns-workflow-card {
  transition: transform 200ms ease-out, box-shadow 200ms ease-out, border-color 200ms ease-out;
}

.cns-workflow-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px var(--ds-shadow-lg);
  border-color: var(--ds-primary);
}

.cns-workflow-step {
  opacity: 0;
  animation: cns-slide-in-from-left 200ms ease-out forwards;
}

/* Stagger workflow steps */
.cns-workflow-step:nth-child(1) { animation-delay: 0ms; }
.cns-workflow-step:nth-child(2) { animation-delay: 50ms; }
.cns-workflow-step:nth-child(3) { animation-delay: 100ms; }
.cns-workflow-step:nth-child(4) { animation-delay: 150ms; }

/* =============================================================================
   QUICK VIEW POPUP
   ============================================================================= */

.cns-quick-view {
  animation: cns-scale-in 150ms ease-out forwards;
  transform-origin: center left;
}

.cns-quick-view[data-side="right"] {
  transform-origin: center right;
}

.cns-quick-view[data-side="top"] {
  transform-origin: bottom center;
}

.cns-quick-view[data-side="bottom"] {
  transform-origin: top center;
}

/* =============================================================================
   COMMAND PALETTE
   ============================================================================= */

.cns-command-overlay {
  animation: cns-fade-in 100ms ease-out forwards;
}

.cns-command-dialog {
  animation: cns-slide-in-from-top 200ms ease-out forwards;
}

.cns-command-item {
  transition: background-color 100ms ease-out;
}

.cns-command-item[data-selected="true"] {
  background-color: var(--ds-subtle);
}

/* =============================================================================
   KEYBOARD INDICATOR
   ============================================================================= */

.cns-keyboard-indicator {
  animation: cns-bounce-in 200ms ease-out forwards;
}

.cns-keyboard-key {
  transition: transform 100ms ease-out, box-shadow 100ms ease-out;
}

.cns-keyboard-key:active {
  transform: scale(0.95);
  box-shadow: inset 0 2px 4px var(--ds-shadow-sm);
}

/* =============================================================================
   QUICK ACCESS SIDEBAR
   ============================================================================= */

.cns-quick-access-item {
  transition: all 150ms ease-out;
}

.cns-quick-access-item:hover {
  background-color: var(--ds-subtle);
  padding-left: 12px;
}

.cns-quick-access-pin {
  opacity: 0;
  transition: opacity 150ms ease-out;
}

.cns-quick-access-item:hover .cns-quick-access-pin {
  opacity: 1;
}

/* =============================================================================
   SCROLL INDICATOR
   ============================================================================= */

.cns-scroll-shadow-top {
  background: linear-gradient(to bottom, var(--ds-surface), transparent);
  height: 16px;
  position: sticky;
  top: 0;
  opacity: 0;
  transition: opacity 200ms ease-out;
}

.cns-scroll-shadow-top[data-visible="true"] {
  opacity: 1;
}

.cns-scroll-shadow-bottom {
  background: linear-gradient(to top, var(--ds-surface), transparent);
  height: 16px;
  position: sticky;
  bottom: 0;
  opacity: 0;
  transition: opacity 200ms ease-out;
}

.cns-scroll-shadow-bottom[data-visible="true"] {
  opacity: 1;
}

/* =============================================================================
   REDUCED MOTION
   ============================================================================= */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

