/* Text Animation System - Makes content appear as if being written */

/* Base animation states */
.animate-text {
  opacity: 0;
  transform: translateY(20px);
  transition: all 0.8s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: opacity, transform;
}

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

/* Typewriter effect for headings */
.typewriter {
  overflow: hidden;
  border-right: 2px solid;
  border-color: var(--text-color-secondary);
  white-space: nowrap;
  animation: typewriter 2s steps(40, end), blink-caret 1s step-end infinite;
  animation-delay: 0.3s;
  animation-fill-mode: both;
}

@keyframes typewriter {
  from {
    width: 0;
  }
  to {
    width: 100%;
  }
}

@keyframes blink-caret {
  from, to {
    border-color: transparent;
  }
  50% {
    border-color: var(--text-color-secondary);
  }
}

/* Clean fade-in for elements */
.fade-in-up {
  opacity: 0;
  animation: fadeInUp 0.8s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes fadeInUp {
  to {
    opacity: 1;
  }
}

/* Smooth image fade-in animation */
.image-fade-in {
  opacity: 0;
  animation: imageFadeIn 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

@keyframes imageFadeIn {
  0% {
    opacity: 0;
  }
  100% {
    opacity: 1;
  }
}

/* Staggered animations for lists and multiple elements */
.stagger-animation {
  opacity: 0;
  animation: staggerIn 0.6s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes staggerIn {
  to {
    opacity: 1;
  }
}

/* Word-by-word typing animation */
.typing-word {
  opacity: 0;
  transform: translateY(10px);
  animation: typeWord 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
  will-change: opacity, transform;
}

@keyframes typeWord {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Letter-by-letter typing animation */
.typing-letter {
  opacity: 0;
  transform: translateY(5px);
  animation: typeLetter 0.2s cubic-bezier(0.4, 0, 0.2, 1) forwards;
  will-change: opacity, transform;
}

@keyframes typeLetter {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Line-by-line mysterious fade-in animation for body text */
.fade-line {
  opacity: 0;
  animation: mysteriousLineFade 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
  will-change: opacity;
}

@keyframes mysteriousLineFade {
  0% {
    opacity: 0;
  }
  20% {
    opacity: 0;
  }
  100% {
    opacity: 1;
  }
}

/* Sequential footer animation for quotes and epigraphs */
.quote-footer-delay {
  opacity: 0;
  animation: mysteriousFadeIn 1.2s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
  will-change: opacity;
}

@keyframes mysteriousFadeIn {
  0% {
    opacity: 0;
  }
  30% {
    opacity: 0;
  }
  100% {
    opacity: 1;
  }
}

/* Legacy word reveal effect for backwards compatibility */
.word-reveal {
  opacity: 0;
  transform: translateY(10px);
  animation: wordReveal 0.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes wordReveal {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Simple fade for important elements */
.bounce-in {
  opacity: 0;
  animation: bounceIn 0.8s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes bounceIn {
  to {
    opacity: 1;
  }
}

/* Fade in for quotes and special content */
.fade-in-left {
  opacity: 0;
  animation: fadeInLeft 0.8s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes fadeInLeft {
  to {
    opacity: 1;
  }
}

/* Fade in for metadata and secondary content */
.slide-in-right {
  opacity: 0;
  animation: slideInRight 0.8s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes slideInRight {
  to {
    opacity: 1;
  }
}

/* Page load animation for main content */
.page-load {
  opacity: 0;
  animation: pageLoad 1s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes pageLoad {
  to {
    opacity: 1;
  }
}

/* Enhanced red underline animation for titles and post links */
.link-reveal {
  text-decoration: none;
  background: linear-gradient(to right, var(--text-color-secondary), var(--text-color-secondary));
  background-size: 0% 3px;
  background-position: bottom left;
  background-repeat: no-repeat;
  transition: all 0.4s ease;
  position: relative;
}

.link-reveal::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0;
  height: 3px;
  background: var(--text-color-secondary);
  animation: underlineGrow 1.2s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes underlineGrow {
  0% {
    width: 0;
    opacity: 0;
  }
  50% {
    opacity: 1;
  }
  100% {
    width: 100%;
    opacity: 1;
  }
}

/* Tag pop-in animation */
.tag-pop-in {
  animation: tagPopIn 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards;
  will-change: transform, opacity;
}

@keyframes tagPopIn {
  0% {
    transform: scale(0.8);
    opacity: 0;
  }
  50% {
    transform: scale(1.05);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

/* Animation delays for staggered effects */
.delay-1 { animation-delay: 0.1s; }
.delay-2 { animation-delay: 0.2s; }
.delay-3 { animation-delay: 0.3s; }
.delay-4 { animation-delay: 0.4s; }
.delay-5 { animation-delay: 0.5s; }
.delay-6 { animation-delay: 0.6s; }
.delay-7 { animation-delay: 0.7s; }
.delay-8 { animation-delay: 0.8s; }

/* Reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
  .animate-text,
  .typewriter,
  .fade-in-up,
  .stagger-animation,
  .word-reveal,
  .bounce-in,
  .fade-in-left,
  .slide-in-right,
  .page-load,
  .link-reveal,
  .typing-word,
  .typing-letter,
  .fade-line,
  .quote-footer-delay,
  .image-fade-in {
    animation: none;
    opacity: 1;
  }
}

/* Intersection observer trigger points */
.animate-on-scroll {
  opacity: 0;
  transform: translateY(20px);
  transition: all 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

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

/* Special effects for different content types */
.essay-content .animate-on-scroll {
  animation-duration: 1s;
}

.story-content .animate-on-scroll {
  animation-duration: 0.8s;
}

.post-content .animate-on-scroll {
  animation-duration: 0.6s;
}

/* Animation-only additions - don't change existing styles */
.animate-title {
  animation: fadeInUp 1.2s cubic-bezier(0.4, 0, 0.2, 1) forwards;
  animation-delay: 0.2s;
}

.animate-subtitle {
  animation: fadeInUp 0.8s cubic-bezier(0.4, 0, 0.2, 1) forwards;
  animation-delay: 0.4s;
}

.animate-content {
  animation: fadeInUp 0.8s cubic-bezier(0.4, 0, 0.2, 1) forwards;
  animation-delay: 0.6s;
}

.animate-meta {
  animation: slideInRight 0.6s cubic-bezier(0.4, 0, 0.2, 1) forwards;
  animation-delay: 0.8s;
}

.animate-toc {
  animation: slideInRight 0.8s cubic-bezier(0.4, 0, 0.2, 1) forwards;
  animation-delay: 0.5s;
} 