/* ============================================
   IHOS Terminal  - CRT Aesthetic
   ============================================ */

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

:root {
  --term-bg: #0a0a0a;
  --term-green: #00ff88;
  --term-green-dim: rgba(0, 255, 136, 0.6);
  --term-green-glow: rgba(0, 255, 136, 0.15);
  --term-amber: #ffaa00;
  --term-red: #ff4444;
  --term-cyan: #00ddff;
  --term-muted: #335544;
  --term-font: 'JetBrains Mono', 'Consolas', 'Courier New', monospace;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  background: var(--term-bg);
  font-family: var(--term-font);
  font-size: 14px;
  color: var(--term-green);
  line-height: 1.6;
}

/* --- Scanlines overlay --- */
.scanlines {
  position: fixed;
  inset: 0;
  z-index: 100;
  pointer-events: none;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.08) 2px,
    rgba(0, 0, 0, 0.08) 4px
  );
}

.scanlines::after {
  content: '';
  position: fixed;
  inset: 0;
  background: radial-gradient(
    ellipse at center,
    transparent 50%,
    rgba(0, 0, 0, 0.4) 100%
  );
}

/* --- Terminal container --- */
.terminal {
  width: 100%;
  height: 100vh;
  height: 100dvh;
  padding: 2rem;
  padding-bottom: 6rem;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: none;
  z-index: 1;
}

.terminal::-webkit-scrollbar {
  width: 4px;
}

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

.terminal::-webkit-scrollbar-thumb {
  background: var(--term-muted);
  border-radius: 2px;
}

/* --- Output lines --- */
.terminal__output {
  white-space: pre-wrap;
  word-break: break-word;
}

.line {
  opacity: 0;
  animation: lineAppear 0.05s ease forwards;
  padding: 1px 0;
}

@keyframes lineAppear {
  to { opacity: 1; }
}

.line--system {
  color: var(--term-muted);
  font-size: 0.85em;
}

.line--ihos {
  color: var(--term-cyan);
}

.line--ihos .line__prefix {
  color: var(--term-cyan);
  font-weight: 700;
}

.line--ctrl .line__prefix {
  color: var(--term-green);
  font-weight: 700;
}

.line--alert {
  color: var(--term-amber);
}

.line--alert .line__prefix {
  color: var(--term-red);
  font-weight: 700;
}

.line--user {
  color: #ffffff;
}

.line--user .line__prefix {
  color: var(--term-green-dim);
}

.line--empty {
  height: 1.6em;
}

.line__prefix {
  user-select: none;
}

/* typing cursor for active line */
.line--typing::after {
  content: '\2588';
  animation: termBlink 0.7s step-end infinite;
  color: var(--term-green);
}

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

/* --- Input line --- */
.terminal__input-line {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

.terminal__prompt {
  color: var(--term-green);
  font-weight: 700;
  user-select: none;
  flex-shrink: 0;
}

.terminal__input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: #ffffff;
  font-family: var(--term-font);
  font-size: 14px;
  caret-color: var(--term-green);
  line-height: 1.6;
}

.terminal__input::placeholder {
  color: var(--term-muted);
}

/* --- Choice buttons --- */
.terminal__choices {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-top: 0.5rem;
}

.terminal__choice {
  background: none;
  border: 1px solid var(--term-muted);
  border-radius: 4px;
  padding: 0.5rem 1rem;
  color: var(--term-green);
  font-family: var(--term-font);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s ease;
  max-width: 500px;
}

.terminal__choice:hover {
  border-color: var(--term-green);
  background: var(--term-green-glow);
  text-shadow: 0 0 8px var(--term-green-glow);
}

.terminal__choice .choice__key {
  color: var(--term-amber);
  font-weight: 700;
  margin-right: 0.5rem;
}

/* --- Bottom action buttons --- */
.terminal__actions {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 50;
  display: flex;
  justify-content: center;
  gap: 1rem;
  padding: 1.5rem 2rem;
  background: linear-gradient(to top, var(--term-bg) 60%, transparent);
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.terminal__actions--visible {
  opacity: 1;
  transform: translateY(0);
}

.terminal__btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--term-font);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.75rem 1.5rem;
  border-radius: 6px;
  text-decoration: none;
  transition: all 0.3s ease;
  cursor: pointer;
}

.terminal__btn--steam {
  background: var(--term-green);
  color: #0a0a0a;
  border: none;
}

.terminal__btn--steam:hover {
  background: #00cc6e;
  box-shadow: 0 0 24px rgba(0, 255, 136, 0.4);
  transform: translateY(-2px);
}

.terminal__btn--back {
  background: transparent;
  color: var(--term-muted);
  border: 1px solid var(--term-muted);
}

.terminal__btn--back:hover {
  color: var(--term-green);
  border-color: var(--term-green);
}

/* --- Responsive --- */
@media (max-width: 768px) {
  body {
    font-size: 12px;
  }

  .terminal {
    padding: 0.75rem;
    padding-bottom: 8rem;
  }

  .terminal__output {
    overflow-wrap: break-word;
    word-break: break-word;
  }

  .line {
    max-width: 100%;
  }

  .terminal__choice {
    max-width: 100%;
    font-size: 12px;
    padding: 0.6rem 0.75rem;
  }

  .terminal__input {
    font-size: 16px; /* prevents iOS auto-zoom on focus */
  }

  .terminal__actions {
    flex-direction: column;
    align-items: center;
    padding: 1rem 1.5rem;
    gap: 0.75rem;
  }

  .terminal__btn {
    width: 100%;
    justify-content: center;
    max-width: 100%;
    text-align: center;
  }
}
