/* EPHERGENT:// Terminal — CRT Phosphor Aesthetic
   IBM 3270 mainframe meets deep-space radio telescope
   Amber phosphor primary, green secondary, scanlines, phosphor glow
*/

@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;700&display=swap');

/* ── Overlay Shell ─────────────────────────────────────── */
#terminal-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: #08080d;
  display: flex;
  flex-direction: column;
  font-family: 'JetBrains Mono', 'Courier New', monospace;
  overflow: hidden;
}

/* CRT scanline overlay */
#terminal-overlay::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 10;
  background: repeating-linear-gradient(
    0deg,
    rgba(0, 0, 0, 0.15) 0px,
    rgba(0, 0, 0, 0.15) 1px,
    transparent 1px,
    transparent 3px
  );
}

/* Vignette — darker edges */
#terminal-overlay::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 11;
  background: radial-gradient(
    ellipse at center,
    transparent 0%,
    transparent 60%,
    rgba(0, 0, 0, 0.35) 100%
  );
}

/* ── Screen flicker animation ───────────────────────────── */
@keyframes screen-flicker {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.97; }
}

@keyframes boot-flicker {
  0%, 100% { opacity: 1; }
  10% { opacity: 0.85; }
  20% { opacity: 1; }
  30% { opacity: 0.9; }
  40% { opacity: 1; }
  70% { opacity: 0.95; }
  80% { opacity: 1; }
}

@keyframes text-glow-pulse {
  0%, 100% { text-shadow: 0 0 4px currentColor, 0 0 8px currentColor; }
  50% { text-shadow: 0 0 6px currentColor, 0 0 12px currentColor; }
}

@keyframes amber-pulse {
  0%, 100% { text-shadow: 0 0 5px #ffb020, 0 0 10px rgba(255,176,32,0.5); }
  50% { text-shadow: 0 0 8px #ffb020, 0 0 20px rgba(255,176,32,0.7); }
}

@keyframes green-pulse {
  0%, 100% { text-shadow: 0 0 5px #00d4ff, 0 0 10px rgba(0,212,255,0.4); }
  50% { text-shadow: 0 0 8px #00d4ff, 0 0 18px rgba(0,212,255,0.6); }
}

@keyframes error-flicker {
  0%, 100% { color: #ff4444; }
  25% { color: #ff6666; }
  50% { color: #ff4444; }
  75% { color: #cc2222; }
}

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

/* ── Terminal Output Area ─────────────────────────────── */
#terminal-output {
  flex: 1;
  overflow-y: auto;
  padding: 2rem 2rem 1rem;
  position: relative;
  z-index: 5;
  scroll-behavior: smooth;
}

#terminal-output::-webkit-scrollbar {
  width: 6px;
}
#terminal-output::-webkit-scrollbar-track {
  background: #0c0d10;
}
#terminal-output::-webkit-scrollbar-thumb {
  background: #2a2a3a;
  border-radius: 3px;
}

/* ── Output Lines ─────────────────────────────────────── */
.line {
  display: block;
  font-size: 0.875rem;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  animation: float-in 0.08s ease-out;
}

/* Color classes */
.l-amber  { color: #ffb020; }
.l-green  { color: #00d4ff; }
.l-dim   { color: #9090b0; }
.l-warn  { color: #ff6644; }
.l-white { color: #e8e8f0; }
.l-dim-white { color: #606080; }

/* Boot lines stagger in */
.l-boot {
  color: #9090b0;
  animation: float-in 0.1s ease-out;
}

/* OK status line */
.l-ok {
  color: #00d4ff;
  text-shadow: 0 0 5px rgba(0,212,255,0.4);
}

/* Amber label like [01] */
.l-label {
  color: #ffb020;
  text-shadow: 0 0 5px rgba(255,176,32,0.4);
}

/* Prompt EPHERGENT:// */
.l-prompt {
  color: #00d4ff;
  font-weight: 700;
  text-shadow: 0 0 8px rgba(0,212,255,0.6);
  animation: green-pulse 3s ease-in-out infinite;
}

/* Input echo */
.l-cmd {
  color: #e8e8f0;
  font-weight: 500;
}

/* Section header */
.l-header {
  color: #ffb020;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-shadow: 0 0 6px rgba(255,176,32,0.5);
  animation: amber-pulse 4s ease-in-out infinite;
  margin-top: 0.5rem;
}

/* Error / flicker effect */
.l-error {
  color: #ff4444;
  text-shadow: 0 0 5px rgba(255,68,68,0.4);
  animation: error-flicker 0.15s infinite;
}

/* Typing scroll effect */
.l-typing {
  color: #9090b0;
  border-right: 2px solid #9090b0;
  animation: blink-cursor 0.7s step-end infinite;
}

@keyframes blink-cursor {
  0%, 100% { border-color: #9090b0; }
  50% { border-color: transparent; }
}

/* Flicker effect for INVADER */
.l-flicker {
  animation: terminal-flicker 0.5s;
}

@keyframes terminal-flicker {
  0%   { opacity: 1; }
  10%  { opacity: 0.3; }
  20%  { opacity: 1; }
  30%  { opacity: 0.5; }
  40%  { opacity: 1; }
  50%  { opacity: 0.2; }
  60%  { opacity: 1; }
  100% { opacity: 1; }
}

/* Warmth — Mochi effect */
.l-warmth {
  color: #ffd700;
  text-shadow: 0 0 8px rgba(255,215,0,0.6);
  animation: warmth-pulse 2s ease-in-out infinite;
}

@keyframes warmth-pulse {
  0%, 100% { text-shadow: 0 0 8px rgba(255,215,0,0.5); }
  50% { text-shadow: 0 0 16px rgba(255,215,0,0.9); }
}

/* Haiku style */
.l-haiku {
  color: #ffb020;
  font-style: italic;
}

/* Station divider */
.l-divider {
  color: #2a2a3a;
  user-select: none;
}

/* Link style inside terminal */
.l-link {
  color: #00d4ff;
  text-decoration: underline;
  cursor: pointer;
  text-shadow: 0 0 5px rgba(0,212,255,0.4);
}
.l-link:hover {
  color: #66e0ff;
  text-shadow: 0 0 10px rgba(0,212,255,0.7);
}

/* Earnest text */
.l-earnest {
  color: #e8e8f0;
  font-style: italic;
}

/* ── Input Area ────────────────────────────────────────── */
#terminal-input-row {
  display: flex;
  align-items: center;
  padding: 0.75rem 2rem 1.5rem;
  position: relative;
  z-index: 5;
  flex-shrink: 0;
}

#terminal-prompt-label {
  color: #00d4ff;
  font-size: 0.875rem;
  font-weight: 700;
  text-shadow: 0 0 8px rgba(0,212,255,0.6);
  margin-right: 0.5rem;
  white-space: nowrap;
  flex-shrink: 0;
  animation: green-pulse 3s ease-in-out infinite;
}

#terminal-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: #e8e8f0;
  font-family: 'JetBrains Mono', 'Courier New', monospace;
  font-size: 0.875rem;
  line-height: 1.6;
  caret-color: #00d4ff;
  text-shadow: 0 0 5px rgba(232,232,240,0.3);
}

#terminal-input::placeholder {
  color: #2a2a3a;
}

/* ── Help overlay ─────────────────────────────────────── */
#terminal-help {
  display: none;
  padding: 0 2rem 1rem;
  position: relative;
  z-index: 5;
  flex-shrink: 0;
}

/* ── Boot animation wrapper ──────────────────────────── */
#boot-container {
  animation: boot-flicker 0.4s ease-out;
}

/* ── Hide native page ────────────────────────────────── */
body.terminal-active .terminal-hide {
  display: none !important;
}

/* ── Reduced Motion ───────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .line {
    animation: none !important;
  }
  .l-boot,
  .l-flicker,
  .l-typing {
    animation: none !important;
  }
  .l-prompt,
  .l-header,
  .l-warmth {
    animation: none !important;
  }
  #boot-container {
    animation: none !important;
  }
}

/* ── Responsive ──────────────────────────────────────── */
@media (max-width: 640px) {
  #terminal-output {
    padding: 1rem 1rem 0.75rem;
  }
  #terminal-input-row {
    padding: 0.5rem 1rem 1rem;
  }
  .line {
    font-size: 0.8rem;
  }
}
