/* ==========================================================================
   Animations & Transitions
   Scroll Reveal, Hover Effects, Terminal Effects
   ========================================================================== */

/* ========================================
   Scroll Reveal Animations
   ======================================== */
.reveal {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

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

/* Staggered reveal for cards */
.grid .card:nth-child(1) { transition-delay: 0.1s; }
.grid .card:nth-child(2) { transition-delay: 0.2s; }
.grid .card:nth-child(3) { transition-delay: 0.3s; }
.grid .card:nth-child(4) { transition-delay: 0.4s; }

/* ========================================
   Card Hover Animations
   ======================================== */
.card {
  transition: transform var(--transition-base), box-shadow var(--transition-base);
}

.card:hover {
  transform: translateY(-4px);
}

.card-project .card-image img {
  transition: transform var(--transition-slow);
}

.card-project:hover .card-image img {
  transform: scale(1.05);
}

/* ========================================
   Button Hover Effects
   ======================================== */
.btn {
  transition: all var(--transition-base);
  position: relative;
  overflow: hidden;
}

.btn::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  transition: width 0.6s, height 0.6s;
}

.btn:active::before {
  width: 300px;
  height: 300px;
}

.btn-primary:hover {
  transform: translateY(-2px);
}

.btn-secondary:hover {
  transform: translateY(-2px);
}

/* ========================================
   Status Badge Pulse
   ======================================== */
.badge-dot {
  animation: pulse 2s infinite;
}

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

/* ========================================
   Terminal Cursor Blink
   ======================================== */
.terminal-cursor {
  display: inline-block;
  width: 8px;
  height: 16px;
  background-color: var(--terminal-text);
  animation: blink 1s step-end infinite;
  vertical-align: middle;
  margin-left: 2px;
}

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

/* ========================================
   Terminal Typing Animation System
   ======================================== */

/* Lines hidden by default, shown via JS */
.terminal-body.typing-active .terminal-line {
  opacity: 0;
  height: 0;
  overflow: hidden;
  transition: height 0.1s ease;
}

.terminal-body.typing-active .terminal-line.visible {
  opacity: 1;
  height: auto;
}

/* Blinking cursor for typing effect */
.typing-cursor {
  display: inline-block;
  width: 8px;
  height: 16px;
  background-color: var(--terminal-success, #22c55e);
  animation: cursorBlink 1s step-end infinite;
  vertical-align: middle;
  margin-left: 2px;
}

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

/* Typed text container */
.typed-text {
  display: inline;
}

/* Fallback: Static display when JS hasn't run yet or animation complete */
.terminal-body:not(.typing-active) .terminal-line {
  opacity: 1;
}

/* ========================================
   Social Link Hover
   ======================================== */
.social-link {
  transition: all var(--transition-base);
}

.social-link:hover {
  transform: translateY(-4px);
}

.social-link svg {
  transition: transform var(--transition-base);
}

.social-link:hover svg {
  transform: scale(1.1);
}

/* ========================================
   Tag Hover Effect
   ======================================== */
.tag {
  transition: all var(--transition-fast);
}

.tag:hover {
  background-color: var(--color-accent-bg);
  border-color: var(--color-accent-primary);
  color: var(--color-accent-primary);
}

/* ========================================
   Interest Item Hover
   ======================================== */
.interest-item {
  transition: all var(--transition-base);
}

.interest-item:hover {
  transform: translateX(4px);
}

.interest-item:hover .interest-icon {
  background-color: var(--color-accent-bg);
  color: var(--color-accent-primary);
}

/* ========================================
   Navbar Scroll Effect
   ======================================== */
.nav.scrolled {
  box-shadow: var(--shadow-sm);
}

/* ========================================
   Theme Toggle Animation
   ======================================== */
.theme-toggle svg {
  transition: transform var(--transition-base), opacity var(--transition-base);
}

.theme-toggle:hover svg {
  transform: rotate(15deg);
}

/* Sun/Moon swap animation */
[data-theme="light"] .theme-toggle .icon-sun {
  opacity: 0;
  transform: rotate(-90deg) scale(0);
}

[data-theme="light"] .theme-toggle .icon-moon {
  opacity: 1;
  transform: rotate(0) scale(1);
}

[data-theme="dark"] .theme-toggle .icon-sun {
  opacity: 1;
  transform: rotate(0) scale(1);
}

[data-theme="dark"] .theme-toggle .icon-moon {
  opacity: 0;
  transform: rotate(90deg) scale(0);
}

/* ========================================
   Page Transition System
   ======================================== */

/* Page content wrapper for transitions */
.page-content {
  animation: pageEnter 0.3s ease forwards;
}

/* Page entering animation */
@keyframes pageEnter {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Page leaving animation */
.page-content.page-exit {
  animation: pageExit 0.2s ease forwards;
}

@keyframes pageExit {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(-10px);
  }
}

/* Ensure nav stays fixed and doesn't animate */
.nav {
  position: fixed !important;
  z-index: 1000;
}

/* ========================================
   Page Load Animation
   ======================================== */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.hero-content {
  animation: fadeInUp 0.8s ease forwards;
}

.hero-terminal {
  animation: fadeInUp 0.8s ease 0.3s forwards;
  opacity: 0;
  transition: transform 0.6s ease;
}

/* Rotation happens after typing animation completes */
.hero-terminal.typing-complete {
  transform: rotate(2deg);
}

/* ========================================
   Page Hero Animations (About, News, Docs, etc.)
   ======================================== */

/* Staggered fade in from left */
@keyframes fadeInLeft {
  from {
    opacity: 0;
    transform: translateX(-30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Staggered fade in from right */
@keyframes fadeInRight {
  from {
    opacity: 0;
    transform: translateX(30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Scale up animation */
@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* About Page Animations */
.about-hero-content {
  opacity: 0;
  animation: fadeInLeft 0.8s ease 0.1s forwards;
  will-change: opacity, transform;
}

.about-hero-sidebar {
  opacity: 0;
  animation: fadeInRight 0.8s ease 0.3s forwards;
  will-change: opacity, transform;
}

.about-profile-card {
  opacity: 0;
  animation: scaleIn 0.6s ease 0.5s forwards;
  will-change: opacity, transform;
}

.about-experience-card {
  opacity: 0;
  animation: fadeInUp 0.6s ease 0.7s forwards;
  will-change: opacity, transform;
}

.about-works-section {
  opacity: 0;
  animation: fadeInUp 0.8s ease 0.2s forwards;
}

.about-work-card {
  opacity: 0;
  animation: fadeInUp 0.6s ease forwards;
}

.about-work-card:nth-child(1) { animation-delay: 0.3s; }
.about-work-card:nth-child(2) { animation-delay: 0.4s; }
.about-work-card:nth-child(3) { animation-delay: 0.5s; }

.about-cta-section {
  opacity: 0;
  animation: fadeInUp 0.8s ease 0.2s forwards;
}

/* News Page Animations */
.news-hero-container {
  opacity: 0;
  animation: fadeInUp 0.8s ease 0.1s forwards;
}

.news-hero-title {
  opacity: 0;
  animation: fadeInUp 0.6s ease 0.2s forwards;
}

.news-hero-subtitle {
  opacity: 0;
  animation: fadeInUp 0.6s ease 0.3s forwards;
}

.news-search {
  opacity: 0;
  animation: fadeInUp 0.6s ease 0.4s forwards;
}

.news-filters {
  opacity: 0;
  animation: fadeInUp 0.6s ease 0.5s forwards;
}

.news-grid {
  opacity: 0;
  animation: fadeInUp 0.8s ease 0.3s forwards;
}

.news-article-card {
  opacity: 0;
  animation: fadeInUp 0.5s ease forwards;
}

.news-article-card:nth-child(1) { animation-delay: 0.4s; }
.news-article-card:nth-child(2) { animation-delay: 0.5s; }
.news-article-card:nth-child(3) { animation-delay: 0.6s; }
.news-article-card:nth-child(4) { animation-delay: 0.7s; }
.news-article-card:nth-child(5) { animation-delay: 0.8s; }
.news-article-card:nth-child(6) { animation-delay: 0.9s; }

/* Docs Page Animations */
.docs-hero {
  opacity: 0;
  animation: fadeInUp 0.8s ease 0.1s forwards;
}

.docs-hero-content {
  opacity: 0;
  animation: fadeInUp 0.6s ease 0.2s forwards;
}

.docs-hero-title {
  opacity: 0;
  animation: fadeInUp 0.6s ease 0.3s forwards;
}

.docs-content {
  opacity: 0;
  animation: fadeInUp 0.8s ease 0.4s forwards;
}

.docs-sidebar {
  opacity: 0;
  animation: fadeInLeft 0.6s ease 0.3s forwards;
}

.docs-main {
  opacity: 0;
  animation: fadeInUp 0.6s ease 0.5s forwards;
}

/* Contact Page Animations */
.page-header {
  opacity: 0;
  animation: fadeInUp 0.8s ease 0.1s forwards;
}

.page-title {
  opacity: 0;
  animation: fadeInUp 0.6s ease 0.2s forwards;
}

.page-subtitle {
  opacity: 0;
  animation: fadeInUp 0.6s ease 0.3s forwards;
}

/* Article Page Animations */
.article-page .article-header {
  opacity: 0;
  animation: fadeInUp 0.8s ease 0.1s forwards;
}

.article-page .article-title {
  opacity: 0;
  animation: fadeInUp 0.6s ease 0.2s forwards;
}

.article-page .article-meta {
  opacity: 0;
  animation: fadeInUp 0.6s ease 0.3s forwards;
}

.article-page .article-content {
  opacity: 0;
  animation: fadeInUp 0.8s ease 0.4s forwards;
}

/* ========================================
   Mobile Menu Animation
   ======================================== */
.nav-menu {
  transition: opacity var(--transition-base), visibility var(--transition-base);
}

@media (max-width: 1023px) {
  .nav-menu {
    opacity: 0;
    visibility: hidden;
  }

  .nav-menu.active {
    opacity: 1;
    visibility: visible;
  }
}

/* Hamburger Animation */
.nav-toggle span {
  transition: all var(--transition-base);
}

.nav-toggle.active span:nth-child(1) {
  transform: rotate(45deg) translate(5px, 5px);
}

.nav-toggle.active span:nth-child(2) {
  opacity: 0;
}

.nav-toggle.active span:nth-child(3) {
  transform: rotate(-45deg) translate(5px, -5px);
}

/* Text gradient shimmer removed - using base.css static gradient */

/* ========================================
   Terminal Typing Effect
   ======================================== */
.terminal-typing {
  overflow: hidden;
  white-space: nowrap;
  border-right: 2px solid var(--terminal-text);
  animation: typing 2s steps(30) forwards, blinkCaret 0.75s step-end infinite;
}

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

@keyframes blinkCaret {
  50% { border-color: transparent; }
}


/* ========================================
   Stats Counter Animation
   ======================================== */
.card-stat-value {
  display: inline-block;
}

.card-stat.animate .card-stat-value {
  animation: countPulse 0.6s ease-out;
}

@keyframes countPulse {
  0% {
    transform: scale(0.5);
    opacity: 0;
  }
  50% {
    transform: scale(1.1);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

/* Stat card glow on reveal */
.card-stat {
  position: relative;
  overflow: hidden;
}

.card-stat::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, var(--color-accent-primary) 0%, transparent 70%);
  opacity: 0;
  transform: scale(0);
  transition: opacity 0.5s, transform 0.5s;
}

.card-stat.animate::before {
  animation: statGlow 1s ease-out forwards;
}

@keyframes statGlow {
  0% {
    opacity: 0.3;
    transform: scale(0);
  }
  50% {
    opacity: 0.1;
    transform: scale(1);
  }
  100% {
    opacity: 0;
    transform: scale(1.5);
  }
}

/* ========================================
   Feature Card Icon Animations
   ======================================== */
.card-feature .card-icon {
  transition: all 0.3s ease;
  position: relative;
}

.card-feature:hover .card-icon {
  transform: scale(1.1) rotate(5deg);
}

.card-feature .card-icon svg {
  transition: all 0.3s ease;
}

.card-feature:hover .card-icon svg {
  filter: drop-shadow(0 0 8px var(--color-accent-primary));
}

/* Icon pulse animation on hover */
.card-feature:hover .card-icon::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: inherit;
  background: var(--color-accent-primary);
  opacity: 0;
  animation: iconPulse 0.6s ease-out;
}

@keyframes iconPulse {
  0% {
    transform: scale(1);
    opacity: 0.4;
  }
  100% {
    transform: scale(1.5);
    opacity: 0;
  }
}

/* Button Glow Effects - removed */

/* Logo Hover Glow - removed */

/* ========================================
   Neural Network Background (Hero)
   ======================================== */
.hero {
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-image:
    radial-gradient(circle at 20% 30%, var(--color-accent-primary) 1px, transparent 1px),
    radial-gradient(circle at 80% 70%, var(--color-accent-secondary) 1px, transparent 1px),
    radial-gradient(circle at 40% 80%, var(--color-accent-primary) 1px, transparent 1px),
    radial-gradient(circle at 60% 20%, var(--color-accent-secondary) 1px, transparent 1px);
  background-size: 100px 100px;
  opacity: 0.15;
  animation: floatParticles 20s linear infinite;
  pointer-events: none;
}

@keyframes floatParticles {
  0% {
    transform: translateY(0) translateX(0);
  }
  25% {
    transform: translateY(-10px) translateX(10px);
  }
  50% {
    transform: translateY(0) translateX(20px);
  }
  75% {
    transform: translateY(10px) translateX(10px);
  }
  100% {
    transform: translateY(0) translateX(0);
  }
}

/* ========================================
   Section Title Reveal Animation
   ======================================== */
.section-title {
  position: relative;
}

.section-title.animate {
  animation: titleReveal 0.8s ease-out forwards;
}

@keyframes titleReveal {
  0% {
    opacity: 0;
    transform: translateY(20px);
    filter: blur(10px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
    filter: blur(0);
  }
}

/* Tag Ripple Effect - removed */

/* ========================================
   Showcase Card Float Animation
   ======================================== */
.dastur-showcase-card {
  animation: subtleFloat 6s ease-in-out infinite;
}

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

/* ========================================
   AI Processing Indicator
   ======================================== */
.terminal-status-badge {
  position: relative;
  overflow: hidden;
}

.terminal-status-badge::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
  animation: statusShine 2s ease-in-out infinite;
}

@keyframes statusShine {
  0% { left: -100%; }
  50%, 100% { left: 100%; }
}

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

  .reveal {
    opacity: 1;
    transform: none;
  }

  .terminal-line {
    opacity: 1;
    animation: none;
  }

  .hero-content,
  .hero-terminal {
    opacity: 1;
    animation: none;
  }

  /* Page animations - reduced motion */
  .about-hero-content,
  .about-hero-sidebar,
  .about-profile-card,
  .about-experience-card,
  .about-works-section,
  .about-work-card,
  .about-cta-section,
  .news-hero-container,
  .news-hero-title,
  .news-hero-subtitle,
  .news-search,
  .news-filters,
  .news-grid,
  .news-article-card,
  .docs-hero,
  .docs-hero-content,
  .docs-hero-title,
  .docs-content,
  .docs-sidebar,
  .docs-main,
  .page-header,
  .page-title,
  .page-subtitle,
  .article-page .article-header,
  .article-page .article-title,
  .article-page .article-meta,
  .article-page .article-content {
    opacity: 1;
    animation: none;
    transform: none;
  }
}
