/* --------------------------------------------------------------------------
   Gebärden-Lernplattform — Grundgestaltung
   Mobil zuerst: gelernt wird meistens auf dem Handy, nicht am Schreibtisch.
   -------------------------------------------------------------------------- */

:root {
  --bg: #f6f6f3;
  --surface: #ffffff;
  --surface-2: #eeeeea;
  --text: #1b1b18;
  --text-dim: #5f6058;
  --border: #e0e0d8;
  --accent: #2f6f4e;
  --accent-text: #ffffff;
  --accent-soft: #e4f0e9;

  /* Bewertungsfarben. Auf Weiß geprüft — alle über 4,5:1 (WCAG AA),
     denn die Beschriftungen sind klein und müssen im Sonnenlicht lesbar sein. */
  --again: #b8442f; /* 5,4:1 */
  --hard: #96631c; /* 5,1:1 */
  --good: #2f6f4e; /* 6,0:1 */
  --easy: #2f5f8f; /* 6,7:1 */

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgb(0 0 0 / 6%), 0 4px 12px rgb(0 0 0 / 4%);
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15171a;
    --surface: #1d2024;
    --surface-2: #262a2f;
    --text: #e9e9e4;
    --text-dim: #9aa0a6;
    --border: #2f343a;
    --accent: #6fbf95;
    --accent-text: #10241a;
    --accent-soft: #1f3830;

    --again: #e0705a;
    --hard: #d9a04a;
    --good: #6fbf95;
    --easy: #7aa9d8;
    --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 4px 14px rgb(0 0 0 / 20%);
  }
}

* {
  box-sizing: border-box;
}

/*
  Das hidden-Attribut kommt aus dem Browser-Stylesheet und verliert gegen
  jede eigene display-Regel. Ohne diese Zeile bleibt z. B. der Hinweis
  "Kein Video vorhanden" (display: grid) sichtbar über dem laufenden Video.
*/
[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  font-size: 16px;
}

h1, h2, h3 {
  line-height: 1.25;
  margin: 0 0 0.5em;
  font-weight: 650;
}

h1 { font-size: 1.6rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; }

p { margin: 0 0 1em; }
a { color: var(--accent); }

/* --- Kopfzeile ------------------------------------------------------------ */

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0.6rem 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.brand {
  font-weight: 700;
  letter-spacing: -0.01em;
  text-decoration: none;
  color: var(--text);
  white-space: nowrap;
}

.brand span { color: var(--accent); }

.nav {
  display: flex;
  gap: 0.15rem;
  overflow-x: auto;
  flex: 1;
  scrollbar-width: none;
}
.nav::-webkit-scrollbar { display: none; }

.nav a {
  padding: 0.4rem 0.7rem;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text-dim);
  white-space: nowrap;
  font-size: 0.92rem;
}

.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.topbar .badge {
  background: var(--accent);
  color: var(--accent-text);
  border-radius: 999px;
  padding: 0.05rem 0.45rem;
  font-size: 0.75rem;
  margin-left: 0.3rem;
  font-weight: 700;
}

/* --- Layout --------------------------------------------------------------- */

main {
  max-width: 1080px;
  margin: 0 auto;
  padding: 1.25rem 1rem 5rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem;
  box-shadow: var(--shadow);
}

.grid {
  display: grid;
  gap: 0.9rem;
}

.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }

.row {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  flex-wrap: wrap;
}

.row.between { justify-content: space-between; }
.spacer { flex: 1; }
.stack > * + * { margin-top: 0.9rem; }

.muted { color: var(--text-dim); }
.small { font-size: 0.86rem; }
.center { text-align: center; }
.hidden { display: none !important; }

/* --- Bedienelemente ------------------------------------------------------- */

button, .btn {
  font: inherit;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 0.55rem 0.95rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  transition: background 0.12s, border-color 0.12s;
  /* Auf dem Handy nicht versehentlich Text markieren */
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

button:hover, .btn:hover { background: var(--surface-2); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

button:focus-visible, .btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}
.btn-primary:hover { filter: brightness(1.08); background: var(--accent); }

.btn-big {
  font-size: 1.05rem;
  padding: 0.85rem 1.5rem;
  width: 100%;
}

.btn-ghost { background: transparent; border-color: transparent; color: var(--text-dim); }
.btn-ghost:hover { background: var(--surface-2); }

.btn-sm { padding: 0.3rem 0.6rem; font-size: 0.85rem; }

input, select, textarea {
  font: inherit;
  width: 100%;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
}

textarea { min-height: 8rem; resize: vertical; font-family: var(--font); }

label { display: block; font-weight: 600; font-size: 0.9rem; margin-bottom: 0.3rem; }
.field + .field { margin-top: 0.85rem; }

/* --- Meldungen ------------------------------------------------------------ */

.notice {
  padding: 0.7rem 0.9rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 0.92rem;
}

.notice.error { border-color: var(--again); color: var(--again); background: transparent; }
.notice.ok { border-color: var(--good); color: var(--good); background: transparent; }

#toast {
  position: fixed;
  left: 50%;
  bottom: 1.5rem;
  transform: translateX(-50%) translateY(150%);
  background: var(--text);
  color: var(--bg);
  padding: 0.6rem 1.1rem;
  border-radius: 999px;
  z-index: 100;
  transition: transform 0.25s;
  max-width: 90vw;
  font-size: 0.92rem;
}
#toast.show { transform: translateX(-50%) translateY(0); }

/* --- Kennzahlen ----------------------------------------------------------- */

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem;
  text-align: center;
}

.stat .value { font-size: 1.9rem; font-weight: 700; line-height: 1.1; }
.stat .label { font-size: 0.82rem; color: var(--text-dim); margin-top: 0.2rem; }
.stat.accent .value { color: var(--accent); }

.progress {
  height: 7px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
}
.progress > div { height: 100%; background: var(--accent); border-radius: 999px; }

/* --- Videoplayer ---------------------------------------------------------- */

.player {
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  position: relative;
  aspect-ratio: 4 / 3;
  max-height: 52vh;
  margin: 0 auto;
  width: 100%;
  max-width: 460px;
}

.player video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  background: #000;
}

.player video.mirrored { transform: scaleX(-1); }

.player .player-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #888;
  font-size: 0.9rem;
  text-align: center;
  padding: 1rem;
}

.player-controls {
  display: flex;
  gap: 0.4rem;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 0.6rem;
}

.speed-group { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.speed-group button {
  border: 0;
  border-radius: 0;
  padding: 0.35rem 0.6rem;
  font-size: 0.85rem;
  background: var(--surface);
}
.speed-group button + button { border-left: 1px solid var(--border); }
.speed-group button.active { background: var(--accent); color: var(--accent-text); }

/* --- Lernen --------------------------------------------------------------- */

.study-shell { max-width: 560px; margin: 0 auto; }

.study-progress {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-bottom: 0.8rem;
}
.study-progress .progress { flex: 1; }

.prompt {
  text-align: center;
  padding: 1.2rem 0.5rem;
}
.prompt .term { font-size: 2rem; font-weight: 700; line-height: 1.2; }
.prompt .sense { color: var(--text-dim); font-size: 0.95rem; }

.direction-tag {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-dim);
}

.grades {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.4rem;
  margin-top: 0.9rem;
}

.grade {
  flex-direction: column;
  gap: 0.1rem;
  padding: 0.7rem 0.2rem;
  border-width: 1px;
  border-style: solid;
  background: var(--surface);
}
.grade .g-label { font-size: 0.9rem; font-weight: 700; }
.grade .g-time { font-size: 0.72rem; opacity: 0.75; font-weight: 500; }
.grade .g-key { font-size: 0.65rem; opacity: 0.5; }

.grade[data-grade="1"] { border-color: var(--again); color: var(--again); }
.grade[data-grade="2"] { border-color: var(--hard); color: var(--hard); }
.grade[data-grade="3"] { border-color: var(--good); color: var(--good); }
.grade[data-grade="4"] { border-color: var(--easy); color: var(--easy); }

.grade:hover { background: var(--surface-2); }

/* --- Quiz ----------------------------------------------------------------- */

.quiz-options { display: grid; gap: 0.5rem; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.quiz-option { padding: 0.8rem; font-size: 1rem; }
.quiz-option.correct { border-color: var(--good); background: var(--accent-soft); color: var(--good); }
.quiz-option.wrong { border-color: var(--again); color: var(--again); }

/* --- Karten und Decks ----------------------------------------------------- */

.deck-item {
  display: flex;
  gap: 0.9rem;
  align-items: center;
  padding: 0.85rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: inherit;
}
.deck-item:hover { border-color: var(--accent); }
.deck-item .deck-main { flex: 1; min-width: 0; }
.deck-item .deck-name { font-weight: 650; }

.pill {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-dim);
  white-space: nowrap;
}
.pill.due { background: var(--accent); color: var(--accent-text); }
.pill.new { background: var(--easy); color: #fff; }
.pill.warn { background: var(--hard); color: #fff; }

.card-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.card-tile .thumb {
  aspect-ratio: 4 / 3;
  background: #000;
  position: relative;
  cursor: pointer;
}
.card-tile .thumb video, .card-tile .thumb img {
  width: 100%; height: 100%; object-fit: contain; display: block;
}
.card-tile .thumb .placeholder {
  position: absolute; inset: 0; display: grid; place-items: center;
  color: #777; font-size: 0.8rem; text-align: center; padding: 0.5rem;
}
.card-tile .body { padding: 0.6rem 0.7rem; flex: 1; display: flex; flex-direction: column; gap: 0.25rem; }
.card-tile .term { font-weight: 650; line-height: 1.3; }

/* --- Heatmap -------------------------------------------------------------- */

.heatmap { display: flex; gap: 3px; overflow-x: auto; padding-bottom: 0.4rem; }
.heatmap .week { display: grid; grid-template-rows: repeat(7, 1fr); gap: 3px; }
.heatmap .day {
  width: 11px; height: 11px; border-radius: 2px;
  background: var(--surface-2);
}
.heatmap .day[data-level="1"] { background: color-mix(in srgb, var(--accent) 30%, var(--surface-2)); }
.heatmap .day[data-level="2"] { background: color-mix(in srgb, var(--accent) 55%, var(--surface-2)); }
.heatmap .day[data-level="3"] { background: color-mix(in srgb, var(--accent) 78%, var(--surface-2)); }
.heatmap .day[data-level="4"] { background: var(--accent); }

.bars { display: flex; align-items: flex-end; gap: 4px; height: 110px; }
.bars .bar { flex: 1; background: var(--accent); border-radius: 3px 3px 0 0; min-height: 2px; }
.bars .bar.empty { background: var(--surface-2); }

/* --- Suche ---------------------------------------------------------------- */

.search-result-tile { position: relative; }
.search-result-tile .added {
  position: absolute; top: 0.4rem; right: 0.4rem;
  background: var(--accent); color: var(--accent-text);
  border-radius: 999px; padding: 0.1rem 0.5rem; font-size: 0.72rem; font-weight: 700;
}

/* --- Dialoge -------------------------------------------------------------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgb(0 0 0 / 55%);
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 1rem;
  overflow-y: auto;
}

.modal-box {
  max-width: 460px;
  width: 100%;
  max-height: 92vh;
  overflow-y: auto;
}

/* --- Grammatik ------------------------------------------------------------ */

.prose { max-width: 62ch; }
.prose h2 { margin-top: 1.8rem; padding-bottom: 0.3rem; border-bottom: 1px solid var(--border); }
.prose h3 { margin-top: 1.3rem; color: var(--accent); }
.prose ul, .prose ol { padding-left: 1.3rem; }
.prose li { margin-bottom: 0.4rem; }
.prose blockquote {
  margin: 1rem 0; padding: 0.7rem 1rem;
  border-left: 3px solid var(--accent); background: var(--surface);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.prose code {
  background: var(--surface-2); padding: 0.1rem 0.35rem;
  border-radius: 4px; font-size: 0.9em;
}

/* --- Anmeldeseite --------------------------------------------------------- */

.auth-shell {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 1.5rem 1rem;
}
.auth-box { width: 100%; max-width: 400px; }
.auth-box h1 { text-align: center; margin-bottom: 0.2rem; }
.auth-tabs { display: flex; gap: 0.3rem; margin-bottom: 1.1rem; }
.auth-tabs button { flex: 1; }
.auth-tabs button.active { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }

/* --- Ladeanzeige ---------------------------------------------------------- */

.spinner {
  width: 18px; height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--border) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: var(--radius-sm);
}
@keyframes shimmer { to { background-position: -200% 0; } }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* --- Größere Bildschirme -------------------------------------------------- */

@media (min-width: 700px) {
  h1 { font-size: 2rem; }
  main { padding: 1.75rem 1.25rem 4rem; }
  .btn-big { width: auto; }
}
