/* ==========================================================
   Arabisch für Kinder – Grundstil
   Logische CSS-Eigenschaften (inline-start/end) → funktioniert
   automatisch in RTL (Arabisch) und LTR (Deutsch/Englisch).
   Schriften lokal gehostet (DSGVO, keine Google Fonts).
   ========================================================== */

@font-face { font-family: "Naskh"; src: url("../fonts/noto-naskh-arabic-arabic-400-normal.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Naskh"; src: url("../fonts/noto-naskh-arabic-arabic-700-normal.woff2") format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Nunito"; src: url("../fonts/nunito-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Nunito"; src: url("../fonts/nunito-latin-700-normal.woff2") format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Nunito"; src: url("../fonts/nunito-latin-800-normal.woff2") format("woff2"); font-weight: 800; font-display: swap; }

:root {
  --bg: #fdf8f1;
  --surface: #ffffff;
  --surface-2: #f6efe4;
  --ink: #23303a;
  --ink-soft: #5b6872;
  --line: #e6dccd;
  --primary: #0f766e;
  --primary-ink: #ffffff;
  --primary-soft: #d6f0ec;
  --accent: #f08a24;
  --accent-soft: #fde7cf;
  --danger: #b42318;
  --danger-soft: #fde4e1;
  --ok: #2f7d32;
  --ok-soft: #e1f3e2;
  --warn: #9a6700;
  --warn-soft: #fff1c7;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 2px 0 rgba(35, 48, 58, .06), 0 8px 24px rgba(35, 48, 58, .06);
  --font: "Nunito", "Naskh", system-ui, -apple-system, "Segoe UI", sans-serif;
}

[dir="rtl"] { --font: "Naskh", "Nunito", system-ui, "Segoe UI", sans-serif; }

*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 1.0625rem;
  line-height: 1.7;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

[dir="rtl"] body { font-size: 1.15rem; line-height: 1.9; }

main { flex: 1; }

a { color: var(--primary); text-underline-offset: 3px; }
a:hover { color: #0b5b55; }

h1, h2, h3 { line-height: 1.3; margin-block: 0 .6em; }
h1 { font-size: clamp(1.6rem, 4vw, 2.4rem); font-weight: 800; }
h2 { font-size: 1.4rem; font-weight: 700; }
h3 { font-size: 1.15rem; font-weight: 700; }
p { margin-block: 0 1em; }

.container { width: min(1120px, 100% - 32px); margin-inline: auto; }
.narrow { width: min(560px, 100% - 32px); margin-inline: auto; }
.stack > * + * { margin-block-start: 1rem; }
.muted { color: var(--ink-soft); }
.small { font-size: .9rem; }
.center { text-align: center; }
.mt { margin-block-start: 1.5rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Kopfzeile ---------- */
.site-header {
  background: var(--surface);
  border-block-end: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.site-header .container { display: flex; align-items: center; gap: 1rem; min-height: 68px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: .6rem; font-weight: 800; font-size: 1.25rem; color: var(--ink); text-decoration: none; }
.brand-mark {
  display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px;
  background: var(--primary); color: #fff; font-family: "Naskh", serif; font-size: 1.4rem; font-weight: 700;
}
.nav { display: flex; align-items: center; gap: .25rem; margin-inline-start: auto; flex-wrap: wrap; }
.nav a, .nav button.linklike {
  padding: .4rem .75rem; border-radius: 999px; text-decoration: none; color: var(--ink); font-weight: 600;
  background: none; border: 0; font: inherit; cursor: pointer;
}
.nav a:hover, .nav button.linklike:hover, .nav a[aria-current="page"] { background: var(--surface-2); }
.nav form { margin: 0; }

.menu-toggle { display: none; margin-inline-start: auto; }

.lang-switch { display: flex; gap: .25rem; padding: .2rem; background: var(--surface-2); border-radius: 999px; }
.lang-switch a { padding: .2rem .6rem; border-radius: 999px; font-size: .85rem; text-decoration: none; color: var(--ink-soft); font-weight: 700; }
.lang-switch a[aria-current="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

@media (max-width: 760px) {
  .menu-toggle { display: inline-flex; }
  .nav { display: none; width: 100%; flex-direction: column; align-items: stretch; padding-block-end: 1rem; }
  .nav.open { display: flex; }
  .nav a, .nav button.linklike { text-align: start; }
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .7rem 1.25rem; border-radius: 999px; border: 2px solid transparent;
  font: inherit; font-weight: 700; text-decoration: none; cursor: pointer; line-height: 1.2;
  transition: transform .08s ease, background .15s ease;
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible, .input:focus-visible, a:focus-visible, select:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.btn-primary { background: var(--primary); color: var(--primary-ink); }
.btn-primary:hover { background: #0b5b55; color: #fff; }
.btn-accent { background: var(--accent); color: #2b1600; }
.btn-accent:hover { background: #dd7612; color: #2b1600; }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-ok { background: var(--ok-soft); color: var(--ok); }
.btn-ok:hover { background: var(--ok); color: #fff; }
.btn-sm { padding: .35rem .8rem; font-size: .9rem; }
.btn-lg { padding: 1rem 1.75rem; font-size: 1.2rem; }
.btn-block { width: 100%; }
.btn-row { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

/* ---------- Karten & Raster ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.5rem; box-shadow: var(--shadow); }
.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.page { padding-block: 2.5rem 4rem; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-block-end: 1.5rem; }
.page-head h1 { margin: 0; }

/* ---------- Startseite ---------- */
.hero { padding-block: 3.5rem 2.5rem; }
.hero-inner { display: grid; grid-template-columns: 1.2fr .8fr; gap: 2rem; align-items: center; }
.hero p { font-size: 1.15rem; color: var(--ink-soft); max-width: 46ch; }
.hero-art {
  aspect-ratio: 1; border-radius: 32px; background: var(--primary-soft);
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; padding: 18px;
}
.hero-art span {
  display: grid; place-items: center; border-radius: 18px; background: var(--surface);
  font-family: "Naskh", serif; font-weight: 700; font-size: clamp(1.6rem, 5vw, 2.6rem); color: var(--primary);
  box-shadow: var(--shadow);
}
.hero-art span:nth-child(3n+2) { background: var(--accent-soft); color: #9a4a00; }
@media (max-width: 760px) { .hero-inner { grid-template-columns: 1fr; } .hero-art { max-width: 320px; } }

.feature .icon {
  width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center;
  background: var(--accent-soft); font-size: 1.5rem; margin-block-end: .75rem;
}

.levels { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); counter-reset: lvl; }
.level-card { position: relative; padding: 1.25rem; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); }
.level-card .num {
  display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 50%;
  background: var(--primary); color: #fff; font-weight: 800; margin-block-end: .5rem;
}
.level-card.current { border: 2px solid var(--accent); background: var(--accent-soft); }
.level-card.done .num { background: var(--ok); }

/* ---------- Formulare ---------- */
.form { display: grid; gap: 1rem; }
.field { display: grid; gap: .35rem; }
.label { font-weight: 700; }
.input, select.input, textarea.input {
  width: 100%; padding: .7rem .9rem; border: 2px solid var(--line); border-radius: var(--radius-sm);
  background: #fff; color: var(--ink); font: inherit;
}
.input:focus { border-color: var(--primary); outline: none; }
.input[aria-invalid="true"] { border-color: var(--danger); }
.input.ltr { direction: ltr; text-align: start; }
[dir="rtl"] .input.ltr { text-align: right; }
.hint { font-size: .88rem; color: var(--ink-soft); }
.error { font-size: .9rem; color: var(--danger); font-weight: 700; }
.check { display: flex; gap: .6rem; align-items: flex-start; }
.check input { width: 1.2rem; height: 1.2rem; margin-block-start: .35rem; accent-color: var(--primary); flex: none; }

.avatar-pick { display: flex; gap: .5rem; flex-wrap: wrap; }
.avatar-pick label { cursor: pointer; }
.avatar-pick input { position: absolute; opacity: 0; }
.avatar-pick span {
  display: grid; place-items: center; width: 52px; height: 52px; border-radius: 14px; font-size: 1.6rem;
  border: 2px solid var(--line); background: #fff;
}
.avatar-pick input:checked + span { border-color: var(--primary); background: var(--primary-soft); }
.avatar-pick input:focus-visible + span { outline: 3px solid var(--accent); }

/* ---------- Meldungen ---------- */
.alert { padding: .9rem 1.1rem; border-radius: var(--radius-sm); margin-block-end: 1rem; font-weight: 600; }
.alert-ok { background: var(--ok-soft); color: var(--ok); }
.alert-error { background: var(--danger-soft); color: var(--danger); }
.alert-info { background: var(--primary-soft); color: #0b5b55; }
.alert-warn { background: var(--warn-soft); color: var(--warn); }

/* ---------- Tabellen ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: .75rem 1rem; text-align: start; border-block-end: 1px solid var(--line); vertical-align: middle; }
.table th { background: var(--surface-2); font-size: .88rem; color: var(--ink-soft); white-space: nowrap; }
.table tr:last-child td { border-block-end: 0; }
.table .email { direction: ltr; unicode-bidi: isolate; }

.badge { display: inline-block; padding: .1rem .6rem; border-radius: 999px; font-size: .82rem; font-weight: 700; white-space: nowrap; }
.badge-unverified { background: var(--surface-2); color: var(--ink-soft); }
.badge-pending { background: var(--warn-soft); color: var(--warn); }
.badge-active { background: var(--ok-soft); color: var(--ok); }
.badge-suspended, .badge-rejected { background: var(--danger-soft); color: var(--danger); }
.badge-role { background: var(--primary-soft); color: #0b5b55; }

.tabs { display: flex; gap: .4rem; flex-wrap: wrap; margin-block-end: 1rem; }
.tabs a { padding: .4rem .9rem; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); text-decoration: none; color: var(--ink); font-weight: 700; font-size: .92rem; }
.tabs a[aria-current="page"] { background: var(--ink); color: #fff; border-color: var(--ink); }
.tabs .count { opacity: .7; margin-inline-start: .25rem; }

.toolbar { display: flex; gap: .5rem; flex-wrap: wrap; margin-block-end: 1rem; }
.toolbar .input { width: auto; flex: 1 1 220px; }

details.inline-form summary { cursor: pointer; list-style: none; }
details.inline-form summary::-webkit-details-marker { display: none; }
details.inline-form[open] { background: var(--surface-2); padding: .75rem; border-radius: var(--radius-sm); }
details.inline-form form { margin-block-start: .5rem; display: grid; gap: .5rem; }

.pagination { display: flex; gap: .3rem; flex-wrap: wrap; margin-block-start: 1rem; list-style: none; padding: 0; }
.pagination a, .pagination span { display: inline-block; padding: .3rem .7rem; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); text-decoration: none; }

/* ---------- Kinderbereich ---------- */
.kid-body { background: linear-gradient(180deg, #e7f6f3 0%, var(--bg) 60%); }
.kid-login .card { border-radius: 28px; padding: 2rem; }
.kid-login .input { font-size: 1.4rem; text-align: center; padding: .9rem; }
.pin-input { letter-spacing: .6em; direction: ltr; }
.kid-hello { display: flex; align-items: center; gap: 1rem; }
.kid-avatar {
  width: 72px; height: 72px; border-radius: 22px; display: grid; place-items: center;
  font-size: 2.4rem; background: var(--surface); box-shadow: var(--shadow);
}
.child-row { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.child-row .kid-avatar { width: 56px; height: 56px; font-size: 1.8rem; border-radius: 16px; }
.child-row .grow { flex: 1 1 200px; }

/* ---------- Fußzeile ---------- */
.site-footer { border-block-start: 1px solid var(--line); padding-block: 1.5rem; color: var(--ink-soft); font-size: .92rem; }
.site-footer .container { display: flex; gap: 1rem; flex-wrap: wrap; justify-content: space-between; }
.site-footer nav { display: flex; gap: 1rem; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
.kid-avatar.centered { margin-inline: auto; }

/* Menü-Knopf nur auf schmalen Bildschirmen (.btn setzt sonst display:inline-flex) */
.btn.menu-toggle { display: none; }
@media (max-width: 760px) { .btn.menu-toggle { display: inline-flex; } }
.pin-code { font-size: 1.4rem; font-weight: 800; letter-spacing: .3em; background: var(--accent-soft); padding: .1rem .6rem; border-radius: 8px; }

/* ---------- Lern-Player ---------- */
[hidden] { display: none !important; }
.ar { font-family: "Naskh", serif; }
.player-wrap .page-head { margin-block-end: 1rem; }
.player-title { font-size: 1.3rem; }
.player .card { border-radius: 28px; padding: 2rem 1.25rem; }
.letter-big { font-size: clamp(6rem, 22vw, 9rem); line-height: 1.1; color: var(--primary); font-weight: 700; }
.letter-big.small { font-size: 5rem; }
.letter-name { font-size: 1.8rem; }
.center-row { justify-content: center; }
.speak-btn {
  display: inline-flex; align-items: center; gap: .4rem; border: 0; cursor: pointer;
  background: var(--primary-soft); color: #0b5b55; border-radius: 999px; padding: .6rem 1rem; font: inherit; font-size: 1.3rem;
}
.speak-btn.big { font-size: 3rem; padding: 1.2rem 1.6rem; }
.speak-btn:hover { background: #c3e8e2; }
.harakat-row { display: flex; gap: .75rem; justify-content: center; flex-wrap: wrap; }
.haraka-btn {
  display: grid; place-items: center; min-width: 96px; padding: .5rem 1rem; border-radius: 20px; cursor: pointer;
  border: 2px solid var(--line); background: #fff; font-size: 3rem; color: var(--ink);
}
.haraka-btn small { font-size: .9rem; }
.word-card {
  display: grid; justify-items: center; gap: .2rem; padding: 1rem 2rem; border-radius: 24px; cursor: pointer;
  border: 2px solid var(--line); background: #fff; font: inherit; margin-inline: auto;
}
.word-card.static { cursor: default; }
.word-card .emoji, .opt .emoji { font-size: 3.2rem; line-height: 1.2; }
.word-card .word { font-size: 2.4rem; }
.word-card .meaning { color: var(--ink-soft); }
.instruction { font-size: 1.2rem; font-weight: 700; }
.prompt { display: grid; justify-items: center; gap: .75rem; }
.options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; }
.opt {
  min-height: 92px; border-radius: 22px; border: 3px solid var(--line); background: #fff; cursor: pointer;
  font: inherit; font-size: 2.6rem; display: grid; place-items: center; gap: .2rem; padding: .5rem; color: var(--ink);
}
.options-words .opt { font-size: 1.6rem; }
.opt:hover:not(:disabled) { border-color: var(--primary); }
.opt:disabled { cursor: default; }
.opt.correct { border-color: var(--ok); background: var(--ok-soft); }
.opt.wrong { border-color: var(--danger); background: var(--danger-soft); }
.opt.picked { border-color: var(--primary); background: var(--primary-soft); }
.feedback { min-height: 1.6em; font-weight: 800; font-size: 1.2rem; }
.feedback.ok { color: var(--ok); }
.feedback.no { color: var(--danger); }
.progressbar { height: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.progressbar .fill { display: block; height: 100%; width: 0; background: var(--accent); transition: width .3s ease; }
.stars { font-size: 3rem; color: #f2b100; letter-spacing: .2em; }
.big-emoji { font-size: 4rem; }
.result-level { font-size: 1.3rem; font-weight: 800; }
.text-lesson .arabic-block { font-size: 2rem; line-height: 2; white-space: pre-line; }
.text-lesson .explain { text-align: start; }

/* Lektionsübersicht */
.lesson-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: .75rem; }
.lesson-tile {
  display: grid; justify-items: center; gap: .1rem; padding: 1rem .5rem; border-radius: 22px; text-decoration: none;
  background: #fff; border: 2px solid var(--line); color: var(--ink); box-shadow: var(--shadow);
}
.lesson-tile:hover { border-color: var(--primary); color: var(--ink); }
.lesson-tile.done { border-color: var(--ok); background: var(--ok-soft); }
.lesson-tile.locked { opacity: .55; box-shadow: none; }
.tile-letter { font-size: 2.8rem; line-height: 1.2; color: var(--primary); }
.tile-emoji { font-size: 1.4rem; }
.tile-stars { color: #f2b100; letter-spacing: .1em; }
.continue-card { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.big-letter-inline { font-size: 2.6rem; margin: 0; color: var(--primary); }

/* ---------- Admin: Inhalte ---------- */
.tr-fields { border: 0; padding: 0; margin: 0; display: grid; gap: .5rem; }
.tr-row { display: grid; grid-template-columns: 90px 1fr; gap: .5rem; align-items: start; }
.tr-lang { font-size: .85rem; color: var(--ink-soft); padding-block-start: .7rem; }
.ar-input { font-family: "Naskh", serif; font-size: 1.3rem; }
.clip-row { display: grid; grid-template-columns: 1fr auto; gap: .5rem 1rem; align-items: center; padding: .75rem; border-radius: var(--radius-sm); border: 1px solid var(--line); }
.clip-row.is-recording { border-color: var(--danger); background: var(--danger-soft); }
.clip-row audio { grid-column: 1 / -1; width: 100%; height: 36px; }
.clip-row .btn-row { grid-column: 1 / -1; }
.clip-text { display: grid; }
.clip-ar { font-size: 1.8rem; line-height: 1.4; }
.file-btn { cursor: pointer; }
.upload-form { margin: 0; }
.post-thumb { max-width: 220px; border-radius: var(--radius-sm); }
.post-image { width: 100%; border-radius: var(--radius); }
.post-card { display: flex; gap: 1rem; align-items: flex-start; flex-wrap: wrap; }
.post-card h2 { margin: 0; }
.post-card h2 a { text-decoration: none; color: var(--ink); }
.event-date { font-weight: 700; color: var(--primary); margin: 0; }
.prose { line-height: 1.8; }
.prose h2, .prose h3 { margin-block-start: 1.4em; }
.prose ul, .prose ol { padding-inline-start: 1.4em; }
