/* =========================================================
   Sun Panel — Advanced Motion System
   GSAP-powered animations, micro-interactions, transitions
   ========================================================= */

@import 'design-tokens.css';

/* ============ ENTRANCE & EXIT ANIMATIONS ============ */

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes fadeOut {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes slideOutRight {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(30px);
  }
}

@keyframes slideInLeft {
  from {
    opacity: 0;
    transform: translateX(-30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes slideOutLeft {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(-30px);
  }
}

@keyframes slideInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideOutDown {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(20px);
  }
}

@keyframes slideInDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideOutUp {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(-20px);
  }
}

/* ============ SCALE & ZOOM ANIMATIONS ============ */

@keyframes zoomIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes zoomOut {
  from {
    opacity: 1;
    transform: scale(1);
  }
  to {
    opacity: 0;
    transform: scale(0.95);
  }
}

@keyframes scaleUp {
  from {
    transform: scale(0.98);
  }
  to {
    transform: scale(1);
  }
}

@keyframes scaleDown {
  from {
    transform: scale(1);
  }
  to {
    transform: scale(0.98);
  }
}

/* ============ ROTATION ANIMATIONS ============ */

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

@keyframes rotatePlane {
  0% {
    transform: rotateX(0deg) rotateY(0deg);
  }
  50% {
    transform: rotateX(10deg) rotateY(10deg);
  }
  100% {
    transform: rotateX(0deg) rotateY(0deg);
  }
}

/* ============ GLOW & PULSE ANIMATIONS ============ */

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.7;
  }
}

@keyframes glow {
  0%, 100% {
    box-shadow: 0 0 12px rgba(139, 92, 246, 0.15);
  }
  50% {
    box-shadow: 0 0 24px rgba(139, 92, 246, 0.35);
  }
}

@keyframes glowColor {
  0%, 100% {
    box-shadow: 0 0 12px rgba(139, 92, 246, 0.2), 0 0 30px rgba(139, 92, 246, 0.1);
  }
  50% {
    box-shadow: 0 0 20px rgba(139, 92, 246, 0.4), 0 0 50px rgba(139, 92, 246, 0.2);
  }
}

@keyframes shimmer {
  0% {
    background-position: -1000px 0;
  }
  100% {
    background-position: 1000px 0;
  }
}

/* ============ BOUNCE & ELASTIC ANIMATIONS ============ */

@keyframes bounce {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

@keyframes bounceIn {
  0% {
    opacity: 0;
    transform: scale(0.3);
  }
  50% {
    opacity: 1;
    transform: scale(1.05);
  }
  70% {
    transform: scale(0.9);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes shake {
  0%, 100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-5px);
  }
  75% {
    transform: translateX(5px);
  }
}

/* ============ SKELETON LOADING ANIMATIONS ============ */

@keyframes skeletonLoading {
  0% {
    background-position: -1000px 0;
  }
  100% {
    background-position: 1000px 0;
  }
}

.skeleton {
  background: linear-gradient(
    90deg,
    rgba(139, 92, 246, 0.05) 25%,
    rgba(139, 92, 246, 0.15) 50%,
    rgba(139, 92, 246, 0.05) 75%
  );
  background-size: 1000px 100%;
  animation: skeletonLoading 2s infinite;
  border-radius: var(--radius-md);
}

.skeleton-text {
  height: 14px;
  margin-bottom: 8px;
  border-radius: var(--radius-xs);
}

.skeleton-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
}

.skeleton-card {
  height: 200px;
  border-radius: var(--radius-md);
}

/* ============ BUTTON MICRO-INTERACTIONS ============ */

button, .btn {
  position: relative;
  overflow: hidden;
}

/* Ripple effect on click */
button::after, .btn::after {
  content: '';
  position: absolute;
  top: 50%;
  right: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.5);
  transform: translate(50%, -50%);
  pointer-events: none;
  transition: width 0.6s, height 0.6s;
}

button:active::after, .btn:active::after {
  width: 300px;
  height: 300px;
  opacity: 0;
}

/* ============ INPUT FOCUS ANIMATIONS ============ */

input, textarea, select {
  position: relative;
}

input::before, textarea::before, select::before {
  content: '';
  position: absolute;
  bottom: 0;
  right: 0;
  width: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--color-purple), var(--color-cyan));
  transition: width var(--transition-normal);
  pointer-events: none;
}

input:focus::before, textarea:focus::before, select:focus::before {
  width: 100%;
}

/* ============ CARD HOVER ANIMATIONS ============ */

.card, .glass-card {
  position: relative;
  overflow: hidden;
}

.card::before, .glass-card::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(139, 92, 246, 0.1) 0%, transparent 70%);
  opacity: 0;
  transition: opacity var(--transition-normal);
  pointer-events: none;
}

.card:hover::before, .glass-card:hover::before {
  opacity: 1;
}

/* ============ CHECKBOX & RADIO ANIMATIONS ============ */

input[type="checkbox"],
input[type="radio"] {
  appearance: none;
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border: 2px solid var(--color-border-soft);
  border-radius: var(--radius-sm);
  background-color: transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
}

input[type="checkbox"]:hover,
input[type="radio"]:hover {
  border-color: var(--color-purple);
  box-shadow: var(--shadow-glow-sm);
}

input[type="checkbox"]:checked,
input[type="radio"]:checked {
  background: linear-gradient(135deg, var(--color-purple), var(--color-purple-l));
  border-color: var(--color-purple);
  box-shadow: var(--shadow-glow-md);
}

input[type="checkbox"]::after {
  content: '✓';
  position: absolute;
  top: 50%;
  right: 50%;
  transform: translate(50%, -50%);
  color: white;
  font-weight: bold;
  opacity: 0;
  transition: opacity var(--transition-fast);
}

input[type="checkbox"]:checked::after {
  opacity: 1;
}

input[type="radio"] {
  border-radius: 50%;
}

input[type="radio"]::after {
  content: '';
  position: absolute;
  top: 50%;
  right: 50%;
  width: 6px;
  height: 6px;
  background: white;
  border-radius: 50%;
  transform: translate(50%, -50%);
  opacity: 0;
  transition: opacity var(--transition-fast);
}

input[type="radio"]:checked::after {
  opacity: 1;
}

/* ============ DROPDOWN & MENU ANIMATIONS ============ */

.dropdown {
  animation: slideInUp var(--transition-normal) ease-out;
}

.menu {
  animation: slideInUp var(--transition-normal) ease-out;
}

.menu-item {
  transition: background-color var(--transition-fast), padding-right var(--transition-fast);
}

.menu-item:hover {
  background-color: var(--color-base-5);
  padding-right: calc(var(--spacing-4) + 4px);
}

/* ============ MODAL & DIALOG ANIMATIONS ============ */

.modal {
  animation: zoomIn var(--transition-normal) ease-out;
}

.modal-overlay {
  animation: fadeIn var(--transition-normal) ease-out;
}

.modal.closing {
  animation: zoomOut var(--transition-fast) ease-in forwards;
}

.modal-overlay.closing {
  animation: fadeOut var(--transition-fast) ease-in forwards;
}

/* ============ TOAST ANIMATIONS ============ */

.toast {
  animation: slideInRight var(--transition-normal) ease-out;
  position: fixed;
  right: var(--spacing-4);
  bottom: var(--spacing-4);
  z-index: var(--z-notification);
}

.toast.closing {
  animation: slideOutRight var(--transition-fast) ease-in forwards;
}

.toast-icon {
  animation: scaleUp var(--transition-normal) cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ============ PROGRESS BAR ANIMATIONS ============ */

.progress {
  height: 4px;
  background-color: var(--color-base-4);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--color-purple), var(--color-cyan));
  border-radius: var(--radius-full);
  transition: width var(--transition-slow);
}

.progress-fill.animated {
  animation: shimmer 2s infinite;
}

/* ============ SPINNER/LOADER ANIMATIONS ============ */

.spinner {
  width: 20px;
  height: 20px;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-purple);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.spinner-ring {
  width: 30px;
  height: 30px;
  border: 3px solid transparent;
  border-top-color: var(--color-purple);
  border-right-color: var(--color-cyan);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.spinner-pulse {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background-color: var(--color-purple);
  animation: pulse 1.2s ease-in-out infinite;
}

/* ============ PAGE TRANSITION ANIMATIONS ============ */

.page-enter {
  animation: slideInDown var(--transition-normal) ease-out;
}

.page-exit {
  animation: slideOutUp var(--transition-fast) ease-in forwards;
}

.fade-enter {
  animation: fadeIn var(--transition-normal) ease-out;
}

.fade-exit {
  animation: fadeOut var(--transition-fast) ease-in forwards;
}

/* ============ PARALLAX SCROLL ANIMATIONS ============ */

.parallax {
  background-attachment: fixed;
  background-size: cover;
  background-position: center;
}

.parallax-content {
  transform: translate3d(0, 0, 0);
  will-change: transform;
}

/* ============ STAGGER ANIMATIONS ============ */

.stagger-item {
  opacity: 0;
  animation: slideInUp var(--transition-normal) ease-out forwards;
}

.stagger-item:nth-child(1) { animation-delay: 0ms; }
.stagger-item:nth-child(2) { animation-delay: 100ms; }
.stagger-item:nth-child(3) { animation-delay: 200ms; }
.stagger-item:nth-child(4) { animation-delay: 300ms; }
.stagger-item:nth-child(5) { animation-delay: 400ms; }
.stagger-item:nth-child(n+6) { animation-delay: calc((var(--index, 5) - 5) * 100ms); }

/* ============ MAGICAL BUTTON ANIMATIONS ============ */

.btn-magnetic {
  position: relative;
  transition: all var(--transition-fast);
}

.btn-magnetic::before {
  content: '';
  position: absolute;
  inset: -2px;
  background: radial-gradient(circle, rgba(139, 92, 246, 0.3), transparent);
  border-radius: inherit;
  opacity: 0;
  transition: opacity var(--transition-fast);
  pointer-events: none;
}

.btn-magnetic:hover::before {
  opacity: 1;
}

/* ============ TEXT ANIMATIONS ============ */

.text-fade {
  animation: fadeIn var(--transition-slow) ease-out;
}

.text-glow {
  animation: glowColor 2s ease-in-out infinite;
}

.text-shimmer {
  background: linear-gradient(
    90deg,
    var(--color-text-0) 0%,
    var(--color-purple) 50%,
    var(--color-text-0) 100%
  );
  background-size: 200% auto;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: shimmer 3s linear infinite;
}

/* ============ BREADCRUMB ANIMATIONS ============ */

.breadcrumb-item {
  transition: color var(--transition-fast);
}

.breadcrumb-item:hover {
  color: var(--color-purple);
  text-shadow: 0 0 8px rgba(139, 92, 246, 0.3);
}

.breadcrumb-separator {
  display: inline-block;
  margin: 0 var(--spacing-2);
  animation: pulse 2s ease-in-out infinite;
}

/* ============ FLOATING ELEMENTS ============ */

@keyframes float {
  0%, 100% {
    transform: translateY(0px);
  }
  50% {
    transform: translateY(-10px);
  }
}

.float {
  animation: float 3s ease-in-out infinite;
}

.float-slow {
  animation: float 4s ease-in-out infinite;
}

.float-fast {
  animation: float 2s ease-in-out infinite;
}

/* ============ UTILITY ANIMATION CLASSES ============ */

.animate-fade-in {
  animation: fadeIn var(--transition-normal);
}

.animate-slide-in {
  animation: slideInUp var(--transition-normal);
}

.animate-zoom-in {
  animation: zoomIn var(--transition-normal);
}

.animate-pulse {
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.animate-spin {
  animation: spin 1s linear infinite;
}

.animate-bounce {
  animation: bounce 1s infinite;
}

.animate-glow {
  animation: glow 2s ease-in-out infinite;
}

/* ============ PREFERS REDUCED MOTION ============ */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ============ PERFORMANCE OPTIMIZATION ============ */

/* Use will-change sparingly and remove after animation */
.will-animate {
  will-change: transform, opacity;
}

.animate-gpu {
  transform: translateZ(0);
  backface-visibility: hidden;
  perspective: 1000px;
}
