/**
 * karte.css — Lernkartei: Fächer, Karteikarte, Bewertung und Tageszahlen.
 *
 * Copyright (c) 2026 Rico Pinzke. Alle Rechte vorbehalten.
 * Stand: 2026-12-05 22:47
 */

.auswahl {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px 14px;
  margin: 0 0 22px;
  padding: 12px 14px 14px;
  border: 1px solid var(--rand);
  border-radius: var(--radius);
  background: var(--flaeche-leise);
  box-shadow: var(--innenkante);
}

.wahl {
  display: grid;
  gap: 5px;
}

.wahl-titel {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-leise);
}

.wahl-feld {
  position: relative;
  color: var(--text);
}

.wahl-feld::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 17px;
  width: 8px;
  height: 8px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}

.wahl select {
  appearance: none;
  width: 100%;
  min-height: 48px;
  padding: 10px 44px 10px 14px;
  border: 2px solid var(--rand);
  border-radius: 10px;
  background: var(--karte);
  box-shadow: var(--innenkante);
  font-size: 16px;
  font-weight: 600;
  text-overflow: ellipsis;
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s;
}

.wahl select:hover {
  border-color: var(--text-leise);
}

.wahl select:focus-visible {
  outline: 3px solid var(--kopflinie);
  outline-offset: 2px;
}

.wahl option {
  background: var(--karte);
  color: var(--text);
  font-weight: 400;
}

.wahl[data-gesetzt="ja"] .wahl-titel {
  color: var(--akzent);
}

.wahl[data-gesetzt="ja"] .wahl-feld {
  color: var(--kasten-text);
}

.wahl[data-gesetzt="ja"] select {
  border-color: var(--kasten);
  background: var(--kasten);
  color: var(--kasten-text);
}

.kasten {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 6px;
  padding: 10px 10px 0;
  background: var(--kasten);
  border-radius: var(--radius) var(--radius) 0 0;
}

.fach {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  height: 92px;
  padding: 6px 8px 8px;
  border-radius: 6px 6px 0 0;
  background: var(--kasten-tief);
  color: var(--kasten-text);
}

.fach-stapel {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 50px;
  height: calc(34px * var(--fuellung));
  background: repeating-linear-gradient(to top, var(--kasten-text) 0 3px, transparent 3px 5px);
  opacity: 0.9;
}

.fach-zahl {
  font-size: 20px;
  line-height: 1;
}

.fach-name {
  font-size: 13px;
  color: var(--kasten-leise);
}

.karte {
  min-height: 340px;
  padding: 0 22px 22px;
  border: 1px solid var(--rand);
  border-top: 0;
  border-radius: 0 0 var(--radius) var(--radius);
  background: var(--karte);
  box-shadow: var(--schatten), var(--innenkante);
}

.karte-kopf {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 16px 0 10px;
  border-bottom: 2px solid var(--kopflinie);
  color: var(--text-leise);
  font-size: 14px;
}

.karte-kopf-rechts {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.karte-drucken {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  margin: -6px 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--text-leise);
  cursor: pointer;
}

.karte-drucken svg.i {
  width: 19px;
  height: 19px;
}

.karte-drucken:hover {
  background: color-mix(in srgb, var(--kopflinie) 14%, transparent);
  color: var(--text);
}

.karte-drucken:focus-visible {
  outline: 2px solid var(--kopflinie);
  outline-offset: 1px;
}

.pille-neu {
  display: inline-block;
  padding: 2px 10px 3px;
  border: 1px solid var(--kopflinie);
  border-radius: 99px;
  background: color-mix(in srgb, var(--kopflinie) 16%, var(--karte));
  color: color-mix(in srgb, var(--kopflinie) 55%, var(--text));
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 16px;
}

.karte-frage {
  margin: 18px 0 10px;
  font-size: clamp(21px, 2.4vw, 27px);
  line-height: 1.25;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

.karte-kern {
  margin-top: 16px;
  line-height: 32px;
  background: repeating-linear-gradient(to bottom, transparent 0 31px, var(--linie) 31px 32px);
}

.karte-kern p,
.karte-kern ul,
.karte-kern ol {
  margin: 0 0 32px;
}

.karte-kern > :last-child {
  margin-bottom: 0;
}

.karte-kern ul li,
.karte-kern ol li {
  margin: 0;
}

.molekuel {
  display: grid;
  gap: 8px;
  justify-items: start;
  margin: 24px 0 0;
}

.molekuel img {
  width: min(100%, 300px);
  height: auto;
  border: 1px solid var(--rand);
  border-radius: 10px;
  background: #fff;
}

.molekuel figcaption {
  display: grid;
  gap: 2px;
  font-size: 14px;
  line-height: 1.45;
  color: var(--text-leise);
}

.molekuel figcaption b {
  color: var(--text);
}

.karte-warnung {
  margin: 18px 0 0;
  padding: 12px 14px;
  border: 1px solid var(--schlecht);
  border-left-width: 5px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--schlecht) 9%, transparent);
  color: var(--schlecht);
  font-weight: 600;
  line-height: 1.45;
}

.karte-hinweis {
  color: var(--text-leise);
  max-width: 60ch;
}

.marken {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.marke {
  padding: 2px 8px;
  border: 1px solid var(--rand);
  border-radius: 99px;
  background: var(--flaeche-leise);
  color: var(--text-leise);
  font-size: 13px;
}

.steuerung {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.karte-abschnitte {
  margin: 22px -22px -22px;
  border-top: 2px solid var(--kopflinie);
  border-radius: 0 0 var(--radius) var(--radius);
  overflow: hidden;
}

.karte-abschnitte .abschnitt > .abschnitt-kopf {
  padding-left: 22px;
}

.karte-lang {
  padding: 8px 22px 20px;
}

.karte-lang > :first-child {
  margin-top: 6px;
}

.karte-lang table {
  display: block;
  max-width: 100%;
  overflow-x: auto;
}

.zahlen {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.zahl {
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--flaeche-leise);
}

.zahl b {
  display: block;
  font-size: 26px;
  line-height: 1.1;
}

.zahl span {
  font-size: 14px;
  color: var(--text-leise);
}

.lerncode {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 2px 14px;
  margin: 0;
  padding: 12px 14px;
  border: 1px solid var(--rand);
  border-radius: 10px;
  background: var(--flaeche-leise);
  box-shadow: var(--innenkante);
}

.lerncode-wert,
.lerncode-zustand {
  grid-column: 1;
}

.lerncode-qr {
  grid-column: 2;
  grid-row: 2 / span 2;
  align-self: center;
  width: 87px;
  height: 87px;
  border-radius: 6px;
  image-rendering: pixelated;
}

@media (min-width: 440px) {
  .lerncode-qr {
    width: 116px;
    height: 116px;
    border-radius: 8px;
  }
}

.lerncode-titel {
  grid-column: 1 / -1;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-leise);
}

.lerncode-wert {
  white-space: nowrap;
  font: 700 28px/1.25 ui-monospace, "Cascadia Mono", Consolas, monospace;
  letter-spacing: 0.08em;
  user-select: all;
}

.lerncode-wert[data-leer="ja"] {
  color: var(--text-leise);
}

.lerncode-zustand {
  font-size: 14px;
  color: var(--gut);
}

.lerncode-zustand[data-zustand="speichert"] {
  color: var(--text-leise);
}

.lerncode-zustand[data-zustand="offline"],
.lerncode-zustand[data-zustand="ohneCode"] {
  color: var(--mittel);
}

.code-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
}

.code-form .eingabe {
  flex: 100 1 170px;
  min-width: 0;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.code-form .knopf[type="submit"] {
  flex: 1 0 auto;
}

.code-form .knopf-kamera {
  flex: none;
  width: 44px;
  padding: 0;
  border-radius: 50%;
}

.scanbox {
  width: 100%;
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: 14px;
  background: #000000;
}

.scanbox video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.code-form .eingabe::placeholder {
  text-transform: none;
  letter-spacing: 0;
}

.schaltliste {
  display: grid;
  margin: 0 0 10px;
  padding: 0;
  list-style: none;
  border: 1px solid var(--rand);
  border-radius: 10px;
  background: var(--karte);
  overflow: hidden;
}

.schaltliste li + li {
  border-top: 1px solid var(--rand);
}

.schalt-zeile {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 56px;
  padding: 8px 12px 8px 14px;
  cursor: pointer;
}

.schalt-text {
  display: grid;
  gap: 1px;
  min-width: 0;
}

.schalt-text b {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.3;
}

.schalt-text small {
  color: var(--text-leise);
  font-size: 13px;
}

.schalter {
  position: relative;
  flex: none;
  width: 46px;
  height: 28px;
  margin: 0;
  border-radius: 99px;
  background: var(--rand);
  appearance: none;
  cursor: pointer;
  transition: background-color 0.15s;
}

.schalter::before {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--kasten-text);
  box-shadow: var(--schatten);
  transition: transform 0.15s;
}

.schalter:checked {
  background: var(--kasten);
}

.schalter:checked::before {
  transform: translateX(18px);
}

.schalter:focus-visible {
  outline: 3px solid var(--kopflinie);
  outline-offset: 2px;
}

@media (max-width: 860px) {
  .fach {
    align-items: center;
    height: 64px;
    text-align: center;
  }

  .fach-zahl {
    margin-bottom: 5px;
  }

  .fach-stapel {
    display: none;
  }
}

.fragen-auswahl {
  grid-template-columns: minmax(0, 1fr);
  margin-bottom: 12px;
}

@media (max-width: 600px) {
  .auswahl {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 16px;
    padding: 10px;
  }

  .wahl-thema,
  .fragen-auswahl .wahl {
    grid-column: 1 / -1;
  }

  .wahl select {
    min-height: 44px;
    padding: 8px 36px 8px 12px;
    font-size: 15px;
  }

  .wahl-feld::after {
    right: 14px;
  }

  .kasten {
    gap: 4px;
    padding: 8px 8px 0;
  }

  .fach {
    padding: 6px 2px 6px;
  }

  .fach-zahl {
    font-size: 17px;
  }

  .fach-name {
    font-size: 12px;
  }

  .karte {
    min-height: 280px;
    padding: 0 14px 16px;
  }

  .karte-abschnitte {
    margin: 18px -14px -16px;
  }

  .karte-abschnitte .abschnitt > .abschnitt-kopf {
    padding-left: 14px;
  }

  .karte-lang {
    padding: 6px 14px 16px;
  }

  .steuerung {
    position: sticky;
    bottom: 0;
    z-index: 3;
    margin: 0;
    padding: 10px 0 calc(10px + env(safe-area-inset-bottom, 0px));
    background: var(--flaeche);
    border-top: 1px solid var(--rand);
  }

  .steuerung .knopf {
    flex: 1 1 30%;
    min-height: 42px;
    padding: 8px 8px;
    font-size: 15px;
    line-height: 1.2;
  }

  .steuerung .knopf-tonne {
    flex: 0 0 42px;
    padding: 0;
  }
}

.karte-vorlesen[data-spricht="ja"] {
  background: color-mix(in srgb, var(--kopflinie) 22%, transparent);
  color: var(--text);
}

.fach-name {
  display: flex;
  align-items: center;
  gap: 3px;
  max-width: 100%;
  height: 18px;
  line-height: 18px;
}

.fach-wort {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.fach-gemerkt {
  margin-left: 4px;
}

.fach-gemerkt .fach-stapel,
.fach-gemerkt .fach-symbol {
  color: var(--kopflinie);
}

.fach-gemerkt .fach-stapel {
  background: repeating-linear-gradient(to top, var(--kopflinie) 0 3px, transparent 3px 5px);
}

.fach-symbol {
  display: none;
  flex: none;
  width: 15px;
  height: 15px;
}

.fach-gemerkt .fach-symbol {
  display: block;
  width: 12px;
  height: 12px;
  fill: currentColor;
}

@media (max-width: 1023px) {
  .fach-symbol {
    display: block;
  }

  .fach-wort.mit-symbol {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }
}

.karte-merken[aria-pressed="true"] {
  color: var(--kopflinie);
}

.karte-merken[aria-pressed="true"] svg.i {
  fill: currentColor;
}
