/* ============================================================
   ANIMATIONS — Scroll Reveals, Micro-Interactions, Keyframes
   ============================================================ */

/* ============================================================
   1. KEYFRAME DEFINITIONS
   ============================================================ */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeInLeft {
  from {
    opacity: 0;
    transform: translateX(-30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes fadeInRight {
  from {
    opacity: 0;
    transform: translateX(30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes slideInFromLeft {
  from {
    opacity: 0;
    transform: translateX(-50px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

@keyframes glow {
  0%, 100% { box-shadow: 0 0 5px var(--accent-glow); }
  50% { box-shadow: 0 0 20px var(--accent-glow-strong); }
}

@keyframes float {
  0%, 100% { transform: translateY(0px); }
  50% { transform: translateY(-10px); }
}

@keyframes rotateIn {
  from {
    opacity: 0;
    transform: rotate(-10deg) scale(0.9);
  }
  to {
    opacity: 1;
    transform: rotate(0deg) scale(1);
  }
}

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

@keyframes scrollDown {
  0% {
    opacity: 1;
    transform: translateY(0);
  }
  75% {
    opacity: 0;
    transform: translateY(15px);
  }
  100% {
    opacity: 0;
    transform: translateY(15px);
  }
}

/* ============================================================
   2. SCROLL-TRIGGERED ANIMATION CLASSES
   ============================================================ */
.animate-on-scroll {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.6s cubic-bezier(0.4, 0, 0.2, 1),
              transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.animate-on-scroll.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Direction variants */
.animate-on-scroll--left {
  transform: translateX(-30px);
}

.animate-on-scroll--left.visible {
  transform: translateX(0);
}

.animate-on-scroll--right {
  transform: translateX(30px);
}

.animate-on-scroll--right.visible {
  transform: translateX(0);
}

.animate-on-scroll--scale {
  transform: scale(0.9);
}

.animate-on-scroll--scale.visible {
  transform: scale(1);
}

/* ============================================================
   3. STAGGER DELAY CLASSES
   ============================================================ */
.stagger-1 { transition-delay: 0.1s; }
.stagger-2 { transition-delay: 0.2s; }
.stagger-3 { transition-delay: 0.3s; }
.stagger-4 { transition-delay: 0.4s; }
.stagger-5 { transition-delay: 0.5s; }
.stagger-6 { transition-delay: 0.6s; }
.stagger-7 { transition-delay: 0.7s; }
.stagger-8 { transition-delay: 0.8s; }

/* ============================================================
   4. HERO ANIMATIONS
   ============================================================ */
.hero__label {
  animation: fadeInUp 0.8s ease forwards;
}

.hero__greeting {
  animation: fadeInUp 0.8s 0.2s ease both;
}

.hero__tagline {
  animation: fadeInUp 0.8s 0.4s ease both;
}

.hero__typed-wrapper {
  animation: fadeInUp 0.8s 0.6s ease both;
}

.hero__cta-group {
  animation: fadeInUp 0.8s 0.8s ease both;
}

.hero__illustration {
  animation: fadeIn 1.2s 0.5s ease both;
}

/* Floating effect for hero illustration */
.hero__illustration img {
  animation: float 6s ease-in-out infinite;
}

/* ============================================================
   5. SIDEBAR ANIMATIONS
   ============================================================ */
.sidebar__avatar-wrapper {
  animation: scaleIn 0.6s ease both;
}

.sidebar__name {
  animation: fadeInUp 0.5s 0.2s ease both;
}

.sidebar__title {
  animation: fadeInUp 0.5s 0.3s ease both;
}

.sidebar__cv-btn {
  animation: fadeInUp 0.5s 0.4s ease both;
}

.sidebar__nav-item {
  animation: fadeInUp 0.4s ease both;
}

.sidebar__nav-item:nth-child(1) { animation-delay: 0.3s; }
.sidebar__nav-item:nth-child(2) { animation-delay: 0.35s; }
.sidebar__nav-item:nth-child(3) { animation-delay: 0.4s; }
.sidebar__nav-item:nth-child(4) { animation-delay: 0.45s; }
.sidebar__nav-item:nth-child(5) { animation-delay: 0.5s; }
.sidebar__nav-item:nth-child(6) { animation-delay: 0.55s; }

/* Avatar hover glow */
.sidebar__avatar-wrapper:hover {
  animation: glow 2s ease-in-out infinite;
}

/* ============================================================
   6. CARD HOVER MICRO-ANIMATIONS
   ============================================================ */
/* Service cards icon bounce on hover */
.service-card:hover .service-card__icon {
  animation: pulse 0.5s ease;
}

/* Portfolio card overlay slide up */
.portfolio-card__overlay {
  transform: translateY(10px);
}

.portfolio-card:hover .portfolio-card__overlay {
  transform: translateY(0);
}

/* Blog card read-more arrow */
.blog-card__read-more i {
  transition: transform 0.3s ease;
}

.blog-card:hover .blog-card__read-more i {
  transform: translateX(4px);
}

/* ============================================================
   7. SKILL BAR ANIMATION
   ============================================================ */
.skill-item__fill {
  position: relative;
  overflow: hidden;
}

.skill-item__fill.animated::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.15),
    transparent
  );
  background-size: 200% 100%;
  animation: shimmer 2s ease-in-out;
}

/* ============================================================
   8. COUNTER ANIMATION
   ============================================================ */
.fact-card__number {
  transition: all 0.3s ease;
}

.fact-card:hover .fact-card__number {
  transform: scale(1.1);
  color: var(--accent);
}

/* ============================================================
   9. BUTTON RIPPLE EFFECT
   ============================================================ */
.btn {
  position: relative;
  overflow: hidden;
}

.btn::after {
  content: '';
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  background: radial-gradient(circle, rgba(255,255,255,0.2) 0%, transparent 60%);
  transform: scale(0);
  opacity: 0;
  transition: transform 0.5s ease, opacity 0.3s ease;
}

.btn:active::after {
  transform: scale(2.5);
  opacity: 1;
  transition: transform 0s, opacity 0s;
}

/* ============================================================
   10. SECTION TRANSITIONS
   ============================================================ */
.section {
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.section:hover {
  border-color: rgba(219, 164, 35, 0.15);
}

/* ============================================================
   11. TIMELINE ENTRY ANIMATIONS
   ============================================================ */
.timeline-item.animate-on-scroll {
  transform: translateX(-20px);
}

.timeline-item.animate-on-scroll.visible {
  transform: translateX(0);
}

/* ============================================================
   12. PORTFOLIO FILTER TRANSITIONS
   ============================================================ */
.portfolio-card {
  transition: opacity 0.4s ease, transform 0.4s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

.portfolio-card.hidden {
  opacity: 0;
  transform: scale(0.8);
  pointer-events: none;
  position: absolute;
  visibility: hidden;
}

.portfolio-card.shown {
  opacity: 1;
  transform: scale(1);
}

/* ============================================================
   13. SCROLL INDICATOR
   ============================================================ */
.scroll-indicator {
  position: absolute;
  bottom: var(--space-xl);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-xs);
  color: var(--text-muted);
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 2px;
}

.scroll-indicator__dot {
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
  background: var(--accent);
  animation: scrollDown 2s ease-in-out infinite;
}

/* ============================================================
   14. LOADING STATE
   ============================================================ */
.page-loader {
  position: fixed;
  inset: 0;
  background: var(--bg-body);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.5s ease, visibility 0.5s ease;
}

.page-loader.hidden {
  opacity: 0;
  visibility: hidden;
}

.page-loader__spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: var(--radius-full);
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

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

  .animate-on-scroll {
    opacity: 1;
    transform: none;
  }

  html {
    scroll-behavior: auto;
  }
}
