/*
 * Lernen (vorlagen/lernen/*, assets/lernen.js): Lernauswahl, Lernkarte gross
 * und kindgerecht, Ampel richtig/fast/falsch, Bildschirmtastatur und
 * Ziffernblock, Sprechen, Diktat, Lueckentext, Multiple Choice, Zuordnen,
 * Probe/Duell-Uhr, Ende-Seite. Farben aus app.css (--kern-akzent, --richtig,
 * --fast, --falsch, --flaeche-hell) und Bootstrap (--bs-...).
 */

/* ── Lernauswahl: Kacheln mit verstecktem Radioknopf ── */
.kacheln { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: .75rem; }
.kacheln.klein { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.kachel {
  position: relative; display: flex; flex-direction: column; gap: .3rem; cursor: pointer;
  padding: .9rem 1rem; border: 2px solid transparent; transition: border-color .15s, background .15s;
}
.kachel input { position: absolute; opacity: 0; pointer-events: none; }
.kachel:hover { border-color: color-mix(in srgb, var(--kern-akzent) 35%, transparent); }
.kachel:has(input:checked) { border-color: var(--kern-akzent); background: var(--flaeche-hell); }
.kachel:has(input:focus-visible) { outline: 3px solid color-mix(in srgb, var(--kern-akzent) 45%, transparent); outline-offset: 2px; }
.kachel.leer { opacity: .65; }
.bedeutungs-optionen legend { margin-bottom: .25rem; }

/* ── Lerneinheit: Kopf, Fortschritt, Karte ── */
.lernkopf > span:nth-child(2) { flex: 1; min-width: 0; }
.lernfortschritt { height: .6rem; }
.lernfortschritt .progress-bar { width: 0; background: var(--kern-akzent); transition: width .3s; }
.lernflaeche { max-width: 560px; margin: 0 auto; }
.lernkarte { padding: 1.75rem 1.25rem; text-align: center; margin-bottom: 1rem; border-radius: 1.5rem; }
.lernkarte.nichts-zu-tun, .lernkarte.duell-start, .korrekturen { max-width: 560px; }
.lernkarte .sprache { font-size: .8rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; color: var(--bs-secondary-color); }
.lernkarte .wort { font-size: 2.1rem; font-weight: 800; margin: .35rem 0; overflow-wrap: anywhere; line-height: 1.25; }
.lernkarte .wort .bedeutung { display: block; }
.lernkarte .wort.loesung { color: var(--richtig); font-size: 1.6rem; }
.lernkarte .rueckseite { border-top: 2px dashed var(--bs-border-color); margin-top: 1.25rem; padding-top: 1rem; }
.lernkarte .notiz { margin: .6rem 0 0; font-size: .95rem; font-style: italic; color: var(--bs-secondary-color); }
.lernkarte p.beispiel { font-style: italic; margin: .3rem 0; }
.lernkarte .fachmarke { margin-left: .4rem; vertical-align: middle; }
.lernkarte .hinweismarke { font-size: .9rem; margin-left: .4rem; cursor: help; }
.lektion-tipp { max-width: 560px; margin: .5rem auto; padding: .45rem .8rem; border-radius: .8rem; background: var(--fast-hell); border-left: 4px solid var(--fast); }
.lernkarte kbd, .lernflaeche kbd {
  font: 11px/1 ui-monospace, monospace; opacity: .6; background: none; color: inherit;
  border: 1px solid currentColor; border-radius: 3px; padding: 2px 4px; margin-left: .4em;
}

.vorlesen { background: none; border: 0; cursor: pointer; font-size: 1.15rem; vertical-align: middle; opacity: .65; padding: .2rem .4rem; border-radius: .6rem; }
.vorlesen:hover { opacity: 1; }
.vorlesen.gross { font-size: 2.4rem; opacity: 1; padding: .3rem .9rem; background: var(--flaeche-hell); }
.diktat-knoepfe { display: flex; justify-content: center; gap: 1rem; }
.anzahl-bedeutungen { display: inline-block; margin-top: .3rem; font-size: .85rem; font-weight: 700; padding: .15rem .7rem; border-radius: 999px; background: var(--flaeche-hell); color: var(--kern-akzent); }
[data-bs-theme="dark"] .anzahl-bedeutungen { color: #b9a2ff; }

/* Karteikarte: umdrehen und selbst bewerten */
.steuerung { text-align: center; }
.bewerten { display: grid; grid-template-columns: repeat(4, 1fr); gap: .4rem; }
.bewerten .btn { padding: .75rem .2rem; }
.tastenhilfe { margin-top: 1rem; }
@media (pointer: coarse) { .tastenhilfe { display: none; } }
@media (max-width: 420px) { .bewerten kbd, .optionen kbd { display: none; } }

/* Eintippen */
.antwortform { margin-top: 1.25rem; }
.eingaben { position: relative; display: flex; flex-direction: column; gap: .4rem; }
.lernkarte .eingabe { font-size: 1.4rem; font-weight: 700; text-align: center; padding: .8rem; border-radius: 1rem; border-width: 2px; }
.eingabe.aktiv-feld { border-color: var(--kern-akzent); }
.eingabe.mit-bildschirmtastatur { caret-color: transparent; cursor: default; }
.eingabe.mit-bildschirmtastatur:focus { box-shadow: none; border-color: var(--kern-akzent); }
.eingabe:disabled { opacity: 1; }
.schreibmarke { position: absolute; width: 2px; border-radius: 1px; background: var(--kern-akzent); pointer-events: none; }
.schreibmarke.blinkt { animation: schreibmarke-blinken 1s steps(1) infinite; }
@keyframes schreibmarke-blinken { 50% { opacity: 0; } }
.weitere-bedeutung { margin-top: .4rem; }
.alle-hinweis { margin: 0 0 .5rem; font-size: .9rem; }
.sonderzeichen { display: flex; flex-wrap: wrap; justify-content: center; gap: .3rem; margin-top: .5rem; }
.sonderzeichen .btn { min-width: 2.4rem; padding-inline: .5rem; }
.tipp-anzeige { font: 700 1.3rem/1.4 ui-monospace, monospace; letter-spacing: .05em; color: var(--fast); margin-bottom: .5rem; overflow-wrap: anywhere; }
.tipp-hinweis { font-size: .82rem; color: var(--bs-secondary-color); margin: .6rem 0 0; }
.tipp-hinweis.aktiv { color: var(--fast); font-weight: 700; }

/* Knopfleiste beim Eintippen (Konto -> Beim Lernen: oben / mitte / unten) */
.knopfleiste { margin: .6rem 0; }
.antwortform > .knopfleiste:first-child { margin-top: 0; margin-bottom: .8rem; }
.knopfleiste .knoepfe { display: grid; grid-template-columns: 1.4fr 1fr 1.3fr; gap: .4rem; }
.knopfleiste .knoepfe:has(> :nth-child(2):last-child) { grid-template-columns: 1fr 1fr; }
.knopfleiste .btn { padding: .65rem .4rem; white-space: nowrap; }

/* Ergebnis: Ampel richtig - fast - falsch */
.ergebnis { margin-top: 1.25rem; padding: 1rem; border-radius: 1.1rem; }
.ergebnis .urteil { font-weight: 800; font-size: 1.25rem; }
.ergebnis.gut { background: var(--richtig-hell); }
.ergebnis.gut .urteil { color: var(--richtig); }
.ergebnis.fast, .ergebnis.teils { background: var(--fast-hell); }
.ergebnis.fast .urteil, .ergebnis.teils .urteil, .ergebnis.fast .wort.loesung { color: var(--fast); }
.ergebnis.schlecht { background: var(--falsch-hell); }
.ergebnis.schlecht .urteil { color: var(--falsch); }
.ergebnis .deine { color: var(--bs-secondary-color); margin-top: .3rem; }
.loesung .getroffen { color: var(--richtig); }
.loesung .verfehlt { color: var(--falsch); }
.korrektur-hinweis { margin: .4rem 0; padding: .4rem .6rem; border-radius: .8rem; background: var(--flaeche-hell); text-align: left; }
.eselsbruecke { margin: .6rem 0 0; padding: .55rem .8rem; border-radius: .8rem; background: var(--fast-hell); text-align: left; font-size: .95rem; }
.eselsbruecke p { margin: 0; }
.eselsbruecke p + p { margin-top: .35rem; }
.eselsbruecke .tipp strong { color: var(--kern-akzent); }
[data-bs-theme="dark"] .eselsbruecke .tipp strong { color: #b9a2ff; }

/* Multiple Choice */
.optionen { display: grid; gap: .5rem; margin-top: 1.25rem; }
.option {
  font: inherit; font-size: 1.15rem; font-weight: 700; text-align: left; cursor: pointer; display: flex; align-items: center; gap: .6rem;
  padding: .85rem 1rem; border-radius: 1rem; border: 2px solid var(--bs-border-color); background: var(--bs-body-bg); color: var(--bs-body-color);
}
.option kbd { margin: 0; }
.option:hover:not(:disabled) { border-color: var(--kern-akzent); }
.option:disabled { cursor: default; color: var(--bs-body-color); }
.option.gut { border-color: var(--richtig); background: var(--richtig-hell); }
.option.schlecht { border-color: var(--falsch); background: var(--falsch-hell); }
.nach-auswahl { padding-block: 1rem; }

/* Zuordnen */
.zuordnen { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem .7rem; padding: 1rem; }
.zuordnen .sprache { text-align: center; }
.spalte { display: flex; flex-direction: column; gap: .5rem; }
.paar {
  font: inherit; font-weight: 700; cursor: pointer; padding: .8rem .5rem; min-height: 56px; border-radius: 1rem;
  border: 2px solid var(--bs-border-color); background: var(--bs-body-bg); color: var(--bs-body-color); overflow-wrap: anywhere;
  transition: background .2s, border-color .2s, opacity .3s;
}
.paar.aktiv { border-color: var(--kern-akzent); background: var(--flaeche-hell); }
.paar.gut { border-color: var(--richtig); background: var(--richtig-hell); opacity: .45; cursor: default; }
.paar.schlecht { border-color: var(--falsch); background: var(--falsch-hell); animation: wackeln .3s; }
@keyframes wackeln { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }

/* Lueckentext */
.luecke-satz { font-size: 1.4rem; line-height: 1.5; }
.luecke-satz .luecke { display: inline-block; min-width: 4rem; border-bottom: 3px solid var(--kern-akzent); color: transparent; }

/* Sprechen */
.sprech-steuerung { margin-top: 1.25rem; }
.mikro {
  width: 92px; height: 92px; border-radius: 50%; border: 0; font-size: 2.5rem; cursor: pointer;
  background: var(--kern-akzent); color: #fff; box-shadow: 0 4px 14px rgba(109, 60, 224, .35);
}
.mikro.aktiv { background: var(--falsch); animation: pulsieren 1.2s infinite; }
@keyframes pulsieren { 50% { box-shadow: 0 0 0 14px color-mix(in srgb, var(--falsch) 20%, transparent); } }
.sprech-status { margin: .8rem 0 .2rem; }

/* ── Bildschirmtastatur (Handy) und Ziffernblock ── */
.bildschirmtastatur {
  margin: .8rem -.75rem 0; padding: .4rem .25rem; background: var(--flaeche-hell); border-radius: 1rem;
  user-select: none; -webkit-user-select: none; touch-action: manipulation;
}
.tastenreihe { display: flex; justify-content: center; gap: 4px; margin: 4px 0; }
.taste {
  flex: 1 1 0; min-width: 0; max-width: 44px; height: 46px; padding: 0;
  font: inherit; font-size: 1.2rem; font-weight: 700; border: 0; border-radius: .6rem;
  background: var(--bs-body-bg); color: var(--bs-body-color); box-shadow: 0 1px 0 var(--bs-border-color); cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
[data-bs-theme="dark"] .taste { background: var(--bs-tertiary-bg); }
.taste.gedrueckt { background: color-mix(in srgb, var(--kern-akzent) 25%, var(--bs-body-bg)); transform: translateY(1px); }
.zeichenreihe .taste.zeichen { max-width: 40px; height: 40px; font-size: 1.05rem; background: var(--bs-secondary-bg); }
.taste.leer { flex: 5 1 0; max-width: none; }
.taste.loeschen { flex: 1.5 1 0; max-width: 64px; }
.taste.umschalt { flex: 1.4 1 0; max-width: 56px; background: var(--bs-secondary-bg); }
.taste.umschalt.an, .taste.umschalt.fest { background: var(--kern-akzent); color: #fff; }
.taste.umschalt.fest { text-decoration: underline; text-underline-offset: 3px; }
.ziffernblock { max-width: 320px; margin-left: auto; margin-right: auto; }
.ziffernblock .taste { max-width: none; height: 52px; font-size: 1.4rem; }
.ziffernblock .taste.loeschen { max-width: none; }

/* ── Probe-Klassenarbeit, Duell, Fehlerfrei ── */
.testuhr { font-variant-numeric: tabular-nums; font-weight: 800; }
.testuhr.knapp { color: var(--falsch); }
.fehlerfrei { font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--fast); }
.fehlerfrei.rekord { background: var(--fast-hell); border-radius: 999px; padding: 0 .5em; }
.fehlerfrei.neu { animation: rekord-hupf .6s ease-out; }
@keyframes rekord-hupf { 30% { transform: scale(1.35); } 60% { transform: scale(.95); } }
@media (prefers-reduced-motion: reduce) { .fehlerfrei.neu { animation: none; } }
p.fehlerfrei { white-space: normal; }
p.fehlerfrei.rekord { padding: .3em .8em; border-radius: .8rem; }
.duell.sieg { border-left: 4px solid var(--richtig) !important; }
.duell.niederlage { border-left: 4px solid var(--falsch) !important; }

/* ── Ende der Einheit ── */
.ende .gross-zahl { font-size: 3.2rem; font-weight: 900; margin: .2rem 0; color: var(--kern-akzent); }
.ende .gross-zahl.gut { color: var(--richtig); }
.ende .gross-zahl.fast { color: var(--fast); }
.ende .gross-zahl.schlecht { color: var(--falsch); }
.fehlerliste { text-align: left; display: inline-block; margin: 0 0 1rem; padding: 0; }
.fehlerliste li { list-style: none; margin: .3rem 0; padding: .35rem .75rem; border-radius: .7rem; border-left: 4px solid var(--falsch); background: var(--falsch-hell); }
.fehlerliste li.tipp, .fehlerliste li.fast { border-left-color: var(--fast); background: var(--fast-hell); }
.fehlerliste li.gut { border-left-color: var(--richtig); background: var(--richtig-hell); }
.deine-eingabe { color: var(--bs-secondary-color); }
.testliste .punkt { display: inline-block; width: 1.4rem; font-weight: 800; }
.testliste li.gut .punkt { color: var(--richtig); }
.testliste li.fast .punkt { color: var(--fast); }
.testliste li.schlecht .punkt { color: var(--falsch); }

/* ── Korrekturen vor dem Lernen ── */
.hinweisliste .list-group-item { border-left: 3px solid var(--fast); padding-left: .75rem !important; margin-bottom: .5rem; }
