/* ============================================================
   base.css — strukturelles Base-Stylesheet für ALLE Renderer & Komponenten.
   Konsumiert Theme-Tokens (--bg,--ink,--accent,…) aus tokens.js via Lessons.theme.apply.
   Enthält die A11y-Kerngarantien (Fokus, 44px, reduced-motion, Reflow, sr-only).
   Module dürfen mit eigener style.css ergänzen/überschreiben.
   ============================================================ */

/* ---- Token-Fallbacks (falls Theme noch nicht injiziert) ---- */
:root{
  --bg:#eef2fb; --paper:#fff; --panel:#fff; --soft:#f5f8fd;
  --ink:#1f2433; --muted:#586074; --line:#d8dee9;
  --accent:#2f5fb0; --accent2:#1d3557; --navy:#1d3557;
  --ok:#1f9d7a; --bad:#c0392b; --warn:#b8860b; --focus:#2f5fb0;
  --k-red:#e21b3c; --k-blue:#1368ce; --k-yellow:#9a6a00; --k-green:#26890c;
  --radius-card:16px; --radius-btn:12px; --radius-pill:999px; --radius-sm:6px;
  --tap:44px; --shadow:0 8px 24px rgba(29,53,87,.12);
  --font-ui:system-ui,-apple-system,"Segoe UI",Roboto,Lato,Helvetica,Arial,sans-serif;
  --font-display:system-ui,"Segoe UI",Roboto,sans-serif;
  --font-mono:ui-monospace,"Cascadia Code",Consolas,monospace;
  --dur:260ms; --ease:cubic-bezier(.2,.7,.2,1);
}

/* ---- Reset / Basis ---- */
*,*::before,*::after{ box-sizing:border-box; }
html{ -webkit-text-size-adjust:100%; }
body{
  margin:0; font-family:var(--font-ui); color:var(--ink); background:var(--bg);
  line-height:1.55; font-size:clamp(15px,1.6vw,17px); overflow-x:hidden;
}
h1,h2,h3{ font-family:var(--font-display); line-height:1.2; }
a{ color:var(--accent); }
img{ max-width:100%; height:auto; }
p{ margin:.5em 0; }

/* ---- A11y: sichtbarer Fokus (NIE entfernen), Skip-Link, sr-only ---- */
:focus-visible{ outline:3px solid var(--focus); outline-offset:2px; border-radius:4px; }
:focus:not(:focus-visible){ outline:none; }
.sr-only{ position:absolute!important; width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0; }
.skip{ position:absolute; left:-999px; top:0; z-index:1000; background:var(--accent); color:#fff; padding:.6rem 1rem; border-radius:0 0 var(--radius-btn) 0; }
.skip:focus{ left:0; }

/* ---- Touch-Ziele ≥44px (bewusste Über-Erfüllung für Kinder/Tablets) ---- */
button,.btn,a.btn,input[type=button],input[type=submit],summary,.chip,.tile,.card{
  min-height:var(--tap);
}
button,.btn{
  font:inherit; cursor:pointer; border:0; border-radius:var(--radius-btn);
  padding:.6rem 1rem; background:var(--soft); color:var(--ink); transition:transform var(--dur) var(--ease),background var(--dur) var(--ease);
  display:inline-flex; align-items:center; justify-content:center; gap:.4rem;
}
.btn.primary,button.primary,.auth-btn{ background:var(--accent); color:#fff; }
.btn.ghost{ background:transparent; border:1.5px solid var(--line); }
button:hover,.btn:hover{ filter:brightness(1.03); }
button:active,.btn:active{ transform:translateY(1px); }
button:disabled,.btn:disabled{ opacity:.55; cursor:not-allowed; }
input,select,textarea{
  font:inherit; color:var(--ink); background:var(--paper); border:1.5px solid var(--line);
  border-radius:var(--radius-btn); padding:.55rem .7rem; min-height:var(--tap);
}
textarea{ min-height:5rem; resize:vertical; }

/* ---- Reduced Motion (WCAG 2.2.2) ---- */
@media (prefers-reduced-motion: reduce){
  *,*::before,*::after{ animation-duration:.01ms!important; animation-iteration-count:1!important; transition-duration:.01ms!important; scroll-behavior:auto!important; }
}

/* ---- Shell / Header / Top-Bar ---- */
.top,.lesson-header{ background:var(--paper); border-bottom:1px solid var(--line); padding:.6rem clamp(.8rem,3vw,1.4rem); }
.top__row,.lesson-header__row{ max-width:1100px; margin:0 auto; display:flex; align-items:center; gap:.8rem; flex-wrap:wrap; }
.top h1,.lesson-header h1{ margin:0; font-size:clamp(1.1rem,3.5vw,1.5rem); color:var(--navy); }
.top__nav{ max-width:1100px; margin:.2rem auto 0; display:flex; gap:1rem; flex-wrap:wrap; }
main{ max-width:1100px; margin:0 auto; padding:clamp(.8rem,3vw,1.4rem); }

#app-status{ display:flex; align-items:center; gap:.6rem; flex-wrap:wrap; margin-left:auto; font-size:.86rem; }
.app-name{ font-weight:700; color:var(--navy); }
.app-level{ font-weight:700; }
.app-xpbar{ position:relative; width:min(220px,40vw); height:18px; background:var(--soft); border-radius:var(--radius-pill); overflow:hidden; border:1px solid var(--line); }
.app-xpbar__fill{ position:absolute; inset:0 auto 0 0; background:linear-gradient(90deg,var(--accent),var(--accent2)); transition:width var(--dur) var(--ease); }
.app-xpbar__txt{ position:absolute; inset:0; display:grid; place-items:center; font-size:.72rem; font-weight:700; color:var(--ink); mix-blend-mode:luminosity; }
.app-badges{ font-weight:700; }

/* ---- Differenzierungs-Leiste (3 Stufen) ---- */
.tierbar{ display:flex; align-items:center; gap:.5rem; flex-wrap:wrap; margin:0 0 1rem; }
.tierbar__lbl{ font-weight:700; color:var(--muted); }
.tierbtn{ background:var(--soft); border:1.5px solid var(--line); border-radius:var(--radius-pill); padding:.4rem .8rem; }
.tierbtn.is-on{ background:var(--accent); color:#fff; border-color:transparent; }

/* ---- Stationen (linear-stations / Bestands-engine.js-DOM) ---- */
.station{ background:var(--panel); border:1px solid var(--line); border-radius:var(--radius-card); box-shadow:var(--shadow); padding:1.1rem 1.2rem; margin:0 0 1.1rem; }
.station.is-locked{ opacity:.6; }
.station__head{ display:flex; flex-direction:column; gap:.1rem; margin-bottom:.4rem; }
.station__no{ font-size:.78rem; color:var(--muted); font-weight:700; text-transform:uppercase; letter-spacing:.03em; }
.station__title{ margin:0; color:var(--navy); font-size:clamp(1.05rem,3vw,1.35rem); }
.station__basis{ margin:.3rem 0; }
.block{ margin:.6rem 0; border:1px solid var(--line); border-radius:var(--radius-btn); padding:.2rem .7rem; background:var(--soft); }
.block>summary{ cursor:pointer; font-weight:700; padding:.4rem 0; }
.tier-forscher{ border-style:dashed; }
.lab{ margin:.8rem 0; }
.lab__todo{ color:var(--muted); font-style:italic; }
.station__aufgabe{ margin-top:.6rem; padding:.6rem .8rem; background:var(--soft); border-left:4px solid var(--accent); border-radius:var(--radius-sm); }
.station__status{ margin-top:.6rem; }
.badge{ display:inline-flex; align-items:center; gap:.3rem; padding:.25rem .6rem; border-radius:var(--radius-pill); font-size:.8rem; font-weight:700; }
.badge.ok{ background:color-mix(in srgb,var(--ok) 18%,transparent); color:var(--ok); }
.badge.todo{ background:var(--soft); color:var(--muted); }
.badge.locked{ background:var(--soft); color:var(--muted); }
#progress{ color:var(--muted); font-weight:700; margin:.4rem 0 1rem; }

/* ---- Pfad-Hub / station-path ---- */
.path-hub{ display:grid; gap:1rem; grid-template-columns:repeat(auto-fill,minmax(220px,1fr)); margin:0 0 1.4rem; }
.path-card{ background:var(--panel); border:1px solid var(--line); border-left:6px solid var(--accent); border-radius:var(--radius-card); box-shadow:var(--shadow); padding:1rem; text-align:left; }
.path-card[aria-pressed=true]{ outline:3px solid var(--accent); }
.path-card__icon{ font-size:1.6rem; }
.path-card__name{ font-weight:800; color:var(--navy); margin:.2rem 0; }
.path-card__desc{ color:var(--muted); font-size:.9rem; }
.pathbar{ position:sticky; top:0; z-index:5; background:var(--bg); padding:.5rem 0; display:flex; gap:.4rem; flex-wrap:wrap; align-items:center; border-bottom:1px solid var(--line); }
.status-chip{ display:inline-flex; align-items:center; gap:.3rem; padding:.25rem .55rem; border-radius:var(--radius-pill); font-size:.74rem; font-weight:700; background:var(--soft); color:var(--muted); border:1px solid var(--line); }
.status-chip.done{ background:color-mix(in srgb,var(--ok) 16%,transparent); color:var(--ok); }
.status-chip.mastered{ background:color-mix(in srgb,var(--accent) 18%,transparent); color:var(--accent); }
.status-chip.locked{ opacity:.6; }
.next-nudge{ margin:.6rem 0 1rem; }

/* ---- Article-Grid (menschenrechte/voelkerrecht) ---- */
.grid{ display:grid; grid-template-columns:repeat(auto-fill,minmax(150px,1fr)); gap:.8rem; }
.tile,.card{ position:relative; display:flex; flex-direction:column; gap:.3rem; text-align:left; padding:.9rem; background:var(--panel); border:1px solid var(--line); border-radius:var(--radius-card); box-shadow:var(--shadow); min-height:150px; transition:transform var(--dur) var(--ease); cursor:pointer; }
.tile:hover,.card:hover{ transform:translateY(-3px); }
.tile__icon,.card__icon{ font-size:1.8rem; }
.tile__title,.card__title{ font-weight:800; color:var(--navy); }
.tile.is-seen::after,.card.is-seen::after{ content:"✓"; position:absolute; top:.5rem; right:.6rem; color:var(--ok); font-weight:900; }
.detail{ background:var(--panel); border:1px solid var(--line); border-radius:var(--radius-card); box-shadow:var(--shadow); padding:1.2rem; }
.detail__nav{ display:flex; gap:.6rem; flex-wrap:wrap; margin-bottom:.6rem; }
.motion-stage{ display:flex; align-items:center; justify-content:center; min-height:150px; border:1px solid var(--line); border-radius:var(--radius-btn); background:var(--soft); margin:.6rem 0; }
.gloss{ position:relative; border:0; background:none; color:inherit; font:inherit; text-decoration:underline dotted; text-underline-offset:3px; cursor:help; padding:0; }
.gloss-mark{ font-size:.7em; vertical-align:super; color:var(--accent); }
.gloss-tip{ position:absolute; z-index:30; left:0; top:1.6em; max-width:min(300px,90vw); background:var(--navy); color:#fff; padding:.6rem .7rem; border-radius:10px; font-size:.85rem; box-shadow:var(--shadow); opacity:0; visibility:hidden; transition:opacity var(--dur) var(--ease); }
.gloss-tip.show{ opacity:1; visibility:visible; }

/* ---- Kahoot-Quiz ---- */
.quiz-tiles{ display:grid; grid-template-columns:repeat(2,1fr); gap:.7rem; }
@media (max-width:480px){ .quiz-tiles{ grid-template-columns:1fr; } }
.quiz-tile{ display:flex; align-items:center; gap:.5rem; min-height:64px; padding:.8rem 1rem; border-radius:12px; color:#fff; font-weight:800; box-shadow:0 4px 0 rgba(0,0,0,.25); }
.quiz-tile:active{ transform:translateY(2px); box-shadow:0 2px 0 rgba(0,0,0,.25); }
.quiz-tile.t0{ background:var(--k-red); } .quiz-tile.t1{ background:var(--k-blue); }
.quiz-tile.t2{ background:var(--k-yellow); } .quiz-tile.t3{ background:var(--k-green); }
.quiz-tile.is-correct{ outline:4px solid var(--ok); }
.quiz-tile.is-wrong{ outline:4px solid #fff; filter:grayscale(.6) brightness(.85); }

/* ---- Generische Komponenten-Skins (.lc-…) ---- */
.lc{ background:var(--panel); border:1px solid var(--line); border-radius:var(--radius-card); padding:1rem; margin:.6rem 0; box-shadow:var(--shadow); }
.lc__q{ font-weight:700; margin-bottom:.6rem; }
.lc__opts{ display:flex; flex-direction:column; gap:.5rem; }
.lc__opt{ text-align:left; width:100%; border:1.5px solid var(--line); background:var(--soft); border-radius:var(--radius-btn); padding:.6rem .8rem; }
.lc__opt.ok{ background:color-mix(in srgb,var(--ok) 18%,transparent); border-color:var(--ok); }
.lc__opt.no{ background:color-mix(in srgb,var(--bad) 14%,transparent); border-color:var(--bad); }
.lc__opt[aria-pressed=true]{ outline:2px solid var(--accent); }
.lc__fb{ margin-top:.6rem; padding:.6rem .8rem; border-radius:var(--radius-btn); display:none; }
.lc__fb.show{ display:block; }
.lc__fb.good{ background:color-mix(in srgb,var(--ok) 16%,transparent); }
.lc__fb.bad{ background:color-mix(in srgb,var(--warn) 18%,transparent); }
.lc__actions{ display:flex; gap:.5rem; flex-wrap:wrap; margin-top:.7rem; }
.lc input.blank{ display:inline-block; width:auto; min-width:6ch; min-height:auto; padding:.1rem .3rem; }
.lc input.blank.ok{ border-color:var(--ok); background:color-mix(in srgb,var(--ok) 12%,transparent); }
.lc input.blank.no{ border-color:var(--bad); background:color-mix(in srgb,var(--bad) 10%,transparent); }
.lc__bank{ display:flex; flex-wrap:wrap; gap:.4rem; margin:.5rem 0; }
.lc__chip{ border:1.5px solid var(--line); background:var(--soft); border-radius:var(--radius-pill); padding:.4rem .8rem; cursor:grab; }
.lc__chip[aria-grabbed=true]{ outline:2px solid var(--accent); }
.lc__slot{ display:inline-block; min-width:7ch; min-height:1.8em; padding:.1rem .4rem; border-bottom:2px dashed var(--accent); }
.lc__slot.filled{ border-bottom-style:solid; background:var(--soft); }
.word{ cursor:pointer; border-radius:4px; padding:0 .1rem; }
.word.marked{ background:color-mix(in srgb,var(--accent) 25%,transparent); }
.word.hit{ background:color-mix(in srgb,var(--ok) 30%,transparent); }
.word.miss{ outline:2px solid var(--bad); }
.lc__hint{ margin-top:.5rem; padding:.5rem .7rem; background:var(--soft); border-left:4px solid var(--warn); border-radius:var(--radius-sm); }

/* ---- Toasts ---- */
.xp-toast,.badge-toast{ position:fixed; right:1rem; bottom:1rem; z-index:200; background:var(--navy); color:#fff; padding:.7rem 1rem; border-radius:var(--radius-btn); box-shadow:var(--shadow); opacity:0; transform:translateY(12px); transition:opacity var(--dur) var(--ease),transform var(--dur) var(--ease); display:flex; align-items:center; gap:.6rem; }
.xp-toast.show,.badge-toast.show{ opacity:1; transform:none; }
.xp-toast{ font-weight:800; background:var(--accent); }
.badge-toast__icon{ font-size:1.6rem; }

/* ---- Auth-Overlay (auth.js) ---- */
.auth-overlay{ position:fixed; inset:0; z-index:300; background:rgba(10,16,36,.55); display:none; align-items:center; justify-content:center; padding:1rem; }
.auth-overlay.open{ display:flex; }
.auth-card{ background:var(--paper); color:var(--ink); border-radius:var(--radius-card); box-shadow:var(--shadow); padding:1.4rem; max-width:440px; width:100%; }
.auth-card h2{ margin:.1rem 0 .6rem; color:var(--navy); }
.auth-card label{ display:block; font-weight:700; margin:.7rem 0 .2rem; }
.auth-card input{ width:100%; }
.auth-note{ color:var(--muted); font-size:.9rem; }
.auth-opt{ color:var(--muted); font-weight:400; }
.auth-err{ color:var(--bad); font-weight:700; min-height:1.2em; }
.auth-hint{ color:var(--muted); font-size:.82rem; margin-top:.6rem; }
.auth-btn{ width:100%; margin-top:.8rem; }
.auth-guest{ width:100%; margin-top:.5rem; background:transparent; border:1.5px solid var(--line); }
#app-sync{ position:fixed; left:1rem; bottom:1rem; z-index:200; background:var(--navy); color:#fff; padding:.4rem .7rem; border-radius:var(--radius-pill); font-size:.8rem; opacity:0; transition:opacity var(--dur) var(--ease); }
#app-sync.show{ opacity:1; }

/* ---- Footer (Impressum/Datenschutz – auf jeder Seite) ---- */
.lesson-footer{ max-width:1100px; margin:2rem auto 0; padding:1rem clamp(.8rem,3vw,1.4rem); border-top:1px solid var(--line); color:var(--muted); font-size:.85rem; display:flex; gap:1rem; flex-wrap:wrap; }
.lesson-footer a{ color:var(--muted); }
