/* =========================================================================
   Codaluna · design.css — Tokens, Basis, Buttons, Editor-Farben
   Gestaltung „Stationskonsole“ (Oktober 2026): flache Flächen, feine Linien,
   ein Signalton (Amber) für Handlung und Position, Teal nur für Lumo und
   „geschafft“. Keine Verläufe, kein Leuchten, keine Emojis in der Oberfläche
   (Icons: src/js/icons.js). Schrift: Atkinson Hyperlegible Next, gebaut für
   gute Lesbarkeit (I/l/1 und 0/O klar unterscheidbar), Code in JetBrains Mono.
   Offline: alle Schriften liegen in /vendor/fonts.
   ========================================================================= */

@font-face {
  font-family: "Atkinson Hyperlegible Next";
  src: url("/vendor/fonts/atkinson-next-latin.woff2") format("woff2");
  font-weight: 200 800; font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
    U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Atkinson Hyperlegible Next";
  src: url("/vendor/fonts/atkinson-next-latin-ext.woff2") format("woff2");
  font-weight: 200 800; font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF,
    U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("/vendor/fonts/jetbrains-mono-400.woff2") format("woff2");
  font-weight: 400; font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("/vendor/fonts/jetbrains-mono-700.woff2") format("woff2");
  font-weight: 700; font-display: swap;
}

:root {
  /* Flächen: warmes Graphit. Editor und Konsole sind der dunkelste Punkt. */
  --bg: #161513;
  --bg-tint: #1b1a17;
  --surface: #211f1c;
  --surface-2: #2a2824;
  --surface-3: #35322d;
  --border: #3a3732;
  --border-soft: #2b2925;
  --border-strong: #4d4942;
  --bg-deep: #100f0d;

  /* Text (alle Stufen ≥ 4,5:1 auf jeder Fläche) */
  --text: #eeebe4;
  --text-muted: #bdb8ad;
  --text-faint: #949086;

  /* Signal: Amber = Handlung und „hier bist du“ · Teal = Lumo und „geschafft“ */
  --accent: #f2a93b;
  --accent-strong: #e0951f;
  --accent-soft: #f6b955;
  --accent-weak: #f2a93b1a;
  --accent-line: #5a4220;
  --accent-ink: #f2b45a;
  --teal: #3ccfb0;
  --teal-soft: #4fd6b8;
  --teal-weak: #3ccfb017;
  --teal-line: #24473f;
  --teal-ink: #4fd6b8;
  --success: var(--teal);
  --success-weak: var(--teal-weak);
  --warning: #e9c46a;
  --warning-ink: #e9c46a;
  --warning-line: #4f4223;
  --danger: #f2826f;
  --danger-weak: #f2826f17;
  --danger-line: #57302a;
  --on-accent: #1a1306;

  /* Feste Werte für Bereiche, die in beiden Themes dunkel bleiben (Kopf, Werkzeugleiste, Konsole) */
  --chrome: #121110;
  --chrome-line: #2b2925;
  --chrome-text: #eeebe4;
  --chrome-muted: #bdb8ad;
  --chrome-faint: #949086;
  --chrome-hover: #ffffff0f;

  --r-sm: 4px;
  --r-md: 6px;
  --r-lg: 10px;
  --r-pill: 999px;
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
  --shadow-sm: 0 4px 14px rgba(0, 0, 0, 0.3);

  --font: "Atkinson Hyperlegible Next", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --display: var(--font);
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --header-h: 56px;
  --sidebar-w: 280px;
}

/* ---- Helles Theme (Dunkel bleibt Standard) ---- */
:root[data-theme="light"] {
  --bg: #f6f4ef;
  --bg-tint: #efece5;
  --surface: #ffffff;
  --surface-2: #f0ede6;
  --surface-3: #e4e0d7;
  --border: #d9d4c9;
  --border-soft: #e6e2d9;
  --border-strong: #c3bdb0;
  --bg-deep: #100f0d;
  --text: #1d1c1a;
  --text-muted: #55524b;
  --text-faint: #6e6a62;
  --accent-weak: #e0951f1a;
  --accent-line: #e3c48e;
  --accent-ink: #8f5200;
  --teal-weak: #0b6b5812;
  --teal-line: #a9d8cc;
  --teal-ink: #0b6b58;
  --warning-ink: #7d5a00;
  --warning-line: #e6d39c;
  --danger: #b3392a;
  --danger-weak: #b3392a12;
  --danger-line: #e8b8af;
  --shadow: 0 16px 40px rgba(40, 32, 20, 0.16);
  --shadow-sm: 0 4px 14px rgba(40, 32, 20, 0.1);
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-variant-numeric: tabular-nums;
}

h1, h2, h3 {
  font-family: var(--display);
  line-height: 1.2;
  font-weight: 750;
  letter-spacing: -0.01em;
  margin: 0 0 0.4em;
  text-wrap: balance;
}
p { text-wrap: pretty; }

a { color: var(--teal-ink); text-decoration: underline; text-decoration-color: color-mix(in srgb, currentColor 40%, transparent); text-underline-offset: 2px; }
a:hover { text-decoration-color: currentColor; }

code, kbd {
  font-family: var(--mono);
  font-size: 0.88em;
  line-height: 1.3;
  white-space: nowrap;
  background: var(--surface-2);
  color: var(--accent-ink);
  padding: 0.1em 0.32em;
  border-radius: var(--r-sm);
}
pre {
  background: var(--bg-deep);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-md);
  padding: 12px 14px;
  overflow-x: auto;
}
pre code { background: none; padding: 0; color: #e6e1d6; white-space: pre; }
:root[data-theme="light"] pre { border-color: var(--bg-deep); }

::selection { background: #f2a93b40; }

* { scrollbar-width: thin; scrollbar-color: var(--surface-3) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb {
  background: var(--surface-3);
  border-radius: 8px;
  border: 3px solid transparent;
  background-clip: content-box;
}
*::-webkit-scrollbar-thumb:hover { background: var(--border-strong); background-clip: content-box; }

/* ---- Sichtbarer Tastatur-Fokus (WCAG 2.4.7) ---- */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}
.CodeMirror-focused { box-shadow: inset 0 0 0 1px #f2a93b33; }

/* Icons (icons.js) folgen der Textfarbe und sitzen auf der Grundlinie */
.icon { flex: none; display: inline-block; vertical-align: -0.2em; }

/* ============================== Buttons ================================= */
.btn {
  font: inherit;
  font-weight: 650;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45em;
  min-height: 36px;
  padding: 0.45em 0.95em;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease, opacity 0.12s ease;
}
.btn:hover { background: var(--surface-3); border-color: var(--border-strong); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn:disabled:active { transform: none; }

.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-soft); border-color: var(--accent-soft); }

.btn-ghost { background: transparent; border-color: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--surface-2); border-color: transparent; color: var(--text); }

.btn-danger { color: var(--danger); border-color: transparent; background: transparent; }
.btn-danger:hover { background: var(--danger-weak); }

/* =========================================================================
   CodeMirror 5 · Editor-Farben (ruhig, gut unterscheidbar)
   ========================================================================= */
.CodeMirror {
  height: 100%;
  font-family: var(--mono);
  font-size: 14.5px;
  line-height: 1.65;
  background: var(--bg-deep);
  color: #e6e1d6;
}
.CodeMirror-gutters { background: var(--bg-deep); border-right: 1px solid #23211e; }
.CodeMirror-linenumber { color: #6d6960; }
.CodeMirror-cursor { border-left: 2px solid var(--accent); }
.CodeMirror-selected { background: #33302a !important; }
.CodeMirror-focused .CodeMirror-selected { background: #4a3f2c !important; }
.CodeMirror-activeline-background { background: #ffffff06; }

/* Präfix .cm-s-default nötig, damit diese Farben CodeMirrors Standardfarben überschreiben */
.cm-s-default .cm-keyword  { color: #c3a6f2; font-weight: 600; }
.cm-s-default .cm-def, .cm-s-default .cm-property { color: #7fd8c4; }
.cm-s-default .cm-variable { color: #e6e1d6; }
.cm-s-default .cm-variable-2 { color: #f0cf9a; }
.cm-s-default .cm-builtin  { color: #f2b45a; }
.cm-s-default .cm-number   { color: #f0cf7a; }
.cm-s-default .cm-string, .cm-s-default .cm-string-2 { color: #f2a08a; }
.cm-s-default .cm-comment  { color: #9a958a; font-style: italic; }
.cm-s-default .cm-operator { color: #cfcabf; }
.cm-s-default .cm-atom     { color: #c3a6f2; }
.cm-s-default .cm-meta     { color: #aaa597; }
.cm-s-default .cm-error    { color: var(--danger); }
.CodeMirror-matchingbracket {
  color: var(--teal-soft) !important;
  font-weight: 700;
  border-bottom: 1px solid var(--teal);
}

/* Zeile mit dem zuletzt gemeldeten Fehler (wird beim Tippen entfernt) */
.CodeMirror .cm-error-line { background: #f2826f17; box-shadow: inset 2px 0 0 #f2826f; }
.CodeMirror .cm-error-line .CodeMirror-linenumber { color: #f2826f; font-weight: 700; }
.CodeMirror .cm-error-spot { background: #f2826f40; border-bottom: 2px solid #f2826f; border-radius: 2px; }
