/* ==========================================================================
   TechBlog — Animations & Motion (animations.css)
   ==========================================================================
   Keyframe definitions, animation utility classes, scroll-triggered
   reveals, hover effects, stagger delays, and reduced-motion support.
   ========================================================================== */

/* --------------------------------------------------------------------------
   Keyframes — Fade In Up
   -------------------------------------------------------------------------- */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* --------------------------------------------------------------------------
   Keyframes — Fade In
   -------------------------------------------------------------------------- */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* --------------------------------------------------------------------------
   Keyframes — Slide In Left
   -------------------------------------------------------------------------- */
@keyframes slideInLeft {
  from {
    opacity: 0;
    transform: translateX(-30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* --------------------------------------------------------------------------
   Keyframes — Slide In Right
   -------------------------------------------------------------------------- */
@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* --------------------------------------------------------------------------
   Keyframes — Glow Pulse
   -------------------------------------------------------------------------- */
@keyframes glow {
  0%, 100% {
    box-shadow: 0 0 5px rgba(59, 130, 246, 0.2),
                0 0 20px rgba(59, 130, 246, 0.1);
  }
  50% {
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.4),
                0 0 40px rgba(59, 130, 246, 0.2);
  }
}

/* --------------------------------------------------------------------------
   Keyframes — Gradient Shift
   --------------------------------------------------------------------------
   Animate background-position for moving gradient effects.
   Use with `background-size: 200% 200%`.
   -------------------------------------------------------------------------- */
@keyframes gradient-shift {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

/* --------------------------------------------------------------------------
   Keyframes — Float
   -------------------------------------------------------------------------- */
@keyframes float {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-8px);
  }
}

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

/* --------------------------------------------------------------------------
   Keyframes — Scale In
   -------------------------------------------------------------------------- */
@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

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

/* ==========================================================================
   Animation Utility Classes
   ========================================================================== */

.animate-fade-in-up {
  animation: fadeInUp 0.6s ease-out both;
}

.animate-fade-in {
  animation: fadeIn 0.5s ease-out both;
}

.animate-slide-in-left {
  animation: slideInLeft 0.6s ease-out both;
}

.animate-slide-in-right {
  animation: slideInRight 0.6s ease-out both;
}

.animate-scale-in {
  animation: scaleIn 0.4s ease-out both;
}

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

.animate-gradient {
  background-size: 200% 200%;
  animation: gradient-shift 4s ease infinite;
}

.animate-float {
  animation: float 3s ease-in-out infinite;
}

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

/* ==========================================================================
   Scroll Reveal
   ==========================================================================
   Elements start invisible and slide up when the `.revealed` class is
   added via JavaScript (IntersectionObserver).
   ========================================================================== */

.scroll-reveal {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

.scroll-reveal.revealed {
  opacity: 1;
  transform: translateY(0);
}

/* Optional: scale variant */
.scroll-reveal--scale {
  opacity: 0;
  transform: scale(0.95);
  transition: opacity 0.5s ease-out, transform 0.5s ease-out;
}

.scroll-reveal--scale.revealed {
  opacity: 1;
  transform: scale(1);
}

/* Optional: slide-from-left variant */
.scroll-reveal--left {
  opacity: 0;
  transform: translateX(-30px);
  transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

.scroll-reveal--left.revealed {
  opacity: 1;
  transform: translateX(0);
}

/* ==========================================================================
   Hover Effects
   ========================================================================== */

/* — Hover Lift — */
.hover-lift {
  transition: transform var(--transition-base), box-shadow var(--transition-base);
}

.hover-lift:hover {
  transform: translateY(-8px);
  box-shadow: var(--shadow-xl);
}

/* — Hover Glow — */
.hover-glow {
  transition: box-shadow var(--transition-base);
}

.hover-glow:hover {
  box-shadow: var(--shadow-glow-blue);
}

.hover-glow--purple:hover {
  box-shadow: var(--shadow-glow-purple);
}

.hover-glow--cyan:hover {
  box-shadow: var(--shadow-glow-cyan);
}

/* — Hover Scale — */
.hover-scale {
  transition: transform var(--transition-base);
}

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

/* — Hover Brightness — */
.hover-brighten {
  transition: filter var(--transition-base);
}

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

/* ==========================================================================
   Stagger Delays
   ==========================================================================
   Apply to child elements to create a cascading entrance effect.
   Use with any `.animate-*` or `.scroll-reveal` class.
   ========================================================================== */

.stagger-1 { animation-delay: 0.1s; transition-delay: 0.1s; }
.stagger-2 { animation-delay: 0.2s; transition-delay: 0.2s; }
.stagger-3 { animation-delay: 0.3s; transition-delay: 0.3s; }
.stagger-4 { animation-delay: 0.4s; transition-delay: 0.4s; }
.stagger-5 { animation-delay: 0.5s; transition-delay: 0.5s; }
.stagger-6 { animation-delay: 0.6s; transition-delay: 0.6s; }

/* ==========================================================================
   Shimmer / Skeleton Loading
   ==========================================================================
   Apply `.shimmer` to placeholder elements to show a loading state.
   ========================================================================== */

.shimmer {
  position: relative;
  overflow: hidden;
  background: var(--color-bg-card);
  border-radius: var(--radius-md);
}

.shimmer::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.04) 20%,
    rgba(255, 255, 255, 0.08) 50%,
    rgba(255, 255, 255, 0.04) 80%,
    transparent 100%
  );
  background-size: 200% 100%;
  animation: shimmer 1.8s ease-in-out infinite;
}

[data-theme="light"] .shimmer::after {
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(0, 0, 0, 0.03) 20%,
    rgba(0, 0, 0, 0.06) 50%,
    rgba(0, 0, 0, 0.03) 80%,
    transparent 100%
  );
  background-size: 200% 100%;
}

/* Skeleton shapes */
.shimmer--text {
  height: 16px;
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-2);
}

.shimmer--text-sm {
  height: 12px;
  width: 60%;
  border-radius: var(--radius-sm);
}

.shimmer--image {
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-lg);
}

.shimmer--circle {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
}

.shimmer--card {
  height: 320px;
  border-radius: var(--radius-lg);
}

/* ==========================================================================
   Special Animated Elements
   ========================================================================== */

/* Animated gradient border — use on a wrapper element */
.gradient-border-animated {
  position: relative;
  border-radius: var(--radius-lg);
  padding: 1px;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6, #06b6d4, #3b82f6);
  background-size: 300% 300%;
  animation: gradient-shift 4s ease infinite;
}

.gradient-border-animated > * {
  border-radius: calc(var(--radius-lg) - 1px);
  background: var(--color-bg-primary);
}

/* Pulsing dot — for "live" indicators */
.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--color-accent-success);
  position: relative;
}

.pulse-dot::before {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: var(--radius-full);
  background: var(--color-accent-success);
  opacity: 0.4;
  animation: glow 2s ease-in-out infinite;
}

/* Typing cursor — for hero subtitles or code blocks */
.typing-cursor::after {
  content: '|';
  animation: fadeIn 0.8s ease-in-out infinite alternate;
  color: var(--color-accent-primary);
  margin-left: 2px;
}

/* ==========================================================================
   Reduced Motion — Accessibility
   ==========================================================================
   Respects `prefers-reduced-motion` to disable all non-essential motion
   for users who have requested reduced animations in their OS settings.
   ========================================================================== */

@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;
  }

  .scroll-reveal,
  .scroll-reveal--scale,
  .scroll-reveal--left {
    opacity: 1;
    transform: none;
    transition: none;
  }

  .hover-lift:hover {
    transform: none;
  }

  .hover-scale:hover {
    transform: none;
  }

  .animate-float,
  .animate-glow,
  .animate-gradient,
  .animate-bounce {
    animation: none;
  }
}
