/* ============================================================================
 *  ქართული — стили самоучителя
 * ========================================================================== */

:root {
  --bg: #f4f1ea;
  --bg-soft: #ece7dc;
  --card: #ffffff;
  --card-2: #faf8f3;
  --text: #2b2622;
  --text-soft: #6b6457;
  --muted: #9a9182;
  --border: #e2dccf;
  --accent: #8e2434;        /* грузинский винно-красный */
  --accent-soft: #b8434f;
  --accent-bg: #f7e7e6;
  --gold: #c8922a;
  --green: #2e7d57;
  --green-bg: #e3f1e9;
  --red: #c0392b;
  --red-bg: #fbe7e4;
  --shadow: 0 6px 24px rgba(40, 30, 20, 0.10);
  --shadow-lg: 0 16px 48px rgba(40, 30, 20, 0.18);
  --radius: 16px;
  --radius-sm: 10px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-ka: 'Noto Sans Georgian', 'BPG Nino Mtavruli', var(--font);
}

[data-theme='dark'] {
  --bg: #1c1916;
  --bg-soft: #242019;
  --card: #2a2620;
  --card-2: #322d25;
  --text: #efe9df;
  --text-soft: #c2b8a6;
  --muted: #8a8170;
  --border: #3a342b;
  --accent: #e06472;
  --accent-soft: #c84b59;
  --accent-bg: #3a2024;
  --gold: #e0b154;
  --green: #5cba8a;
  --green-bg: #20322a;
  --red: #e0796d;
  --red-bg: #3a221f;
  --shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

.ka { font-family: var(--font-ka); }

/* ---------- Шапка ---------- */
header.topbar {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 1000px; margin: 0 auto; padding: 12px 20px;
  display: flex; align-items: center; gap: 16px;
}
.brand { display: flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.brand .logo {
  width: 38px; height: 38px; border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-soft));
  color: #fff; display: grid; place-items: center;
  font-family: var(--font-ka); font-size: 22px; font-weight: 700;
  box-shadow: var(--shadow);
}
.brand h1 { font-size: 18px; font-weight: 700; letter-spacing: -0.2px; }
.brand small { display: block; font-size: 11px; color: var(--muted); font-weight: 500; }
.topbar .spacer { flex: 1; }
.icon-btn {
  border: 1px solid var(--border); background: var(--card);
  color: var(--text); width: 40px; height: 40px; border-radius: 10px;
  cursor: pointer; font-size: 18px; display: grid; place-items: center;
  transition: transform .12s, background .2s;
}
.icon-btn:hover { background: var(--card-2); transform: translateY(-1px); }

/* ---------- Навигация (вкладки) ---------- */
nav.tabs {
  max-width: 1000px; margin: 0 auto; padding: 0 12px;
  display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none;
}
nav.tabs::-webkit-scrollbar { display: none; }
nav.tabs button {
  border: none; background: none; color: var(--text-soft);
  padding: 12px 14px; font-size: 14px; font-weight: 600; cursor: pointer;
  border-bottom: 2.5px solid transparent; white-space: nowrap;
  transition: color .2s, border-color .2s; font-family: var(--font);
}
nav.tabs button:hover { color: var(--text); }
nav.tabs button.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ---------- Контейнер ---------- */
main { max-width: 1000px; margin: 0 auto; padding: 24px 20px 80px; }
.view { animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

h2.section-title { font-size: 22px; font-weight: 800; letter-spacing: -0.4px; margin-bottom: 4px; }
p.section-sub { color: var(--text-soft); margin-bottom: 20px; font-size: 14px; }

/* ---------- Карточки-плитки ---------- */
.grid { display: grid; gap: 14px; }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 720px) {
  .grid.cols-3, .grid.cols-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 460px) {
  .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; }
}

.tile {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; cursor: pointer; transition: transform .14s, box-shadow .2s, border-color .2s;
  box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.tile:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: var(--accent-soft); }
.tile .emoji { font-size: 26px; }
.tile h3 { font-size: 16px; font-weight: 700; margin: 8px 0 4px; }
.tile p { font-size: 13px; color: var(--text-soft); }
.tile .badge-row { margin-top: 10px; display: flex; gap: 6px; flex-wrap: wrap; }

.badge {
  font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px;
  background: var(--accent-bg); color: var(--accent);
}
.badge.gray { background: var(--bg-soft); color: var(--text-soft); }
.badge.green { background: var(--green-bg); color: var(--green); }
.badge.gold { background: color-mix(in srgb, var(--gold) 18%, transparent); color: var(--gold); }

/* ---------- Кнопки ---------- */
.btn {
  border: none; border-radius: 12px; padding: 12px 20px; font-size: 15px; font-weight: 700;
  cursor: pointer; font-family: var(--font); transition: transform .12s, filter .2s, background .2s;
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.07); }
.btn.ghost { background: var(--card); color: var(--text); border: 1px solid var(--border); }
.btn.ghost:hover { background: var(--card-2); }
.btn.green { background: var(--green); color: #fff; }
.btn.red { background: var(--red); color: #fff; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; transform: none; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- Дашборд / прогресс ---------- */
.hero {
  background: linear-gradient(135deg, var(--accent), var(--accent-soft));
  color: #fff; border-radius: 22px; padding: 26px; margin-bottom: 22px;
  box-shadow: var(--shadow-lg); position: relative; overflow: hidden;
}
.hero::after {
  content: 'ა'; position: absolute; right: -10px; bottom: -40px; font-size: 200px;
  font-family: var(--font-ka); opacity: .10; font-weight: 700; line-height: 1;
}
.hero h2 { font-size: 26px; font-weight: 800; margin-bottom: 6px; }
.hero p { opacity: .92; font-size: 14px; max-width: 60ch; }
.hero .btn { margin-top: 16px; background: #fff; color: var(--accent); }

.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 22px; }
@media (max-width: 560px) { .stat-row { grid-template-columns: repeat(2, 1fr); } }
.stat {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 16px; text-align: center; box-shadow: var(--shadow);
}
.stat .num { font-size: 28px; font-weight: 800; color: var(--accent); line-height: 1; }
.stat .lbl { font-size: 12px; color: var(--text-soft); margin-top: 6px; font-weight: 600; }

.progress-bar { height: 8px; background: var(--bg-soft); border-radius: 999px; overflow: hidden; }
.progress-bar > span { display: block; height: 100%; background: linear-gradient(90deg, var(--gold), var(--accent)); border-radius: 999px; transition: width .5s; }

/* ---------- Урок (детально) ---------- */
.lesson-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 6px; }
.lesson-head .num {
  width: 36px; height: 36px; flex: 0 0 36px; border-radius: 10px; background: var(--accent); color: #fff;
  display: grid; place-items: center; font-weight: 800; font-size: 15px;
}
.panel {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; margin-bottom: 16px; box-shadow: var(--shadow);
}
.panel h3 { font-size: 16px; font-weight: 800; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.rule-text { white-space: pre-line; color: var(--text-soft); font-size: 14.5px; margin-bottom: 12px; }

.ex {
  display: flex; align-items: center; gap: 12px; padding: 11px 0; border-top: 1px dashed var(--border);
}
.ex:first-of-type { border-top: none; }
.ex .ex-ka { font-family: var(--font-ka); font-size: 18px; font-weight: 600; flex: 1; }
.ex .ex-tr { font-size: 12px; color: var(--muted); font-style: italic; }
.ex .ex-ru { font-size: 13.5px; color: var(--text-soft); flex: 1; text-align: right; }
@media (max-width: 560px) {
  .ex { flex-direction: column; align-items: flex-start; gap: 2px; }
  .ex .ex-ru { text-align: left; }
}
.speak {
  border: 1px solid var(--border); background: var(--card-2); color: var(--accent);
  width: 32px; height: 32px; flex: 0 0 32px; border-radius: 8px; cursor: pointer; font-size: 15px;
  display: grid; place-items: center; transition: background .2s;
}
.speak:hover { background: var(--accent-bg); }

.word-chip {
  display: inline-flex; flex-direction: column; gap: 1px; padding: 8px 12px; border-radius: 10px;
  background: var(--card-2); border: 1px solid var(--border); cursor: pointer; transition: transform .12s, border-color .2s;
}
.word-chip:hover { transform: translateY(-2px); border-color: var(--accent-soft); }
.word-chip .wc-ka { font-family: var(--font-ka); font-size: 17px; font-weight: 700; }
.word-chip .wc-ru { font-size: 12px; color: var(--text-soft); }
.chip-wrap { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- Флеш-карточки ---------- */
.fc-stage { perspective: 1400px; max-width: 520px; margin: 0 auto; }
.flashcard {
  position: relative; width: 100%; aspect-ratio: 3 / 2; cursor: pointer;
  transform-style: preserve-3d; transition: transform .5s cubic-bezier(.4,.2,.2,1);
}
.flashcard.flipped { transform: rotateY(180deg); }
.fc-face {
  position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden;
  background: var(--card); border: 1px solid var(--border); border-radius: 22px;
  box-shadow: var(--shadow-lg); display: flex; flex-direction: column;
  align-items: center; justify-content: center; padding: 24px; text-align: center;
}
.fc-back { transform: rotateY(180deg); background: var(--card-2); }
.fc-face .big-ka { font-family: var(--font-ka); font-size: 52px; font-weight: 700; line-height: 1.1; }
.fc-face .tr { color: var(--muted); font-style: italic; margin-top: 8px; font-size: 16px; }
.fc-face .ru { font-size: 30px; font-weight: 700; }
.fc-face .theme-tag { position: absolute; top: 16px; left: 16px; }
.fc-face .hint { position: absolute; bottom: 14px; font-size: 12px; color: var(--muted); }
.fc-face .speak { position: absolute; top: 12px; right: 12px; width: 40px; height: 40px; font-size: 18px; }

.fc-controls { max-width: 520px; margin: 22px auto 0; }
.fc-progress { text-align: center; color: var(--text-soft); font-size: 13px; margin-bottom: 14px; font-weight: 600; }
.grade-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.grade-row .btn { flex-direction: column; padding: 14px 8px; font-size: 14px; line-height: 1.2; }
.grade-row .btn small { font-weight: 500; opacity: .8; font-size: 11px; }

/* ---------- Тест ---------- */
.quiz-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 26px; box-shadow: var(--shadow); max-width: 560px; margin: 0 auto;
}
.quiz-q { font-size: 14px; color: var(--text-soft); margin-bottom: 6px; font-weight: 600; }
.quiz-prompt { font-size: 38px; font-weight: 700; text-align: center; margin: 14px 0 24px; }
.quiz-prompt.ka { font-family: var(--font-ka); }
.opt {
  display: block; width: 100%; text-align: left; padding: 14px 16px; margin-bottom: 10px;
  border: 1.5px solid var(--border); background: var(--card-2); border-radius: 12px;
  font-size: 16px; cursor: pointer; transition: border-color .15s, background .15s; font-family: var(--font);
  color: var(--text);
}
.opt .ka { font-family: var(--font-ka); }
.opt:hover { border-color: var(--accent-soft); }
.opt.correct { border-color: var(--green); background: var(--green-bg); }
.opt.wrong { border-color: var(--red); background: var(--red-bg); }
.opt:disabled { cursor: default; }
.quiz-input {
  width: 100%; padding: 14px 16px; font-size: 22px; text-align: center; border-radius: 12px;
  border: 1.5px solid var(--border); background: var(--card-2); color: var(--text); font-family: var(--font-ka);
}
.quiz-input:focus { outline: none; border-color: var(--accent); }
.feedback { text-align: center; font-weight: 700; margin: 14px 0; min-height: 24px; }
.feedback.ok { color: var(--green); }
.feedback.no { color: var(--red); }

/* ---------- Домашка: конструктор предложения ---------- */
.hw-prompt {
  font-size: 24px; font-weight: 700; text-align: center; margin: 6px 0 20px; line-height: 1.3;
}
.build-zone {
  min-height: 64px; display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-start;
  padding: 14px; border: 1.5px dashed var(--border); border-radius: 12px; background: var(--bg-soft);
  transition: border-color .2s, background .2s;
}
.build-zone.ok { border-color: var(--green); background: var(--green-bg); border-style: solid; }
.build-zone.no { border-color: var(--red); background: var(--red-bg); border-style: solid; }
.bz-hint { color: var(--muted); font-size: 13px; align-self: center; }
.word-bank {
  display: flex; flex-wrap: wrap; gap: 9px; justify-content: center; margin: 16px 0 6px;
  min-height: 44px;
}
.tile-word {
  font-family: var(--font-ka); font-size: 19px; font-weight: 600;
  padding: 10px 15px; border-radius: 11px; cursor: pointer;
  background: var(--card); color: var(--text); border: 1.5px solid var(--border);
  box-shadow: 0 2px 0 var(--border); transition: transform .1s, box-shadow .1s, background .15s;
}
.tile-word:hover { background: var(--card-2); }
.tile-word:active { transform: translateY(2px); box-shadow: none; }
.tile-word.placed {
  background: var(--accent-bg); border-color: var(--accent-soft); color: var(--accent);
  box-shadow: 0 2px 0 var(--accent-soft);
}

/* ---------- Алфавит ---------- */
.alpha-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 14px; text-align: center; cursor: pointer; transition: transform .12s, box-shadow .2s;
  box-shadow: var(--shadow);
}
.alpha-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.alpha-card .a-ka { font-family: var(--font-ka); font-size: 38px; font-weight: 700; color: var(--accent); }
.alpha-card .a-name { font-size: 13px; color: var(--text-soft); margin-top: 4px; }
.alpha-card .a-tr { font-size: 12px; color: var(--muted); }
.alpha-card .a-sound { font-size: 11.5px; color: var(--text-soft); margin-top: 6px; line-height: 1.3; }

/* ---------- Справочник слов (таблица) ---------- */
.vocab-toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.search {
  flex: 1; min-width: 180px; padding: 11px 14px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--card); color: var(--text); font-size: 14px; font-family: var(--font);
}
.search:focus { outline: none; border-color: var(--accent); }
.select {
  padding: 11px 14px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--card); color: var(--text); font-size: 14px; font-family: var(--font); cursor: pointer;
}
.vocab-list { display: grid; gap: 8px; }
.v-row {
  display: flex; align-items: center; gap: 14px; padding: 12px 16px; background: var(--card);
  border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow);
}
.v-row .v-ka { font-family: var(--font-ka); font-size: 21px; font-weight: 700; min-width: 110px; }
.v-row .v-tr { font-size: 12px; color: var(--muted); font-style: italic; min-width: 90px; }
.v-row .v-ru { flex: 1; font-size: 15px; }
.v-row .v-meta { display: flex; gap: 6px; align-items: center; }
.stars { color: var(--gold); font-size: 12px; letter-spacing: -1px; }
@media (max-width: 560px) {
  .v-row { flex-wrap: wrap; gap: 4px 10px; }
  .v-row .v-ru { flex-basis: 100%; order: 5; }
}

/* ---------- Пусто / завершено ---------- */
.empty {
  text-align: center; padding: 50px 20px; color: var(--text-soft);
}
.empty .big { font-size: 56px; margin-bottom: 12px; }
.empty h3 { font-size: 20px; font-weight: 800; color: var(--text); margin-bottom: 8px; }

/* ---------- Тост ---------- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(40px);
  background: var(--text); color: var(--bg); padding: 12px 22px; border-radius: 999px;
  font-weight: 600; font-size: 14px; box-shadow: var(--shadow-lg); opacity: 0; pointer-events: none;
  transition: opacity .25s, transform .25s; z-index: 100;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

footer.foot { text-align: center; color: var(--muted); font-size: 12px; padding: 20px; }
