/* Der von-Neumann-Rechner.
   Schematik nach der ueblichen Lehrbuchdarstellung: die fuenf
   Funktionseinheiten von Neumanns, Zentraleinheit (Steuerwerk +
   Rechenwerk) oben, darunter das Bussystem als breites Band, darunter
   Speicherwerk sowie Eingabe- und Ausgabewerk.
   Farben wie die uebrigen Tools (vgl. Jg6/evaBlackbox.css). */

:root {
  --vnr-primaer: #4a6cf7;
  --vnr-primaer-dunkel: #3a5be0;
  --vnr-tinte: #2f3542;
  --vnr-grund: #eef2f7;
  --vnr-gruen: #2ecc71;
  --vnr-rot: #ff4a4a;
  --vnr-gold: #ffd24a;
  --vnr-linie: #c7d0e0;
}

body {
  margin: 0;
  font-family: Arial, sans-serif;
  background: var(--vnr-grund);
  color: var(--vnr-tinte);
}

.vnr-seite {
  max-width: 1680px;
  margin: 0 auto;
  padding: 14px 20px 24px 20px;
}

/* ---------- Steuerleiste: eine Zeile, damit das Schema oben steht ---------- */

.vnr-leiste {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 10px;
}

.vnr-titel {
  margin: 0;
  font-size: 1.15rem;
  white-space: nowrap;
}

.vnr-progwahl {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  flex: 1 1 auto;
}

.vnr-progbtn {
  padding: 6px 14px;
  border: 2px solid var(--vnr-linie);
  border-radius: 999px;
  background: #fff;
  color: var(--vnr-tinte);
  font-size: 0.85rem;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.vnr-progbtn:hover { border-color: var(--vnr-primaer); }

.vnr-aufgaben-dropdown { position: relative; }

.vnr-aufgaben-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px;
  background: #fff;
  border: 2px solid var(--vnr-linie);
  border-radius: 10px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
  min-width: 230px;
}

.vnr-aufgaben-menu[hidden] { display: none; }

.vnr-aufgaben-menu__eintrag {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 10px;
  border: none;
  border-radius: 6px;
  background: #f3f5f8;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--vnr-tinte);
  text-align: left;
}

.vnr-aufgaben-menu__eintrag:hover { background: #e8edff; }

.vnr-aufgaben-menu__schwierigkeit {
  font-size: 0.7rem;
  font-weight: bold;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

.vnr-aufgaben-menu__schwierigkeit--leicht { background: #e3f8ea; color: #1f8a4c; }
.vnr-aufgaben-menu__schwierigkeit--mittel { background: #fff4d9; color: #9a7200; }
.vnr-aufgaben-menu__schwierigkeit--schwer { background: #fde3e3; color: #b23333; }

.vnr-progbtn--aktiv {
  border-color: var(--vnr-primaer);
  background: var(--vnr-primaer);
  color: #fff;
  font-weight: bold;
}

.vnr-knoepfe { display: flex; gap: 8px; }

.vnr-btn {
  padding: 8px 16px;
  border: none;
  border-radius: 7px;
  background: var(--vnr-primaer);
  color: #fff;
  font-size: 0.9rem;
  font-weight: bold;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease;
}

.vnr-btn:hover:enabled { background: var(--vnr-primaer-dunkel); }
.vnr-btn:disabled { background: #c3c9d4; cursor: default; }
.vnr-btn--sek { background: #99a1b3; }
.vnr-btn--sek:hover:enabled { background: #808a9e; }

.vnr-taktzaehler {
  display: flex;
  align-items: center;
  padding: 0 12px;
  border: 2px solid var(--vnr-linie);
  border-radius: 7px;
  background: #fff;
  font-size: 0.85rem;
  font-weight: bold;
  color: var(--vnr-tinte);
  white-space: nowrap;
}

/* ---------- Phasen und Status: eine gemeinsame Zeile ---------- */

.vnr-zeile2 {
  display: flex;
  align-items: stretch;
  gap: 12px;
  margin-bottom: 14px;
}

/* Labels vor den Phasen-Kaestchen und vor der Statuszeile -- sonst
   ist "Phase" nirgends als Begriff benannt und bleibt unklar. */
.vnr-zeile2__label {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  font-size: 0.78rem;
  font-weight: bold;
  color: var(--vnr-tinte);
  white-space: nowrap;
}

.vnr-phasen { position: relative; display: flex; gap: 6px; flex-shrink: 0; padding-top: 10px; }

/* Kleines Dreieck, das unter das aktive Phasen-Kaestchen wandert --
   deutlicher als nur die Faerbung, vor allem beim Mitschreiben. */
.vnr-phasenzeiger {
  position: absolute;
  top: 0;
  width: 0;
  height: 0;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-top: 8px solid var(--vnr-primaer);
  opacity: 0;
  transition: left 0.3s cubic-bezier(.4,.1,.3,1.3), opacity 0.2s ease;
}

/* Die aktive Phase ist fett UND gerahmt, nicht nur farbig. */
.vnr-phase {
  display: flex;
  align-items: center;
  padding: 0 12px;
  border: 2px solid var(--vnr-linie);
  border-radius: 7px;
  background: #fff;
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  color: #99a1b3;
}

.vnr-phase--aktiv {
  border-color: var(--vnr-primaer);
  background: #e8edff;
  color: var(--vnr-primaer-dunkel);
  font-weight: bold;
}

.vnr-status {
  flex: 1 1 auto;
  /* Feste Hoehe: die Zeile darf beim Wechseln der Meldung nicht
     springen, sonst wandert das ganze Schema. */
  height: 52px;
  display: flex;
  align-items: center;
  margin: 0;
  padding: 8px 14px;
  background: #fff;
  border-left: 4px solid var(--vnr-primaer);
  border-radius: 7px;
  font-size: 0.9rem;
  line-height: 1.35;
  overflow: hidden;
}

.vnr-status--halt {
  border-left-color: var(--vnr-rot);
  background: #fff5f5;
}

/* ---------- Hauptbereich: links CPU/Bus/E-A, rechts Speicherwerk ---------- */

.vnr-haupt {
  display: grid;
  /* Breit genug, dass auch der laengste Befehl im Befehlsregister
     (z.B. "SPRINGE_WENN 0") in einer Zeile bleibt. */
  grid-template-columns: minmax(420px, 590px) 1fr;
  gap: 20px;
  align-items: start;
}

.vnr-haupt__links {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}

.vnr-ea {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

/* Zentraleinheit */

.vnr-cpu {
  position: relative;
  border: 3px solid var(--vnr-tinte);
  border-radius: 12px;
  padding: 16px 14px 12px 14px;
  background: #fff;
}

.vnr-cpu__label {
  position: absolute;
  top: -10px;
  left: 16px;
  padding: 0 8px;
  background: var(--vnr-grund);
  font-size: 0.75rem;
  font-weight: bold;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--vnr-tinte);
}

/* Anschluss der CPU an den Bus */
.vnr-cpu::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -14px;
  width: 8px;
  height: 14px;
  margin-left: -4px;
  background: #aab4c6;
}

.vnr-werke {
  display: grid;
  /* Steuerwerk etwas breiter als Rechenwerk -- das Befehlsregister
     zeigt ganze Befehle samt Adresse/IN und braucht mehr Platz. */
  grid-template-columns: 1.2fr 1fr;
  gap: 14px;
}

.vnr-werk {
  position: relative;
  border: 2px solid var(--vnr-linie);
  border-radius: 9px;
  padding: 10px 12px;
  background: #fbfcfe;
  transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.vnr-werk__titel {
  margin: 0 0 8px 0;
  font-size: 0.9rem;
  color: var(--vnr-tinte);
}

/* Aktives Werk: Rahmen, Hintergrund UND ein Puls -- damit sichtbar
   ist, WELCHE Einheit gerade arbeitet. */
.vnr-werk--aktiv {
  border-color: var(--vnr-primaer);
  background: #eef2ff;
  box-shadow: 0 0 0 3px rgba(74, 108, 247, 0.18);
}

.vnr-werk--rechnet {
  border-color: var(--vnr-gold);
  background: #fffaea;
  box-shadow: 0 0 0 3px rgba(255, 210, 74, 0.35);
  animation: vnrRechnen 0.42s ease-in-out;
}

@keyframes vnrRechnen {
  0%, 100% { transform: translateY(0); }
  30%      { transform: translateY(-3px); }
  65%      { transform: translateY(2px); }
}

.vnr-reg {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 4px 8px;
  margin-bottom: 4px;
  background: #eef1f6;
  border-radius: 5px;
}

.vnr-reg__name { font-size: 0.75rem; color: #667; }

.vnr-reg__wert {
  font-family: "Courier New", monospace;
  font-size: 1rem;
  color: var(--vnr-tinte);
}

/* Registerwert hat sich gerade geaendert */
.vnr-reg__wert--neu {
  animation: vnrRegPuls 0.45s ease-out;
  color: var(--vnr-primaer-dunkel);
}

@keyframes vnrRegPuls {
  0%   { transform: scale(1.5); color: var(--vnr-gold); }
  60%  { transform: scale(1); }
  100% { transform: scale(1); }
}

/* Das Rechenzeichen erscheint nur, waehrend wirklich gerechnet wird. */
.vnr-rechenzeichen {
  position: absolute;
  right: 12px;
  bottom: 8px;
  font-size: 1.6rem;
  font-weight: bold;
  color: var(--vnr-gold);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.vnr-werk--rechnet .vnr-rechenzeichen { opacity: 1; }

/* ---------- Bussystem: das breite Band, nicht ein duenner Strich ---------- */

.vnr-bus {
  position: relative;
  height: 54px;
  margin: 14px 0;
  border-radius: 8px;
  background: #dde3ee;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  transition: background 0.2s ease, box-shadow 0.2s ease;
}

/* Anschluss nach rechts zum Speicherwerk, das jetzt daneben statt
   darunter steht -- derselbe Anschluss-Strich wie bei CPU/Eingabe-
   /Ausgabewerk, nur seitlich statt oben/unten. */
.vnr-bus::after {
  content: "";
  position: absolute;
  right: -14px;
  top: 50%;
  width: 14px;
  height: 8px;
  margin-top: -4px;
  background: #aab4c6;
}

/* Drei Spuren -- Daten-, Adress- und Steuerbus, wie im Lehrbuch */
.vnr-bus__spuren {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 18px;
  margin-top: -9px;
  background: repeating-linear-gradient(
    to bottom,
    #aab4c6 0, #aab4c6 3px,
    transparent 3px, transparent 10px);
}

.vnr-bus__name,
.vnr-bus__legende {
  position: relative;
  z-index: 1;
  background: #dde3ee;
  padding: 0 8px;
  font-size: 0.72rem;
  font-weight: bold;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #6b7488;
  transition: background 0.2s ease, color 0.2s ease;
}

.vnr-bus__legende { text-transform: none; font-weight: normal; }

.vnr-bus--aktiv {
  background: #d3ddff;
  box-shadow: 0 0 0 3px rgba(74, 108, 247, 0.25);
}

.vnr-bus--aktiv .vnr-bus__name,
.vnr-bus--aktiv .vnr-bus__legende {
  background: #d3ddff;
  color: var(--vnr-primaer-dunkel);
}

.vnr-einheit {
  position: relative;
  border: 2px solid var(--vnr-linie);
  border-radius: 10px;
  padding: 12px 14px;
  background: #fff;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

/* Anschluss nach oben an den Bus -- nur fuer Eingabe-/Ausgabewerk,
   die direkt unter dem Bus stehen. Das Speicherwerk sitzt jetzt
   daneben statt darunter und bekommt keinen Anschluss-Strich. */
.vnr-ea .vnr-einheit::before {
  content: "";
  position: absolute;
  left: 50%;
  top: -14px;
  width: 8px;
  height: 14px;
  margin-left: -4px;
  background: #aab4c6;
}

.vnr-einheit--aktiv {
  border-color: var(--vnr-primaer);
  box-shadow: 0 0 0 3px rgba(74, 108, 247, 0.18);
}

.vnr-einheit--blass { opacity: 0.55; }

.vnr-einheit__titel {
  margin: 0 0 6px 0;
  font-size: 0.9rem;
}

.vnr-einheit__hinweis {
  margin: 0;
  font-size: 0.75rem;
  color: #8a92a3;
}

/* ---------- Speicherwerk ---------- */

.vnr-haupt__speicher {
  min-width: 0;
}

.vnr-speicher-bereich {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

/* Raster statt einer einzelnen Spalte -- auf einem breiten Bildschirm
   sollen auch 30+ Zellen ohne Scrollen nebeneinander Platz finden.
   Fuellrichtung Spalte fuer Spalte (von oben nach unten, dann nach
   rechts): 16 feste Zeilenplaetze, neue Spalten entstehen erst,
   wenn eine voll ist -- bei maximal 60 Zellen reichen so hoechstens
   4 Spalten. */
.vnr-speicher {
  position: relative;
  display: grid;
  grid-auto-flow: column;
  grid-template-rows: repeat(16, min-content);
  grid-auto-columns: minmax(230px, 1fr);
  gap: 4px;
  flex: 1 1 auto;
  min-width: 0;
  max-height: 82vh;
  overflow-y: auto;
  align-content: start;
}

.vnr-zelle {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 3px 6px 3px 15px;
  border: 2px solid transparent;
  border-radius: 5px;
  font-family: "Courier New", monospace;
  font-size: 0.78rem;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.vnr-zelle--befehl { background: #eef2ff; }
.vnr-zelle--daten  { background: #f3f5f8; }

.vnr-zelle__nr {
  min-width: 1.6em;
  text-align: right;
  color: #99a1b3;
  font-size: 0.75rem;
}

.vnr-zelle__inhalt { font-weight: bold; }

.vnr-zelle--aktiv {
  border-color: var(--vnr-gruen);
  background: #eafaf0;
}

/* ---------- Editor-/Sandbox-Modus ---------- */

.vnr-editorleiste__feld {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  font-weight: bold;
  color: var(--vnr-tinte);
}

.vnr-editorleiste__feld input {
  width: 4.5em;
  padding: 4px 6px;
  border: 2px solid var(--vnr-linie);
  border-radius: 5px;
  font-family: "Courier New", monospace;
}

.vnr-eingabe {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  margin-top: 6px;
}

.vnr-eingabe input {
  width: 6em;
  padding: 4px 6px;
  border: 2px solid var(--vnr-linie);
  border-radius: 5px;
  font-family: "Courier New", monospace;
}

/* [hidden] hat dieselbe Spezifitaet wie eine einzelne Klasse -- ohne
   diese Regel gewinnt die spaetere .vnr-knoepfe/.vnr-palette-Regel
   (beide setzen display) und macht "hidden" wirkungslos. */
.vnr-knoepfe[hidden],
.vnr-editorleiste__feld[hidden],
.vnr-eingabe[hidden],
.vnr-palette[hidden] {
  display: none;
}

.vnr-zelle--editierbar {
  border-color: var(--vnr-linie);
  border-style: dashed;
}

.vnr-zelle--drop-hover {
  border-color: var(--vnr-primaer);
  background: #e8edff;
}

.vnr-zelle__entfernen {
  border: none;
  background: transparent;
  color: var(--vnr-rot);
  font-weight: bold;
  cursor: pointer;
  font-size: 0.8rem;
  line-height: 1;
  padding: 2px 4px;
}

.vnr-zelle__adressfeld,
.vnr-zelle__wertfeld {
  width: 3.6em;
  padding: 1px 3px;
  border: 1px solid var(--vnr-linie);
  border-radius: 4px;
  font-family: "Courier New", monospace;
  font-size: 0.78rem;
}

.vnr-zelle__inschalter {
  display: flex;
  align-items: center;
  gap: 2px;
  font-size: 0.68rem;
  color: var(--vnr-tinte);
  cursor: pointer;
}

/* Schmale Spalte links im Speicherwerk-Panel -- die Zellen daneben
   bekommen dadurch den Grossteil der (auf einem Breitbildschirm
   reichlich vorhandenen) Breite. */
.vnr-palette {
  flex: 0 0 108px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 8px;
  border: 2px solid var(--vnr-linie);
  border-radius: 8px;
  background: #fbfcfe;
  align-self: stretch;
}

.vnr-palette__hinweis {
  margin: 0 0 2px 0;
  font-size: 0.68rem;
  color: #8a92a3;
}

.vnr-palette__block {
  padding: 6px 4px;
  border: 2px solid var(--vnr-primaer);
  border-radius: 7px;
  background: #eef2ff;
  color: var(--vnr-primaer-dunkel);
  font-family: "Courier New", monospace;
  font-size: 0.72rem;
  font-weight: bold;
  text-align: center;
  cursor: grab;
}

.vnr-palette__block:active { cursor: grabbing; }

/* Der Befehlszaehler als gleitender Zeiger neben der Zellenliste.
   Er wandert sichtbar mit -- das ist der Punkt, an dem sonst nur
   eine Zahl im Register hochzaehlt. */
.vnr-zeiger {
  position: absolute;
  left: 0;
  width: 0;
  height: 0;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-left: 9px solid var(--vnr-primaer);
  transition: top 0.3s cubic-bezier(.4,.1,.3,1.3), left 0.3s cubic-bezier(.4,.1,.3,1.3);
  pointer-events: none;
  z-index: 1;
}

/* ---------- Ausgabewerk ---------- */

.vnr-ausgabe {
  padding: 8px;
  background: #f3f5f8;
  border-radius: 6px;
  font-family: "Courier New", monospace;
  font-size: 1.15rem;
  font-weight: bold;
  text-align: center;
  overflow-wrap: anywhere;
}

/* ---------- Paket auf dem Bus ---------- */

.vnr-paket {
  position: fixed;
  z-index: 60;
  padding: 3px 9px;
  border-radius: 5px;
  background: var(--vnr-primaer);
  color: #fff;
  font-family: "Courier New", monospace;
  font-size: 0.85rem;
  font-weight: bold;
  white-space: nowrap;
  transform: translate(-50%, -50%);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  pointer-events: none;
  transition-property: left, top;
  transition-timing-function: ease-in-out;
}

/* Befehle blau, Daten gruen -- damit im Blick bleibt, dass ueber
   denselben Bus beides laeuft. */
.vnr-paket--daten { background: var(--vnr-gruen); }

/* ---------- Aufgaben-Ergebnis (Popup) ---------- */

.vnr-modal-hintergrund {
  position: fixed;
  inset: 0;
  background: rgba(47, 53, 66, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
}

.vnr-modal {
  background: #fff;
  border-radius: 12px;
  padding: 20px 24px;
  max-width: 560px;
  width: 100%;
  max-height: 80vh;
  overflow: auto;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.3);
}

.vnr-modal__titel { margin: 0 0 14px 0; font-size: 1.2rem; }

.vnr-modal__tabelle {
  width: 100%;
  border-collapse: collapse;
  font-family: "Courier New", monospace;
  font-size: 0.8rem;
  margin-bottom: 18px;
}

.vnr-modal__tabelle th,
.vnr-modal__tabelle td {
  padding: 5px 8px;
  border-bottom: 1px solid var(--vnr-linie);
  text-align: left;
}

.vnr-modal__zeile--ok td:last-child { color: var(--vnr-gruen); font-weight: bold; }
.vnr-modal__zeile--fehler td:last-child { color: var(--vnr-rot); font-weight: bold; }

/* ---------- Schmale Bildschirme ---------- */

@media (max-width: 900px) {
  .vnr-werke { grid-template-columns: 1fr; }
  .vnr-haupt { grid-template-columns: 1fr; }
  .vnr-ea { grid-template-columns: 1fr; }
  .vnr-zeile2 { flex-direction: column; }
  .vnr-status { height: auto; min-height: 44px; }
  .vnr-speicher-bereich { flex-direction: column; }
  .vnr-palette { flex: 1 1 auto; flex-direction: row; flex-wrap: wrap; align-self: stretch; }
  .vnr-speicher { max-height: none; }
}

@media (prefers-reduced-motion: reduce) {
  .vnr-werk--rechnet,
  .vnr-reg__wert--neu { animation: none; }
  .vnr-zeiger,
  .vnr-phasenzeiger { transition: none; }
}
