#terminal-layer {
  position: absolute;
  inset: 0;
  background: #0a0a0a;
  z-index: 200;
  font-family: 'Courier New', 'VT323', monospace;
  color: #33ff33;
  overflow: hidden;
}

/* CRT Scanlines */
#terminal-layer::before {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0,0,0,0.15) 2px,
    rgba(0,0,0,0.15) 4px
  );
  pointer-events: none;
  z-index: 1;
}

/* CRT vignette */
#terminal-layer::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 50%, rgba(0,0,0,0.7) 100%);
  pointer-events: none;
  z-index: 1;
}

.terminal-screen {
  position: relative;
  width: 100%;
  height: 100%;
  padding: 1.5rem;
  overflow-y: auto;
  animation: termFlicker 8s infinite;
  z-index: 2;
}

@keyframes termFlicker {
  0%, 100% { opacity: 1; }
  3% { opacity: 0.97; }
  7.5% { opacity: 0.93; }
  52% { opacity: 0.96; }
}

.terminal-output {
  white-space: pre-wrap;
  word-wrap: break-word;
  font-size: clamp(0.9rem, 2.5vw, 1.3rem);
  line-height: 1.5;
  margin-bottom: 0.5rem;
}

.terminal-output .warn { color: #ffaa00; }
.terminal-output .err { color: #ff3333; }
.terminal-output .ok { color: #33ff33; }
.terminal-output .cyan { color: #33ffff; }
.terminal-output .dim { color: #1a8c1a; }
.terminal-output .bold { font-weight: bold; }

.terminal-input-line {
  display: flex;
  align-items: center;
  font-size: clamp(0.9rem, 2.5vw, 1.3rem);
}

.terminal-prompt {
  color: #33ffff;
  margin-right: 0.5em;
  white-space: nowrap;
}

.terminal-input {
  background: transparent;
  border: none;
  outline: none;
  color: #33ff33;
  font-family: 'Courier New', 'VT323', monospace;
  font-size: inherit;
  flex: 1;
  caret-color: #33ff33;
}

.terminal-input:focus-visible {
  outline: 1px solid #33ffff;
}

.terminal-input::placeholder {
  color: #1a8c1a;
}

/* Glitch transition effect */
.terminal-glitch-in {
  animation: termGlitchIn 0.8s ease-out forwards;
}

@keyframes termGlitchIn {
  0% { opacity: 0; transform: scaleY(0.01); filter: brightness(10); }
  20% { opacity: 1; transform: scaleY(1.1); filter: brightness(3); }
  30% { transform: scaleY(0.95); filter: brightness(1.5); }
  40% { transform: scaleY(1.02); filter: brightness(1); }
  100% { transform: scaleY(1); filter: brightness(1); }
}

.terminal-glitch-out {
  animation: termGlitchOut 0.5s ease-in forwards;
}

@keyframes termGlitchOut {
  0% { opacity: 1; transform: scaleY(1); }
  70% { opacity: 1; transform: scaleY(1.05); filter: brightness(3); }
  100% { opacity: 0; transform: scaleY(0.01); filter: brightness(10); }
}

/* Static noise overlay during transition */
.terminal-static {
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.3'/%3E%3C/svg%3E");
  opacity: 0;
  pointer-events: none;
  z-index: 10;
  animation: staticFlash 0.8s ease-out forwards;
}

@keyframes staticFlash {
  0% { opacity: 0.8; }
  30% { opacity: 0.4; }
  100% { opacity: 0; }
}

/* Header bar in terminal */
.terminal-header {
  border-bottom: 1px solid #1a8c1a;
  padding-bottom: 0.5rem;
  margin-bottom: 1rem;
  font-size: clamp(0.7rem, 2vw, 1rem);
  color: #1a8c1a;
  font-family: Consolas, 'Share Tech Mono', monospace;
}

.terminal-header .node-name {
  color: #33ffff;
}

/* Close hint */
.terminal-close-hint {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  font-size: 0.7rem;
  color: #1a8c1a;
  font-family: Consolas, 'Share Tech Mono', monospace;
  z-index: 5;
}

@media (prefers-reduced-motion: reduce) {
  .terminal-screen,
  .terminal-glitch-in,
  .terminal-glitch-out,
  .terminal-static {
    animation: none !important;
  }
}
