/* MCP Terminal — VT100-inspired CRT emulator */

:root {
  --term-bg: #0a0f0a;
  --term-green: #33ff66;
  --term-green-dim: #1a9e3f;
  --term-green-glow: rgba(51, 255, 102, 0.35);
  --term-amber: #ffb000;
  --term-cursor: #33ff66;
  --term-font: "JetBrains Mono", "SF Mono", "Consolas", monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body.terminal-body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: #050805;
  color: var(--term-green);
  font-family: var(--term-font);
  font-size: 14px;
  line-height: 1.45;
}

.terminal-page {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  padding: 12px;
  gap: 8px;
}

.terminal-chassis {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-radius: 12px;
  border: 2px solid #1a2a1a;
  background: var(--term-bg);
  box-shadow:
    0 0 40px rgba(51, 255, 102, 0.08),
    inset 0 0 80px rgba(0, 0, 0, 0.6);
  overflow: hidden;
}

.terminal-chassis::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    0deg,
    rgba(0, 0, 0, 0.12) 0px,
    rgba(0, 0, 0, 0.12) 1px,
    transparent 1px,
    transparent 3px
  );
  z-index: 3;
}

.terminal-chassis::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(0, 0, 0, 0.45) 100%);
  z-index: 4;
}

.terminal-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 14px;
  background: #0d140d;
  border-bottom: 1px solid #1f3a1f;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--term-green-dim);
  z-index: 5;
}

.terminal-topbar__lights {
  display: flex;
  gap: 6px;
}

.terminal-light {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #1a2a1a;
}

.terminal-light--pwr {
  background: var(--term-green);
  box-shadow: 0 0 8px var(--term-green-glow);
  animation: term-pulse 2s ease-in-out infinite;
}

.terminal-light--net {
  background: var(--term-amber);
  box-shadow: 0 0 6px rgba(255, 176, 0, 0.4);
}

@keyframes term-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.terminal-exit {
  color: var(--term-green-dim);
  text-decoration: none;
  font-size: 11px;
  transition: color 0.15s;
}

.terminal-exit:hover {
  color: var(--term-green);
  text-shadow: 0 0 8px var(--term-green-glow);
}

.terminal-screen {
  position: relative;
  flex: 1;
  min-height: 0;
  padding: 16px 18px 8px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  z-index: 2;
}

.terminal-output {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  white-space: pre-wrap;
  word-break: break-word;
  text-shadow: 0 0 6px var(--term-green-glow);
  scrollbar-width: thin;
  scrollbar-color: var(--term-green-dim) transparent;
}

.terminal-output::-webkit-scrollbar {
  width: 6px;
}

.terminal-output::-webkit-scrollbar-thumb {
  background: var(--term-green-dim);
  border-radius: 3px;
}

.terminal-line {
  margin: 0 0 2px;
}

.terminal-line--system {
  color: var(--term-green-dim);
}

.terminal-line--error {
  color: #ff5555;
  text-shadow: 0 0 6px rgba(255, 85, 85, 0.4);
}

.terminal-line--success {
  color: var(--term-green);
}

.terminal-line--json {
  color: #7dffb0;
}

.terminal-line--prompt {
  color: var(--term-green);
}

.terminal-line--pretty-header {
  color: var(--term-green);
  text-shadow: 0 0 10px var(--term-green-glow);
  margin-top: 6px;
  margin-bottom: 4px;
}

.terminal-line--pretty-divider {
  color: var(--term-green-dim);
  margin: 4px 0;
}

.terminal-line--pretty-section {
  color: var(--term-green);
  margin-top: 4px;
  margin-bottom: 2px;
}

.terminal-line--pretty {
  margin: 0 0 2px;
}

.terminal-line--pretty .pretty-label {
  color: var(--term-green-dim);
}

.terminal-line--pretty .pretty-value {
  color: var(--term-green);
}

.terminal-line--pretty-text {
  color: var(--term-green);
  padding-left: 2ch;
}

.terminal-line--pretty-bullet {
  color: var(--term-green);
  padding-left: 2ch;
}

.terminal-line--pretty-bullet::before {
  content: "▸ ";
  color: var(--term-green-dim);
}

.terminal-line--pretty-muted {
  color: var(--term-green-dim);
  font-style: italic;
}

.terminal-input-row {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 8px 18px 14px;
  z-index: 5;
  background: var(--term-bg);
  border-top: 1px solid #142014;
}

.terminal-prompt-label {
  color: var(--term-green);
  text-shadow: 0 0 8px var(--term-green-glow);
  white-space: nowrap;
  user-select: none;
}

.terminal-input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  color: var(--term-green);
  font-family: var(--term-font);
  font-size: 14px;
  caret-color: transparent;
  text-shadow: 0 0 6px var(--term-green-glow);
  padding: 0;
  margin: 0;
}

.terminal-cursor {
  display: inline-block;
  width: 0.6em;
  height: 1.1em;
  background: var(--term-cursor);
  box-shadow: 0 0 10px var(--term-green-glow);
  vertical-align: text-bottom;
  animation: term-blink 1s step-end infinite;
}

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

.terminal-boot {
  animation: term-flicker 0.08s ease-in-out 3;
}

@keyframes term-flicker {
  0% { opacity: 0.3; }
  50% { opacity: 1; }
  100% { opacity: 0.85; }
}

@media (max-width: 640px) {
  .terminal-page {
    padding: 6px;
  }

  html,
  body.terminal-body {
    font-size: 12px;
  }

  .terminal-screen {
    padding: 12px 10px 6px;
  }

  .terminal-input-row {
    padding: 6px 10px 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .terminal-light--pwr,
  .terminal-cursor,
  .terminal-boot {
    animation: none;
  }
}
