/* ==========================================================================
   Animations — Agape Labs
   ========================================================================== */

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

.reveal--left {
  transform: translateX(-30px);
}

.reveal--right {
  transform: translateX(30px);
}

.reveal--scale {
  transform: scale(0.95);
}

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

/* Stagger children */
.reveal-group .reveal:nth-child(1) { transition-delay: 0ms; }
.reveal-group .reveal:nth-child(2) { transition-delay: 100ms; }
.reveal-group .reveal:nth-child(3) { transition-delay: 200ms; }
.reveal-group .reveal:nth-child(4) { transition-delay: 300ms; }
.reveal-group .reveal:nth-child(5) { transition-delay: 400ms; }
.reveal-group .reveal:nth-child(6) { transition-delay: 500ms; }

/* --- Keyframe Animations --- */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

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

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

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

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

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

/* --- Space Tech Keyframes --- */

/* Star twinkling */
@keyframes starTwinkle {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 1; }
}

/* Slow nebula color drift for hero bg */
@keyframes nebulaDrift {
  0%, 100% { opacity: 0.08; transform: translate(0, 0) scale(1); }
  33% { opacity: 0.12; transform: translate(10px, -5px) scale(1.02); }
  66% { opacity: 0.06; transform: translate(-8px, 5px) scale(0.98); }
}

/* Orbital rotation for preloader */
@keyframes orbitRotate {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Reverse orbit */
@keyframes orbitRotateReverse {
  from { transform: rotate(360deg); }
  to { transform: rotate(0deg); }
}

/* Warp streak — radial star stretch for preloader exit */
@keyframes warpStreak {
  0% {
    transform: scale(1) rotate(0deg);
    opacity: 0.5;
  }
  60% {
    transform: scale(2) rotate(3deg);
    opacity: 1;
  }
  100% {
    transform: scale(4) rotate(5deg);
    opacity: 0;
  }
}

/* Scanner glow sweep on hover */
@keyframes scannerGlow {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

/* Telemetry data load for stats */
@keyframes telemetryLoad {
  0% { clip-path: inset(0 100% 0 0); opacity: 0; }
  60% { clip-path: inset(0 0 0 0); opacity: 1; }
  100% { clip-path: inset(0 0 0 0); opacity: 1; }
}

/* Corner bracket flash */
@keyframes bracketFlash {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

/* --- Hero Animations --- */
.hero__title {
  animation: fadeInUp 0.8s ease forwards;
}

.hero__subtitle {
  animation: fadeInUp 0.8s ease 0.15s forwards;
  opacity: 0;
}

.hero__actions {
  animation: fadeInUp 0.8s ease 0.3s forwards;
  opacity: 0;
}

.hero__breadcrumb {
  animation: fadeIn 0.6s ease forwards;
}

/* --- Button Hover Effects --- */
.btn {
  position: relative;
  overflow: hidden;
}

.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.1);
  transform: translateX(-100%);
  transition: transform var(--transition-base);
}

.btn:hover::after {
  transform: translateX(0);
}

/* --- Card Hover Glow --- */
.card:hover {
  box-shadow:
    var(--shadow-xl),
    0 0 0 1px var(--color-primary),
    var(--shadow-glow);
}

/* --- Focus Ring --- */
:focus-visible {
  outline: 3px solid var(--color-primary);
  outline-offset: 2px;
}

/* Remove default outline */
:focus:not(:focus-visible) {
  outline: none;
}

/* --- Filtering Animation --- */
.project-card {
  transition: all var(--transition-base);
}

.project-card.filtering-out {
  opacity: 0;
  transform: scale(0.8);
  pointer-events: none;
}

.project-card.filtering-in {
  animation: fadeInUp 0.4s ease forwards;
}

/* --- Stat Number Animation --- */
.stat__number {
  transition: all 0.6s ease;
}

/* --- Loading/Skeleton shimmer --- */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--color-bg-alt) 25%,
    var(--color-border) 50%,
    var(--color-bg-alt) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-md);
}

/* --- Toast Animations --- */
@keyframes toastSlideIn {
  from {
    opacity: 0;
    transform: translateX(100%);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes toastSlideOut {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(100%);
  }
}

/* --- 404 Float --- */
@keyframes float404 {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  25% { transform: translateY(-12px) rotate(1deg); }
  75% { transform: translateY(8px) rotate(-1deg); }
}

/* --- Chatbot Animations --- */
@keyframes chatbotSlideUp {
  from {
    opacity: 0;
    transform: scale(0.8) translateY(10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes chatbotBubblePulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(34, 211, 238, 0.4);
  }
  50% {
    box-shadow: 0 0 0 12px rgba(34, 211, 238, 0);
  }
}

@keyframes chatbotTypingBounce {
  0%, 60%, 100% {
    transform: translateY(0);
  }
  30% {
    transform: translateY(-4px);
  }
}

@keyframes chatbotBadgePing {
  0%, 100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.3);
    opacity: 0.7;
  }
}

@keyframes chatbotWindowGlow {
  0%, 100% {
    box-shadow: var(--shadow-xl), 0 0 0 0 rgba(34, 211, 238, 0);
  }
  50% {
    box-shadow: var(--shadow-xl), 0 0 15px 1px rgba(34, 211, 238, 0.15);
  }
}

/* --- Button Ripple --- */
.btn__ripple {
  position: absolute;
  width: 20px;
  height: 20px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.35);
  transform: translate(-50%, -50%) scale(0);
  animation: btnRipple 0.6s ease-out forwards;
  pointer-events: none;
}

@keyframes btnRipple {
  to {
    transform: translate(-50%, -50%) scale(4);
    opacity: 0;
  }
}

/* --- Stat Glow Pulse --- */
.stat__number--done {
  animation: statGlowPulse 0.8s ease-out;
}

@keyframes statGlowPulse {
  0% {
    filter: drop-shadow(0 0 0 transparent);
  }
  40% {
    filter: drop-shadow(0 0 14px rgba(8, 145, 178, 0.7)) drop-shadow(0 0 28px rgba(124, 58, 237, 0.25));
  }
  100% {
    filter: drop-shadow(0 0 0 transparent);
  }
}

[data-theme="dark"] .stat__number--done {
  animation-name: statGlowPulseDark;
}

@keyframes statGlowPulseDark {
  0% {
    filter: drop-shadow(0 0 0 transparent);
  }
  40% {
    filter: drop-shadow(0 0 16px rgba(34, 211, 238, 0.7)) drop-shadow(0 0 32px rgba(167, 139, 250, 0.3));
  }
  100% {
    filter: drop-shadow(0 0 0 transparent);
  }
}

/* --- Typed Text --- */
.typed-text {
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.typed-cursor {
  display: inline-block;
  width: 3px;
  margin-left: 2px;
  background: var(--color-primary);
  animation: typedBlink 0.7s step-end infinite;
}

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

/* --- Scan Line --- */
@keyframes scanLine {
  0% { top: 0; }
  100% { top: 100%; }
}

/* --- Grain Shift (Premium) --- */
@keyframes grainShift {
  0%, 100% { transform: translate(0, 0); }
  10% { transform: translate(-2%, -3%); }
  20% { transform: translate(3%, 1%); }
  30% { transform: translate(-1%, 4%); }
  40% { transform: translate(4%, -2%); }
  50% { transform: translate(-3%, 2%); }
  60% { transform: translate(1%, -4%); }
  70% { transform: translate(-4%, 3%); }
  80% { transform: translate(2%, -1%); }
  90% { transform: translate(-2%, 4%); }
}

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

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