/* Animations and Keyframes */

/* Nebulous background animation */
@keyframes nebulous-flow {
  0%, 100% {
    transform: translate(-10px, -10px) rotate(0deg) scale(1);
  }
  25% {
    transform: translate(10px, -15px) rotate(1deg) scale(1.02);
  }
  50% {
    transform: translate(15px, 10px) rotate(-1deg) scale(0.98);
  }
  75% {
    transform: translate(-15px, 15px) rotate(0.5deg) scale(1.01);
  }
}

/* Nebulous liquid-glass background overlay for main popup */
.app-container::before {
  content: '';
  position: absolute;
  inset: -20%;
  pointer-events: none;
  z-index: 0;
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.10), rgba(0, 0, 0, 0.14)),
    radial-gradient(140px 200px at 18% 12%, rgba(0, 122, 255, 0.18), transparent 60%),
    radial-gradient(180px 140px at 85% 20%, rgba(255, 99, 71, 0.12), transparent 60%),
    radial-gradient(220px 180px at 28% 82%, rgba(50, 205, 50, 0.12), transparent 60%),
    radial-gradient(200px 220px at 92% 88%, rgba(155, 89, 182, 0.12), transparent 60%);
  filter: blur(34px) saturate(125%);
  opacity: 1;
  animation: nebulous-flow 40s ease-in-out infinite;
}

@media (prefers-color-scheme: dark) {
  .app-container::before {
    background:
      linear-gradient(180deg, rgba(0, 0, 0, 0.14), rgba(0, 0, 0, 0.16)),
      radial-gradient(140px 200px at 16% 10%, rgba(10, 132, 255, 0.22), transparent 60%),
      radial-gradient(160px 140px at 80% 18%, rgba(255, 159, 67, 0.16), transparent 60%),
      radial-gradient(220px 160px at 26% 78%, rgba(46, 213, 115, 0.16), transparent 60%),
      radial-gradient(200px 200px at 86% 86%, rgba(165, 94, 234, 0.18), transparent 60%);
    filter: blur(36px) saturate(125%);
    opacity: 0.9;
    animation: nebulous-flow 40s ease-in-out infinite;
  }
}

/* Fade in animation */
@keyframes fade-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Fade out animation */
@keyframes fade-out {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(-100%);
  }
}

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

/* Slide out to right */
@keyframes slide-out-right {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(100%);
    opacity: 0;
  }
}

/* Slide in from bottom */
@keyframes slideInFromBottom {
  from {
    transform: translateY(100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* Slide out to bottom */
@keyframes slideOutToBottom {
  from {
    transform: translateY(0);
    opacity: 1;
  }
  to {
    transform: translateY(100%);
    opacity: 0;
  }
}

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

/* Scale out animation */
@keyframes scale-out {
  from {
    transform: scale(1);
    opacity: 1;
  }
  to {
    transform: scale(0.9);
    opacity: 0;
  }
}

/* Bounce animation for buttons */
@keyframes bounce {
  0%, 20%, 53%, 80%, 100% {
    transform: translate3d(0, 0, 0);
  }
  40%, 43% {
    transform: translate3d(0, -8px, 0);
  }
  70% {
    transform: translate3d(0, -4px, 0);
  }
  90% {
    transform: translate3d(0, -2px, 0);
  }
}

/* Pulse animation */
@keyframes pulse {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
  100% {
    transform: scale(1);
  }
}

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

/* Loading spinner */
@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* Glow effect */
@keyframes glow {
  0%, 100% {
    box-shadow: 0 0 5px var(--accent-primary);
  }
  50% {
    box-shadow: 0 0 20px var(--accent-primary), 0 0 30px var(--accent-primary);
  }
}

/* Utility animation classes */
.fade-in {
  animation: fade-in 0.3s ease-out;
}

.fade-out {
  animation: fade-out 0.3s ease-in;
}

.slide-in {
  /* Changed to vertical slide from bottom */
  animation: slideInFromBottom 0.3s ease-out;
}

.slide-out {
  /* Changed to vertical slide to bottom */
  animation: slideOutToBottom 0.3s ease-in;
}

/* Matches class used by JS when opening editor */
.editor-fade-in {
  animation: fade-in 0.2s ease-out;
}

.scale-in {
  animation: scale-in 0.2s ease-out;
}

.scale-out {
  animation: scale-out 0.2s ease-in;
}

.bounce {
  animation: bounce 1s ease-in-out;
}

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

.shake {
  animation: shake 0.5s ease-in-out;
}

.spin {
  animation: spin 1s linear infinite;
}

.glow {
  animation: glow 2s ease-in-out infinite;
}

/* Smooth transitions for interactive elements */
.smooth-transition {
  transition: all 0.2s ease;
}

.smooth-transition-slow {
  transition: all 0.3s ease;
}

/* Hover effects */
.hover-lift:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px var(--shadow-dark);
}

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

.hover-glow:hover {
  box-shadow: 0 0 15px var(--accent-primary);
}

/* Focus effects */
.focus-ring:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.3);
}

/* Loading states */
.loading {
  position: relative;
  pointer-events: none;
  opacity: 0.6;
}

.loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 16px;
  height: 16px;
  margin: -8px 0 0 -8px;
  border: 2px solid var(--border-color);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

/* Disabled state */
.disabled {
  opacity: 0.5;
  pointer-events: none;
  cursor: not-allowed;
}

/* Notes animation keyframes */
@keyframes notes-fade-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes notes-stagger-in {
  0% {
    opacity: 0;
    transform: translateY(12px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Notes animation classes */
.notes-fade-in {
  animation: notes-fade-in 0.3s ease-out;
}

.note-item-stagger {
  animation: notes-stagger-in 0.4s ease-out;
  animation-fill-mode: both;
}

/* Stagger animation delays for note items */
.note-item-stagger:nth-child(1) { animation-delay: 0.05s; }
.note-item-stagger:nth-child(2) { animation-delay: 0.1s; }
.note-item-stagger:nth-child(3) { animation-delay: 0.15s; }
.note-item-stagger:nth-child(4) { animation-delay: 0.2s; }
.note-item-stagger:nth-child(5) { animation-delay: 0.25s; }
.note-item-stagger:nth-child(6) { animation-delay: 0.3s; }
.note-item-stagger:nth-child(7) { animation-delay: 0.35s; }
.note-item-stagger:nth-child(8) { animation-delay: 0.4s; }
.note-item-stagger:nth-child(9) { animation-delay: 0.45s; }
.note-item-stagger:nth-child(10) { animation-delay: 0.5s; }
