/* ── Full-screen Terminal ── */
.terminal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--bg);
  z-index: 9999;
  display: none;
  flex-direction: column;
  font-family: 'JetBrains Mono', monospace;
}

.terminal-overlay.active {
  display: flex;
  animation: termSlideDown 0.25s ease;
}

.terminal-overlay.closing {
  animation: termSlideUp 0.2s ease forwards;
}

@keyframes termSlideDown {
  from { transform: translateY(-100%); }
  to { transform: translateY(0); }
}

@keyframes termSlideUp {
  from { transform: translateY(0); }
  to { transform: translateY(-100%); }
}

/* ── Terminal title bar ── */
.term-title-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--glass-border);
  flex-shrink: 0;
}

.term-title-dots {
  display: flex;
  gap: 6px;
}

.term-title-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.term-title-dot.r { background: #ff5f57; }
.term-title-dot.y { background: #ffbd2e; }
.term-title-dot.g { background: #28c840; }

.term-title-label {
  color: #666;
  font-size: 0.75rem;
  margin-left: 8px;
}

/* ── Output area ── */
.terminal-output {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  font-size: 0.88rem;
  line-height: 1.6;
  position: relative;
  z-index: 1;
}

.terminal-output::-webkit-scrollbar { width: 6px; }
.terminal-output::-webkit-scrollbar-track { background: var(--surface); }
.terminal-output::-webkit-scrollbar-thumb { background: #333; border-radius: 3px; }

.term-line {
  white-space: pre-wrap;
  word-break: break-word;
  margin-bottom: 2px;
}

.term-line.out { color: #ccc; }
.term-line.err { color: #ff5f57; }
.term-line.ok { color: var(--accent); }
.term-line.info { color: #6bb5ff; }
.term-line.sys { color: #555; font-style: italic; }
.term-line.ascii { color: var(--accent); line-height: 1.15; font-size: 0.62rem; }

/* ── Input line ── */
.term-input-row {
  display: flex;
  align-items: center;
  padding: 8px 16px 16px;
  border-top: 1px solid var(--glass-border);
  background: var(--surface);
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}

.term-prompt {
  color: var(--accent);
  margin-right: 10px;
  font-size: 0.88rem;
  white-space: nowrap;
}

.term-input {
  background: none;
  border: none;
  color: #fff;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.88rem;
  flex: 1;
  outline: none;
  caret-color: var(--accent);
}

/* ── Matrix canvas ── */
.term-matrix {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s;
}

.term-matrix.active {
  opacity: 0.12;
}

/* ── Toast notification ── */
.toast {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 9998;
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  opacity: 0;
  transform: translateX(120%);
  transition: opacity 0.4s ease, transform 0.4s ease;
  max-width: 340px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.5);
  pointer-events: none;
}

.toast.visible {
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;
}

.toast-icon {
  color: var(--accent);
  font-size: 1.1rem;
  flex-shrink: 0;
}

.toast-text {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  color: #ccc;
  line-height: 1.4;
}

.toast-text kbd {
  background: #222;
  border: 1px solid #444;
  border-radius: 4px;
  padding: 1px 6px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  color: var(--accent);
}

.toast-close {
  background: none;
  border: none;
  color: #555;
  cursor: pointer;
  font-size: 1.2rem;
  padding: 0 4px;
  transition: color 0.2s;
}

.toast-close:hover {
  color: #fff;
}

/* ── Floating terminal button (mobile) ── */
.term-fab {
  display: none;
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9997;
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: 24px;
  padding: 10px 20px;
  color: var(--accent);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.82rem;
  cursor: pointer;
  box-shadow: 0 4px 16px var(--accent-glow);
  align-items: center;
  gap: 6px;
  animation: fabPulse 2s ease-in-out infinite;
  transition: transform 0.2s;
}

.term-fab:active {
  transform: translateX(-50%) scale(0.95);
}

@keyframes fabPulse {
  0%, 100% { box-shadow: 0 4px 16px var(--accent-dim); }
  50% { box-shadow: 0 4px 28px var(--accent-glow); }
}

/* ── Mobile responsive ── */
@media (max-width: 768px) {
  .term-fab {
    display: inline-flex;
  }

  .terminal-output {
    font-size: 0.78rem;
    padding: 12px;
  }

  .term-input {
    font-size: 0.78rem;
  }

  .term-prompt {
    font-size: 0.78rem;
  }

  .term-line.ascii {
    font-size: 0.45rem;
  }

  .toast {
    max-width: calc(100vw - 32px);
    right: 12px;
    top: 12px;
  }
}

@media (max-width: 480px) {
  .term-fab {
    font-size: 0.72rem;
    padding: 8px 14px;
    bottom: 14px;
  }
}
