/* ============================================================
   Animations
   ============================================================ */

/* Only play animations when the user has not requested reduced motion */
@media (prefers-reduced-motion: no-preference) {

  /* File-switch fade */
  @keyframes fileFadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
  }

  .editor__file.state-active .editor__overlay {
    animation: fileFadeIn 0.3s ease forwards;
  }

  /* Code line reveal (used by about/contact) */
  @keyframes lineReveal {
    from { opacity: 0; transform: translateX(-8px); }
    to   { opacity: 1; transform: translateX(0); }
  }

  .overlay__code > * {
    animation: lineReveal 0.25s ease both;
  }

  /* Stagger children — up to 20, then cap */
  .overlay__code > *:nth-child(1)  { animation-delay: 0.00s; }
  .overlay__code > *:nth-child(2)  { animation-delay: 0.03s; }
  .overlay__code > *:nth-child(3)  { animation-delay: 0.06s; }
  .overlay__code > *:nth-child(4)  { animation-delay: 0.09s; }
  .overlay__code > *:nth-child(5)  { animation-delay: 0.12s; }
  .overlay__code > *:nth-child(6)  { animation-delay: 0.15s; }
  .overlay__code > *:nth-child(7)  { animation-delay: 0.18s; }
  .overlay__code > *:nth-child(8)  { animation-delay: 0.21s; }
  .overlay__code > *:nth-child(9)  { animation-delay: 0.24s; }
  .overlay__code > *:nth-child(10) { animation-delay: 0.27s; }
  .overlay__code > *:nth-child(11) { animation-delay: 0.30s; }
  .overlay__code > *:nth-child(12) { animation-delay: 0.33s; }
  .overlay__code > *:nth-child(13) { animation-delay: 0.36s; }
  .overlay__code > *:nth-child(14) { animation-delay: 0.39s; }
  .overlay__code > *:nth-child(15) { animation-delay: 0.42s; }
  .overlay__code > *:nth-child(16) { animation-delay: 0.45s; }
  .overlay__code > *:nth-child(17) { animation-delay: 0.48s; }
  .overlay__code > *:nth-child(18) { animation-delay: 0.51s; }
  .overlay__code > *:nth-child(19) { animation-delay: 0.54s; }
  .overlay__code > *:nth-child(20) { animation-delay: 0.57s; }
  .overlay__code > *:nth-child(n+21) { animation-delay: 0.60s; }

  /* Work card entrance */
  @keyframes cardIn {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
  }

  .work__card {
    animation: cardIn 0.3s ease both;
  }
  .work__card:nth-child(1) { animation-delay: 0.05s; }
  .work__card:nth-child(2) { animation-delay: 0.12s; }
  .work__card:nth-child(3) { animation-delay: 0.19s; }
  .work__card:nth-child(4) { animation-delay: 0.26s; }

  /* ASCII char draw-in */
  @keyframes asciiIn {
    from { opacity: 0; }
    to   { opacity: 1; }
  }

  .editor__ascii { animation: asciiIn 0.6s ease forwards; }

}

/* Typewriter cursor blink — always active (not motion-sensitive) */
@keyframes blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

.typewriter-cursor {
  display: inline-block;
  width: 2px;
  height: 0.85em;
  background: var(--text-bright);
  margin-left: 4px;
  vertical-align: middle;
  animation: blink 1s step-end infinite;
}

/* Disable cursor blink too for strict reduced-motion preference */
@media (prefers-reduced-motion: reduce) {
  .typewriter-cursor { animation: none; opacity: 1; }
}

/* Theme transition */
html {
  transition: background 0.3s, color 0.3s;
}

@media (prefers-reduced-motion: reduce) {
  html { transition: none; }
}
