/* Compile Academy – Mini-Spiele (spiele.js) und Kurs-Finder der Startseite. Baut auf spielwelt.css auf. */

/* ---------- Mini-Spiele ---------- */
.gm {
  position: relative;
  max-width: 720px;
  margin-inline: auto;
  padding: 20px;
  border-radius: 28px;
  background: var(--sw-card);
  border: 2px solid var(--sw-line);
  border-bottom-width: 8px;
  overflow: hidden;
}
.gm-top {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
  font-weight: 800;
}
.gm-track {
  flex: 1;
  height: 14px;
  border-radius: 99px;
  background: var(--sw-line);
  overflow: hidden;
}
.gm-track i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--sw-green);
  transform: scaleX(0);
  transform-origin: 0 50%;
  transition: transform 0.4s var(--sw-pop);
}
/* Feinschliff 14.11.2026: Statt Herzen zeigt der Spielrahmen die Energie wie die Lern-App (dort gibt es nur Energie, keine Herzen): eine
   kleine Batterie mit drei Balken, gezeichnet aus Rahmen, Kontakt (::after) und drei <i> – keine neue Datei. Ein leerer Balken ist
   blass. Die Farbe folgt dem Stand wie in der App: türkis, ab einem Balken bernstein. */
.gm-energy {
  --tone: var(--sw-cyan);
  position: relative;
  flex: none;
  display: inline-flex;
  gap: 2px;
  box-sizing: border-box;
  width: 38px;
  height: 20px;
  margin-right: 4px;
  padding: 2px;
  border: 2px solid var(--sw-muted);
  border-radius: 6px;
}
.gm-energy::after {
  content: '';
  position: absolute;
  top: 50%;
  right: -6px;
  width: 3px;
  height: 8px;
  margin-top: -4px;
  border-radius: 0 2px 2px 0;
  background: var(--sw-muted);
}
.gm-energy[data-level='1'] {
  --tone: var(--sw-orange);
}
.gm-energy i {
  flex: 1;
  border-radius: 2px;
  background: var(--tone);
}
.gm-energy i.is-empty {
  opacity: 0.18;
}
.gm-score {
  color: var(--sw-gold);
  white-space: nowrap;
}
/* Website lebt 14.11.2026: Lautsprecher-Knopf im Spielrahmen (44 px Trefferfläche). Druck-Gefühl wie druck.css: die Kante bleibt als
   Schatten stehen, beim Drücken sinkt der Knopf per transform – nichts im Layout ändert sich. */
.gm-sound {
  flex: none;
  width: 44px;
  height: 44px;
  margin-bottom: 3px;
  padding: 0;
  border-radius: 14px;
  border: 2px solid var(--sw-line);
  box-shadow: 0 3px 0 0 var(--sw-line);
  background: transparent;
  color: var(--ink);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  transition:
    transform 0.12s ease-out,
    box-shadow 0.12s ease-out;
}
.gm-sound[aria-pressed='false'] {
  opacity: 0.7;
}
.gm-sound:active {
  transform: translateY(3px);
  box-shadow: 0 0 0 0 var(--sw-line);
}
.gm-sound:focus-visible {
  outline: 3px solid var(--sw-cyan);
  outline-offset: 3px;
}
.gm-board {
  display: grid;
  gap: 14px;
  min-height: 240px;
  align-content: start;
}
/* Website lebt 14.11.2026: Jede neue Aufgabe (und die Endkarte) steigt 8 px auf, 200 ms, die Teile 40 ms versetzt – nur transform und
   opacity. Der Platz bleibt reserviert (min-height), es verschiebt sich nichts. Bei „Bewegung reduzieren“ steht alles sofort da. */
.gm-top,
.gm-board > *,
.gm-options > .gm-opt {
  animation: gm-rise 0.2s ease-out backwards;
}
.gm-board > :nth-child(2) {
  animation-delay: 0.04s;
}
.gm-board > :nth-child(3) {
  animation-delay: 0.08s;
}
.gm-board > :nth-child(4) {
  animation-delay: 0.12s;
}
.gm-board > :nth-child(5) {
  animation-delay: 0.16s;
}
.gm-options > .gm-opt:nth-child(2) {
  animation-delay: 0.07s;
}
.gm-options > .gm-opt:nth-child(3) {
  animation-delay: 0.1s;
}
@keyframes gm-rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}
.gm-code,
.gm-lines,
.gm-built {
  margin: 0;
  padding: 16px 18px;
  border-radius: 18px;
  background: var(--sw-card-2);
  font: 600 clamp(15px, 2.2vw, 19px) / 1.45 var(--mono);
  color: #e2e8f0;
  white-space: pre-wrap;
}
.gm-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
/* Website lebt 14.11.2026: Druck-Gefühl wie druck.css. Die 4-px-Kante ist ein Schatten ohne Unschärfe (und unten als Rand reserviert);
   beim Drücken sinkt die Kachel per transform und die Kante wird flach – früher wuchs/schrumpfte border-bottom-width und
   die Kachel ruckelte um 4 px (Layout). Jetzt ändert sich nur transform und box-shadow. */
.gm-opt,
.gm-line,
.gm-bugline,
.gm-undo {
  --edge: var(--sw-line);
  min-height: 56px;
  margin-bottom: 4px;
  padding: 10px 14px;
  border-radius: 16px;
  border: 2px solid var(--sw-line);
  box-shadow: 0 4px 0 0 var(--edge);
  background: transparent;
  color: var(--ink);
  font: 800 18px/1.2 var(--mono);
  cursor: pointer;
  transition:
    transform 0.12s ease-out,
    box-shadow 0.12s ease-out,
    border-color 0.15s,
    background-color 0.15s;
}
.gm-opt:hover:not(:disabled),
.gm-line:hover:not(:disabled),
.gm-bugline:hover:not(:disabled) {
  border-color: var(--sw-cyan);
}
.gm-opt:active:not(:disabled),
.gm-line:active:not(:disabled),
.gm-bugline:active:not(:disabled),
.gm-undo:active:not(:disabled) {
  transform: translateY(4px);
  box-shadow: 0 0 0 0 var(--edge);
}
.gm-opt:disabled,
.gm-bugline:disabled {
  cursor: default;
}
.gm-opt.is-right,
.gm-bugline.is-bug {
  --edge: var(--sw-green);
  border-color: var(--sw-green);
  background: rgba(74, 222, 128, 0.16);
  color: var(--sw-green);
}
.gm-opt.is-wrong,
.gm-bugline.is-wrong {
  --edge: #ff6b6b;
  border-color: #ff6b6b;
  background: rgba(255, 107, 107, 0.14);
  color: #ff9b9b;
}
.gm-goal {
  margin: 0;
  font-size: 18px;
  font-weight: 800;
}
.gm-hint {
  margin: 0;
  color: var(--sw-muted);
  font-weight: 700;
}
.gm-built {
  list-style: none;
  display: grid;
  gap: 6px;
  transition: box-shadow 0.2s;
}
.gm-built li {
  min-height: 30px;
  padding: 3px 10px;
  border-radius: 10px;
  border: 2px dashed var(--sw-line);
}
.gm-built li.is-filled {
  border-style: solid;
  border-color: rgba(47, 214, 242, 0.45);
  background: rgba(47, 214, 242, 0.08);
}
.gm-built code,
.gm-line code,
.gm-bugline code {
  font: inherit;
  white-space: pre;
}
.gm-built.is-right {
  box-shadow: 0 0 0 3px var(--sw-green);
}
.gm-built.is-wrong {
  box-shadow: 0 0 0 3px #ff6b6b;
}
.gm-pool {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.gm-line {
  font-size: 15px;
  text-align: left;
  white-space: pre;
}
.gm-line:disabled {
  opacity: 0.25;
  cursor: default;
}
.gm-undo {
  justify-self: start;
  min-height: 44px;
  font: 800 15px/1 var(--body);
}
.gm-undo:disabled {
  opacity: 0.4;
  cursor: default;
}
.gm-lines {
  display: grid;
  gap: 8px;
  padding: 12px;
}
.gm-bugline {
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  font-size: 16px;
  white-space: pre;
  overflow-x: auto;
}
.gm-bugline em {
  font-style: normal;
  color: #94a3b8;
  min-width: 1.2em;
}
/* Rückmeldung von unten – wie in der Lern-App.
   Website lebt 14.11.2026: Die Leiste hat ihren Platz immer (min-height) und fährt nur noch per transform/opacity ein: Die Farbfläche
   (::before) schiebt sich von unten herein, Text und Knopf steigen danach auf. Früher wuchs die Höhe der Leiste von 0 auf 320 px – das war
   Layout in jedem Bild und schob alles unter dem Spiel mit. */
.gm-bar {
  --bar-bg: transparent;
  --bar-line: transparent;
  position: relative;
  isolation: isolate;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 92px;
  margin: 18px -20px -20px;
  padding: 16px 20px 18px;
  overflow: hidden;
}
.gm-bar::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background: var(--bar-bg);
  border-top: 4px solid var(--bar-line);
  transform: translateY(100%);
  transition: transform 0.2s var(--sw-pop);
}
.gm-bar.is-on::before {
  transform: none;
}
/* Text und Knopf steigen 60 ms nach der Fläche auf. Beim Wegfahren sind sie schon leer bzw. versteckt (spiele.js: hush). Der Knopf
   behält sein Druck-Gefühl aus druck.css (sein transform ist dort festgelegt, hier bewegt sich nur die Deckkraft). */
.gm-bar.is-on .gm-msg,
.gm-bar.is-on .gm-next {
  animation: gm-rise 0.2s ease-out 0.06s backwards;
}
.gm-bar[data-kind='right'] {
  --bar-bg: #12392a;
  --bar-line: var(--sw-green);
  color: var(--sw-green);
}
.gm-bar[data-kind='wrong'] {
  --bar-bg: #3a1620;
  --bar-line: #ff6b6b;
  color: #ffb3b3;
}
.gm-msg {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  font-size: 17px;
  flex: 1;
  min-width: 220px;
}
.gm-msg b {
  font-size: 20px;
}
.gm-why {
  flex-basis: 100%;
  color: var(--ink);
  font-weight: 600;
}
.gm-combo {
  padding: 4px 10px;
  border-radius: 99px;
  background: var(--sw-orange);
  color: #3a1400;
  font-weight: 900;
}
.gm-bugsy {
  width: 44px;
  height: 44px;
}
.gm-bar[data-kind='wrong'] .gm-next {
  background: #ff6b6b !important;
  border-color: #ff6b6b !important;
  border-bottom-color: #b83b3b !important;
  color: #2a0a0a !important;
}
.gm-bar[data-kind='right'] .gm-next {
  background: var(--sw-green) !important;
  border-color: var(--sw-green) !important;
  border-bottom-color: var(--sw-green-d) !important;
  color: #062a17 !important;
}
.gm-end {
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 18px 0 8px;
  text-align: center;
}
.gm-end img {
  width: 96px;
  height: 96px;
}
.gm-end-title {
  font: 700 clamp(24px, 3vw, 32px) / 1.1 var(--display);
}
.gm-end-points {
  font: 700 clamp(30px, 4vw, 44px) / 1 var(--display);
  color: var(--sw-gold);
}
.gm-end-best {
  color: var(--sw-muted);
  font-weight: 800;
}
/* Website lebt 14.11.2026: Bei „falsch“ wackelt nur die gewählte Kachel bzw. die Zeilenreihe (±4 px, 250 ms) – früher schüttelte
   sich die ganze Spielfläche. Der Zusatz „.gm“ hält diese Regeln stärker als das Aufsteigen der Aufgabe oben. */
.gm .gm-wiggle {
  animation: gm-wiggle 0.25s ease-in-out;
}
.gm .gm-pop {
  animation: gm-pop 0.35s var(--sw-pop);
}
.gm-score.gm-bump,
.gm-energy.gm-bump {
  animation: gm-bump 0.2s var(--sw-pop);
}
@keyframes gm-wiggle {
  20%,
  60% {
    transform: translateX(-4px);
  }
  40%,
  80% {
    transform: translateX(4px);
  }
}
@keyframes gm-pop {
  50% {
    transform: scale(1.08);
  }
}
@keyframes gm-bump {
  from {
    transform: scale(1.12);
  }
}
@keyframes gm-sag {
  40% {
    transform: translateY(4px) scale(1.04, 0.92);
  }
}
/* Endkarte: Koda hüpft beim Sieg, Bugsy sackt kurz ein, der Pokal poppt – jeweils einmal */
.gm-won img {
  animation: wl-hop 0.45s var(--sw-pop) 0.1s backwards;
}
.gm-lost img {
  animation: gm-sag 0.3s ease-out 0.1s backwards;
}
.gm-end-best.is-record {
  animation: wl-pop 0.32s var(--sw-pop) 0.3s backwards;
}
/* Bugsy in der Leiste hüpft bei „richtig“ und neigt den Kopf bei „falsch“ */
.gm-bar[data-kind='right'].is-on .gm-bugsy {
  animation: wl-hop 0.4s var(--sw-pop) 0.12s backwards;
}
.gm-bar[data-kind='wrong'].is-on .gm-bugsy {
  animation: wl-tilt 0.3s ease-in-out 0.12s backwards;
}
@media (max-width: 560px) {
  .gm {
    padding: 14px;
  }
  .gm-bar {
    margin: 14px -14px -14px;
    /* Feinschliff 14.11.2026: Text und Knopf stehen auf dem Handy in zwei Zeilen; die Leiste reserviert beide gleich (16 + 28 + 12 + 54 + 18),
       damit sie mit der Rückmeldung nicht noch wächst. */
    min-height: 128px;
  }
  /* Feinschliff 14.11.2026: „Weiter“ füllt auf dem Handy die ganze Breite der Leiste wie der Hauptknopf der Lern-App (vorher stand der Knopf
     schmal und linksbündig unter dem Text). */
  .gm-bar .gm-next {
    flex: 1 1 100%;
  }
  .gm-options {
    grid-template-columns: minmax(0, 1fr);
  }
  .gm-line {
    font-size: 13.5px;
  }
  .gm-bugline {
    font-size: 14px;
  }
}
/* Bewegung reduzieren (Gerät), Website-Einstellung und Sparmodus: alles Neue steht sofort da. Der Ton bleibt davon unberührt. */
@media (prefers-reduced-motion: reduce) {
  .gm,
  .gm *,
  .gm *::before {
    animation: none !important;
    transition: none !important;
  }
}
:root[data-motion='reduce'] :is(.gm, .gm *),
:root[data-perf='lite'] :is(.gm, .gm *) {
  animation: none !important;
  transition: none !important;
}
/* Website lebt 14.11.2026: ein Pseudo-Element ist in :is() ungültig und fiel dort still weg – darum eigene Regeln,
   sonst glitte die Farbfläche der Rückmeldeleiste (.gm-bar::before) trotz „Bewegung reduzieren“ oder Sparmodus herein. */
:root[data-motion='reduce'] .gm *::before,
:root[data-perf='lite'] .gm *::before {
  animation: none !important;
  transition: none !important;
}

/* ---------- Kurs-Finder (Startseite) ---------- */
.kf {
  max-width: 820px;
  margin-inline: auto;
  padding: clamp(20px, 3vw, 32px);
  border-radius: 30px;
  background: var(--sw-card);
  border: 2px solid var(--sw-line);
  border-bottom-width: 8px;
}
.kf-step[hidden],
.kf-result[hidden] {
  display: none;
}
.kf-step h3 {
  margin: 0 0 16px;
  font-size: clamp(20px, 2.4vw, 26px);
  text-align: center;
}
.kf-choices {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}
.kf-choices button {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 18px 12px;
  border-radius: 20px;
  border: 2px solid var(--sw-line);
  /* Website lebt 14.11.2026: Kante als Schatten statt als dickerer Rand – beim Drücken sinkt nur transform (kein Ruckeln um 4 px) */
  margin-bottom: 4px;
  box-shadow: 0 4px 0 0 var(--sw-line);
  background: transparent;
  color: var(--ink);
  font: 800 16px/1.25 var(--body);
  cursor: pointer;
  transition:
    transform 0.12s ease-out,
    box-shadow 0.12s ease-out,
    border-color 0.15s;
}
.kf-choices button span {
  font-size: 34px;
}
.kf-choices button:hover {
  border-color: var(--sw-cyan);
}
.kf-choices button:active {
  transform: translateY(4px);
  box-shadow: 0 0 0 0 var(--sw-line);
}
.kf-result {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 18px 22px;
  align-items: center;
}
.kf-result .pg-icon {
  width: 84px;
  height: 84px;
  font-size: 42px;
  border-radius: 24px;
}
.kf-result h3 {
  margin: 0 0 6px;
  font-size: clamp(22px, 2.6vw, 30px);
}
.kf-result p {
  margin: 0;
  color: var(--mist);
}
.kf-result .pg-cta {
  grid-column: 1 / -1;
}
.kf-restart {
  background: none;
  border: 0;
  color: var(--sw-cyan);
  font: 800 15px/1 var(--body);
  cursor: pointer;
  text-decoration: underline;
}
.sw-anim .kf-result:not([hidden]) {
  animation: kf-in 0.45s var(--sw-pop) both;
}
@keyframes kf-in {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.96);
  }
}
@media (max-width: 560px) {
  .kf-result {
    grid-template-columns: minmax(0, 1fr);
    justify-items: center;
    text-align: center;
  }
  .kf-result .pg-cta {
    justify-content: center;
  }
}
@media (prefers-reduced-motion: reduce) {
  .sw-anim .kf-result:not([hidden]) {
    animation: none;
  }
}
