/* CRT Animations & Effects */

/* Screen turn-on effect */
@keyframes crt-on {
  0% {
    transform: scale(1, 0.01);
    filter: brightness(30);
  }
  40% {
    transform: scale(1, 0.01);
    filter: brightness(10);
  }
  50% {
    transform: scale(1, 1);
    filter: brightness(5);
  }
  100% {
    transform: scale(1, 1);
    filter: brightness(1);
  }
}

.crt-on {
  animation: crt-on 0.6s cubic-bezier(0.23, 1, 0.32, 1) forwards;
}

/* Horizontal scan line */
@keyframes scanline {
  0% {
    transform: translateY(-100%);
  }
  100% {
    transform: translateY(100vh);
  }
}

.scanline-moving {
  position: absolute;
  left: 0;
  width: 100%;
  height: 4px;
  background: linear-gradient(to bottom, transparent, rgba(100, 200, 255, 0.08), transparent);
  pointer-events: none;
  z-index: 25;
  animation: scanline 4s linear infinite;
  opacity: 0.3;
}

/* Screen flicker on load */
@keyframes screen-flicker {
  0%, 100% { opacity: 1; }
  92% { opacity: 1; }
  93% { opacity: 0.8; }
  94% { opacity: 1; }
  96% { opacity: 0.9; }
  97% { opacity: 1; }
}

.screen-flicker {
  animation: screen-flicker 8s ease-in-out infinite;
}

/* Text glow pulse */
@keyframes glow-pulse {
  0%, 100% {
    text-shadow: 0 0 4px rgba(200, 200, 255, 0.25);
  }
  50% {
    text-shadow: 0 0 8px rgba(200, 200, 255, 0.4), 0 0 12px rgba(100, 255, 100, 0.1);
  }
}

.glow-pulse {
  animation: glow-pulse 3s ease-in-out infinite;
}

/* Boot sequence animation */
@keyframes boot-line {
  from { opacity: 0; transform: translateX(-10px); }
  to { opacity: 1; transform: translateX(0); }
}

.boot-line {
  animation: boot-line 0.3s ease-out forwards;
}

/* Typing effect */
@keyframes typewriter {
  from { width: 0; }
  to { width: 100%; }
}

/* Blinking block cursor */
@keyframes block-blink {
  0%, 50% { background-color: var(--accent-green); }
  51%, 100% { background-color: transparent; }
}

.block-cursor {
  display: inline-block;
  width: 0.6em;
  height: 1.1em;
  background-color: var(--accent-green);
  animation: block-blink 1s step-end infinite;
  vertical-align: text-bottom;
}

/* Glitch effect */
@keyframes glitch {
  0%, 100% { transform: translate(0); }
  20% { transform: translate(-2px, 2px); }
  40% { transform: translate(-2px, -2px); }
  60% { transform: translate(2px, 2px); }
  80% { transform: translate(2px, -2px); }
}

.glitch:hover {
  animation: glitch 0.3s ease-in-out;
}

/* Status LED blink */
@keyframes led-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.led-blink {
  animation: led-blink 1.5s ease-in-out infinite;
}

/* Loading bar */
@keyframes load-bar {
  0% { width: 0%; }
  100% { width: 100%; }
}

.loading-bar {
  height: 2px;
  background: var(--accent-green);
  box-shadow: 0 0 8px var(--accent-green);
  animation: load-bar 2s ease-in-out infinite;
}

/* Page transition */
@keyframes page-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.page-enter {
  animation: page-in 0.3s ease-out forwards;
}

/* Input focus glow */
.term-input:focus {
  border-bottom-color: var(--accent-green);
  box-shadow: 0 1px 0 0 var(--accent-green);
}

/* Button press effect */
.key:active, .term-btn:active, .nav-pill:active {
  transform: scale(0.96);
}

/* Smooth scroll for terminal */
.terminal {
  scroll-behavior: smooth;
}

/* Selection color */
::selection {
  background: rgba(51, 255, 51, 0.3);
  color: var(--text-bright);
}

/* Focus visible */
:focus-visible {
  outline: 1px solid var(--accent-green);
  outline-offset: 2px;
}

/* Print styles */
@media print {
  .device-chassis, .bezel, .control-deck, .nav-bar, .scanlines, .crt-glow, .crt-flicker {
    display: none !important;
  }
  
  .crt-screen {
    border: none;
    box-shadow: none;
  }
  
  body {
    background: white;
    color: black;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  
  .scanlines, .crt-flicker, .scanline-moving {
    display: none;
  }
}