/* =========================================================================
   KI-Entdecker – Designsystem
   ========================================================================= */

:root {
  --color-bg: #f5f7fb;
  --color-surface: #ffffff;
  --color-surface-alt: #eef1f8;
  --color-text: #1b2430;
  --color-text-muted: #5b6b7c;
  --color-border: #dfe4ee;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 22px;

  --shadow-card: 0 4px 18px rgba(25, 35, 60, 0.08);
  --shadow-card-hover: 0 10px 28px rgba(25, 35, 60, 0.14);

  --focus-ring: 3px solid #0ea5e9;

  /* Lernwelt-Akzentfarben */
  --world-algo: #2563eb;
  --world-algo-bg: #e8f0ff;
  --world-ml: #16a34a;
  --world-ml-bg: #e7f7ec;
  --world-nn: #7c3aed;
  --world-nn-bg: #f1e9fe;
  --world-llm: #ea580c;
  --world-llm-bg: #fef0e6;

  --font-base: "Segoe UI", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-base);
  font-size: 18px;
  line-height: 1.5;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 0.5em 0; }
h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.2rem; }
p { margin: 0 0 1em 0; }

a { color: inherit; }

button {
  font: inherit;
  cursor: pointer;
}

/* -------------------------------------------------------------------------
   Barrierefreiheit
   ------------------------------------------------------------------------- */

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: #000;
  color: #fff;
  padding: 0.75em 1.25em;
  z-index: 1000;
  border-radius: 0 0 var(--radius-sm) 0;
}
.skip-link:focus {
  left: 0;
}

:focus-visible {
  outline: var(--focus-ring);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* -------------------------------------------------------------------------
   Header / Navigation
   ------------------------------------------------------------------------- */

.site-header {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0.75em 1.25em;
  display: flex;
  align-items: center;
  gap: 1.5em;
  flex-wrap: wrap;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.4em;
  font-weight: 700;
  font-size: 1.2rem;
  text-decoration: none;
  flex-shrink: 0;
}
.logo-icon { font-size: 1.4em; }

.main-nav {
  display: flex;
  gap: 0.25em;
  flex-wrap: wrap;
  flex: 1;
}

.main-nav a {
  text-decoration: none;
  padding: 0.5em 0.9em;
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
  font-weight: 600;
}
.main-nav a:hover { background: var(--color-surface-alt); color: var(--color-text); }
.main-nav a.active {
  background: var(--color-surface-alt);
  color: var(--color-text);
}

.header-xp { flex-shrink: 0; }
.xp-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
  background: #fff7e6;
  border: 1px solid #f2d79b;
  padding: 0.4em 0.8em;
  border-radius: 999px;
  font-weight: 700;
  color: #8a6400;
}

/* -------------------------------------------------------------------------
   Layout
   ------------------------------------------------------------------------- */

#app-main {
  flex: 1;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 1.5em 1.25em 3em 1.25em;
}

.site-footer {
  text-align: center;
  padding: 1.5em;
  color: var(--color-text-muted);
  font-size: 0.85rem;
  border-top: 1px solid var(--color-border);
}

/* -------------------------------------------------------------------------
   Karten / Komponenten
   ------------------------------------------------------------------------- */

.card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 1.5em;
}

.hero {
  text-align: center;
  padding: 2em 1em 2.5em 1em;
}
.hero p.lead {
  max-width: 640px;
  margin: 0 auto;
  color: var(--color-text-muted);
  font-size: 1.1rem;
}

.world-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.25em;
  margin-top: 2em;
}

.world-card {
  display: flex;
  flex-direction: column;
  gap: 0.75em;
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 1.5em;
  text-decoration: none;
  color: var(--color-text);
  border-top: 6px solid var(--accent, var(--world-algo));
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.world-card:hover, .world-card:focus-visible {
  transform: translateY(-4px);
  box-shadow: var(--shadow-card-hover);
}
.world-card .world-icon {
  width: 64px;
  height: 64px;
}
.world-card .world-time {
  font-size: 0.85rem;
  color: var(--color-text-muted);
}
.world-card .progress-bar-track {
  margin-top: 0.25em;
}
.world-card .btn { align-self: flex-start; margin-top: 0.5em; }

.world-card[data-world="algorithmen"] { --accent: var(--world-algo); }
.world-card[data-world="ml"] { --accent: var(--world-ml); }
.world-card[data-world="neuronale-netze"] { --accent: var(--world-nn); }
.world-card[data-world="llm"] { --accent: var(--world-llm); }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  background: var(--accent, var(--world-algo));
  color: #fff;
  border: none;
  padding: 0.6em 1.2em;
  border-radius: 999px;
  font-weight: 700;
  text-decoration: none;
}
.btn:hover { filter: brightness(1.08); }
.btn.secondary {
  background: var(--color-surface-alt);
  color: var(--color-text);
}
.btn.ghost {
  background: transparent;
  color: var(--accent, var(--world-algo));
  border: 2px solid var(--accent, var(--world-algo));
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.progress-bar-track {
  width: 100%;
  height: 10px;
  background: var(--color-surface-alt);
  border-radius: 999px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  background: var(--accent, var(--world-algo));
  border-radius: 999px;
  transition: width 0.3s ease;
}

/* -------------------------------------------------------------------------
   Lernwelt-Seite
   ------------------------------------------------------------------------- */

.world-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1em;
  padding: 1em 1.25em;
  border-radius: var(--radius-lg);
  background: var(--accent-bg, var(--world-algo-bg));
  margin-bottom: 1.5em;
}
.world-header h1 { color: var(--accent, var(--world-algo)); margin: 0; }
.world-header .lead-question { color: var(--color-text-muted); margin: 0.25em 0 0 0; }

.phase-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5em;
  margin-bottom: 1.5em;
}
.phase-nav button {
  border: 2px solid var(--color-border);
  background: var(--color-surface);
  padding: 0.4em 0.9em;
  border-radius: 999px;
  font-weight: 600;
  color: var(--color-text-muted);
}
.phase-nav button.active {
  border-color: var(--accent, var(--world-algo));
  color: var(--accent, var(--world-algo));
  background: var(--accent-bg, var(--world-algo-bg));
}
.phase-nav button.done::after { content: " ✓"; }

.phase-section {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 1.75em;
  margin-bottom: 1.5em;
}
.phase-section h2 {
  color: var(--accent, var(--world-algo));
  display: flex;
  align-items: center;
  gap: 0.5em;
}
.phase-label {
  display: inline-block;
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin-bottom: 0.25em;
}

.phase-footer {
  display: flex;
  justify-content: space-between;
  margin-top: 1.5em;
  gap: 1em;
  flex-wrap: wrap;
}

/* -------------------------------------------------------------------------
   Allgemeine Interaktions-Elemente
   ------------------------------------------------------------------------- */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5em;
  margin-bottom: 1em;
}
.toolbar button {
  border: 2px solid var(--color-border);
  background: var(--color-surface-alt);
  border-radius: var(--radius-sm);
  padding: 0.5em 0.9em;
  font-weight: 600;
}
.toolbar button:hover { border-color: var(--accent, var(--world-algo)); }

.command-list {
  list-style: none;
  margin: 0;
  padding: 0.5em;
  min-height: 48px;
  background: var(--color-surface-alt);
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  gap: 0.35em;
}
.command-list .command-item {
  display: flex;
  align-items: center;
  gap: 0.5em;
  background: #fff;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 0.4em 0.6em;
}
.command-item.current {
  border-color: var(--accent, var(--world-algo));
  background: var(--accent-bg, var(--world-algo-bg));
}
.command-item .remove-btn {
  margin-left: auto;
  background: none;
  border: none;
  color: #b91c1c;
  font-weight: 700;
}
.command-item.block-node { flex-direction: column; align-items: stretch; }
.command-item.block-node .block-head { display: flex; align-items: center; gap: 0.5em; }
.command-item.block-node .command-list { margin-top: 0.4em; margin-left: 1.2em; }

.feedback-box {
  border-radius: var(--radius-sm);
  padding: 0.75em 1em;
  margin-top: 0.75em;
  font-weight: 600;
}
.feedback-box.success { background: #e7f7ec; color: #116530; border: 1px solid #9adbb3; }
.feedback-box.error { background: #fdeaea; color: #8a1c1c; border: 1px solid #f0b3b3; }
.feedback-box.hint { background: #fff7e0; color: #7a5b00; border: 1px solid #f2d98a; }
.feedback-box.info { background: #e8f0ff; color: #163e8a; border: 1px solid #b7cdf5; }

table.data-table {
  border-collapse: collapse;
  width: 100%;
  margin: 1em 0;
}
table.data-table th, table.data-table td {
  border: 1px solid var(--color-border);
  padding: 0.5em 0.7em;
  text-align: left;
}
table.data-table th { background: var(--color-surface-alt); }

.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 0.5em;
  margin: 1em 0;
}
.quiz-options button {
  text-align: left;
  border: 2px solid var(--color-border);
  background: var(--color-surface);
  border-radius: var(--radius-sm);
  padding: 0.7em 1em;
}
.quiz-options button.correct { border-color: #16a34a; background: #e7f7ec; }
.quiz-options button.incorrect { border-color: #dc2626; background: #fdeaea; }

.slider-row {
  display: flex;
  align-items: center;
  gap: 0.75em;
  margin: 0.5em 0;
}
.slider-row label { min-width: 220px; font-weight: 600; }
.slider-row input[type="range"] { flex: 1; }
.slider-row output { min-width: 3em; text-align: right; font-variant-numeric: tabular-nums; }

.grid-wrap { display: flex; flex-wrap: wrap; gap: 2em; align-items: flex-start; }

.badge-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1em;
  margin-top: 1em;
}
.badge-tile {
  text-align: center;
  padding: 1em;
  border-radius: var(--radius-md);
  background: var(--color-surface-alt);
  opacity: 0.4;
}
.badge-tile.earned { opacity: 1; background: #fff7e0; border: 2px solid #f2d98a; }
.badge-tile .badge-icon { font-size: 2.5rem; }

.toast-region {
  position: fixed;
  bottom: 1.25em;
  right: 1.25em;
  display: flex;
  flex-direction: column;
  gap: 0.5em;
  z-index: 1000;
}
.toast {
  background: #1b2430;
  color: #fff;
  padding: 0.75em 1.25em;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-card);
  animation: toast-in 0.2s ease;
}
@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.glossar-list { display: flex; flex-direction: column; gap: 0.75em; }
.glossar-entry {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  padding: 1em 1.25em;
}
.glossar-entry h3 { margin-bottom: 0.25em; }

.help-text { color: var(--color-text-muted); font-size: 0.95rem; }

@media (max-width: 640px) {
  html, body { font-size: 16px; }
  .header-inner { flex-direction: column; align-items: stretch; }
  .main-nav { justify-content: center; }
  .slider-row { flex-wrap: wrap; }
  .slider-row label { min-width: 100%; }
}
