/* Wiederverwendbare UI-Komponenten. Jede Lerneinheit setzt sich aus diesen Bausteinen zusammen. */

/* ---------- Buttons ---------- */
.btn {
  --btn-bg: var(--surface-3);
  --btn-fg: var(--text);
  --btn-line: var(--line-strong);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 18px;
  border: 1px solid var(--btn-line); border-radius: var(--r-md);
  background: var(--btn-bg); color: var(--btn-fg);
  font-weight: 700; font-size: var(--fs-sm); letter-spacing: 0.01em;
  white-space: nowrap; user-select: none;
  transition: transform var(--t-fast) var(--ease-out), background var(--t-fast), border-color var(--t-fast), box-shadow var(--t-fast), opacity var(--t-fast);
}
.btn:hover { --btn-line: #48506a; }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.42; cursor: not-allowed; transform: none; }
.btn svg { width: 18px; height: 18px; flex: none; }
.btn--primary {
  --btn-bg: linear-gradient(180deg, var(--accent-strong), var(--accent));
  --btn-fg: var(--accent-ink); --btn-line: transparent;
  box-shadow: 0 8px 24px -10px rgba(139, 124, 255, 0.7);
}
.btn--primary:hover { --btn-line: transparent; filter: brightness(1.06); }
.btn--ghost { --btn-bg: transparent; --btn-line: transparent; color: var(--text-2); }
.btn--ghost:hover { --btn-bg: var(--surface-2); color: var(--text); }
.btn--ok { --btn-bg: var(--ok); --btn-fg: #04140d; --btn-line: transparent; }
.btn--lg { min-height: 56px; padding: 0 26px; font-size: var(--fs-md); border-radius: var(--r-lg); }
.btn--block { width: 100%; }
.btn--icon { width: 46px; padding: 0; }
.btn--icon.btn--lg { width: 56px; }
.btn.is-attention { animation: attention 1.6s var(--ease-out) infinite; }
@keyframes attention { 0%, 100% { box-shadow: 0 0 0 0 rgba(139, 124, 255, 0.55); } 50% { box-shadow: 0 0 0 8px rgba(139, 124, 255, 0); } }

/* ---------- Karten ---------- */
.card {
  position: relative;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.025), transparent 40%), var(--surface-1);
  border: 1px solid var(--line); border-radius: var(--r-xl);
  padding: clamp(18px, 3.5vw, 28px);
  box-shadow: var(--shadow-1);
}
.card--tight { padding: 16px; border-radius: var(--r-lg); }
.card__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.card__head p { margin-top: 6px; }

/* Auswahlkarten (Navigation zu Modulen) */
.tile {
  display: flex; flex-direction: column; gap: 10px; text-align: left;
  min-height: 170px; padding: 22px; color: inherit; text-decoration: none;
  background: var(--surface-1); border: 1px solid var(--line); border-radius: var(--r-xl);
  transition: transform var(--t-med) var(--ease-out), border-color var(--t-med), background var(--t-med);
  position: relative; overflow: hidden;
}
.tile::after {
  content: ""; position: absolute; inset: auto -30% -60% auto; width: 220px; height: 220px; border-radius: 50%;
  background: radial-gradient(circle, var(--tile-glow, var(--accent-soft)), transparent 70%);
  pointer-events: none; transition: transform var(--t-med) var(--ease-out);
}
a.tile:hover, button.tile:hover { border-color: var(--line-strong); transform: translateY(-2px); }
a.tile:hover::after { transform: scale(1.15); }
.tile__icon {
  display: grid; place-items: center; width: 46px; height: 46px; border-radius: 14px;
  background: var(--tile-soft, var(--accent-soft)); color: var(--tile-color, var(--accent-strong));
}
.tile__icon svg { width: 24px; height: 24px; }
.tile__title { font-size: var(--fs-lg); font-weight: 800; margin-top: auto; }
.tile__meta { color: var(--text-2); font-size: var(--fs-sm); }
.tile--teal { --tile-glow: var(--teal-soft); --tile-soft: var(--teal-soft); --tile-color: var(--teal); }
.tile--amber { --tile-glow: var(--amber-soft); --tile-soft: var(--amber-soft); --tile-color: var(--amber); }
.tile.is-soon { opacity: 0.55; cursor: default; }
.tile .badge { position: absolute; top: 18px; right: 18px; }

/* ---------- Badges / Hinweise ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: var(--r-pill);
  font-size: var(--fs-xs); font-weight: 750; letter-spacing: 0.02em;
  background: var(--surface-3); color: var(--text-2); border: 1px solid var(--line-strong);
}
.badge--accent { background: var(--accent-soft); color: var(--accent-strong); border-color: transparent; }
.badge--teal { background: var(--teal-soft); color: var(--teal); border-color: transparent; }
.badge--amber { background: var(--amber-soft); color: var(--amber); border-color: transparent; }
.badge--ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge--bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }

.notice {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 14px 16px; border-radius: var(--r-md);
  background: var(--surface-2); border: 1px solid var(--line-strong);
  font-size: var(--fs-sm); color: var(--text-2);
}
.notice svg { width: 20px; height: 20px; flex: none; margin-top: 1px; }
.notice b { color: var(--text); }
.notice--warn { background: var(--amber-soft); border-color: rgba(251, 191, 36, 0.3); }
.notice--warn svg { color: var(--amber); }
.notice--info svg { color: var(--teal); }
.notice--bad { background: var(--bad-soft); border-color: rgba(251, 113, 133, 0.35); }
.notice--bad svg { color: var(--bad); }

/* ---------- Formularelemente ---------- */
.field { display: grid; gap: 8px; }
.field__label { font-size: var(--fs-sm); font-weight: 750; color: var(--text); }
.field__hint { font-size: var(--fs-xs); color: var(--text-3); }
.input, .select {
  width: 100%; min-height: 46px; padding: 0 14px;
  background: var(--field); border: 1px solid var(--line-strong); border-radius: var(--r-md);
  color: var(--text); font-size: var(--fs-md);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.select {
  appearance: none; padding-right: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23b4bccc' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center;
}
.input:focus, .select:focus { border-color: var(--accent); box-shadow: var(--shadow-focus); outline: none; }

/* Segmentierte Auswahl (Radio-Gruppe) */
.segmented {
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px;
  padding: 4px; border-radius: var(--r-md); background: var(--field); border: 1px solid var(--line-strong);
}
.segmented--wrap { grid-auto-flow: row; grid-template-columns: repeat(auto-fit, minmax(84px, 1fr)); }
.segmented--grid2 { grid-auto-flow: row; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.segmented--stack { grid-auto-flow: row; grid-template-columns: 1fr; }
@media (min-width: 560px) {
  .segmented--grid2 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .segmented--stack { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
.segmented label { position: relative; min-width: 0; }
.field, .settings-grid > *, .card, .stack > *, .grid-2 > *, .grid-4 > * { min-width: 0; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span {
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
  min-height: 42px; padding: 6px 10px; border-radius: 10px; cursor: pointer;
  font-size: var(--fs-sm); font-weight: 700; color: var(--text-2); line-height: 1.25;
  overflow-wrap: break-word; hyphens: manual;
  transition: background var(--t-fast), color var(--t-fast), transform var(--t-fast) var(--ease-out);
}
.segmented span small { font-size: 0.7rem; font-weight: 600; color: var(--text-3); }
.segmented label:hover span { color: var(--text); }
.segmented input:checked + span { background: var(--surface-3); color: var(--text); box-shadow: 0 1px 0 rgba(255,255,255,.06) inset, 0 4px 14px -6px rgba(0,0,0,.7); }
.segmented input:checked + span small { color: var(--accent-strong); }
.segmented input:focus-visible + span { box-shadow: var(--shadow-focus); }
.segmented input:disabled + span { opacity: 0.4; cursor: not-allowed; }

/* Schalter */
.switch { display: flex; align-items: center; justify-content: space-between; gap: 14px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch__track {
  flex: none; width: 46px; height: 28px; border-radius: var(--r-pill); position: relative;
  background: var(--surface-3); border: 1px solid var(--line-strong); transition: background var(--t-fast);
}
.switch__track::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%;
  background: var(--text-2); transition: transform var(--t-med) var(--ease-spring), background var(--t-fast);
}
.switch input:checked + .switch__track { background: var(--accent); border-color: transparent; }
.switch input:checked + .switch__track::after { transform: translateX(18px); background: #fff; }
.switch input:focus-visible + .switch__track { box-shadow: var(--shadow-focus); }

/* Schieberegler */
.range { width: 100%; accent-color: var(--accent); height: 28px; }
.range-row { display: flex; align-items: center; gap: 14px; }
.range-row output { min-width: 64px; text-align: right; font-family: var(--font-mono); font-size: var(--fs-sm); color: var(--text); }

/* ---------- Fortschritt ---------- */
.progress { position: relative; height: 8px; border-radius: var(--r-pill); background: var(--surface-3); overflow: hidden; }
.progress__bar {
  position: absolute; inset: 0 auto 0 0; width: 0; border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--teal));
  transition: width var(--t-med) var(--ease-out);
}
.progress__bar::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.35), transparent);
  transform: translateX(-100%); animation: shimmer 2.4s ease-in-out infinite;
}
@keyframes shimmer { 60%, 100% { transform: translateX(100%); } }

.ring { --p: 0; --size: 148px; position: relative; width: var(--size); height: var(--size); flex: none; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 10; stroke-linecap: round; }
.ring .ring__track { stroke: var(--surface-3); }
.ring .ring__value { stroke: url(#ringGradient); stroke-dasharray: 100; stroke-dashoffset: calc(100 - var(--p)); transition: stroke-dashoffset 600ms var(--ease-out); }
.ring__label { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.ring__label b { font-family: var(--font-display); font-size: 1.75rem; font-weight: 600; line-height: 1; letter-spacing: -0.02em; }
.ring__label span { color: var(--text-2); font-size: var(--fs-xs); margin-top: 6px; }

/* ---------- Statistik-Kacheln ---------- */
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.stat { padding: 14px; border-radius: var(--r-md); background: var(--surface-2); border: 1px solid var(--line); }
.stat b { display: block; font-family: var(--font-display); font-weight: 600; font-size: var(--fs-xl); }
.stat span { color: var(--text-3); font-size: var(--fs-xs); }
.stat--ok b { color: var(--ok); }
.stat--bad b { color: var(--bad); }

/* ---------- Chips (Schnelleingabe) ---------- */
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding: 2px; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; min-width: 44px; height: 40px; padding: 0 12px; border-radius: 12px;
  background: var(--surface-3); border: 1px solid var(--line-strong);
  font-family: var(--font-mono); font-weight: 700; font-size: var(--fs-md);
  transition: transform var(--t-fast) var(--ease-out), background var(--t-fast);
}
.chip:active { transform: scale(0.92); background: var(--accent-soft); }

/* ---------- Toast ---------- */
.toast-host { position: fixed; left: 50%; top: 16px; transform: translateX(-50%); z-index: 90; display: grid; gap: 8px; width: min(92vw, 420px); pointer-events: none; }
.toast {
  padding: 12px 16px; border-radius: var(--r-md); background: var(--surface-3); border: 1px solid var(--line-strong);
  box-shadow: 0 16px 40px -12px rgba(0,0,0,.7); font-size: var(--fs-sm); font-weight: 650;
  animation: toast-in 240ms var(--ease-out) both;
}
.toast.is-leaving { animation: toast-out 200ms ease-in both; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px) scale(.98); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-6px); } }

/* ---------- Tabelle (Spickzettel / Auswertung) ---------- */
.list { display: grid; gap: 8px; }
.list-row {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 14px;
  padding: 12px 14px; border-radius: var(--r-md); background: var(--surface-2); border: 1px solid var(--line);
}
.list-row__code {
  min-width: 64px; padding: 6px 10px; border-radius: 10px; text-align: center;
  background: var(--accent-soft); color: var(--accent-strong); font-family: var(--font-mono); font-weight: 700;
}
.list-row__body { min-width: 0; }
.list-row__body .ru-line { font-weight: 700; }
.list-row__body .tr-line { color: var(--text-3); font-size: var(--fs-sm); }
.list-row__body .de-line { color: var(--text-2); font-size: var(--fs-sm); }
.list-row.is-wrong { border-color: rgba(251, 113, 133, 0.35); }
.list-row.is-wrong .list-row__code { background: var(--bad-soft); color: var(--bad); }
.answer-pair { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 4px; font-size: var(--fs-sm); }
.answer-pair .yours { color: var(--bad); text-decoration: line-through; text-decoration-thickness: 1.5px; font-family: var(--font-mono); }
.answer-pair .right { color: var(--ok); font-family: var(--font-mono); font-weight: 700; }

details.disclosure { border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface-1); }
details.disclosure > summary {
  list-style: none; cursor: pointer; padding: 16px 18px; font-weight: 750;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
details.disclosure > summary::-webkit-details-marker { display: none; }
details.disclosure > summary::after { content: "+"; font-size: 1.3rem; color: var(--text-3); transition: transform var(--t-fast); }
details.disclosure[open] > summary::after { transform: rotate(45deg); }
details.disclosure > .disclosure__body { padding: 0 18px 18px; display: grid; gap: 12px; }
.variant-line { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 4px 0; }
.variant-line + .variant-line { border-top: 1px solid var(--line); }

/* Teil-Einstellungen (z. B. Zahlen: zweistellig / dreistellig) */
.part-editor { display: grid; gap: 14px; padding: 16px; border-radius: var(--r-lg); background: var(--surface-2); border: 1px solid var(--line); }
.part-editor__head { display: flex; align-items: center; gap: 12px; }
.part-editor__num {
  display: grid; place-items: center; width: 28px; height: 28px; border-radius: 9px; flex: none;
  background: var(--teal-soft); color: var(--teal); font-weight: 800; font-size: var(--fs-sm);
}
