/* Nerd Fonts Symbols Only — web fallback so icons work without local install.
   unicode-range limits this font to the Private Use Areas where Nerd Font
   glyphs live, so Victor Mono is still used for regular text. */
@font-face {
  font-family: 'Symbols Nerd Font';
  font-style: normal;
  font-weight: normal;
  font-display: block;
  src: url('https://cdn.jsdelivr.net/gh/ryanoasis/nerd-fonts@v3.2.1/patched-fonts/NerdFontsSymbolsOnly/SymbolsNerdFontMono-Regular.ttf') format('truetype');
  unicode-range: U+23FB-23FE, U+2B58, U+E000-E00A, U+E0A0-E0A3, U+E0B0-E0C8, U+E0CA, U+E0CC-E0D7, U+E200-E2A9, U+E300-E3E3, U+E5FA-E6B7, U+E700-E8EF, U+EA60-EC1E, U+ED00-EFCE, U+F000-F2FF, U+F300-F381, U+F400-F533, U+F500-FD46, U+F0001-F1AF0;
}

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

:root {
  --bg: #000000;
  --fg: #f5f5f5;
  --dim: #8a8a8a;
  --error: #ff6b6b;
  --warn: #ffd580;
  --ok: #7ee787;

  /* Syntax tokens */
  --tok-cmd: #7ee787;
  --tok-cmd-unknown: #ff6b6b;
  --tok-flag: #d2a8ff;
  --tok-path: #79c0ff;
  --tok-arg: #ffd580;
  --tok-string: #ffa657;
  --tok-comment: #8b949e;
  --tok-number: #ffa657;
  --tok-keyword: #ff7b72;
  --tok-heading: #ffd580;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: 'VictorMono Nerd Font', 'Victor Mono', 'Symbols Nerd Font', ui-monospace, monospace;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.2;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

::selection {
  background: var(--fg);
  color: var(--bg);
}

#terminal {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
  padding: 12px 16px;
}

#output {
  flex: 1;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--dim) transparent;
}

#output::-webkit-scrollbar {
  width: 6px;
}

#output::-webkit-scrollbar-thumb {
  background: var(--dim);
}

.line {
  white-space: pre-wrap;
  word-break: break-word;
}

.line a {
  color: inherit;
  text-decoration: none;
  transition: color 0.2s ease;
}
.line a:hover {
  color: #8be9fd;
}

.prompt-line {
  display: flex;
  gap: 0;
  flex-wrap: wrap;
}

.prompt {
  color: var(--fg);
  white-space: pre;
}

.error { color: var(--error); }
.dim   { color: var(--dim); }
.ok    { color: var(--ok); }
.warn  { color: var(--warn); }

.cat-image,
.cat-video {
  max-width: 100%;
  max-height: 70vh;
  margin: 4px 0;
  display: block;
}

/* screenfetch-style startup banner */
.fetch {
  margin-bottom: 16px;
  display: flex;
  flex-wrap: wrap;
  column-gap: 2ch;
  row-gap: 1.2em;
}
.fetch-art {
  white-space: pre;
  flex-shrink: 0;
}
.fetch-info {
  white-space: pre;
}
.fetch-logo,
.fetch-info-row {
  white-space: pre;
}
.fetch-k {
  color: #7ee787;
  font-weight: 700;
}
.fetch-sep {
  color: var(--dim);
}
.fetch-v {
  color: var(--fg);
}
.fetch-title {
  color: #79c0ff;
  font-weight: 700;
}
.fetch-rule {
  color: var(--dim);
}
/* Apple rainbow colors */
.apl-g { color: #78c64a; }
.apl-y { color: #fcb72a; }
.apl-o { color: #f37b2d; }
.apl-r { color: #e8442c; }
.apl-p { color: #a252a1; }
.apl-b { color: #3894cf; }

/* Windows logo colors */
.win-r { color: #f25022; }
.win-g { color: #7fba00; }
.win-b { color: #00a4ef; }
.win-y { color: #ffb900; }

/* Linux Tux colors */
.lin-w { color: #f5f5f5; }
.lin-o { color: #f37b2d; }

/* Android Bugdroid color */
.droid { color: #a4c639; }

/* ls output: inline, space-separated */
.ls-list {
  display: block;
}

.ls-list .ls-entry {
  display: inline-block;
  margin-right: 24px;
  white-space: nowrap;
}

.ls-long .ls-long-meta {
  white-space: pre;
}

.nf {
  display: inline-block;
  width: 1.3em;
  text-align: center;
  margin-right: 0.35em;
  font-weight: 400;
}

/* Terminal-Icons-inspired file/folder colors */
.ic-folder { color: #ffd580; }
.ic-folder-git { color: #f0883e; }
.ic-folder-code { color: #79c0ff; }
.ic-folder-node { color: #7ee787; }
.ic-text { color: #c9d1d9; }
.ic-md { color: #58a6ff; }
.ic-js { color: #f1e05a; }
.ic-ts { color: #3178c6; }
.ic-jsx { color: #61dafb; }
.ic-json { color: #f1e05a; }
.ic-html { color: #e34c26; }
.ic-css { color: #563d7c; }
.ic-sass { color: #cf649a; }
.ic-py { color: #3572a5; }
.ic-go { color: #00add8; }
.ic-rust { color: #dea584; }
.ic-php { color: #a373ff; }
.ic-shell { color: #89e051; }
.ic-yaml { color: #cb171e; }
.ic-toml { color: #9c4221; }
.ic-xml { color: #0060ac; }
.ic-pdf { color: #d93025; }
.ic-archive { color: #d4a72c; }
.ic-image { color: #f9a8d4; }
.ic-audio { color: #ff7eb6; }
.ic-video { color: #ff7b72; }
.ic-env { color: #faf594; }
.ic-git { color: #f0883e; }
.ic-npm { color: #cb3837; }
.ic-docker { color: #2496ed; }
.ic-lock { color: #a0a0a0; }
.ic-license { color: #ffd580; }
.ic-file { color: #c9d1d9; }

/* Inline color tags inside file contents: <red>…</red>, <green>…</green>, etc. */
.ct-red    { color: #ff6b6b; }
.ct-green  { color: #7ee787; }
.ct-yellow { color: #ffd580; }
.ct-blue   { color: #79c0ff; }
.ct-grey   { color: #8a8a8a; }

/* Inline style tags inside file contents: <bold>…</bold>, etc. */
/* Victor Mono caps at 700 on Google Fonts; body sits at 600 (synthesized),
   so we add a hairline text-shadow to give <bold> visible extra weight. */
.ct-bold       { font-weight: 700; text-shadow: 0 0 0.6px currentColor; }
.ct-italic     { font-style: italic; }
.ct-underlined { text-decoration: underline; }

#input-line {
  display: flex;
  align-items: baseline;
  gap: 0;
  flex-shrink: 0;
}

#input-wrap {
  position: relative;
  flex: 1;
  display: block;
}

#input-highlight {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  white-space: pre;
  overflow: hidden;
  font: inherit;
  line-height: inherit;
}

#input {
  position: relative;
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  color: transparent;
  font-family: inherit;
  font-size: inherit;
  font-weight: inherit;
  line-height: inherit;
  caret-color: var(--fg);
  padding: 0;
}

/* Password mode: hide the highlight overlay entirely */
#input-line.password-mode #input-highlight {
  display: none;
}
#input-line.password-mode #input {
  color: transparent;
  caret-color: transparent;
}
#input-line.password-mode #input-wrap::before {
  content: '\f023'; /* Nerd Font lock glyph */
  font-family: 'Symbols Nerd Font', 'VictorMono Nerd Font', 'Victor Mono', ui-monospace, monospace;
  font-weight: 400;
  color: var(--fg);
  position: absolute;
  left: 0;
  top: 0;
  pointer-events: none;
}

/* Syntax token colors */
.tok-cmd { color: var(--tok-cmd); }
.tok-cmd-unknown { color: var(--tok-cmd-unknown); }
.tok-flag { color: var(--tok-flag); }
.tok-path { color: var(--tok-path); }
.tok-arg { color: var(--tok-arg); }
.tok-string { color: var(--tok-string); }
.tok-comment { color: var(--tok-comment); font-style: italic; }
.tok-number { color: var(--tok-number); }
.tok-keyword { color: var(--tok-keyword); }
.tok-heading { color: var(--tok-heading); font-weight: 700; }
.tok-punct { color: var(--dim); }

#input::selection {
  background: var(--fg);
  color: var(--bg);
}

/* ───────── vim-style editor overlay ───────── */
#editor {
  display: none;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}
#editor.active {
  display: flex;
}
#terminal.editor-active #output,
#terminal.editor-active #input-line {
  display: none;
}

#editor-textarea {
  flex: 1;
  min-height: 0;
  background: transparent;
  color: var(--fg);
  border: none;
  outline: none;
  resize: none;
  font-family: inherit;
  font-size: inherit;
  font-weight: inherit;
  line-height: 1.3;
  padding: 0;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
  overflow-x: hidden;
  overflow-y: auto;
  caret-color: var(--fg);
  scrollbar-width: thin;
  scrollbar-color: var(--dim) transparent;
}
#editor-textarea::-webkit-scrollbar { width: 6px; }
#editor-textarea::-webkit-scrollbar-thumb { background: var(--dim); }

#editor-status {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  background: #1a1a1a;
  color: var(--fg);
  padding: 2px 6px;
  flex-shrink: 0;
  white-space: pre;
}
#editor-status-left { color: var(--tok-path); }
#editor-status-right { color: var(--dim); }
#editor-status-right.error { color: var(--error); }

#editor-cmdline {
  display: none;
  align-items: baseline;
  gap: 0;
  flex-shrink: 0;
  padding-top: 2px;
}
#editor-cmdline.active { display: flex; }
#editor-cmd {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--fg);
  font-family: inherit;
  font-size: inherit;
  font-weight: inherit;
  line-height: inherit;
  caret-color: var(--fg);
  padding: 0;
}

@keyframes blink {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0; }
}

.cursor {
  display: inline-block;
  width: 0.55ch;
  height: 1.1em;
  background: var(--fg);
  vertical-align: middle;
  margin-left: 1px;
  animation: blink 1s step-end infinite;
}

.bible-loading span {
  display: inline-block;
  animation: blink 1.2s step-end infinite;
}
.bible-loading span:nth-child(2) { animation-delay: 0.4s; }
.bible-loading span:nth-child(3) { animation-delay: 0.8s; }

/* ───────── Game overlay (.app files via `run`) ─────────
   Full-window phosphor-CRT look. The overlay sits on top of the terminal
   and is opaque, so light/dark theme of the host terminal is irrelevant
   while a game is active. Per-game color schemes can override --game-fg. */
#game {
  display: none;
  flex-direction: column;
  position: fixed;
  inset: 0;
  z-index: 10;
  background: #050505;
  color: var(--game-fg, #ffb000);
  font-family: inherit;
  font-size: inherit;
  font-weight: inherit;
  padding: 16px 20px;
  overflow: hidden;
}
#game.active { display: flex; }
#terminal.game-active #output,
#terminal.game-active #input-line,
#terminal.game-active #editor { display: none; }

#game-screen {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
  scrollbar-width: thin;
  scrollbar-color: var(--game-fg, #ffb000) transparent;
  text-shadow: 0 0 1px currentColor;
}
#game-screen::-webkit-scrollbar { width: 6px; }
#game-screen::-webkit-scrollbar-thumb { background: var(--game-fg, #ffb000); opacity: 0.5; }

#game-screen .g-line { white-space: pre-wrap; min-height: 1.2em; }
#game-screen .g-dim    { opacity: 0.55; }
#game-screen .g-bright { color: #fff5cc; }
#game-screen .g-warn   { color: #ff8a40; }
#game-screen .g-ok     { color: #6efc8f; }
#game-screen .g-banner {
  color: #fff5cc;
  white-space: pre;
  display: block;
}

#game-input-line {
  display: none;
  align-items: baseline;
  gap: 0;
  flex-shrink: 0;
  padding-top: 6px;
}
#game-input-line.active { display: flex; }
#game-prompt {
  color: var(--game-fg, #ffb000);
  white-space: pre;
}
#game-input-wrap { flex: 1; position: relative; display: flex; }
#game-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--game-fg, #ffb000);
  font-family: inherit;
  font-size: inherit;
  font-weight: inherit;
  line-height: inherit;
  caret-color: var(--game-fg, #ffb000);
  padding: 0;
  text-shadow: 0 0 1px currentColor;
}
#game-input-line.password #game-input {
  color: transparent;
  caret-color: transparent;
  text-shadow: none;
}

#game .g-caret {
  display: inline-block;
  width: 0.55ch;
  height: 1.05em;
  background: var(--game-fg, #ffb000);
  vertical-align: text-bottom;
  margin-left: 1px;
  animation: blink 1s step-end infinite;
}

/* ───────── Mobile: Schrift skalieren & screenfetch stapeln ─────────
   Auf schmalen Viewports verkleinern wir die Schriftgröße proportional, damit
   der ASCII-Banner und die `ls`-Spalten meist hineinpassen. Reicht das nicht
   (sehr schmal), stapeln wir bei `screenfetch` Logo und Info-Block
   untereinander, statt horizontal zu scrollen. */
@media (max-width: 640px) {
  html, body { font-size: 14px; }
  #terminal { padding: 10px 12px; }
  .ls-list .ls-entry { margin-right: 16px; }
}

@media (max-width: 480px) {
  html, body { font-size: 12px; }
  #terminal { padding: 8px 10px; }
  .ls-list .ls-entry { margin-right: 12px; }
}

@media (max-width: 360px) {
  html, body { font-size: 11px; }
  #terminal { padding: 6px 8px; }
}

/* ───────── Light-Theme ─────────
   Aktiv, sobald am <html>-Element `data-theme="light"` gesetzt ist.
   Dark bleibt der Default (siehe :root). Welche der beiden Varianten
   gilt, entscheidet der Inline-Bootstrap in index.html (auto = Browser-
   Präferenz, persistente Wahl via `theme -l|-d|-a` aus dem Terminal). */
:root[data-theme="light"] {
  --bg: #ffffff;
  --fg: #1f2328;
  --dim: #656d76;
  --error: #cf222e;
  --warn: #9a6700;
  --ok: #1a7f37;

  --tok-cmd: #1a7f37;
  --tok-cmd-unknown: #cf222e;
  --tok-flag: #8250df;
  --tok-path: #0969da;
  --tok-arg: #953800;
  --tok-string: #0a3069;
  --tok-comment: #6e7781;
  --tok-number: #0550ae;
  --tok-keyword: #cf222e;
  --tok-heading: #9a6700;
}

:root[data-theme="light"] .line a:hover { color: #0969da; }

:root[data-theme="light"] .fetch-k     { color: #1a7f37; }
:root[data-theme="light"] .fetch-title { color: #0969da; }

/* Tux: weiße Bauchpartie würde sonst auf weißem Grund verschwinden. */
:root[data-theme="light"] .lin-w { color: #1f2328; }

/* Datei-/Ordner-Icons: nur die zu hellen Töne anpassen. */
:root[data-theme="light"] .ic-folder  { color: #bf8700; }
:root[data-theme="light"] .ic-text    { color: #57606a; }
:root[data-theme="light"] .ic-md      { color: #0969da; }
:root[data-theme="light"] .ic-js      { color: #9a6700; }
:root[data-theme="light"] .ic-json    { color: #9a6700; }
:root[data-theme="light"] .ic-shell   { color: #1a7f37; }
:root[data-theme="light"] .ic-env     { color: #9a6700; }
:root[data-theme="light"] .ic-license { color: #bf8700; }
:root[data-theme="light"] .ic-file    { color: #57606a; }

:root[data-theme="light"] .ct-red    { color: #cf222e; }
:root[data-theme="light"] .ct-green  { color: #1a7f37; }
:root[data-theme="light"] .ct-yellow { color: #9a6700; }
:root[data-theme="light"] .ct-blue   { color: #0969da; }
:root[data-theme="light"] .ct-grey   { color: #57606a; }

:root[data-theme="light"] #editor-status { background: #eaeef2; }
