/* ========================================================================
   SONOLINK — animations.css
   Glitch text · Fade · Slide · Screen transitions · Micro-interactions
   ======================================================================== */

/* ========== Glitch text (used on boot title) ========== */

.glitch {
  position: relative;
  display: inline-block;
}

.glitch::before,
.glitch::after {
  content: attr(data-text);
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.glitch::before {
  color: var(--accent);
  transform: translate(-1px, 0);
  clip-path: polygon(0 0, 100% 0, 100% 45%, 0 45%);
  animation: glitch-1 3.2s steps(1) infinite;
  opacity: 0.7;
}

.glitch::after {
  color: var(--accent-2);
  transform: translate(1px, 0);
  clip-path: polygon(0 55%, 100% 55%, 100% 100%, 0 100%);
  animation: glitch-2 2.8s steps(1) infinite;
  opacity: 0.7;
}

@keyframes glitch-1 {
  0%, 95%, 100% { transform: translate(0, 0); }
  96% { transform: translate(-2px, -1px); }
  97% { transform: translate(2px, 1px); }
  98% { transform: translate(-1px, 1px); }
}

@keyframes glitch-2 {
  0%, 93%, 100% { transform: translate(0, 0); }
  94% { transform: translate(2px, 1px); }
  95% { transform: translate(-2px, -1px); }
  96% { transform: translate(1px, -1px); }
}

/* ========== Fade ========== */

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

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

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

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

/* ========== Screen enter ========== */

.screen.active > * {
  animation: screen-enter 380ms cubic-bezier(0.22, 1, 0.36, 1) backwards;
}

.screen.active > *:nth-child(1) { animation-delay: 60ms; }
.screen.active > *:nth-child(2) { animation-delay: 120ms; }
.screen.active > *:nth-child(3) { animation-delay: 180ms; }
.screen.active > *:nth-child(4) { animation-delay: 240ms; }

@keyframes screen-enter {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Mode card stagger */
.mode-grid .mode-card {
  animation: card-enter 480ms cubic-bezier(0.22, 1, 0.36, 1) backwards;
}

.mode-grid .mode-card:nth-child(1) { animation-delay: 80ms; }
.mode-grid .mode-card:nth-child(2) { animation-delay: 140ms; }
.mode-grid .mode-card:nth-child(3) { animation-delay: 200ms; }
.mode-grid .mode-card:nth-child(4) { animation-delay: 260ms; }
.mode-grid .mode-card:nth-child(5) { animation-delay: 320ms; }
.mode-grid .mode-card:nth-child(6) { animation-delay: 380ms; }

@keyframes card-enter {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Shake (for PIN error) */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

.shake {
  animation: shake 380ms cubic-bezier(0.36, 0.07, 0.19, 0.97);
}

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