/* ---------- Schrift (lokal, keine Verbindung zu Google) ---------- */
@font-face {
  font-family: "Nunito";
  src: url("../fonts/nunito.woff2") format("woff2");
  font-weight: 200 1000;
  font-style: normal;
  font-display: swap;
}

/* ---------- Farben & Grundwerte ---------- */
:root {
  --terracotta: #c8553d;
  --terracotta-dark: #9a3b26;
  --sand: #f6ebd9;
  --sand-deep: #ead8ba;
  --cream: #fffaf2;
  --olive: #6f8a2b;
  --olive-dark: #4d611c;
  --saffron: #f2b134;
  --saffron-dark: #c48614;
  --ink: #3a2a20;
  --muted: #86705f;
  --line: #e3d2b6;

  --radius: 22px;
  --radius-sm: 16px;
  --press: 5px; /* Höhe des "drückbaren" Schattens */
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  font-family: "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--sand);
  color: var(--ink);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  /* Dezentes Kachelmuster wie spanische Fliesen */
  background-image:
    radial-gradient(circle at 0 0, rgba(200, 85, 61, .06) 22px, transparent 23px),
    radial-gradient(circle at 100% 100%, rgba(111, 138, 43, .06) 22px, transparent 23px);
  background-size: 64px 64px;
}

button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }
.nowrap { white-space: nowrap; }

/* ---------- Kopfzeile ---------- */
.topbar {
  max-width: 760px;
  margin: 0 auto;
  padding: 16px 16px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  font-size: 1.6rem;
  font-weight: 900;
  color: var(--terracotta);
  text-decoration: none;
  letter-spacing: -.02em;
}
.logo-mark { color: var(--saffron-dark); }

.streak {
  background: var(--cream);
  border: 2px solid var(--line);
  border-radius: 999px;
  padding: 4px 14px;
  font-weight: 700;
  font-size: .95rem;
}
.streak strong { color: var(--terracotta); }

main {
  max-width: 760px;
  margin: 0 auto;
  padding: 16px 16px 40px;
}

/* ---------- Übersicht ---------- */
.hero { padding: 12px 0 20px; }

.hero h1 {
  font-size: clamp(1.6rem, 5vw, 2.3rem);
  font-weight: 900;
  line-height: 1.15;
  margin: 0 0 8px;
  letter-spacing: -.02em;
}
.hero-sub { margin: 0 0 18px; color: var(--muted); font-size: 1.05rem; }

.overall {
  background: var(--cream);
  border: 2px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
}
.overall-text { font-weight: 700; margin-bottom: 8px; }
.overall-text strong { color: var(--olive); font-size: 1.2rem; }

.bar {
  height: 14px;
  background: var(--sand-deep);
  border-radius: 999px;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  width: 0;
  background: var(--olive);
  border-radius: 999px;
  transition: width .4s ease;
  /* Glanzstreifen für die verspielte Optik */
  box-shadow: inset 0 3px 0 rgba(255, 255, 255, .3);
}

/* Kacheln: Thema + Mischen */
.mix-tile,
.topic-tile {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  text-align: left;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: var(--cream);
  padding: 16px;
  box-shadow: 0 var(--press) 0 var(--line);
  transition: transform .1s, box-shadow .1s;
}
.mix-tile:hover, .topic-tile:hover { border-color: var(--saffron); box-shadow: 0 var(--press) 0 var(--saffron-dark); }
.mix-tile:active, .topic-tile:active { transform: translateY(var(--press)); box-shadow: 0 0 0 transparent; }

.mix-tile {
  background: var(--saffron);
  border-color: var(--saffron-dark);
  box-shadow: 0 var(--press) 0 var(--saffron-dark);
  margin-bottom: 18px;
}
.mix-tile:hover { border-color: var(--saffron-dark); }

.tile-icon {
  flex: 0 0 auto;
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  font-size: 1.8rem;
  background: var(--sand);
  border-radius: 16px;
}
.mix-tile .tile-icon { background: rgba(255, 255, 255, .45); }

.tile-body { flex: 1; min-width: 0; }
.tile-title { display: block; font-weight: 800; font-size: 1.1rem; }
.tile-meta { display: block; color: var(--muted); font-size: .9rem; margin-bottom: 6px; }
.mix-tile .tile-meta { color: var(--ink); opacity: .75; margin: 0; }
.topic-tile .bar { display: block; height: 10px; }
.topic-tile.is-done .bar-fill { background: var(--saffron); }

.topic-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}
@media (min-width: 560px) {
  .topic-grid { grid-template-columns: 1fr 1fr; }
}

.home-footer {
  margin-top: 32px;
  text-align: center;
  color: var(--muted);
  font-size: .9rem;
}
.home-footer p { margin: 0 0 4px; }
.link-btn {
  background: none;
  border: none;
  color: var(--terracotta);
  text-decoration: underline;
  font-weight: 700;
  padding: 4px;
}

/* ---------- Lernrunde ---------- */
.learn-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 6px;
}
.bar-round { flex: 1; height: 16px; }
.round-count { font-weight: 800; color: var(--muted); min-width: 44px; text-align: right; }

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: transparent;
  font-size: 1.3rem;
  color: var(--muted);
}
.icon-btn:hover { background: var(--sand-deep); }

.learn-topic {
  text-align: center;
  color: var(--muted);
  font-weight: 700;
  margin: 8px 0 14px;
}

.card-wrap {
  position: relative;
  max-width: 460px;
  margin: 0 auto;
  perspective: 1200px;
}

.card {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  min-height: 240px;
  padding: 0;
  border: none;
  background: none;
}

.card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform .5s cubic-bezier(.3, 1.4, .5, 1);
  transform-style: preserve-3d;
}
.card.is-flipped .card-inner { transform: rotateY(180deg); }

.card-face {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 24px;
  border-radius: 28px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  text-align: center;
}

.card-front {
  background: var(--cream);
  border: 3px solid var(--line);
  box-shadow: 0 8px 0 var(--line);
}
.card-back {
  background: var(--terracotta);
  color: var(--cream);
  border: 3px solid var(--terracotta-dark);
  box-shadow: 0 8px 0 var(--terracotta-dark);
  transform: rotateY(180deg);
}

.card-lang {
  position: absolute;
  top: 16px;
  left: 20px;
  font-size: .8rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .08em;
  opacity: .6;
}
.card-word {
  font-size: clamp(1.8rem, 7vw, 2.6rem);
  font-weight: 900;
  line-height: 1.15;
  word-break: break-word;
}
.card-tip { color: var(--muted); font-size: .9rem; font-weight: 600; }
.card-note {
  font-size: .95rem;
  font-weight: 600;
  background: rgba(255, 255, 255, .16);
  border-radius: 12px;
  padding: 6px 12px;
  max-width: 100%;
}
.card-note:empty { display: none; }

/* Lautsprecher liegt über der Rückseite (kein Button im Button) */
.speak-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 3px solid var(--saffron-dark);
  background: var(--saffron);
  font-size: 1.4rem;
  box-shadow: 0 4px 0 var(--saffron-dark);
  z-index: 2;
}
.speak-btn:active { transform: translateY(4px); box-shadow: none; }

.level-dots {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 18px;
}
.level-dots span {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--sand-deep);
}
.level-dots span.on { background: var(--olive); }

.actions {
  max-width: 460px;
  margin: 22px auto 0;
}
.rate {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* ---------- Buttons ---------- */
.btn {
  display: block;
  border-radius: var(--radius-sm);
  border: none;
  padding: 16px 18px;
  font-weight: 800;
  font-size: 1.05rem;
  letter-spacing: .02em;
  text-transform: uppercase;
  transition: transform .08s, box-shadow .08s, filter .15s;
}
.btn:hover { filter: brightness(1.05); }
.btn:active { transform: translateY(var(--press)); box-shadow: 0 0 0 transparent !important; }
.btn-wide { width: 100%; }

.btn-primary { background: var(--terracotta); color: #fff; box-shadow: 0 var(--press) 0 var(--terracotta-dark); }
.btn-right   { background: var(--olive);      color: #fff; box-shadow: 0 var(--press) 0 var(--olive-dark); }
.btn-wrong   { background: var(--cream); color: var(--terracotta); border: 2px solid var(--terracotta); box-shadow: 0 var(--press) 0 var(--terracotta); }
.btn-ghost   { background: transparent; color: var(--muted); margin-top: 10px; text-transform: none; }

.kbd-hint {
  text-align: center;
  color: var(--muted);
  font-size: .85rem;
  margin-top: 22px;
}
kbd {
  background: var(--cream);
  border: 1px solid var(--line);
  border-bottom-width: 3px;
  border-radius: 6px;
  padding: 1px 6px;
  font-family: inherit;
  font-size: .8rem;
}
/* Tastaturhinweis nur auf Geräten mit Maus */
@media (hover: none) { .kbd-hint { display: none; } }

/* Fokusrahmen für Tastaturnutzer */
:focus-visible { outline: 3px solid var(--saffron-dark); outline-offset: 3px; }

/* ---------- Rundenabschluss ---------- */
.done-box {
  max-width: 460px;
  margin: 24px auto 0;
  text-align: center;
  background: var(--cream);
  border: 3px solid var(--line);
  border-radius: 28px;
  box-shadow: 0 8px 0 var(--line);
  padding: 32px 20px 24px;
}
.done-badge {
  font-size: 3rem;
  width: 88px;
  height: 88px;
  margin: 0 auto 8px;
  display: grid;
  place-items: center;
  background: var(--saffron);
  border-radius: 50%;
  box-shadow: 0 6px 0 var(--saffron-dark);
  animation: pop .5s cubic-bezier(.3, 1.6, .5, 1);
}
.done-box h2 { font-size: 2rem; font-weight: 900; margin: 8px 0 4px; color: var(--terracotta); }
.done-sub { color: var(--muted); margin: 0 0 20px; }

.done-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 24px;
}
.stat {
  border-radius: var(--radius-sm);
  padding: 12px 6px;
  background: var(--sand);
}
.stat strong { display: block; font-size: 1.8rem; font-weight: 900; line-height: 1.1; }
.stat span { font-size: .8rem; font-weight: 700; color: var(--muted); }
.stat-right strong { color: var(--olive); }
.stat-wrong strong { color: var(--terracotta); }
.stat-master strong { color: var(--saffron-dark); }

@keyframes pop {
  0% { transform: scale(.3); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

/* ---------- Konfetti ---------- */
.confetti {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 10;
}
.confetti i {
  position: absolute;
  top: -20px;
  width: 10px;
  height: 14px;
  border-radius: 3px;
  animation: fall linear forwards;
}
@keyframes fall {
  to { transform: translateY(110vh) rotate(720deg); }
}

/* Weniger Bewegung, wenn im System so eingestellt */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
  .confetti { display: none; }
}

/* Kleine Handys: Buttons kompakter, damit der Text in eine Zeile passt */
@media (max-width: 420px) {
  .rate .btn { font-size: .95rem; padding: 16px 8px; letter-spacing: 0; }
}
