/* =============================================
   ANIMATIONS — Scroll-triggered & Keyframes
   ============================================= */

/* =============================================
   KEYFRAMES
   ============================================= */

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

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(40px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

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

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

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

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

@keyframes pulse-ring {
  0% { transform: scale(1); opacity: 0.6; }
  100% { transform: scale(1.5); opacity: 0; }
}

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

@keyframes draw-line {
  from { height: 0; }
  to { height: 100%; }
}

/* =============================================
   SCROLL-TRIGGERED ANIMATIONS
   Base state: hidden. JS adds .animate-in to trigger.
   ============================================= */

.animate-on-scroll {
  opacity: 0;
  will-change: opacity, transform;
}

/* Variants — initial state */
.animate-on-scroll.fade-up {
  transform: translateY(40px);
  transition: opacity 0.7s cubic-bezier(0.25, 0.46, 0.45, 0.94),
              transform 0.7s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.animate-on-scroll.fade-in {
  transition: opacity 0.7s ease;
}

.animate-on-scroll.fade-right {
  transform: translateX(50px);
  transition: opacity 0.7s cubic-bezier(0.25, 0.46, 0.45, 0.94),
              transform 0.7s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.animate-on-scroll.slide-left {
  transform: translateX(-40px);
  transition: opacity 0.7s cubic-bezier(0.25, 0.46, 0.45, 0.94),
              transform 0.7s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.animate-on-scroll.slide-right {
  transform: translateX(40px);
  transition: opacity 0.7s cubic-bezier(0.25, 0.46, 0.45, 0.94),
              transform 0.7s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.animate-on-scroll.scale-in {
  transform: scale(0.93);
  transition: opacity 0.7s cubic-bezier(0.25, 0.46, 0.45, 0.94),
              transform 0.7s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* Animated-in state */
.animate-on-scroll.animate-in {
  opacity: 1;
  transform: none;
}

/* Stagger delays */
.animate-on-scroll.delay-1 {
  transition-delay: 0.1s;
}

.animate-on-scroll.delay-2 {
  transition-delay: 0.2s;
}

.animate-on-scroll.delay-3 {
  transition-delay: 0.3s;
}

.animate-on-scroll.delay-4 {
  transition-delay: 0.4s;
}

/* =============================================
   HERO ANIMATIONS
   ============================================= */

.hero-text.animate-in .hero-name {
  animation: fadeUp 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

.hero-text.animate-in .hero-sub {
  animation: fadeUp 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94) 0.15s both;
}

.hero-text.animate-in .hero-tagline {
  animation: fadeUp 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94) 0.25s both;
}

.hero-text.animate-in .hero-ctas {
  animation: fadeUp 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94) 0.35s both;
}

/* =============================================
   PORTRAIT DECORATIVE EFFECTS
   ============================================= */

.portrait-frame::before {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: 23px;
  background: linear-gradient(135deg, rgba(165,28,48,0.4), transparent 50%, rgba(165,28,48,0.2));
  z-index: -1;
}

.portrait-frame::after {
  content: '';
  position: absolute;
  top: -20px;
  right: -20px;
  width: 80px;
  height: 80px;
  border: 2px solid rgba(201,142,142,0.3);
  border-radius: 50%;
  animation: pulse-ring 3s ease-out infinite;
}

/* =============================================
   TIMELINE LINE DRAW ANIMATION
   ============================================= */

.timeline-line {
  animation: draw-line 1.5s ease forwards;
}

/* =============================================
   NAV HAMBURGER ANIMATION
   ============================================= */

.nav-hamburger.open span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.nav-hamburger.open span:nth-child(2) {
  opacity: 0;
  transform: scaleX(0);
}

.nav-hamburger.open span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* =============================================
   SECTION ENTRANCE EFFECTS
   ============================================= */

section {
  position: relative;
}

/* Crimson accent line on section hover transitions */
#me .about-block,
#projects,
#research,
#achievements {
  position: relative;
}

/* =============================================
   CARD HOVER MICRO-INTERACTIONS
   ============================================= */

.shape-card .shape-icon svg,
.lab-card .lab-icon svg {
  transition: transform 0.3s ease;
}

.shape-card:hover .shape-icon svg,
.lab-card:hover .lab-icon svg {
  transform: scale(1.15) rotate(-5deg);
}

.philosophy-card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  width: 3px;
  height: 0;
  background: var(--gradient-crimson);
  border-radius: 3px 0 0 3px;
  transition: height 0.4s ease;
}

.philosophy-card:hover::before {
  height: 100%;
}

/* Achievement card glow on hover */
.achievement-card {
  position: relative;
  overflow: hidden;
}

.achievement-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(165,28,48,0.03), transparent);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.achievement-card:hover::after {
  opacity: 1;
}

/* =============================================
   MINDSET CONTENT TRANSITION
   ============================================= */

.mindset-content {
  transition: opacity 0.3s ease;
}

/* =============================================
   REDUCED MOTION SUPPORT
   ============================================= */

@media (prefers-reduced-motion: reduce) {
  .animate-on-scroll {
    opacity: 1;
    transform: none;
    transition: none;
  }

  .portrait-frame::after {
    animation: none;
  }

  .timeline-line {
    animation: none;
  }

  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
