/* OSI-Agenten – Bausteine: Knöpfe, Karten, Eingaben, Fortschritt, Kopfleiste, Toasts, Dialoge, Figuren, Belohnungen. */

/* ---------------------------------------------------------------- Knöpfe (Duolingo: Farbe + 3D-Kante, sinkt beim Drücken ein) */
.btn {
  --c: var(--green); --c-edge: var(--green-edge); --c-ink: var(--on-strong);
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 10px 22px; border: 2px solid transparent; border-radius: var(--r);
  background: var(--c); color: var(--c-ink); box-shadow: 0 var(--kante) 0 var(--c-edge);
  font-weight: 900; font-size: .92rem; text-transform: uppercase; letter-spacing: .06em; line-height: 1.15;
  cursor: pointer; user-select: none; -webkit-tap-highlight-color: transparent;
  transition: transform var(--schnell), box-shadow var(--schnell), filter var(--schnell), background var(--schnell);
}
.btn:hover { filter: brightness(1.07); }
a.btn, a.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(var(--kante)); box-shadow: 0 0 0 var(--c-edge); }
.btn:disabled { --c: var(--locked); --c-edge: var(--locked-edge); --c-ink: var(--locked-ink); cursor: default; filter: none; transform: none; }
.btn.sec { --c: var(--surface); --c-edge: var(--line); --c-ink: var(--blue-ink); border-color: var(--line); }
.btn.sec:hover { --c: var(--surface-2); filter: none; }
.btn.blau { --c: var(--blue); --c-edge: var(--blue-edge); }
.btn.rot { --c: var(--red); --c-edge: var(--red-edge); }
.btn.ghost { --c: transparent; --c-edge: transparent; --c-ink: var(--blue-ink); box-shadow: none; }
.btn.ghost:hover { --c: var(--blue-soft); filter: none; }
.btn.ghost:active { transform: none; }
.btn.gross { min-height: 52px; padding: 12px 30px; font-size: 1rem; }
.btn.klein { min-height: 36px; padding: 6px 14px; font-size: .76rem; --kante: 3px; }
.btn.voll { width: 100%; }
.btn small { text-transform: none; letter-spacing: 0; font-weight: 800; opacity: .92; font-size: .82rem; }
.btnrow { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin-top: 16px; }

.hintbtn {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: var(--r);
  background: var(--surface); color: var(--kalle); border: 2px solid var(--line); box-shadow: 0 3px 0 var(--line);
  font-weight: 800; cursor: pointer; transition: transform var(--schnell), box-shadow var(--schnell);
}
.hintbtn:hover:not(:disabled) { background: var(--blue-soft); }
.hintbtn:active:not(:disabled) { transform: translateY(3px); box-shadow: none; }
.hintbtn:disabled { opacity: .45; cursor: default; }

/* ---------------------------------------------------------------- Karten, Eingaben */
.card {
  background: var(--surface); border: 2px solid var(--line); border-radius: var(--r-l);
  padding: 22px 24px; margin-bottom: 18px; box-shadow: 0 var(--kante) 0 var(--line);
}
@media (max-width: 560px) { .card { padding: 18px 16px; border-radius: var(--r); } }
input[type=text], input[type=password] {
  width: 100%; padding: 12px 14px; border: 2px solid var(--line); border-radius: var(--r-s);
  background: var(--surface-2); color: var(--text); font-weight: 700;
  transition: border-color var(--schnell), box-shadow var(--schnell);
}
input[type=text]:focus, input[type=password]:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 4px var(--blue-soft); background: var(--surface); }
input::placeholder { color: var(--subtle); font-weight: 600; }
label { display: block; margin: 12px 0 6px; color: var(--muted); font-size: .9rem; font-weight: 800; }
.feld2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.dropzone { margin-top: 16px; border: 3px dashed var(--line); border-radius: var(--r); padding: 28px 16px; text-align: center; color: var(--muted); font-weight: 800; transition: border-color var(--schnell), background var(--schnell); }
.dropzone.over { border-color: var(--blue); background: var(--blue-soft); color: var(--blue-ink); }
.warnbar { background: var(--brand-soft); border: 2px solid var(--brand); border-radius: var(--r); padding: 10px 14px; margin-bottom: 16px; font-size: .94rem; }
.tabelle-scroll { overflow-x: auto; }

/* ---------------------------------------------------------------- Fortschrittsbalken (mit Glanzkante) */
.fortschritt { --f: var(--green); height: 16px; border-radius: var(--r-pill); background: var(--locked); overflow: hidden; margin: 10px 0 8px; }
.fortschritt i, .step-bar i, .timebar i, .map-kapitel-bar i {
  position: relative; display: block; height: 100%; border-radius: inherit; background: var(--f, var(--green));
  transition: width .6s var(--sanft);
}
.fortschritt i::after, .step-bar i::after, .timebar i::after, .map-kapitel-bar i::after {
  content: ""; position: absolute; left: 8px; right: 8px; top: 3px; height: 4px; border-radius: 4px; background: rgba(255, 255, 255, .35);
}
.fortschritt.gold { --f: var(--gold); }
.fortschritt.lila { --f: var(--purple); }
.fortschritt.blau { --f: var(--blue); }

/* ---------------------------------------------------------------- Kopfleiste */
#topbar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 10px;
  padding: 8px 16px; min-height: 62px; background: var(--surface); border-bottom: 2px solid var(--line);
}
.tb-logo { display: inline-flex; align-items: center; gap: 8px; border: 0; background: none; padding: 4px; cursor: pointer; border-radius: var(--r-s); }
.tb-logo-mark { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 11px; background: var(--brand); color: #fff; font-weight: 900; box-shadow: 0 3px 0 var(--brand-edge); }
.tb-logo-text { white-space: nowrap; font-weight: 900; font-size: 1.15rem; color: var(--brand-ink); letter-spacing: -.01em; }
.tb-figur { display: inline-flex; align-items: center; gap: 8px; border: 2px solid transparent; background: none; border-radius: var(--r); padding: 2px 10px 2px 2px; cursor: pointer; min-width: 0; }
.tb-figur:hover { background: var(--surface-2); border-color: var(--line); }
.tb-figur .av { width: 40px; height: 46px; flex: none; }
.tb-duo { display: flex; flex-direction: column; line-height: 1.15; text-align: left; min-width: 0; }
.tb-duo b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 160px; }
.tb-duo small { color: var(--muted); font-weight: 700; }
.tb-stat { display: inline-flex; align-items: center; gap: 4px; padding: 4px 8px; border-radius: var(--r-s); font-weight: 900; font-size: 1.02rem; white-space: nowrap; }
.tb-stat.xp { color: var(--gold-ink); }
.tb-stat.flamme { color: var(--subtle); filter: grayscale(1); }
.tb-stat.flamme.an { color: var(--brand-ink); filter: none; }
.tb-rang { display: inline-flex; align-items: center; gap: 8px; }
.tb-rang-ring {
  --a: calc(var(--anteil, 0) * 1%);
  display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%;
  background: conic-gradient(var(--purple) var(--a), var(--locked) 0);
}
.tb-rang-ring b { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--surface); color: var(--purple-ink); font-size: .9rem; }
.rang { font-weight: 900; white-space: nowrap; }
.tb-tools { display: inline-flex; align-items: center; gap: 6px; }
.tb-btn {
  display: inline-flex; align-items: center; gap: 4px; min-height: 40px; padding: 6px 10px; border-radius: var(--r-s);
  border: 2px solid var(--line); background: var(--surface); box-shadow: 0 3px 0 var(--line); cursor: pointer; font-weight: 800; font-size: .9rem; white-space: nowrap;
  transition: transform var(--schnell), box-shadow var(--schnell), background var(--schnell);
}
.tb-btn:hover { background: var(--surface-2); }
.tb-btn:active { transform: translateY(3px); box-shadow: none; }
a.tb-btn { color: var(--text); text-decoration: none; }
.tb-save { color: var(--blue-ink); }
.tb-teacher { border-color: var(--brand); box-shadow: 0 3px 0 var(--brand-edge); }
.savestate { font-size: .82rem; font-weight: 800; color: var(--green-ink); white-space: nowrap; }
.savestate.warn { color: var(--brand-ink); }
@media (max-width: 1400px) { .tb-label { display: none; } }
@media (max-width: 1100px) { .tb-duo, .tb-label-save { display: none; } }
@media (max-width: 720px) {
  #topbar { flex-wrap: wrap; gap: 6px; padding: 6px 10px; }
  .tb-logo-text, .tb-duo { display: none; }
  .tb-tools { order: 9; width: 100%; justify-content: flex-end; }
}

/* ---------------------------------------------------------------- Toasts */
#toasts { position: fixed; right: 16px; bottom: 16px; z-index: 60; display: flex; flex-direction: column; gap: 10px; align-items: flex-end; pointer-events: none; }
.toast {
  display: flex; gap: 12px; align-items: center; max-width: 360px; padding: 12px 16px; pointer-events: auto;
  background: var(--surface); border: 2px solid var(--line); border-radius: var(--r); box-shadow: var(--schatten), 0 var(--kante) 0 var(--line);
  animation: toast-rein .45s var(--feder);
}
.toast b { color: var(--text); }
.toast.ok { border-color: var(--green); box-shadow: var(--schatten), 0 var(--kante) 0 var(--green-edge); }
.toast.kombo { border-color: var(--brand); background: linear-gradient(135deg, var(--brand-soft), var(--surface)); }
.toast.medaille { border-color: var(--gold); box-shadow: var(--schatten), 0 var(--kante) 0 var(--gold-edge); }
.toast-medaille { display: grid; place-items: center; flex: none; width: 48px; height: 48px; border-radius: 50%; font-size: 1.6rem; background: var(--gold-soft); border: 3px solid var(--gold); animation: pop .6s var(--feder) .15s both; }
.toast.weg { animation: toast-raus .3s ease forwards; }
@media (max-width: 760px) { #toasts { left: 12px; right: 12px; bottom: 84px; align-items: stretch; } .toast { max-width: none; } }
@keyframes toast-rein { from { opacity: 0; transform: translateX(40px) scale(.9); } to { opacity: 1; transform: none; } }
@keyframes toast-raus { to { opacity: 0; transform: translateX(30px); } }

/* ---------------------------------------------------------------- Dialoge */
#modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; padding: 16px; background: var(--backdrop); animation: einblenden .2s ease; }
#modal .box {
  position: relative; width: 100%; max-width: 640px; max-height: 90vh; overflow: auto; padding: 24px 24px 20px;
  background: var(--surface); border: 2px solid var(--line); border-radius: var(--r-l); box-shadow: var(--schatten);
  animation: pop-rein .35s var(--feder);
}
#modal .box.breit { max-width: 880px; }
#modal .box h2 { padding-right: 40px; }
.modal-x { position: absolute; top: 12px; right: 12px; width: 38px; height: 38px; border-radius: 50%; border: 2px solid var(--line); background: var(--surface); font-size: 1.3rem; line-height: 1; cursor: pointer; color: var(--muted); }
.modal-x:hover { color: var(--text); background: var(--surface-2); }
.egg-text { padding-right: 24px; }

/* Inhaltsverzeichnis, Lehrkraft-Sprungliste */
.toc-e { margin: 10px 0; border: 2px solid var(--line); border-radius: var(--r); background: var(--surface); }
.toc-e > summary { display: flex; align-items: center; gap: 10px; padding: 10px 14px; font-weight: 900; list-style: none; }
.toc-e > summary::-webkit-details-marker { display: none; }
.toc-e > summary:hover { background: var(--surface-2); border-radius: var(--r); }
div.toc-e.toc-off { display: flex; gap: 10px; align-items: center; padding: 10px 14px; opacity: .55; font-weight: 900; }
.toc-kap { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 10px; background: var(--k); flex: none; }
.toc-pct { margin-left: auto; color: var(--muted); font-size: .85rem; }
.toc-list { list-style: none; margin: 0; padding: 0 8px 8px; }
.toc-step { display: flex; align-items: center; gap: 10px; width: 100%; padding: 7px 10px; text-align: left; background: transparent; border: 0; border-radius: var(--r-s); cursor: pointer; font-weight: 700; }
.toc-step:hover:not(:disabled) { background: var(--surface-2); }
.toc-step.cur { background: var(--blue-soft); outline: 2px solid var(--blue); }
.toc-step:disabled { opacity: .45; cursor: default; }
.toc-nr { width: 22px; text-align: right; font-family: var(--mono); color: var(--muted); font-size: .85rem; }
.toc-ic { width: 22px; text-align: center; }
.toc-t { flex: 1; }
.toc-ok { color: var(--green-ink); font-weight: 900; }
.lk-steps { display: grid; gap: 6px; }
.lk-step { text-align: left; padding: 8px 12px; border-radius: var(--r-s); border: 2px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 700; }
.lk-step:hover { border-color: var(--blue); }

/* ---------------------------------------------------------------- Figuren */
.av { display: block; width: 100%; height: auto; overflow: visible; }
.av-gross { width: 140px; margin: 0 auto; }
.av-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(86px, 1fr)); gap: 10px; }
.av-wahl {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px 6px; cursor: pointer;
  background: var(--surface); border: 2px solid var(--line); border-radius: var(--r); box-shadow: 0 3px 0 var(--line);
  font-size: .72rem; font-weight: 800; color: var(--muted); line-height: 1.15; text-align: center;
  transition: transform var(--schnell), box-shadow var(--schnell), border-color var(--schnell), background var(--schnell);
}
.av-wahl .av { width: 60px; height: 70px; }
.av-wahl:hover { background: var(--surface-2); }
.av-wahl:active { transform: translateY(3px); box-shadow: none; }
.av-wahl[aria-checked="true"] { border-color: var(--blue); background: var(--blue-soft); color: var(--blue-ink); box-shadow: 0 3px 0 var(--blue-edge); }
.av-wahl.hupf .av { animation: hupf .55s var(--feder); }

/* ---------------------------------------------------------------- Statistik-Kacheln (Kapitel-Ende, Challenge) */
.statkacheln { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; margin: 18px 0; }
.statkachel { --c: var(--green); border: 3px solid var(--c); border-radius: var(--r); overflow: hidden; background: var(--surface); text-align: center; animation: pop-rein .5s var(--feder) both; }
.statkachel:nth-child(2) { animation-delay: .12s; }
.statkachel:nth-child(3) { animation-delay: .24s; }
.statkachel span { display: block; padding: 4px 8px; background: var(--c); color: var(--on-color); font-size: .74rem; font-weight: 900; text-transform: uppercase; letter-spacing: .08em; }
.statkachel b { display: block; padding: 10px 6px 12px; font-size: 1.7rem; color: var(--text); }
.statkachel b i { font-style: normal; }
.statkachel.gold { --c: var(--gold); }
.statkachel.gruen { --c: var(--green); }
.statkachel.blau { --c: var(--blue); }

/* ---------------------------------------------------------------- Belohnung (Vollbild) */
.belohnung { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 16px; background: var(--backdrop); cursor: pointer; animation: einblenden .2s ease; }
.belohnung.weg { animation: ausblenden .25s ease forwards; }
.belohnung-box { position: relative; width: min(420px, 100%); padding: 34px 24px 22px; text-align: center; background: var(--surface); border-radius: 28px; box-shadow: var(--schatten); overflow: hidden; animation: pop-rein .5s var(--feder); }
.belohnung-strahlen { position: absolute; left: 50%; top: 92px; width: 520px; height: 520px; margin: -260px 0 0 -260px; background: repeating-conic-gradient(var(--gold-soft) 0 10deg, transparent 10deg 20deg); border-radius: 50%; animation: drehen 12s linear infinite; }
.belohnung-icon { position: relative; font-size: 4.2rem; line-height: 1; margin-bottom: 10px; animation: hupf 1s var(--feder) .2s both; }
.belohnung-icon .av { width: 130px; margin: 0 auto; }
.belohnung-titel { position: relative; font-size: 1.7rem; font-weight: 900; color: var(--gold-ink); }
.belohnung-text { position: relative; margin-top: 6px; font-size: 1.05rem; }
.belohnung-tipp { position: relative; margin-top: 16px; font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }

/* XP fliegt in die Kopfleiste */
.xp-flug { position: fixed; z-index: 90; pointer-events: none; transform: translate(-50%, -50%); font-weight: 900; font-size: 1.15rem; color: var(--gold-ink); text-shadow: 0 2px 0 var(--surface), 0 0 10px var(--surface); white-space: nowrap; }
.puls { animation: puls .5s var(--feder); }

/* Konfetti */
.konfetti { position: fixed; inset: 0; z-index: 95; pointer-events: none; overflow: hidden; }
.konfetti i { position: absolute; top: -14px; width: 10px; height: 14px; border-radius: 3px; animation-name: konfetti-fall; animation-timing-function: cubic-bezier(.25, .6, .5, 1); animation-fill-mode: forwards; }
.konfetti i:nth-child(3n) { border-radius: 50%; width: 10px; height: 10px; }
@keyframes konfetti-fall { to { top: 105%; transform: translateX(var(--drift, 40px)) rotate(var(--dreh, 720deg)); } }

/* ---------------------------------------------------------------- Bewegungen (gemeinsam) */
@keyframes einblenden { from { opacity: 0; } }
@keyframes ausblenden { to { opacity: 0; } }
@keyframes pop-rein { from { opacity: 0; transform: scale(.85) translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes rein { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.08); } 100% { transform: scale(1); } }
@keyframes shake { 0%, 100% { transform: none; } 20% { transform: translateX(-7px); } 40% { transform: translateX(6px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(3px); } }
@keyframes wackel { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-8deg); } 75% { transform: rotate(8deg); } }
@keyframes hupf { 0% { transform: translateY(0) scale(1); } 30% { transform: translateY(-14px) scale(1.05, .95); } 55% { transform: translateY(0) scale(1.05, .92); } 75% { transform: translateY(-4px); } 100% { transform: none; } }
@keyframes puls { 0% { transform: scale(1); } 45% { transform: scale(1.25); } 100% { transform: scale(1); } }
@keyframes drehen { to { transform: rotate(360deg); } }
@keyframes schweben { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
.pop { animation: pop .4s var(--feder); }
.shake { animation: shake .4s ease; }
.wackel { animation: wackel .35s ease; }
.rein { animation: rein .35s var(--feder); }
