/* ═══════════════════════════════════════════════
   GLOBAL SECRET TERMINAL — VT220 CRT Overlay
   Green Phosphor P1 Monochrome
   ═══════════════════════════════════════════════ */

/* ── Overlay Container ── */
.terminal-overlay {
  --bg: #05060b;
  --surface: #0b0f0c;
  --accent: #33ff66;
  --green: #33ff66;
  --text: #d7e9da;
  --muted: rgba(51, 255, 102, 0.4);
  --yellow: #ffb000;
  --warning: #ffb000;
  --alert: #ff3333;

  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 70vh;
  z-index: 9999;
  background: var(--bg);
  border-bottom: 2px solid var(--accent);
  box-shadow:
    0 4px 40px rgba(51, 255, 102, 0.15),
    0 2px 8px  rgba(0, 0, 0, 0.6),
    inset 0 0 120px rgba(0, 0, 0, 0.4);

  /* Slide-down: starts hidden above viewport */
  transform: translateY(-100%);
  visibility: hidden;
  transition:
    transform 0.45s cubic-bezier(0.22, 1, 0.36, 1),
    visibility 0s linear 0.45s;

  display: flex;
  flex-direction: column;
  font-family: var(--font-mono);
  overflow: hidden;
}

.terminal-overlay.is-open {
  transform: translateY(0);
  visibility: visible;
  transition:
    transform 0.45s cubic-bezier(0.22, 1, 0.36, 1),
    visibility 0s linear 0s;
}

/* ── CRT Phosphor Themes ── */
.terminal-overlay.theme-amber {
  --accent: #ffb000;
  --green: #ffb000;
  --text: #ffe2a8;
  --muted: rgba(255, 176, 0, 0.4);
  border-bottom-color: #ffb000;
  box-shadow: 0 4px 40px rgba(255, 176, 0, 0.15), 0 2px 8px rgba(0, 0, 0, 0.6), inset 0 0 120px rgba(0, 0, 0, 0.4);
}

.terminal-overlay.theme-cyan {
  --accent: #00e5ff;
  --green: #00e5ff;
  --text: #d6f9ff;
  --muted: rgba(0, 229, 255, 0.4);
  border-bottom-color: #00e5ff;
  box-shadow: 0 4px 40px rgba(0, 229, 255, 0.15), 0 2px 8px rgba(0, 0, 0, 0.6), inset 0 0 120px rgba(0, 0, 0, 0.4);
}

.terminal-overlay.theme-mono {
  --accent: #e0e0e0;
  --green: #e0e0e0;
  --text: #ffffff;
  --muted: rgba(224, 224, 224, 0.4);
  border-bottom-color: #e0e0e0;
  box-shadow: 0 4px 40px rgba(224, 224, 224, 0.15), 0 2px 8px rgba(0, 0, 0, 0.6), inset 0 0 120px rgba(0, 0, 0, 0.4);
}

.terminal-overlay.theme-matrix {
  --accent: #00ff41;
  --green: #00ff41;
  --text: #c0ffc8;
  --muted: rgba(0, 255, 65, 0.4);
  border-bottom-color: #00ff41;
  box-shadow: 0 4px 40px rgba(0, 255, 65, 0.2), 0 2px 8px rgba(0, 0, 0, 0.6), inset 0 0 120px rgba(0, 0, 0, 0.4);
}

/* ── CRT Glitch Effect ── */
@keyframes crtJitter {
  0%   { transform: translateY(0) translate(0, 0); }
  25%  { transform: translateY(0) translate(-3px, 1px); }
  50%  { transform: translateY(0) translate(2px, -2px); }
  75%  { transform: translateY(0) translate(-2px, -1px); }
  100% { transform: translateY(0) translate(0, 0); }
}

.terminal-overlay.is-glitching {
  animation: crtJitter 0.08s infinite !important;
}

/* ── CRT Scanlines ── */
.terminal-overlay::before {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    rgba(0, 0, 0, 0.12) 0px,
    rgba(0, 0, 0, 0.12) 1px,
    transparent 1px,
    transparent 3px
  );
  pointer-events: none;
  z-index: 1;
}

/* ── CRT Flicker ── */
/* Removed as per user request to stop background blinking */


/* ── Terminal Header Bar ── */
.terminal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.6rem 1.2rem;
  border-bottom: 1px solid rgba(51, 255, 102, 0.2);
  font-size: 0.65rem;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.15em;
  flex-shrink: 0;
  position: relative;
  z-index: 3;
  opacity: 0.85;
}

.terminal-header-title {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.terminal-header-led {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 6px var(--accent);
  animation: blink 1.2s step-end infinite;
}

.terminal-header-close {
  font-size: 0.6rem;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.2s;
}
.terminal-header-close:hover {
  color: var(--accent);
}

/* ── Output Area ── */
.terminal-output {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 1rem 1.2rem;
  position: relative;
  z-index: 3;
  scroll-behavior: smooth;

  /* Custom Scrollbar */
  scrollbar-width: thin;
  scrollbar-color: rgba(51, 255, 102, 0.3) transparent;
}

.terminal-output::-webkit-scrollbar {
  width: 4px;
}
.terminal-output::-webkit-scrollbar-track {
  background: transparent;
}
.terminal-output::-webkit-scrollbar-thumb {
  background: rgba(51, 255, 102, 0.3);
  border-radius: 2px;
}

/* ── Terminal Lines ── */
.terminal-line {
  font-size: 0.78rem;
  line-height: 1.65;
  color: var(--accent);
  text-shadow: 0 0 4px rgba(51, 255, 102, 0.15);
  white-space: pre-wrap;
  word-break: break-word;
  font-family: var(--font-mono, monospace);
}

.terminal-line.sys-msg {
  color: var(--yellow);
  text-shadow: 0 0 4px rgba(255, 176, 0, 0.15);
}

.terminal-line.err-msg {
  color: var(--alert);
  text-shadow: 0 0 3px rgba(255, 51, 51, 0.15);
  opacity: 0.8;
}

.terminal-line.cmd-echo {
  color: var(--text);
  text-shadow: 0 0 4px rgba(215, 233, 218, 0.12);
}

.terminal-line.muted-msg {
  color: var(--muted);
  text-shadow: none;
}

.terminal-line.ascii-art {
  font-size: 0.55rem;
  line-height: 1.15;
  color: var(--accent);
  text-shadow: 0 0 3px rgba(51, 255, 102, 0.1);
  letter-spacing: 0;
}

/* ── Input Area ── */
.terminal-input-area {
  display: flex;
  align-items: center;
  padding: 0.6rem 1.2rem;
  border-top: 1px solid rgba(51, 255, 102, 0.15);
  flex-shrink: 0;
  position: relative;
  z-index: 3;
  gap: 0.5rem;
}

.terminal-prompt {
  font-size: 0.78rem;
  color: var(--accent);
  text-shadow: 0 0 4px rgba(51, 255, 102, 0.2);
  font-family: var(--font-mono, monospace);
  white-space: nowrap;
  flex-shrink: 0;
}

.terminal-input-wrapper {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
}

.terminal-input {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  font-size: 0.78rem;
  font-family: var(--font-mono, monospace);
  background: transparent;
  border: none;
  color: transparent;
  caret-color: transparent;
  outline: none;
  z-index: 2;
}

.terminal-input-display {
  font-size: 0.78rem;
  color: var(--accent);
  text-shadow: 0 0 4px rgba(51, 255, 102, 0.15);
  font-family: var(--font-mono, monospace);
  white-space: pre;
  pointer-events: none;
  min-height: 1.2em;
}

.terminal-cursor {
  display: inline-block;
  color: var(--accent);
  animation: cursor-blink 0.8s step-end infinite;
  font-size: 0.78rem;
  text-shadow: 0 0 4px rgba(51, 255, 102, 0.25);
  margin-left: 1px;
}

@keyframes cursor-blink {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0; }
}

/* ── Boot Sequence Typewriter ── */
.terminal-boot-cursor {
  display: inline;
  animation: cursor-blink 0.5s step-end infinite;
}

/* ── Responsive ── */
@media (max-width: 600px) {
  .terminal-overlay {
    height: 100vh;
  }
  .terminal-line {
    font-size: 0.68rem;
  }
  .terminal-line.ascii-art {
    font-size: 0.35rem;
    line-height: 1.1;
  }
}

/* ── Reduced Motion ── */
@media (prefers-reduced-motion: reduce) {
  .terminal-overlay {
    transition: none;
  }
/* Removed ::after from reduced motion */
  .terminal-cursor,
  .terminal-boot-cursor,
  .terminal-header-led {
    animation: none;
    opacity: 1;
  }
}
