/* ===== Matrix terminal theme ===== */

:root {
  --matrix-green: #00c8ff;
  --matrix-green-dim: #0a2a3d;
  --matrix-bg: #000000;
  --terminal-bg: rgba(0, 10, 0, 0.85);
  --font-mono: 'Consolas', 'Courier New', monospace;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: var(--matrix-bg);
  color: var(--matrix-green);
  font-family: var(--font-mono);
  overflow-x: hidden;
}

/* The falling-code animation canvas sits fixed behind everything */
#matrix-rain {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 0;
  display: block;
}

.page {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  gap: 24px;
}

/* ===== Hero header ===== */

.hero {
  text-align: center;
}

.glitch {
  font-size: clamp(1.8rem, 6vw, 3rem);
  margin: 0;
  letter-spacing: 0.15em;
  color: var(--matrix-green);
  text-shadow:
    0 0 5px var(--matrix-green),
    0 0 15px var(--matrix-green),
    0 0 30px rgba(0, 200, 255, 0.4);
}

.subtitle {
  margin: 8px 0 0;
  font-size: clamp(0.7rem, 2.2vw, 0.95rem);
  color: var(--matrix-green);
  opacity: 0.7;
  letter-spacing: 0.1em;
}

/* ===== Terminal window ===== */

.terminal {
  width: min(680px, 100%);
  background: var(--terminal-bg);
  border: 1px solid var(--matrix-green);
  border-radius: 6px;
  box-shadow:
    0 0 20px rgba(0, 200, 255, 0.25),
    inset 0 0 40px rgba(0, 200, 255, 0.05);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  backdrop-filter: blur(1px);
}

.terminal-titlebar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: rgba(0, 200, 255, 0.08);
  border-bottom: 1px solid var(--matrix-green-dim);
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--matrix-green);
  opacity: 0.5;
}

.terminal-title {
  margin-left: 8px;
  font-size: 0.8rem;
  opacity: 0.8;
}

/* Scanline overlay effect on the whole terminal body */
.terminal-log {
  position: relative;
  height: 360px;
  overflow-y: auto;
  padding: 16px;
  font-size: 0.9rem;
  line-height: 1.5;
  background-image: repeating-linear-gradient(
    0deg,
    rgba(0, 200, 255, 0.035) 0px,
    rgba(0, 200, 255, 0.035) 1px,
    transparent 1px,
    transparent 3px
  );
}

.terminal-log .line {
  margin-bottom: 6px;
  white-space: pre-wrap;
  word-break: break-word;
  text-shadow: 0 0 4px rgba(0, 200, 255, 0.6);
}

.line.system {
  opacity: 0.6;
  font-style: italic;
}

.line.user::before {
  content: "> ";
  opacity: 0.8;
}

.line.bot {
  color: var(--matrix-green);
}

.line.error {
  color: #ff3b3b;
  text-shadow: 0 0 4px rgba(255, 59, 59, 0.7);
}

.line.pending {
  opacity: 0.6;
}

/* Blinking cursor after the last pending/typing line */
.line.pending::after {
  content: "▍";
  animation: blink 1s steps(1) infinite;
}

@keyframes blink {
  50% { opacity: 0; }
}

/* ===== Input line ===== */

.terminal-inputline {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--matrix-green-dim);
  background: rgba(0, 200, 255, 0.04);
}

.prompt {
  color: var(--matrix-green);
  font-weight: bold;
}

#chat-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--matrix-green);
  font-family: var(--font-mono);
  font-size: 0.95rem;
  caret-color: var(--matrix-green);
}

#chat-input::placeholder {
  color: rgba(0, 200, 255, 0.35);
}

#chat-input:disabled {
  opacity: 0.5;
}

.send-btn {
  background: transparent;
  border: 1px solid var(--matrix-green);
  color: var(--matrix-green);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  letter-spacing: 0.1em;
  padding: 6px 12px;
  border-radius: 3px;
  cursor: pointer;
  transition: background 0.15s ease, box-shadow 0.15s ease;
}

.send-btn:hover:not(:disabled) {
  background: rgba(0, 200, 255, 0.15);
  box-shadow: 0 0 10px rgba(0, 200, 255, 0.5);
}

.send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ===== Scrollbar theming (webkit) ===== */

.terminal-log::-webkit-scrollbar {
  width: 8px;
}

.terminal-log::-webkit-scrollbar-track {
  background: transparent;
}

.terminal-log::-webkit-scrollbar-thumb {
  background: var(--matrix-green-dim);
  border-radius: 4px;
}

/* ===== Responsive ===== */

@media (max-width: 480px) {
  .terminal-log {
    height: 300px;
    font-size: 0.82rem;
  }

  .send-btn {
    padding: 6px 8px;
    font-size: 0.7rem;
  }
}
