/* Elementary Persian — learning app */

:root {
  --bg: #0f1115;
  --surface: #171a21;
  --surface-2: #1f2330;
  --border: #2a2f3d;
  --text: #e8eaef;
  --muted: #9aa0ad;
  --accent: #58a6ff;
  --accent-2: #4ade80;
  --error: #f87171;
  --warn: #fbbf24;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,0.3), 0 8px 24px rgba(0,0,0,0.25);
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f7f8fa;
    --surface: #ffffff;
    --surface-2: #f1f3f6;
    --border: #e3e6ec;
    --text: #1a1d23;
    --muted: #5c6573;
    --accent: #2563eb;
    --accent-2: #16a34a;
    --error: #dc2626;
    --warn: #d97706;
    --shadow: 0 1px 2px rgba(0,0,0,0.04), 0 6px 18px rgba(0,0,0,0.06);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 16px;
  line-height: 1.55;
  min-height: 100vh;
}

/* RTL Persian text — used wherever we render Persian script */
.fa, [lang="fa"] {
  font-family: 'Vazirmatn', 'Iran Sans', Tahoma, sans-serif;
  direction: rtl;
  unicode-bidi: isolate;
  font-size: 1.15em;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0.9rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand {
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--text);
  text-decoration: none;
}
.brand-fa {
  font-family: 'Vazirmatn', sans-serif;
  font-weight: 500;
  margin-left: 0.4rem;
  color: var(--accent);
}
.topbar nav {
  display: flex;
  gap: 1rem;
  flex: 1;
}
.topbar nav a {
  color: var(--muted);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.95rem;
}
.topbar nav a:hover { color: var(--text); }
.topbar nav a.active { color: var(--accent); }

.streak {
  font-size: 0.9rem;
  color: var(--muted);
}

main {
  max-width: 760px;
  margin: 2rem auto;
  padding: 0 1.25rem;
}

footer {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--muted);
  font-size: 0.85rem;
  border-top: 1px solid var(--border);
  margin-top: 4rem;
}

h1, h2, h3 { color: var(--text); margin-top: 0; }
h1 { font-size: 1.85rem; }
h2 { font-size: 1.35rem; margin-top: 1.5rem; }
h3 { font-size: 1.1rem; }

p { color: var(--text); }
a { color: var(--accent); }

/* Lesson list cards */
.card-list { display: grid; gap: 0.9rem; margin-top: 1.5rem; }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  text-decoration: none;
  color: inherit;
  display: block;
  transition: transform .12s ease, border-color .12s ease;
}
.card:hover { transform: translateY(-2px); border-color: var(--accent); }
.card .meta { color: var(--muted); font-size: 0.85rem; margin-top: 0.4rem; }
.card .title { font-weight: 600; font-size: 1.1rem; }
.card .badge {
  display: inline-block;
  background: var(--surface-2);
  color: var(--muted);
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  margin-left: 0.5rem;
}
.card.completed { border-color: var(--accent-2); }
.card.completed .badge { background: rgba(74, 222, 128, 0.15); color: var(--accent-2); }

/* Lesson view */
.lesson-section { margin-bottom: 2rem; }
.lesson-section h2 { border-bottom: 1px solid var(--border); padding-bottom: 0.4rem; }
.example-list { display: grid; gap: 0.6rem; margin: 1rem 0; }
.example {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.8rem 1rem;
}
.example .ex-fa { font-size: 1.3rem; margin-bottom: 0.2rem; }
.example .ex-translit { color: var(--muted); font-size: 0.9rem; font-style: italic; }
.example .ex-en { color: var(--text); font-weight: 500; }

table.grid { width: 100%; border-collapse: collapse; margin: 1rem 0; }
table.grid th, table.grid td {
  border: 1px solid var(--border);
  padding: 0.5rem 0.75rem;
  text-align: left;
}
table.grid th { background: var(--surface-2); font-weight: 600; }

.letters-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 0.75rem; margin: 1rem 0; }
.letter-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem;
  text-align: center;
}
.letter-card .letter {
  font-family: 'Vazirmatn', sans-serif;
  font-size: 2.6rem;
  line-height: 1;
  margin-bottom: 0.3rem;
}
.letter-card .name { font-weight: 600; }
.letter-card .sound { color: var(--muted); font-size: 0.85rem; }
.letter-card .note { font-size: 0.78rem; color: var(--muted); margin-top: 0.3rem; }

/* Buttons */
button, .btn {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 0.65rem 1.2rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: filter .12s ease, transform .12s ease;
}
button:hover, .btn:hover { filter: brightness(1.08); }
button:active, .btn:active { transform: translateY(1px); }
button:disabled { opacity: 0.5; cursor: not-allowed; }
button.secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
button.ghost { background: transparent; color: var(--text); border: 1px solid var(--border); }

.row { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: center; }
.right { margin-inline-start: auto; }

/* Exercise UI */
.exercise-shell {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

.progress-bar {
  background: var(--surface-2);
  border-radius: 999px;
  height: 8px;
  overflow: hidden;
  margin-bottom: 1.5rem;
}
.progress-bar > div {
  background: var(--accent-2);
  height: 100%;
  transition: width .3s ease;
}

.prompt { font-size: 1.05rem; font-weight: 500; margin-bottom: 1rem; }
.prompt-fa { font-size: 1.6rem; margin: 0.5rem 0 1rem; }

/* MCQ options */
.options { display: grid; gap: 0.5rem; margin-top: 0.5rem; }
.option {
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 0.8rem 1rem;
  cursor: pointer;
  font: inherit;
  text-align: left;
  color: var(--text);
  transition: border-color .12s ease, background .12s ease;
}
.option:hover { border-color: var(--accent); }
.option.selected { border-color: var(--accent); background: rgba(88, 166, 255, 0.08); }
.option.correct { border-color: var(--accent-2); background: rgba(74, 222, 128, 0.12); }
.option.incorrect { border-color: var(--error); background: rgba(248, 113, 113, 0.10); }
.option.fa { font-size: 1.3rem; }

/* Word bank (translation) */
.composed {
  min-height: 60px;
  background: var(--surface-2);
  border: 1.5px dashed var(--border);
  border-radius: 8px;
  padding: 0.6rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
  margin-bottom: 0.75rem;
}
.composed.fa { direction: rtl; }
.bank { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.token {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 6px;
  padding: 0.4rem 0.75rem;
  cursor: pointer;
  font-family: 'Vazirmatn', sans-serif;
  font-size: 1.15rem;
  user-select: none;
}
.token.used { opacity: 0.35; cursor: default; }

/* Match pairs */
.match-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.match-col { display: grid; gap: 0.5rem; }
.match-cell {
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  cursor: pointer;
  font-size: 1.05rem;
}
.match-cell.fa { font-family: 'Vazirmatn', sans-serif; font-size: 1.3rem; direction: rtl; text-align: right; }
.match-cell:hover { border-color: var(--accent); }
.match-cell.selected { border-color: var(--accent); background: rgba(88,166,255,0.10); }
.match-cell.matched { border-color: var(--accent-2); background: rgba(74,222,128,0.10); cursor: default; }
.match-cell.wrong { border-color: var(--error); background: rgba(248,113,113,0.10); }

/* Fill input */
input.fill-input {
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 0.7rem 1rem;
  font: inherit;
  color: var(--text);
  width: 100%;
  font-family: 'Vazirmatn', sans-serif;
  font-size: 1.3rem;
  direction: rtl;
}
input.fill-input:focus { outline: 2px solid var(--accent); outline-offset: 2px; }

textarea.translate-input {
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 0.7rem 1rem;
  font: inherit;
  color: var(--text);
  width: 100%;
  min-height: 60px;
  resize: vertical;
}
textarea.translate-input.fa {
  font-family: 'Vazirmatn', sans-serif;
  font-size: 1.25rem;
  direction: rtl;
}

/* Feedback banner */
.feedback {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-weight: 500;
}
.feedback.correct { background: rgba(74,222,128,0.12); color: var(--accent-2); border: 1px solid var(--accent-2); }
.feedback.incorrect { background: rgba(248,113,113,0.10); color: var(--error); border: 1px solid var(--error); }

/* Result screen */
.result {
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
}
.result .score { font-size: 3rem; font-weight: 700; color: var(--accent-2); }

/* Vocab cards */
.vocab-list { display: grid; gap: 0.5rem; margin-top: 1rem; }
.vocab-row {
  display: grid;
  grid-template-columns: minmax(80px, 1fr) auto 1fr auto;
  gap: 1rem;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem 1rem;
}
.vocab-row .v-fa { font-family: 'Vazirmatn', sans-serif; font-size: 1.4rem; direction: rtl; text-align: right; }
.vocab-row .v-translit { color: var(--muted); font-style: italic; font-size: 0.9rem; }
.vocab-row .v-en { font-weight: 500; }
.vocab-row .v-pos { font-size: 0.75rem; color: var(--muted); text-transform: uppercase; }

/* Flashcard */
.flashcard {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 3rem 2rem;
  text-align: center;
  min-height: 220px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  cursor: pointer;
}
.flashcard .front { font-size: 2.2rem; }
.flashcard .front.fa { font-family: 'Vazirmatn', sans-serif; }
.flashcard .back { color: var(--muted); margin-top: 0.6rem; }

.btn-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.5rem; margin-top: 1rem; }
.btn-row button { padding: 0.7rem 0.4rem; font-size: 0.9rem; }
.btn-again { background: var(--error); }
.btn-hard { background: var(--warn); color: #1a1d23; }
.btn-good { background: var(--accent); }
.btn-easy { background: var(--accent-2); }

@media (max-width: 600px) {
  .topbar { padding: 0.7rem 1rem; gap: 1rem; }
  .topbar nav { gap: 0.7rem; }
  main { margin: 1rem auto; }
  .vocab-row { grid-template-columns: 1fr 1fr; }
  .vocab-row .v-pos, .vocab-row .v-translit { display: none; }
}
