/* AI Vision kit: the CRT terminal (terminal.js). The same screen as
   Terminal Quest: scanlines, a curved-tube vignette, phosphor glow with a
   slight red/blue fringe, and a refresh band rolling down. */

@font-face {
  font-family: "JetBrains Mono";
  src: url("../training/fonts/jetbrains-mono.woff") format("woff");
  font-weight: 400 700;
  font-display: swap;
}

.kt, .kt[data-phosphor="green"] { --phos: #86ffa6; --phos-hi: #d9ffe3; --phos-soft: rgba(134, 255, 166, .7); --phos-dim: rgba(134, 255, 166, .46); --phos-faint: rgba(134, 255, 166, .16); --phos-glow: rgba(90, 255, 140, .3); --screen: #020a05; --mast: #061209; --dir: #6ab4ff; }
.kt[data-phosphor="amber"] { --phos: #ffc35c; --phos-hi: #fff0d4; --phos-soft: rgba(255, 195, 92, .72); --phos-dim: rgba(255, 195, 92, .48); --phos-faint: rgba(255, 195, 92, .17); --phos-glow: rgba(255, 170, 40, .28); --screen: #0b0702; --mast: #150e04; --dir: #7cc0ff; }
.kt[data-phosphor="white"] { --phos: #e9ebee; --phos-hi: #fff; --phos-soft: rgba(241, 243, 245, .7); --phos-dim: rgba(241, 243, 245, .44); --phos-faint: rgba(255, 255, 255, .14); --phos-glow: rgba(255, 255, 255, .18); --screen: #08080a; --mast: #111113; --dir: #6ab4ff; }
.kt[data-phosphor="blue"] { --phos: #93d4ff; --phos-hi: #e4f5ff; --phos-soft: rgba(147, 212, 255, .72); --phos-dim: rgba(147, 212, 255, .46); --phos-faint: rgba(147, 212, 255, .17); --phos-glow: rgba(80, 170, 255, .28); --screen: #02060c; --mast: #07101a; --dir: #3f86ff; }

.kt {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  border: 1px solid #000;
  border-radius: 20px;
  background: var(--screen);
  color: var(--phos);
  box-shadow: 0 24px 60px rgba(18, 22, 30, .22);
  font-variant-ligatures: none;
  font-feature-settings: "liga" 0, "calt" 0;
  text-align: left;
  direction: ltr;
}
.kt::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  background:
    linear-gradient(160deg, rgba(255, 255, 255, .05), rgba(255, 255, 255, 0) 26%),
    radial-gradient(ellipse 120% 110% at 50% 50%, rgba(0, 0, 0, 0) 64%, rgba(0, 0, 0, .48) 100%),
    repeating-linear-gradient(0deg, rgba(0, 0, 0, .24) 0 1px, rgba(0, 0, 0, 0) 1px 3px);
  box-shadow: inset 0 0 80px rgba(0, 0, 0, .65), inset 0 0 0 1px rgba(255, 255, 255, .04);
  animation: kt-flicker 5s steps(1) infinite;
}
.kt::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 100%;
  z-index: 4;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0) 42%, rgba(255, 255, 255, .03) 50%, rgba(255, 255, 255, 0) 58%);
  animation: kt-refresh 7s linear infinite;
}

.kt__mast {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: none;
  height: 40px;
  padding: 0 16px;
  border-bottom: 1px solid var(--phos-faint);
  background: var(--mast);
  color: var(--phos-soft);
  font: 500 12.5px/1 "JetBrains Mono", ui-monospace, Consolas, monospace;
  text-shadow: 0 0 8px var(--phos-glow);
}
.kt__lights { display: flex; gap: 7px; }
.kt__lights i { width: 10px; height: 10px; border-radius: 50%; background: #3a3b40; }
.kt__lights i:first-child { background: #e2231a; box-shadow: 0 0 6px rgba(226, 35, 26, .6); }
.kt__title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.kt__screen {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 14px 18px 18px;
  color: var(--phos);
  font: 500 14px/1.62 "JetBrains Mono", ui-monospace, Consolas, monospace;
  text-shadow: -.4px 0 rgba(255, 45, 85, .22), .4px 0 rgba(70, 170, 255, .22), 0 0 7px var(--phos-glow);
  cursor: text;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--phos-faint) transparent;
}
.kt__screen ::selection { background: var(--phos); color: var(--screen); text-shadow: none; }
.kt__line { min-height: 1.62em; white-space: pre-wrap; overflow-wrap: anywhere; }
.kt__block + .kt__block { margin-top: 2px; }
.kt__cmd { color: var(--phos-hi); }
.kt__ps1 { white-space: pre; }
.kt__u { color: var(--phos-hi); font-weight: 700; }
.kt__p { color: var(--dir); font-weight: 700; }
.kt-err { color: #ff6b5f; }
.kt-dim { color: var(--phos-dim); }
.kt-gold { color: #ff5d52; }
.kt-man-h, .kt-man-b, .kt-ls-exec { color: var(--phos-hi); font-weight: 700; }
.kt-man-ex { color: var(--phos-soft); }
.kt-ls-dir { color: var(--dir); font-weight: 700; }
.kt-ls-sticky { background: var(--phos); color: var(--screen); text-shadow: none; }
.kt__cols { display: flex; flex-wrap: wrap; }
.kt__cell { width: var(--col); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: pre; }
.kt-sys { display: flex; gap: 9px; margin: 6px 0; padding: 6px 12px; border-left: 2px solid var(--phos-dim); border-radius: 0 9px 9px 0; background: linear-gradient(90deg, var(--phos-faint), rgba(0, 0, 0, 0) 85%); color: var(--phos-hi); }

/* The live command line: a transparent input under a painted copy. */
.kt__cmdline { display: flex; min-height: 1.62em; }
.kt__field { position: relative; flex: 1; min-width: 0; height: 1.62em; overflow: hidden; }
.kt__paint { position: absolute; left: 0; top: 0; color: var(--phos-hi); white-space: pre; pointer-events: none; }
.kt__input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; padding: 0; border: 0; outline: 0; background: transparent; color: transparent; caret-color: transparent; font: inherit; letter-spacing: inherit; }
.kt__input::selection { background: transparent; color: transparent; }
.kt__cursor { outline: 1px solid var(--phos-dim); outline-offset: -1px; }
.kt__cmdline.is-focused .kt__cursor { outline: 0; background: var(--phos); color: var(--screen); text-shadow: none; animation: kt-cursor 1.1s steps(1) infinite; }

/* Narrator mode (mountNarrator): no command line, a block cursor on the line being typed. */
.kt[data-mode="narrate"] .kt__screen { cursor: default; }
.kt__typing::after, .kt__idle::after { content: ""; display: inline-block; width: .6em; height: 1.1em; margin-left: 1px; vertical-align: -.18em; background: var(--phos); box-shadow: 0 0 8px var(--phos-glow); animation: kt-cursor 1.1s steps(1) infinite; }
.kt__idle::before { content: "> "; white-space: pre; color: var(--phos-dim); }
.kt-bar { color: var(--phos-soft); white-space: pre; overflow: hidden; text-overflow: clip; }
.kt-hi { color: var(--phos-hi); font-weight: 700; }

/* Status pill in the title bar (narrator status()). */
.kt__pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex: none;
  margin-left: auto;
  padding: 8px 12px;
  border: 1px solid var(--phos-faint);
  border-radius: 999px;
  color: var(--phos-dim);
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: uppercase;
  text-shadow: none;
  transition: color .3s ease, border-color .3s ease, background .3s ease;
}
.kt__pill[hidden] { display: none; }
.kt__pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.kt__pill[data-tone="busy"] { color: var(--phos); border-color: var(--phos-dim); }
.kt__pill[data-tone="busy"]::before { box-shadow: 0 0 8px var(--phos-glow); animation: kt-pulse 1s ease-in-out infinite; }
.kt__pill[data-tone="ready"] { color: var(--phos-hi); border-color: var(--phos-soft); background: var(--phos-faint); }
.kt__pill[data-tone="sent"] { color: #fff; border-color: #ff5d52; background: rgba(226, 35, 26, .32); }

@keyframes kt-flicker { 0%, 100% { opacity: 1; } 41% { opacity: .93; } 42% { opacity: 1; } 77% { opacity: .96; } 78% { opacity: 1; } }
@keyframes kt-refresh { from { transform: translateY(-100%); } to { transform: translateY(100%); } }
@keyframes kt-cursor { 50% { background: transparent; color: var(--phos-hi); } }
@keyframes kt-pulse { 50% { opacity: .35; } }

@media (pointer: coarse) { .kt__input { font-size: 16px; } }
@media (prefers-reduced-motion: reduce) {
  .kt::before, .kt::after, .kt__cmdline.is-focused .kt__cursor, .kt__typing::after, .kt__idle::after, .kt__pill::before { animation: none !important; }
  .kt::after { display: none; }
}
