/* Animations - Scroll reveals, transitions, micro-interactions */

/* Scroll Reveal - Initial state */
.reveal {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity var(--transition-slow), transform var(--transition-slow);
}

/* Scroll Reveal - Revealed state */
.reveal.revealed {
  opacity: 1;
  transform: translateY(0);
}

/* Stagger animations for multiple elements */
.reveal:nth-child(1) {
  transition-delay: 0s;
}

.reveal:nth-child(2) {
  transition-delay: 0.1s;
}

.reveal:nth-child(3) {
  transition-delay: 0.2s;
}

.reveal:nth-child(4) {
  transition-delay: 0.3s;
}

.reveal:nth-child(5) {
  transition-delay: 0.4s;
}

/* Counter Animation for Hero Numbers */
@property --num {
  syntax: '<integer>';
  initial-value: 0;
  inherits: false;
}

.pillar-number[data-count] {
  animation: counter 1.5s ease-out forwards;
  counter-reset: num var(--num);
}

.pillar-number[data-count]::before {
  content: counter(num);
}

@keyframes counter {
  from {
    --num: 0;
  }
  to {
    --num: var(--target);
  }
}

/* Timeline Line Growth */
.timeline-content {
  position: relative;
}

.timeline-content::before {
  content: '';
  position: absolute;
  left: -2px;
  top: 0;
  width: 2px;
  height: 0;
  background: var(--color-text-primary);
  transition: height 0.8s ease-out;
}

.timeline-block.revealed .timeline-content::before {
  height: 100%;
}

/* Hover Animations */
.project-card {
  position: relative;
}

.project-card::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--border-radius-md);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
  opacity: 0;
  transition: opacity var(--transition-base);
}

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

/* Link Hover Underline Animation */
.contact-links a {
  position: relative;
  display: inline-block;
}

.contact-links a::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 100%;
  height: 1px;
  background: currentColor;
  transform: scaleX(1);
  transform-origin: right;
  transition: transform var(--transition-base);
}

.contact-links a:hover::after {
  transform: scaleX(0);
  transform-origin: left;
}

/* Drawer Open/Close Animation */
body.drawer-open {
  overflow: hidden;
}

/* Nav Scroll Hide/Show */
.nav.nav-hidden {
  transform: translateY(-100%);
}

/* Signature Fade In */
.signature {
  animation: fadeIn 1s ease-out 0.5s both;
}

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

/* Value Item Expand Indicator */
.value-item {
  overflow: hidden;
}

.value-item::before {
  content: '';
  position: absolute;
  left: 0;
  bottom: 0;
  width: 0;
  height: 2px;
  background: var(--color-text-primary);
  transition: width var(--transition-base);
}

.value-item:hover::before {
  width: 100%;
}

/* Tag Cloud Organic Layout Animation */
@media (min-width: 768px) {
  .tag:nth-child(odd) {
    animation: floatUp 3s ease-in-out infinite;
  }

  .tag:nth-child(even) {
    animation: floatDown 3s ease-in-out infinite;
    animation-delay: 0.5s;
  }

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

  @keyframes floatDown {
    0%,
    100% {
      transform: translateY(0);
    }
    50% {
      transform: translateY(5px);
    }
  }

  /* Disable float on hover */
  .tag:hover {
    animation: none;
  }
}

/* Reduced Motion Override */
@media (prefers-reduced-motion: reduce) {
  .reveal {
    opacity: 1;
    transform: none;
    transition: none;
  }

  .timeline-content::before {
    height: 100%;
    transition: none;
  }

  .pillar-number[data-count] {
    animation: none;
  }

  .tag:nth-child(odd),
  .tag:nth-child(even) {
    animation: none;
  }

  .scroll-indicator {
    animation: none;
  }

  .signature {
    animation: none;
    opacity: 1;
  }

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

/* Focus Visible Animation */
:focus-visible {
  animation: focusPulse 0.3s ease-out;
}

@keyframes focusPulse {
  0% {
    outline-offset: 0;
  }
  50% {
    outline-offset: 4px;
  }
  100% {
    outline-offset: 2px;
  }
}

/* Loading State Animation (if needed) */
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.loading::after {
  content: '';
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--color-border);
  border-top-color: var(--color-text-primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

/* Smooth Scroll Behavior */
html {
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

/* Page Load Animation */
@keyframes pageLoad {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

body {
  animation: pageLoad 0.5s ease-out;
}

/* Drawer Content Fade In */
.drawer[aria-hidden='false'] .drawer-content {
  animation: drawerContentFadeIn 0.4s ease-out 0.2s both;
}

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

/* Accordion Smooth Expand */
.accordion-content {
  transition: max-height var(--transition-slow), padding var(--transition-slow);
}

.accordion-content[aria-hidden='true'] {
  padding-top: 0;
  padding-bottom: 0;
}
