/* ============================================================
   Agenten-Schule — Design-System «Digitale Lehrwerkstatt»
   Light-first, Dark Mode, Motion ruhig + reduced-motion-fest.
   ============================================================ */

:root {
  /* Farbe */
  --paper: #FAFAF7;
  --surface: #FFFFFF;
  --surface-2: #F3F2EC;
  --ink: #191C20;
  --ink-soft: #5A6270;
  --line: #E6E4DC;
  --brand: #2B59D9;
  --brand-deep: #1E3FA0;
  --brand-soft: #EAF0FF;
  --ok: #1F9D6B;
  --ok-soft: #E6F6EF;
  --err: #D84A38;
  --err-soft: #FCEDEA;
  --xp: #E29A00;
  --xp-soft: #FFF4D6;
  --shadow: 0 1px 2px rgba(20, 24, 34, 0.06), 0 8px 24px rgba(20, 24, 34, 0.07);

  /* Typografie */
  --font-body: "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-mono: "Cascadia Code", Consolas, "Courier New", monospace;
  --text-base: clamp(1rem, 0.95rem + 0.2vw, 1.0625rem);

  /* Rhythmus */
  --radius: 16px;
  --radius-sm: 10px;
  --space: clamp(1rem, 0.8rem + 0.8vw, 1.5rem);
  --dur: 260ms;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

[data-theme="dark"] {
  --paper: #14161A;
  --surface: #1C1F25;
  --surface-2: #23262d;
  --ink: #ECEEF2;
  --ink-soft: #9AA3B0;
  --line: #2C3038;
  --brand: #86A3F5;
  --brand-deep: #A8BDF8;
  --brand-soft: #22304F;
  --ok: #4BC393;
  --ok-soft: #17352A;
  --err: #F0806F;
  --err-soft: #3D2320;
  --xp: #F2B234;
  --xp-soft: #3A2F14;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 10px 30px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.6;
  color: var(--ink);
  background: var(--paper);
  min-height: 100vh;
}
img, svg { max-width: 100%; display: block; }
button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; }
a { color: var(--brand); }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; border-radius: 4px; }

/* ---------- App-Gerüst: Seitenleiste + Inhalt ---------- */
.app {
  display: grid;
  grid-template-columns: 232px 1fr;
  min-height: 100vh;
}
.rail {
  border-right: 1px solid var(--line);
  padding: 1.25rem 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  position: sticky;
  top: 0;
  height: 100vh;
  background: var(--surface);
}
.rail-logo {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.4rem 0.6rem 1.1rem;
}
.rail-logo img { width: 36px; height: 36px; border-radius: 9px; }
.rail-logo strong { font-size: 1.02rem; letter-spacing: -0.01em; }
.rail-logo span { display: block; font-family: var(--font-mono); font-size: 0.66rem; color: var(--ink-soft); }
.nav-btn {
  display: flex; align-items: center; gap: 0.7rem;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-sm);
  color: var(--ink-soft);
  font-weight: 600;
  text-align: left;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.nav-btn:hover { background: var(--surface-2); color: var(--ink); }
.nav-btn.active { background: var(--brand-soft); color: var(--brand-deep); }
.nav-btn .ico { font-size: 1.15rem; width: 1.4rem; text-align: center; }
.nav-badge {
  margin-left: auto;
  background: var(--err);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  border-radius: 99px;
  padding: 0.05rem 0.5rem;
}
.rail-foot { margin-top: auto; font-size: 0.72rem; color: var(--ink-soft); padding: 0.6rem; }

.main { padding: clamp(1.2rem, 2.5vw, 2.6rem); max-width: 980px; width: 100%; margin: 0 auto; }

/* Mobile: untere Tab-Leiste */
.tabbar { display: none; }
@media (max-width: 800px) {
  .app { grid-template-columns: 1fr; }
  .rail { display: none; }
  .main { padding-bottom: 5.5rem; }
  .tabbar {
    display: flex;
    position: fixed; bottom: 0; left: 0; right: 0;
    background: var(--surface);
    border-top: 1px solid var(--line);
    z-index: 40;
    padding: 0.35rem 0.25rem calc(0.35rem + env(safe-area-inset-bottom));
  }
  .tabbar .nav-btn { flex-direction: column; gap: 0.1rem; flex: 1; font-size: 0.66rem; padding: 0.4rem 0.2rem; align-items: center; }
  .tabbar .nav-btn .ico { width: auto; }
  .tabbar .nav-badge { position: absolute; transform: translate(14px, -26px); margin: 0; }
}

/* ---------- Typo-Bausteine ---------- */
.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--brand);
  font-weight: 600;
}
h1.page { font-size: clamp(1.6rem, 1.3rem + 1.4vw, 2.3rem); letter-spacing: -0.02em; line-height: 1.15; margin: 0.25rem 0 0.4rem; font-weight: 800; }
.lead { color: var(--ink-soft); max-width: 60ch; }

/* ---------- Karten ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--space);
  box-shadow: var(--shadow);
}
.card + .card, .stack > * + * { margin-top: 1rem; }

/* ---------- Dashboard «Heute» ---------- */
.hero {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 1rem;
  align-items: center;
  background: linear-gradient(135deg, var(--brand-soft), var(--surface));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--space);
  overflow: hidden;
}
@media (max-width: 640px) { .hero { grid-template-columns: 1fr; } .hero .maskottchen { justify-self: center; } }

.statrow { display: flex; gap: 0.75rem; flex-wrap: wrap; margin-top: 1rem; }
.stat {
  flex: 1 1 130px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.7rem 0.9rem;
}
.stat b { display: block; font-size: 1.45rem; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat span { font-size: 0.78rem; color: var(--ink-soft); }
.stat.xp b { color: var(--xp); }
.stat.streak b { color: var(--err); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  background: var(--brand);
  color: #fff;
  font-weight: 700;
  padding: 0.7rem 1.3rem;
  border-radius: 12px;
  transition: transform var(--dur) var(--ease), filter var(--dur) var(--ease);
}
[data-theme="dark"] .btn { color: #10131c; }
.btn:hover { filter: brightness(1.08); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn.ghost { background: transparent; color: var(--brand-deep); border: 1.5px solid var(--brand); }
.btn.small { padding: 0.45rem 0.9rem; font-size: 0.88rem; }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; transform: none; }

/* Tagesplan */
.plan { list-style: none; }
.plan li {
  display: flex; gap: 0.8rem; align-items: baseline;
  padding: 0.55rem 0;
  border-bottom: 1px dashed var(--line);
}
.plan li:last-child { border-bottom: 0; }
.plan .t { font-family: var(--font-mono); font-size: 0.78rem; color: var(--brand); white-space: nowrap; font-weight: 600; }

/* ---------- Lehrgang: Wochenliste ---------- */
.monat-label { display: flex; align-items: center; gap: 0.75rem; margin: 1.6rem 0 0.7rem; }
.monat-label .eyebrow { color: var(--ink-soft); }
.monat-label::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.woche-row {
  width: 100%;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 1rem;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.9rem 1.1rem;
  text-align: left;
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.woche-row:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--brand); }
.woche-row + .woche-row { margin-top: 0.6rem; }
.woche-row .num {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--brand);
  background: var(--brand-soft);
  border-radius: 8px;
  padding: 0.35rem 0.55rem;
}
.woche-row h3 { font-size: 1.02rem; letter-spacing: -0.01em; }
.woche-row p { font-size: 0.82rem; color: var(--ink-soft); }
.woche-row .done { color: var(--ok); font-weight: 700; font-size: 0.9rem; white-space: nowrap; }
.woche-row .todo { color: var(--ink-soft); font-size: 0.8rem; white-space: nowrap; }
.woche-row.locked { opacity: 0.55; }

.progressbar { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin-top: 0.6rem; }
.progressbar > div { height: 100%; background: var(--brand); border-radius: 99px; transition: width 600ms var(--ease); }
.progressbar.ok > div { background: var(--ok); }

/* ---------- Wochen-Detail / Lektionen ---------- */
.lektion h3 { margin-bottom: 0.4rem; letter-spacing: -0.01em; }
.lektion p + p, .lektion ul + p, .lektion p + ul { margin-top: 0.7rem; }
.lektion ul { padding-left: 1.2rem; }
.lektion li + li { margin-top: 0.3rem; }
.lektion strong { color: var(--brand-deep); }
[data-theme="dark"] .lektion strong { color: var(--brand); }

.merk {
  border-left: 4px solid var(--xp);
  background: var(--xp-soft);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 0.75rem 1rem;
  margin-top: 0.9rem;
  font-weight: 600;
}
.merk::before { content: "🧠 Merksatz"; display: block; font-family: var(--font-mono); font-size: 0.68rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--xp); margin-bottom: 0.25rem; }

.beispiel {
  border: 1px dashed var(--line);
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  margin-top: 0.9rem;
  font-size: 0.94rem;
}
.beispiel::before { content: "💡 Beispiel"; display: block; font-family: var(--font-mono); font-size: 0.68rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-soft); margin-bottom: 0.25rem; }

.hinweis-personal {
  border-left: 4px solid var(--brand);
  background: var(--brand-soft);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 0.75rem 1rem;
  margin-top: 0.9rem;
  font-size: 0.92rem;
}
.hinweis-personal::before { content: "👤 Für dich"; display: block; font-family: var(--font-mono); font-size: 0.68rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--brand); margin-bottom: 0.25rem; }

.lektion-check { display: flex; justify-content: flex-end; margin-top: 1rem; }

/* ---------- Quiz ---------- */
.quiz-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 0.8rem; }
.quiz-frage { font-size: 1.15rem; font-weight: 700; letter-spacing: -0.01em; margin-bottom: 1rem; }
.optionen { display: grid; gap: 0.6rem; }
.option {
  text-align: left;
  border: 1.5px solid var(--line);
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  font-weight: 600;
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.option:hover:not([disabled]) { border-color: var(--brand); transform: translateX(3px); }
.option.richtig { border-color: var(--ok); background: var(--ok-soft); }
.option.falsch { border-color: var(--err); background: var(--err-soft); }
.feedback { border-radius: var(--radius-sm); padding: 0.8rem 1rem; margin-top: 0.9rem; animation: pop 320ms var(--ease); }
.feedback.ok { background: var(--ok-soft); border-left: 4px solid var(--ok); }
.feedback.err { background: var(--err-soft); border-left: 4px solid var(--err); }
.feedback b { display: block; margin-bottom: 0.2rem; }

@keyframes pop { from { transform: scale(0.96); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.quiz-ende { text-align: center; padding: 1.5rem 0.5rem; }
.quiz-ende .gross { font-size: 3rem; }
.quiz-ende h2 { letter-spacing: -0.02em; margin: 0.4rem 0; }

/* ---------- Abzeichen / Auszeichnungen ---------- */
.badges { display: flex; flex-wrap: wrap; gap: 0.6rem; }
.badge {
  display: inline-flex; align-items: center; gap: 0.45rem;
  border: 1px solid var(--line);
  border-radius: 99px;
  padding: 0.35rem 0.85rem;
  font-size: 0.83rem;
  font-weight: 600;
  background: var(--surface);
}
.badge.hat { border-color: var(--xp); background: var(--xp-soft); }
.badge.fehlt { opacity: 0.45; filter: grayscale(1); }

/* ---------- Maskottchen «Agentli» ---------- */
.maskottchen { width: clamp(110px, 16vw, 150px); }
.maskottchen .auge { transform-origin: center; animation: blinzeln 5.5s infinite; }
@keyframes blinzeln {
  0%, 92%, 100% { transform: scaleY(1); }
  95% { transform: scaleY(0.08); }
}
.maskottchen .antenne-licht { animation: pulsieren 2.8s ease-in-out infinite; }
@keyframes pulsieren { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

/* ---------- Einstellungen / Formulare ---------- */
.setting-row { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 0.8rem 0; border-bottom: 1px solid var(--line); }
.setting-row:last-child { border-bottom: 0; }
.setting-row p { font-size: 0.82rem; color: var(--ink-soft); }
select, input[type="file"] {
  font: inherit; color: inherit;
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.7rem;
}

/* ---------- Glossar ---------- */
.glossar-eintrag { padding: 0.9rem 0; border-bottom: 1px solid var(--line); }
.glossar-eintrag:last-child { border-bottom: 0; }
.glossar-eintrag dt { font-weight: 800; letter-spacing: -0.01em; }
.glossar-eintrag dd { color: var(--ink-soft); margin-top: 0.2rem; }
.suchfeld {
  width: 100%;
  font: inherit; color: inherit;
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.9rem;
  margin-bottom: 0.5rem;
}

/* ---------- Einblend-Animationen ---------- */
.view { animation: einblenden 380ms var(--ease); }
@keyframes einblenden {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.konfetti { position: fixed; inset: 0; pointer-events: none; z-index: 90; overflow: hidden; }
.konfetti i {
  position: absolute; top: -4vh;
  width: 9px; height: 14px;
  border-radius: 2px;
  animation: fallen 2.6s var(--ease) forwards;
}
@keyframes fallen {
  to { transform: translateY(110vh) rotate(540deg); opacity: 0.2; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  html { scroll-behavior: auto; }
}
