/**
 * Nordic Corporate Design System - Animations & Effects
 * Transitions, Micro-interactions, Skeleton Loading
 */

/* =============================================
   KEYFRAME ANIMATIONS
   ============================================= */

/* Fade In */
@keyframes nordic-fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Fade In Up */
@keyframes nordic-fade-in-up {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Fade In Down */
@keyframes nordic-fade-in-down {
  from {
    opacity: 0;
    transform: translateY(-16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Fade In Left */
@keyframes nordic-fade-in-left {
  from {
    opacity: 0;
    transform: translateX(-16px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Fade In Right */
@keyframes nordic-fade-in-right {
  from {
    opacity: 0;
    transform: translateX(16px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Scale In */
@keyframes nordic-scale-in {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Slide In Right */
@keyframes nordic-slide-in-right {
  from {
    transform: translateX(100%);
  }
  to {
    transform: translateX(0);
  }
}

/* Slide In Left */
@keyframes nordic-slide-in-left {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(0);
  }
}

/* Pulse */
@keyframes nordic-pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

/* Spin */
@keyframes nordic-spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* Bounce */
@keyframes nordic-bounce {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-8px);
  }
}

/* Shimmer (for skeleton loading) */
@keyframes nordic-shimmer {
  0% {
    background-position: -200% 0;
  }
  100% {
    background-position: 200% 0;
  }
}

/* Shake (for errors) */
@keyframes nordic-shake {
  0%, 100% {
    transform: translateX(0);
  }
  10%, 30%, 50%, 70%, 90% {
    transform: translateX(-4px);
  }
  20%, 40%, 60%, 80% {
    transform: translateX(4px);
  }
}

/* Pop */
@keyframes nordic-pop {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
  100% {
    transform: scale(1);
  }
}

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

.nordic-animate-fade-in {
  animation: nordic-fade-in var(--nordic-duration-normal) var(--nordic-ease-out);
}

.nordic-animate-fade-in-up {
  animation: nordic-fade-in-up var(--nordic-duration-normal) var(--nordic-ease-out);
}

.nordic-animate-fade-in-down {
  animation: nordic-fade-in-down var(--nordic-duration-normal) var(--nordic-ease-out);
}

.nordic-animate-scale-in {
  animation: nordic-scale-in var(--nordic-duration-normal) var(--nordic-ease-out);
}

.nordic-animate-spin {
  animation: nordic-spin 1s linear infinite;
}

.nordic-animate-pulse {
  animation: nordic-pulse 2s var(--nordic-ease-in-out) infinite;
}

.nordic-animate-bounce {
  animation: nordic-bounce 1s var(--nordic-ease-in-out) infinite;
}

.nordic-animate-shake {
  animation: nordic-shake 0.5s var(--nordic-ease-default);
}

.nordic-animate-pop {
  animation: nordic-pop 0.3s var(--nordic-ease-bounce);
}

/* =============================================
   STAGGERED ANIMATIONS
   ============================================= */

.nordic-stagger > * {
  animation: nordic-fade-in-up var(--nordic-duration-normal) var(--nordic-ease-out) forwards;
  opacity: 0;
}

.nordic-stagger > *:nth-child(1) { animation-delay: 0ms; }
.nordic-stagger > *:nth-child(2) { animation-delay: 50ms; }
.nordic-stagger > *:nth-child(3) { animation-delay: 100ms; }
.nordic-stagger > *:nth-child(4) { animation-delay: 150ms; }
.nordic-stagger > *:nth-child(5) { animation-delay: 200ms; }
.nordic-stagger > *:nth-child(6) { animation-delay: 250ms; }
.nordic-stagger > *:nth-child(7) { animation-delay: 300ms; }
.nordic-stagger > *:nth-child(8) { animation-delay: 350ms; }
.nordic-stagger > *:nth-child(9) { animation-delay: 400ms; }
.nordic-stagger > *:nth-child(10) { animation-delay: 450ms; }
.nordic-stagger > *:nth-child(11) { animation-delay: 500ms; }
.nordic-stagger > *:nth-child(12) { animation-delay: 550ms; }

/* Slower stagger variant */
.nordic-stagger--slow > * {
  animation-duration: var(--nordic-duration-slow);
}

.nordic-stagger--slow > *:nth-child(1) { animation-delay: 0ms; }
.nordic-stagger--slow > *:nth-child(2) { animation-delay: 75ms; }
.nordic-stagger--slow > *:nth-child(3) { animation-delay: 150ms; }
.nordic-stagger--slow > *:nth-child(4) { animation-delay: 225ms; }
.nordic-stagger--slow > *:nth-child(5) { animation-delay: 300ms; }
.nordic-stagger--slow > *:nth-child(6) { animation-delay: 375ms; }

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

.nordic-skeleton {
  background: linear-gradient(
    90deg,
    var(--nordic-bg-warm) 0%,
    var(--nordic-bg-surface) 50%,
    var(--nordic-bg-warm) 100%
  );
  background-size: 200% 100%;
  animation: nordic-shimmer 1.5s ease-in-out infinite;
  border-radius: var(--nordic-radius-md);
}

.nordic-skeleton--text {
  height: 1em;
  width: 100%;
  margin-bottom: var(--nordic-space-2);
}

.nordic-skeleton--text:last-child {
  width: 75%;
}

.nordic-skeleton--title {
  height: 1.5em;
  width: 60%;
  margin-bottom: var(--nordic-space-3);
}

.nordic-skeleton--avatar {
  width: 48px;
  height: 48px;
  border-radius: var(--nordic-radius-full);
}

.nordic-skeleton--avatar-lg {
  width: 80px;
  height: 80px;
  border-radius: var(--nordic-radius-full);
}

.nordic-skeleton--card {
  height: 200px;
  border-radius: var(--nordic-radius-xl);
}

.nordic-skeleton--button {
  height: 40px;
  width: 120px;
  border-radius: var(--nordic-radius-lg);
}

.nordic-skeleton--image {
  width: 100%;
  padding-top: 60%;
  border-radius: var(--nordic-radius-lg);
}

/* =============================================
   HOVER EFFECTS
   ============================================= */

.nordic-hover-lift {
  transition: transform var(--nordic-duration-fast) var(--nordic-ease-out),
              box-shadow var(--nordic-duration-fast) var(--nordic-ease-out);
}

.nordic-hover-lift:hover {
  transform: translateY(-4px);
  box-shadow: var(--nordic-shadow-lg);
}

.nordic-hover-scale {
  transition: transform var(--nordic-duration-fast) var(--nordic-ease-bounce);
}

.nordic-hover-scale:hover {
  transform: scale(1.02);
}

.nordic-hover-scale-sm:hover {
  transform: scale(1.01);
}

.nordic-hover-glow {
  transition: box-shadow var(--nordic-duration-fast) var(--nordic-ease-default);
}

.nordic-hover-glow:hover {
  box-shadow: 0 0 20px rgba(13, 92, 99, 0.15);
}

.nordic-hover-brighten {
  transition: filter var(--nordic-duration-fast) var(--nordic-ease-default);
}

.nordic-hover-brighten:hover {
  filter: brightness(1.05);
}

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

.nordic-transition {
  transition: all var(--nordic-duration-normal) var(--nordic-ease-default);
}

.nordic-transition-fast {
  transition: all var(--nordic-duration-fast) var(--nordic-ease-default);
}

.nordic-transition-slow {
  transition: all var(--nordic-duration-slow) var(--nordic-ease-default);
}

.nordic-transition-colors {
  transition: color var(--nordic-duration-fast) var(--nordic-ease-default),
              background-color var(--nordic-duration-fast) var(--nordic-ease-default),
              border-color var(--nordic-duration-fast) var(--nordic-ease-default);
}

.nordic-transition-opacity {
  transition: opacity var(--nordic-duration-fast) var(--nordic-ease-default);
}

.nordic-transition-transform {
  transition: transform var(--nordic-duration-fast) var(--nordic-ease-default);
}

/* =============================================
   COLLAPSE ANIMATION
   ============================================= */

.nordic-collapse {
  overflow: hidden;
  transition: max-height var(--nordic-duration-normal) var(--nordic-ease-default);
}

.nordic-collapse--closed {
  max-height: 0;
}

.nordic-collapse--open {
  max-height: 1000px;
}

/* =============================================
   GRADIENT MESH BACKGROUND
   ============================================= */

.nordic-gradient-mesh {
  position: relative;
  overflow: hidden;
}

.nordic-gradient-mesh::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background:
    radial-gradient(ellipse at 20% 20%, rgba(13, 92, 99, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 80%, rgba(224, 122, 95, 0.06) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 50%, rgba(129, 178, 154, 0.04) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

.nordic-gradient-mesh > * {
  position: relative;
  z-index: 1;
}

/* Hero gradient background */
.nordic-gradient-hero {
  background: linear-gradient(135deg, var(--nordic-primary) 0%, var(--nordic-primary-light) 100%);
  position: relative;
  overflow: hidden;
}

.nordic-gradient-hero::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -20%;
  width: 60%;
  height: 200%;
  background: radial-gradient(ellipse, rgba(255, 255, 255, 0.1) 0%, transparent 70%);
  pointer-events: none;
}

/* =============================================
   GLASSMORPHISM
   ============================================= */

.nordic-glass {
  background: var(--nordic-glass-bg);
  backdrop-filter: var(--nordic-glass-blur);
  -webkit-backdrop-filter: var(--nordic-glass-blur);
  border: var(--nordic-glass-border);
  box-shadow: var(--nordic-glass-shadow);
}

.nordic-glass--light {
  background: var(--nordic-glass-bg-light);
}

.nordic-glass--heavy {
  backdrop-filter: var(--nordic-glass-blur-heavy);
  -webkit-backdrop-filter: var(--nordic-glass-blur-heavy);
}

/* =============================================
   SPINNER
   ============================================= */

.nordic-spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--nordic-border-light);
  border-top-color: var(--nordic-primary);
  border-radius: var(--nordic-radius-full);
  animation: nordic-spin 0.8s linear infinite;
}

.nordic-spinner--sm {
  width: 16px;
  height: 16px;
  border-width: 2px;
}

.nordic-spinner--lg {
  width: 32px;
  height: 32px;
  border-width: 3px;
}

.nordic-spinner--xl {
  width: 48px;
  height: 48px;
  border-width: 4px;
}

/* =============================================
   PROGRESS BAR
   ============================================= */

.nordic-progress {
  height: 8px;
  background: var(--nordic-bg-warm);
  border-radius: var(--nordic-radius-full);
  overflow: hidden;
}

.nordic-progress__bar {
  height: 100%;
  background: linear-gradient(90deg, var(--nordic-primary), var(--nordic-primary-light));
  border-radius: var(--nordic-radius-full);
  transition: width var(--nordic-duration-slow) var(--nordic-ease-out);
}

.nordic-progress--accent .nordic-progress__bar {
  background: linear-gradient(90deg, var(--nordic-accent), var(--nordic-accent-light));
}

.nordic-progress--animated .nordic-progress__bar {
  background-size: 200% 100%;
  animation: nordic-shimmer 2s linear infinite;
}

/* =============================================
   NOTIFICATION DOT
   ============================================= */

.nordic-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--nordic-radius-full);
  background: var(--nordic-accent);
}

.nordic-dot--animated {
  animation: nordic-pulse 2s var(--nordic-ease-in-out) infinite;
}

.nordic-dot--success { background: var(--nordic-success); }
.nordic-dot--warning { background: var(--nordic-warning); }
.nordic-dot--error { background: var(--nordic-error); }
.nordic-dot--info { background: var(--nordic-info); }

/* =============================================
   RIPPLE EFFECT
   ============================================= */

.nordic-ripple {
  position: relative;
  overflow: hidden;
}

.nordic-ripple::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  background: rgba(255, 255, 255, 0.3);
  border-radius: var(--nordic-radius-full);
  transform: translate(-50%, -50%);
  opacity: 0;
}

.nordic-ripple:active::after {
  width: 200%;
  padding-top: 200%;
  opacity: 1;
  transition: width 0.4s, padding-top 0.4s, opacity 0.4s;
}

/* =============================================
   MOTION PREFERENCES
   ============================================= */

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

  .nordic-skeleton {
    animation: none;
    background: var(--nordic-bg-warm);
  }
}

/* =============================================
   ENTRANCE ANIMATIONS (for page load)
   ============================================= */

.nordic-page-enter {
  animation: nordic-fade-in-up var(--nordic-duration-slow) var(--nordic-ease-out);
}

.nordic-hero-enter {
  animation: nordic-scale-in var(--nordic-duration-slower) var(--nordic-ease-out);
}

/* =============================================
   TOAST NOTIFICATIONS
   ============================================= */

.nordic-toast-container {
  position: fixed;
  top: var(--nordic-space-6);
  right: var(--nordic-space-6);
  z-index: var(--nordic-z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--nordic-space-3);
}

.nordic-toast {
  background: var(--nordic-bg-surface);
  border-radius: var(--nordic-radius-lg);
  box-shadow: var(--nordic-shadow-xl);
  padding: var(--nordic-space-4);
  min-width: 300px;
  max-width: 400px;
  display: flex;
  align-items: flex-start;
  gap: var(--nordic-space-3);
  animation: nordic-fade-in-right var(--nordic-duration-normal) var(--nordic-ease-out);
}

.nordic-toast--success {
  border-left: 4px solid var(--nordic-success);
}

.nordic-toast--error {
  border-left: 4px solid var(--nordic-error);
}

.nordic-toast--warning {
  border-left: 4px solid var(--nordic-warning);
}

.nordic-toast--info {
  border-left: 4px solid var(--nordic-info);
}

.nordic-toast__icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.nordic-toast__content {
  flex: 1;
  min-width: 0;
}

.nordic-toast__title {
  font-weight: var(--nordic-weight-semibold);
  font-size: var(--nordic-text-sm);
  color: var(--nordic-text-primary);
  margin-bottom: var(--nordic-space-1);
}

.nordic-toast__message {
  font-size: var(--nordic-text-sm);
  color: var(--nordic-text-secondary);
}

.nordic-toast__close {
  width: 24px;
  height: 24px;
  border-radius: var(--nordic-radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--nordic-text-muted);
  flex-shrink: 0;
}

.nordic-toast__close:hover {
  background: var(--nordic-bg-warm);
  color: var(--nordic-text-primary);
}
