/* mrei.it — Phosphor-Terminal-Look */
:root {
  --bg: #040a06;
  --panel: #071309;
  --fg: #3ef06e;
  --fg-bright: #b9ffcf;
  --fg-dim: rgba(62, 240, 110, 0.52);
  --fg-faint: rgba(62, 240, 110, 0.28);
  --err: #ff7b72;
  --ok: #3ef06e;
  --sel-bg: #3ef06e;
  --sel-fg: #031207;
  color-scheme: dark;
}

html.light {
  --bg: #f3f6f1;
  --panel: #ffffff;
  --fg: #14532a;
  --fg-bright: #06240f;
  --fg-dim: rgba(20, 83, 42, 0.6);
  --fg-faint: rgba(20, 83, 42, 0.22);
  --err: #b3261e;
  --ok: #14532a;
  --sel-bg: #14532a;
  --sel-fg: #f2fdf4;
  color-scheme: light;
}
html.light body { text-shadow: none; }
html.light .crt { opacity: 0.4; }
html.light body::before {
  background: radial-gradient(120% 90% at 50% -10%, rgba(20, 83, 42, 0.05), transparent 55%);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
}

body {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-family: "JetBrains Mono", "Cascadia Code", "Fira Code", ui-monospace, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 15px;
  line-height: 1.5;
  color: var(--fg);
  text-shadow: 0 0 6px rgba(62, 240, 110, 0.25);
}

/* Ambienter Schein + CRT-Scanlines */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(120% 90% at 50% -10%, rgba(62, 240, 110, 0.08), transparent 55%);
  z-index: 0;
}

.crt {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 10;
  background: repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.16) 0 1px, transparent 1px 3px);
  mix-blend-mode: multiply;
}

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

/* ---------- Terminal ---------- */
.terminal {
  position: relative;
  z-index: 1;
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 28px 20px 96px;
  scrollbar-width: thin;
  scrollbar-color: var(--fg-faint) transparent;
}
.terminal::-webkit-scrollbar { width: 8px; }
.terminal::-webkit-scrollbar-thumb { background: var(--fg-faint); border-radius: 4px; }
.terminal::-webkit-scrollbar-track { background: transparent; }

#screen {
  max-width: 1040px;
  margin: 0;
}

.line {
  white-space: pre-wrap;
  overflow-wrap: break-word;
  min-height: 1.2em;
}
.neo-row {
  line-height: 1.2;
}


.block {
  font-family: inherit;
  font-size: inherit;
  line-height: 1.35;
  white-space: pre;
  overflow-x: auto;
  margin: 0;
}

/* ---------- Banner ---------- */
.banner {
  color: var(--fg-bright);
  text-shadow: 0 0 14px rgba(62, 240, 110, 0.55), 0 0 2px rgba(185, 255, 207, 0.8);
  font-size: clamp(9px, 5.4vw, 30px);
  animation: flicker-in 4s steps(1, end) both, flicker-loop 30s linear 4s infinite;
  line-height: 1.12;
  letter-spacing: 0.02em;
  margin-bottom: 4px;
}

/* ---------- Zustandsklassen ---------- */
.info    { color: var(--fg-bright); font-weight: 600; }
.bright  { color: var(--fg-bright); text-shadow: 0 0 8px rgba(62, 240, 110, 0.4); }
.dim     { color: var(--fg-dim); text-shadow: none; }
.err     { color: var(--err); text-shadow: none; }
.ok-line { color: var(--ok); }
.hint    { color: var(--fg-bright); font-weight: 600; }
.hidden  { display: none !important; }

/* ---------- Prompt & Cursor ---------- */
.prompt-line {
  position: relative;
  display: block;
  margin-top: 12px; /* Abstand zur letzten Ausgabe — gewünscht: spürbarer Luftraum über guest@cli:~$ */
}

.prompt {
  color: var(--fg-bright);
  font-weight: 600;
}

#cli {
  position: absolute;
  inset: 0;
  width: 100%;
  border: 0;
  padding: 0;
  margin: 0;
  background: transparent;
  color: transparent;
  caret-color: transparent;
  font: inherit;
  text-shadow: none;
  outline: none;
}

.caret {
  display: inline-block;
  width: 1ch;
  height: 1.15em;
  vertical-align: text-bottom;
  margin-left: 3px;
  background: var(--fg);
  animation: blink 1.1s steps(1, end) infinite;
  box-shadow: 0 0 8px rgba(62, 240, 110, 0.5);
}

@keyframes blink {
  0%, 55%   { opacity: 1; }
  56%, 100% { opacity: 0; }
}



/* ---------- Links & klickbare Befehle ---------- */
.cmd-link, .ext-link {
  color: var(--fg-bright);
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 3px;
  cursor: pointer;
  text-shadow: none;
}
.cmd-link:hover, .ext-link:hover {
  background: var(--sel-bg);
  color: var(--sel-fg);
  text-decoration: none;
}
.ext-link { text-decoration-style: solid; }

/* ---------- Menü ---------- */
.menu {
  display: inline-block;
  margin: 2px 0 6px;
  padding: 6px 4px;
  border: 1px solid var(--fg-faint);
  border-radius: 4px;
  background: var(--panel);
}
/* Aktives Menü bleibt beim Scrollen oben angeheftet (Class-Wanderung in msh.js). */
.menu.sticky {
  position: sticky;
  top: 6px;
  z-index: 5;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
}
.light .menu.sticky { box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12); }
.menu-row {
  padding: 2px 10px;
  white-space: pre;
  cursor: pointer;
}
.menu-row.selected {
  background: var(--sel-bg);
  color: var(--sel-fg);
  text-shadow: none;
}
.menu-row.dim { opacity: 0.45; }
.menu-row.checked { color: var(--fg-bright); opacity: 1; }
.menu-row.checked::before { content: '✓ '; }
.menu-row .menu-info {
  padding-left: 46px;
  white-space: pre-wrap;
  color: var(--fg-dim);
  font-size: 0.82em;
  line-height: 1.35;
}

/* Icon-Spalte der Menüzeilen */
.menu-icon {
  display: inline-block;
  width: 1ch;
  margin-right: 2px;
}
.menu-row.selected .menu-info { color: inherit; opacity: 0.75; }

/* ---------- Quick-Bar ---------- */
.bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  background: linear-gradient(transparent, var(--bg) 35%);
  justify-content: center;
}
.bar button {
  font: inherit;
  font-size: 13px;
  color: var(--fg);
  background: var(--panel);
  border: 1px solid var(--fg-faint);
  border-radius: 3px;
  padding: 5px 12px;
  cursor: pointer;
  text-shadow: none;
}
.bar button:hover {
  background: var(--sel-bg);
  color: var(--sel-fg);
  border-color: var(--sel-bg);
}
.bar #theme-btn { margin-left: auto; }
.bar .bar-legal { display: flex; gap: 6px; align-items: center; }
.bar .small { font-size: 11px; padding: 3px 8px; opacity: 0.9; }
.bar .mobile-only { display: none; }
#quit-btn { display: none; } /* nur mobil und nur bei offenem Menü sichtbar */
.legal-pop {
  position: fixed;
  right: 12px;
  bottom: calc(64px + env(safe-area-inset-bottom));
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px;
  background: var(--panel);
  border: 1px solid var(--fg-faint);
  border-radius: 6px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
}
.legal-pop button {
  font: inherit;
  color: var(--fg);
  background: transparent;
  border: 1px solid var(--fg-faint);
  border-radius: 3px;
  padding: 6px 12px;
  text-align: left;
  cursor: pointer;
  text-shadow: none;
}
.legal-pop button:hover { background: var(--sel-bg); color: var(--sel-fg); }
.legal-pop .legal-close { text-align: center; }

/* ---------- Mobile ---------- */
@media (max-width: 640px) {
  body { font-size: 14px; }
  .terminal { padding: 16px 12px 110px; }
  .bar { justify-content: flex-start; }
  .bar button { font-size: 12px; padding: 4px 8px; }
  .bar .bar-legal { display: none; }
  .bar .mobile-only { display: block; margin-left: auto; }
  .bar #theme-btn { margin-left: 0; }
  /* Menüs schmiegen sich an den Screen, Labels umbrechen; Höhenlimit mit Innen-Scroll,
     damit das sticky Menü den Screen nie überwächst (untere Zeilen bleiben erreichbar). */
  .menu {
    display: block;
    max-width: 100%;
    max-height: calc(100vh - 110px);
    max-height: calc(100svh - 110px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    font-size: 0.92em;
  }
  .menu-row { white-space: pre-wrap; }
  /* Kompakt: Info-Zeilen ausblenden — Details gibt's beim Antappen (get cv <key> etc.) */
  .menu-row .menu-info { display: none; }
  body.menu-open #quit-btn { display: inline-block; }
}

@media (min-width: 1400px) {
  body { font-size: 16px; }
}

/* CRT-Flackern des Banners (Röhrenfernseher mit schlechtem Signal).
   Achtung: respektiert prefers-reduced-motion. */
@keyframes flicker-in {
  0%   { opacity: 0; }
  10%  { opacity: 1; }
  18%  { opacity: 0.15; }
  26%  { opacity: 0.9; }
  34%  { opacity: 0.35; }
  45%  { opacity: 1; }
  58%  { opacity: 0.7; }
  66%  { opacity: 1; }
  82%  { opacity: 0.88; }
  100% { opacity: 1; }
}
@keyframes flicker-loop {
  0%, 90%, 100% { opacity: 1; }
  91.5% { opacity: 0.2; }
  93% { opacity: 0.9; }
  95% { opacity: 0.4; }
  97% { opacity: 1; }
}
/* ---------- Intro-Overlay (Erstbesuch, zentriert, hebt sich vom Terminal ab) ---------- */
#intro {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 24px;
}
#intro[hidden] { display: none; }
.intro-box {
  width: 100%;
  max-width: min(94vw, 560px);
  text-align: left;
}
.intro-logo { margin: 0 0 18px; white-space: pre; }
.intro-line { color: var(--fg-dim); text-shadow: none; margin: 0 0 16px; line-height: 1.5; }
.intro-cmd { margin: 0; }
.intro-cmd input {
  position: absolute;
  inset: 0;
  width: 100%;
  border: 0;
  padding: 0;
  margin: 0;
  background: transparent;
  color: transparent;
  caret-color: transparent;
  font: inherit;
  text-shadow: none;
  outline: none;
}
.intro-hint { color: var(--fg-dim); text-shadow: none; margin: 10px 0 0; }
@media (prefers-reduced-motion: reduce) {
  .banner { animation: none; }
}

/* Intro wie die CLI überziehen Scanlines + Umgebungs-Schein liegen (CRT-Konsistenz). */
#intro::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(120% 90% at 50% -10%, rgba(62, 240, 110, 0.08), transparent 55%);
}
#intro::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.16) 0 1px, transparent 1px 3px);
  mix-blend-mode: multiply;
}
