/* Qur'an-Wörter — Design-System v2
   Ruhig, buchhaft, würdevoll: tiefes Teal (Tinte) + feines Gold (Mushaf-
   Ornamentik), Serifen-Displayschrift für Titel und Zahlen, klare Sans für
   Fließtext, Naskh für Arabisch. Hell/dunkel, responsiv, reduzierte Motion. */

:root {
  --accent: #0e7268;
  --accent-strong: #0a5d55;
  --accent-soft: rgba(14, 114, 104, 0.1);
  --gold: #b8912f;
  --gold-soft: rgba(184, 145, 47, 0.35);
  --bg: #f3f4f2;
  --card: #ffffff;
  --text: #1b2528;
  --text-secondary: #5f6b6e;
  --border: rgba(27, 37, 40, 0.09);
  --shadow: 0 1px 2px rgba(27, 37, 40, 0.05), 0 10px 28px -18px rgba(27, 37, 40, 0.25);
  --red: #c04a4a;
  --red-soft: rgba(192, 74, 74, 0.1);
  --orange: #b56a1e;
  --orange-soft: rgba(181, 106, 30, 0.1);
  --blue: #3a6ea5;
  --blue-soft: rgba(58, 110, 165, 0.1);
  --green: #2e8b4f;
  --radius: 16px;
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --arabic-font: "KFGQPC Uthman Taha Naskh", "Geeza Pro", "Al Bayan",
    "Noto Naskh Arabic", "Traditional Arabic", "Amiri", serif;
}
/* Dunkles Farbschema: greift bei data-theme="dark" oder — im System-Modus —
   wenn das Betriebssystem Dunkelmodus meldet. */
:root[data-theme="dark"] {
  --accent: #3aaf9f;
  --accent-strong: #4cc4b3;
  --accent-soft: rgba(58, 175, 159, 0.14);
  --gold: #d0ab52;
  --gold-soft: rgba(208, 171, 82, 0.35);
  --bg: #131719;
  --card: #1d2326;
  --text: #eef1f1;
  --text-secondary: #98a4a6;
  --border: rgba(238, 241, 241, 0.09);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 12px 30px -18px rgba(0, 0, 0, 0.6);
  --red: #d97070;
  --red-soft: rgba(217, 112, 112, 0.13);
  --orange: #d29050;
  --orange-soft: rgba(210, 144, 80, 0.13);
  --blue: #7aa3d0;
  --blue-soft: rgba(122, 163, 208, 0.13);
  --green: #67b385;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) {
    --accent: #3aaf9f;
    --accent-strong: #4cc4b3;
    --accent-soft: rgba(58, 175, 159, 0.14);
    --gold: #d0ab52;
    --gold-soft: rgba(208, 171, 82, 0.35);
    --bg: #131719;
    --card: #1d2326;
    --text: #eef1f1;
    --text-secondary: #98a4a6;
    --border: rgba(238, 241, 241, 0.09);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 12px 30px -18px rgba(0, 0, 0, 0.6);
    --red: #d97070;
    --red-soft: rgba(217, 112, 112, 0.13);
    --orange: #d29050;
    --orange-soft: rgba(210, 144, 80, 0.13);
    --blue: #7aa3d0;
    --blue-soft: rgba(122, 163, 208, 0.13);
    --green: #67b385;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

/* ---- Layout: Sidebar (Desktop) / Tabbar (Mobil) ---- */
#app {
  display: grid;
  grid-template-areas: "brand main" "nav main";
  grid-template-columns: 232px 1fr;
  grid-template-rows: auto 1fr;
  min-height: 100vh;
}
#brand {
  grid-area: brand;
  padding: 24px 20px 8px;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 11px;
}
.brand-logo { width: 64px; height: 64px; border-radius: 14px; flex: none; }
.onboarding-logo { width: 116px; height: 116px; border-radius: 26px; }
/* Logo-Variante folgt dem Farbschema (wie die Farb-Tokens) */
.logo-dark { display: none; }
:root[data-theme="dark"] .logo-light { display: none; }
:root[data-theme="dark"] .logo-dark { display: inline-block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) .logo-light { display: none; }
  :root:not([data-theme="light"]):not([data-theme="dark"]) .logo-dark { display: inline-block; }
}
.brand-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.01em;
}
#nav { grid-area: nav; padding: 14px 12px; display: flex; flex-direction: column; gap: 2px; }
#nav a {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 13px;
  border-radius: 11px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14.5px;
  font-weight: 500;
  transition: background 0.15s ease, color 0.15s ease;
}
#nav a:hover { color: var(--text); background: var(--accent-soft); }
#nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
#nav .icon { display: inline-flex; }
.ic { width: 19px; height: 19px; flex: none; vertical-align: -4px; }

#main {
  grid-area: main;
  padding: 28px clamp(16px, 4vw, 48px) 104px;
  max-width: 760px;
  width: 100%;
  margin: 0 auto;
  animation: view-in 0.22s ease both;
}
@keyframes view-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

@media (max-width: 820px) {
  #app {
    grid-template-areas: "brand" "main" "nav";
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr auto;
  }
  #brand { padding: 12px 16px 4px; }
  .brand-logo { width: 44px; height: 44px; border-radius: 10px; }
  #nav {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    flex-direction: row;
    justify-content: space-around;
    background: var(--card);
    border-top: 1px solid var(--border);
    padding: 8px 4px calc(8px + env(safe-area-inset-bottom));
    z-index: 40;
  }
  #nav a { flex-direction: column; gap: 3px; padding: 4px 10px; font-size: 10.5px; border-radius: 9px; }
  #nav a.active { background: none; }
}

/* ---- Typografie ---- */
h1.page-title {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 600;
  letter-spacing: 0.005em;
  margin: 4px 0 18px;
}
h2.section { font-size: 16px; margin: 24px 0 10px; }
.muted { color: var(--text-secondary); }
.small { font-size: 13px; }
.footnote { font-size: 12.5px; color: var(--text-secondary); margin: 10px 2px 0; line-height: 1.55; }

/* ---- Karten & Bausteine ---- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.card h3 {
  margin: 0 0 12px;
  font-size: 11.5px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 7px;
}
.card h3 .ic { width: 15px; height: 15px; color: var(--accent); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.card.stat { padding: 18px 20px; }
.stat-icon { color: var(--accent); display: inline-flex; }
.stat-icon .ic { width: 20px; height: 20px; }
.stat-value {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 600;
  margin: 6px 0 2px;
  font-variant-numeric: oldstyle-nums;
}
.stat-label { color: var(--text-secondary); font-size: 12.5px; }

progress {
  width: 100%;
  height: 7px;
  appearance: none;
  border: none;
  border-radius: 4px;
  overflow: hidden;
  background: var(--accent-soft);
}
progress::-webkit-progress-bar { background: var(--accent-soft); }
progress::-webkit-progress-value { background: var(--accent); border-radius: 4px; }
progress::-moz-progress-bar { background: var(--accent); }

.btn {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border: none;
  border-radius: 13px;
  padding: 13px 18px;
  font-size: 15.5px;
  font-weight: 600;
  cursor: pointer;
  background: var(--accent-soft);
  color: var(--accent);
  width: 100%;
  margin-bottom: 10px;
  font-family: inherit;
  transition: transform 0.12s ease, filter 0.15s ease;
}
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-strong); }
.btn.compact { width: auto; padding: 9px 15px; font-size: 14px; margin: 0; }
.btn.danger { background: var(--red-soft); color: var(--red); }
.btn:active { transform: scale(0.985); }
.btn .ic { width: 17px; height: 17px; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

.chip {
  display: inline-block;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  border-radius: 999px;
  padding: 3px 11px;
  margin: 2px;
}

/* ---- Arabisch ---- */
.arabic {
  font-family: var(--arabic-font);
  direction: rtl;
  unicode-bidi: isolate;
  line-height: 1.9;
}
.arabic.xl { font-size: clamp(46px, 9vw, 66px); text-align: center; }
.arabic.lg { font-size: 34px; text-align: center; }
.arabic.md { font-size: 26px; }
.arabic.sm { font-size: 21px; }

/* ---- Lernkarte: 3D-Flip mit Mushaf-Ornament ---- */
.flashcard-scene {
  perspective: 1400px;
  height: clamp(340px, 52vh, 460px);
  margin-bottom: 4px;
}
.flashcard3d {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.55s cubic-bezier(0.2, 0.7, 0.25, 1);
  cursor: pointer;
}
.flashcard3d.is-flipped { transform: rotateY(180deg); }
.face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow-y: auto;
  display: flex;
}
.face.back { transform: rotateY(180deg); }
.face-inner {
  margin: auto;
  width: 100%;
  padding: 34px 24px 26px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
}
/* Ornament: feine Goldlinie mit Stern — Anklang an Mushaf-Seitenrahmen */
.face::before {
  content: "";
  position: absolute;
  top: 15px; left: 26px; right: 26px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold-soft) 18%, var(--gold-soft) 82%, transparent);
  pointer-events: none;
}
.face::after {
  content: "✦";
  position: absolute;
  top: 4px; left: 50%;
  transform: translateX(-50%);
  font-size: 12px;
  color: var(--gold);
  background: var(--card);
  padding: 0 10px;
  pointer-events: none;
}
.flashcard3d .translit { font-style: italic; color: var(--text-secondary); font-size: 17px; }
.flashcard3d .meaning { font-size: 22px; font-weight: 650; line-height: 1.35; }
.present-line { font-size: 14px; color: var(--text-secondary); }
.present-line .arabic { font-size: 22px; line-height: 1.4; }
.example-block {
  margin-top: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  width: 100%;
}
.example-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  padding: 7px 16px;
  cursor: pointer;
  font-family: inherit;
  margin-top: 6px;
}
.example-toggle:hover { background: var(--accent-soft); border-color: var(--accent); }
/* Hervorgehobene Fundform des Wortes im Vers */
.hl { color: var(--gold); font-weight: 600; }

@media (prefers-reduced-motion: reduce) {
  .flashcard3d { transition: none; }
  #main { animation: none; }
  .btn { transition: none; }
}

/* ---- Bewertungs-Buttons mit Zeitvorschau ---- */
.review-buttons { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 14px; }
.review-buttons .btn {
  flex-direction: column;
  margin: 0;
  padding: 10px 4px 9px;
  gap: 1px;
  min-height: 58px;
}
.review-buttons .btn span { font-size: 14px; font-weight: 650; }
.review-buttons .btn small { font-size: 11px; font-weight: 500; opacity: 0.75; }
.btn.rate-again { background: var(--red-soft); color: var(--red); }
.btn.rate-hard { background: var(--orange-soft); color: var(--orange); }
.btn.rate-good { background: var(--accent-soft); color: var(--accent); }
.btn.rate-easy { background: var(--blue-soft); color: var(--blue); }

.hint-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 12px auto 0;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 12.5px;
  cursor: pointer;
  font-family: inherit;
  padding: 6px 10px;
  border-radius: 8px;
}
.hint-toggle:hover { color: var(--accent); background: var(--accent-soft); }
.hint-toggle .ic { width: 16px; height: 16px; flex: none; }
/* Label klappt bei Hover/Fokus rechts neben dem Fragezeichen auf */
.hint-toggle .hint-label {
  max-width: 0;
  overflow: hidden;
  white-space: nowrap;
  opacity: 0;
  transition: max-width 0.25s ease, opacity 0.2s ease;
}
.hint-toggle:hover .hint-label,
.hint-toggle:focus-visible .hint-label { max-width: 140px; opacity: 1; }
.hint-box { border-left: 3px solid var(--gold); margin-top: 14px; }

/* ---- Quiz ---- */
.quiz-option {
  width: 100%;
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: 13px;
  padding: 14px 16px;
  margin-bottom: 10px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  color: var(--text);
  text-align: center;
  font-family: inherit;
  transition: border-color 0.15s ease, transform 0.12s ease;
}
.quiz-option:not(:disabled):hover { border-color: var(--accent); }
.quiz-option:not(:disabled):active { transform: scale(0.99); }
.quiz-option.correct { border-color: var(--green); }
.quiz-option.wrong { border-color: var(--red); }
.quiz-option:disabled { cursor: default; }
.result-arabic { font-size: 24px; line-height: 1.6; }
.quiz-score {
  font-family: var(--font-display);
  font-size: 54px;
  font-weight: 650;
  color: var(--accent);
  text-align: center;
  margin: 18px 0 2px;
}

/* ---- Wörterliste ---- */
.searchbar {
  width: 100%;
  padding: 12px 15px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-size: 16px;
  margin-bottom: 10px;
  font-family: inherit;
}
.searchbar:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; align-items: center; }
.filters select {
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-size: 13.5px;
  font-family: inherit;
}
.filters label.toggle { font-size: 13px; color: var(--text-secondary); display: flex; gap: 5px; align-items: center; }
.filters input[type="checkbox"] { accent-color: var(--accent); }
.word-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 13px;
  padding: 12px 16px;
  margin-bottom: 8px;
  text-decoration: none;
  color: var(--text);
  transition: transform 0.12s ease, border-color 0.15s ease;
}
.word-row:hover { transform: translateY(-1px); border-color: var(--accent); }
.word-row .meanings { min-width: 0; }
.word-row .de { font-size: 15px; font-weight: 550; }
.word-row .sub { font-size: 12.5px; color: var(--text-secondary); font-style: italic; }
.word-row .learned-dot { color: var(--accent); font-size: 11px; }

/* ---- Detailseite ---- */
.hero-card { text-align: center; padding: 30px 20px 24px; }
.hero-card .translit { font-style: italic; color: var(--text-secondary); font-size: 18px; margin-top: 2px; }
.review-card { border-left: 3px solid var(--orange); }
.kv {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
  font-size: 15px;
}
.kv:last-of-type { border-bottom: none; }
.kv .k { color: var(--text-secondary); flex: none; }
.kv .v { text-align: right; }
a.similar-row { text-decoration: none; color: var(--text); border-radius: 8px; }
a.similar-row:hover { background: var(--accent-soft); }
a.similar-row .k { color: var(--text); }
.forms-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-cell {
  background: var(--accent-soft);
  border-radius: 12px;
  padding: 12px;
  text-align: center;
}
.forms-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-secondary);
  margin-bottom: 4px;
}
.pager { display: flex; justify-content: space-between; gap: 10px; margin: 18px 0 6px; }
.pager.pager-top { margin: 0 0 14px; }
.theme-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.theme-row .choice { margin-bottom: 0; padding: 12px 10px; justify-content: center; gap: 7px; font-size: 14.5px; }

/* ---- Onboarding-Overlay ---- */
#overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 100;
  overflow-y: auto;
  padding: 36px 20px 44px;
}
.onboarding { max-width: 520px; margin: 0 auto; text-align: center; }
.onboarding .big-icon { font-family: var(--arabic-font); font-size: 52px; color: var(--gold); }
.onboarding h1 { font-family: var(--font-display); font-size: 27px; font-weight: 600; }
.onboarding .claim { text-align: left; }
.choice {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: 13px;
  padding: 15px 18px;
  margin-bottom: 10px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  color: var(--text);
  font-family: inherit;
  transition: border-color 0.15s ease;
}
.choice:hover { border-color: var(--accent); }
.choice.selected { border-color: var(--accent); }
.choice .check { color: var(--accent); }

.empty-state { text-align: center; padding: 52px 16px; }
.empty-state .icon { color: var(--accent); }
.empty-state .icon .ic { width: 44px; height: 44px; }
.empty-state h2 { font-family: var(--font-display); font-size: 20px; font-weight: 600; }
.loading { text-align: center; padding: 60px; color: var(--text-secondary); }
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 12px;
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
}
.back-link .ic { width: 15px; height: 15px; }
a { color: var(--accent); }
