/* ==========================================================================
   HamachiInfo — animations.css
   Анимации, переходы, keyframes
   ========================================================================== */

/* ---- Reveal on scroll ---- */
.reveal {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.5s cubic-bezier(0.4, 0, 0.2, 1),
              transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

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

/* Staggered reveal for grid children */
.reveal-stagger > * {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.5s cubic-bezier(0.4, 0, 0.2, 1),
              transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.reveal-stagger.revealed > *:nth-child(1) { transition-delay: 0.05s; opacity: 1; transform: none; }
.reveal-stagger.revealed > *:nth-child(2) { transition-delay: 0.1s;  opacity: 1; transform: none; }
.reveal-stagger.revealed > *:nth-child(3) { transition-delay: 0.15s; opacity: 1; transform: none; }
.reveal-stagger.revealed > *:nth-child(4) { transition-delay: 0.2s;  opacity: 1; transform: none; }
.reveal-stagger.revealed > *:nth-child(5) { transition-delay: 0.25s; opacity: 1; transform: none; }
.reveal-stagger.revealed > *:nth-child(6) { transition-delay: 0.3s;  opacity: 1; transform: none; }

/* ---- Keyframes ---- */
@keyframes bounceDown {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(3px); }
}

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

@keyframes spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

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

@keyframes slideInRight {
  from { transform: translateX(100%); }
  to   { transform: translateX(0); }
}

@keyframes glow {
  0%, 100% { box-shadow: 0 0 10px rgba(0,212,255,0.2); }
  50%       { box-shadow: 0 0 30px rgba(0,212,255,0.5); }
}

/* VPN tunnel animation (hero illustration) */
@keyframes dashMove {
  from { stroke-dashoffset: 0; }
  to   { stroke-dashoffset: -30; }
}

@keyframes packetMove {
  0%   { offset-distance: 0%; opacity: 0; }
  5%   { opacity: 1; }
  95%  { opacity: 1; }
  100% { offset-distance: 100%; opacity: 0; }
}

/* Hero title gradient animation */
@keyframes gradientShift {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.gradient-text {
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary), var(--accent-primary));
  background-size: 200% 200%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: gradientShift 4s ease infinite;
}

/* Theme toggle icon */
.theme-icon {
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

#theme-toggle:hover .theme-icon {
  transform: rotate(20deg);
}

/* Logo hover */
.logo:hover .logo-text {
  transition: color 0.2s;
}

/* Tunnel SVG animation */
.tunnel-dash {
  stroke-dasharray: 6 6;
  animation: dashMove 1.5s linear infinite;
}

.tunnel-dash-slow {
  stroke-dasharray: 8 8;
  animation: dashMove 2.5s linear infinite;
}

.packet {
  animation: packetMove 2.5s ease-in-out infinite;
}

.packet-2 {
  animation: packetMove 2.5s ease-in-out 1.25s infinite;
}

/* Card hover glow pulse on important cards */
.card--featured {
  animation: glow 3s ease-in-out infinite;
}

/* Loading spinner */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-subtle);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* Fade in for overlays */
.fade-in {
  animation: fadeIn 0.2s ease forwards;
}

/* Accent blink for status indicators */
.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-success);
  animation: pulse 2s ease-in-out infinite;
  vertical-align: middle;
  margin-right: 0.35rem;
}

/* Hover on nav links */
.nav-link {
  position: relative;
}

/* Download button bounce */
@keyframes dlBounce {
  0%   { transform: translateY(0); }
  30%  { transform: translateY(-4px); }
  60%  { transform: translateY(2px); }
  100% { transform: translateY(0); }
}

/* Table row highlight */
@keyframes rowHighlight {
  from { background: rgba(0,212,255,0.15); }
  to   { background: transparent; }
}

/* Scroll fade for ToC */
@keyframes tocFadeIn {
  from { opacity: 0; transform: translateX(10px); }
  to   { opacity: 1; transform: translateX(0); }
}

.toc {
  animation: tocFadeIn 0.3s ease forwards;
}

/* Mobile menu slide in */
.mobile-nav {
  will-change: transform;
}

/* Accordion smooth */
.accordion-body {
  will-change: max-height;
}

/* Disable animations for users who prefer 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, .reveal-stagger > * {
    opacity: 1;
    transform: none;
  }
}
