/* ===== Base ===== */
:root {
  --bg: #070907;
  --screen: #0a0d0a;
  --ph: #4af07a;          /* phosphor */
  --ph-dim: rgba(74, 240, 122, 0.55);
  --ph-faint: rgba(74, 240, 122, 0.18);
  --accent: #ffd866;
  --font: "JetBrains Mono", ui-monospace, monospace;
}

body.amber {
  --ph: #ffb000;
  --ph-dim: rgba(255, 176, 0, 0.55);
  --ph-faint: rgba(255, 176, 0, 0.18);
  --accent: #6ee7ff;
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ph);
  font-size: clamp(0.82rem, 1.6vw, 0.95rem);
  line-height: 1.65;
  min-height: 100svh;
  text-shadow: 0 0 8px var(--ph-faint);
}

::selection {
  background: var(--ph);
  color: var(--bg);
  text-shadow: none;
}

a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}

a:hover {
  background: var(--accent);
  color: var(--bg);
  text-shadow: none;
}

/* ===== CRT overlays ===== */
.scanlines {
  position: fixed;
  inset: 0;
  z-index: 20;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent 2px,
    rgba(0, 0, 0, 0.18) 3px
  );
}

.vignette {
  position: fixed;
  inset: 0;
  z-index: 21;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(0, 0, 0, 0.5));
  animation: flicker 4s infinite;
}

@keyframes flicker {
  0%, 100% { opacity: 1; }
  92% { opacity: 1; }
  93% { opacity: 0.86; }
  94% { opacity: 1; }
  97% { opacity: 0.93; }
}

/* ===== Terminal frame ===== */
.terminal {
  max-width: 980px;
  margin: 0 auto;
  padding: clamp(8px, 2vw, 24px);
}

.titlebar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 14px;
  background: #141714;
  border: 1px solid var(--ph-faint);
  border-bottom: none;
  border-radius: 10px 10px 0 0;
  padding: 10px 14px;
}

.titlebar-dots {
  display: flex;
  gap: 7px;
}

.titlebar-dots i {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #ff5f57;
}

.titlebar-dots i:nth-child(2) { background: #febc2e; }
.titlebar-dots i:nth-child(3) { background: #28c840; }

.titlebar-text {
  color: #8a948a;
  font-size: 0.78rem;
  text-shadow: none;
}

.titlebar-theme {
  margin-left: auto;
  background: none;
  border: 1px solid var(--ph-faint);
  border-radius: 6px;
  color: var(--ph-dim);
  font-family: var(--font);
  font-size: 0.72rem;
  padding: 3px 10px;
  cursor: pointer;
}

.titlebar-theme:hover {
  background: var(--ph);
  color: var(--bg);
  text-shadow: none;
}

.screen {
  background: var(--screen);
  border: 1px solid var(--ph-faint);
  border-top: none;
  border-radius: 0 0 10px 10px;
  padding: clamp(16px, 3vw, 32px);
  min-height: calc(100svh - 110px);
  cursor: text;
}

/* ===== Output ===== */
#output .row {
  white-space: pre-wrap;
  word-break: break-word;
}

.dim { color: var(--ph-dim); }
.faint { color: var(--ph-dim); opacity: 0.6; }
.bright { font-weight: 700; }
.accent { color: var(--accent); }
.invert {
  background: var(--ph);
  color: var(--bg);
  text-shadow: none;
  padding: 0 6px;
}

.cmd-link {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.cmd-link:hover {
  background: var(--accent);
  color: var(--bg);
  text-shadow: none;
}

/* ASCII banner */
.banner {
  color: var(--ph);
  font-size: clamp(0.42rem, 1.55vw, 0.85rem);
  line-height: 1.25;
  font-weight: 700;
  text-shadow: 0 0 14px var(--ph-faint);
}

/* ===== Prompt ===== */
.prompt-line {
  display: flex;
  gap: 10px;
  margin-top: 4px;
}

.prompt {
  white-space: nowrap;
}

.prompt-path {
  color: var(--accent);
}

.input-wrap {
  position: relative;
  flex: 1;
}

#typed-mirror {
  white-space: pre-wrap;
  word-break: break-all;
}

.caret {
  display: inline-block;
  width: 0.6em;
  height: 1.15em;
  background: var(--ph);
  vertical-align: text-bottom;
  animation: caret-blink 1.1s steps(2) infinite;
}

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

/* real input is invisible but focusable — mirror renders the text */
#cmd-input {
  position: absolute;
  inset: 0;
  width: 100%;
  opacity: 0;
  font-size: 16px; /* prevents iOS zoom on focus */
}

/* ===== Command chips (mobile / non-typers) ===== */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 28px;
}

.chips button {
  background: none;
  border: 1px solid var(--ph-faint);
  border-radius: 999px;
  color: var(--ph-dim);
  font-family: var(--font);
  font-size: 0.78rem;
  padding: 6px 16px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.chips button:hover {
  background: var(--ph);
  color: var(--bg);
  text-shadow: none;
}

/* ===== Noscript ===== */
.noscript {
  max-width: 640px;
  margin: 48px auto;
  padding: 0 24px;
}

/* ===== Reduced motion ===== */
@media (prefers-reduced-motion: reduce) {
  .vignette {
    animation: none;
  }

  .caret {
    animation: none;
  }
}
