/* ============================================
   KidsLang — UI Components
   ============================================ */

/* ---------- زر أساسي كبير للأطفال ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-3);
  min-height: var(--tap-min);
  padding: var(--sp-3) var(--sp-6);
  border-radius: var(--radius-full);
  font-family: inherit;
  font-size: var(--fs-lg);
  font-weight: 700;
  color: var(--text-onfill);
  background: var(--color-coral);
  box-shadow: var(--shadow-press);
  transition: transform var(--t-fast) var(--ease-out),
              box-shadow var(--t-fast) var(--ease-out),
              background var(--t-fast);
  touch-action: manipulation;
}

.btn:hover { background: #FF5A5A; }
.btn:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 rgba(45, 42, 74, 0.15);
}

.btn--primary { background: var(--color-coral); }
.btn--mint    { background: var(--color-mint); }
.btn--sun     { background: var(--color-sun); color: var(--color-ink); }
.btn--ghost   {
  background: transparent;
  color: var(--text-strong);
  box-shadow: inset 0 0 0 3px var(--color-ink);
}
.btn--ghost:hover { background: rgba(45, 42, 74, 0.05); }

.btn--lg { font-size: var(--fs-xl); padding: var(--sp-4) var(--sp-7); }
.btn--sm { font-size: var(--fs-sm); min-height: 44px; padding: var(--sp-2) var(--sp-4); }
.btn--block { width: 100%; }

/* ---------- بطاقة عامة ---------- */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: var(--sp-5);
  box-shadow: var(--shadow-md);
}

/* ---------- بطاقة قابلة للنقر ---------- */
.tap-card {
  position: relative;
  min-height: var(--tap-min);
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: var(--sp-4);
  box-shadow: var(--shadow-press);
  transition: transform var(--t-fast) var(--ease-out),
              box-shadow var(--t-fast) var(--ease-out);
  cursor: pointer;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
}
.tap-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.tap-card:active { transform: translateY(1px); }

.tap-card.is-correct {
  background: var(--color-success);
  color: var(--text-onfill);
  animation: pulse-success var(--t-slow);
}
.tap-card.is-wrong {
  background: var(--color-error);
  color: var(--text-onfill);
  animation: shake var(--t-slow);
}

/* ---------- شارة XP ---------- */
.xp-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-4);
  background: var(--color-sun);
  color: var(--color-ink);
  border-radius: var(--radius-full);
  font-weight: 700;
  box-shadow: var(--shadow-sm);
}
.xp-badge::before { content: "⭐"; }

/* ---------- شريط تقدم ---------- */
.progress {
  width: 100%;
  height: 14px;
  background: rgba(45, 42, 74, 0.1);
  border-radius: var(--radius-full);
  overflow: hidden;
}
.progress__bar {
  height: 100%;
  background: linear-gradient(90deg, var(--color-mint), var(--color-success));
  border-radius: inherit;
  transition: width var(--t-slow) var(--ease-out);
}

/* ---------- شريط علوي للدرس ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding: var(--sp-3) var(--sp-4);
}
.topbar__close {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--bg-card);
  display: grid;
  place-items: center;
  font-size: var(--fs-lg);
  box-shadow: var(--shadow-sm);
}
.topbar__progress { flex: 1; }

/* ---------- شبكة الاختيارات ---------- */
.choice-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--sp-4);
  margin-top: var(--sp-5);
}
@media (min-width: 768px) {
  .choice-grid { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
}

.choice-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: var(--sp-4);
  box-shadow: var(--shadow-press);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-3);
  cursor: pointer;
  transition: transform var(--t-fast) var(--ease-out);
  aspect-ratio: 1;
}
.choice-card__image {
  width: 80%;
  height: 70%;
  background: var(--bg-soft);
  border-radius: var(--radius-md);
  display: grid;
  place-items: center;
  font-size: 64px;
}
.choice-card__label {
  font-size: var(--fs-md);
  font-weight: 600;
}
.choice-card:hover { transform: translateY(-3px); }
.choice-card:active { transform: scale(0.97); }
.choice-card.is-correct { background: var(--color-success); color: var(--text-onfill); }
.choice-card.is-correct .choice-card__image { background: rgba(255,255,255,0.3); }
.choice-card.is-wrong { background: var(--color-error); color: var(--text-onfill); }

/* ---------- سؤال الدرس ---------- */
.question {
  text-align: center;
  padding: var(--sp-5) var(--sp-4);
}
.question__instruction {
  font-size: var(--fs-md);
  color: var(--text-soft);
  margin-bottom: var(--sp-4);
}
.question__word {
  font-size: var(--fs-3xl);
  font-weight: 700;
  color: var(--color-coral);
  margin-bottom: var(--sp-4);
}
.question__speak-btn {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--color-mint);
  color: white;
  font-size: 36px;
  margin: 0 auto;
  box-shadow: var(--shadow-md);
  display: grid;
  place-items: center;
}
.question__speak-btn:active { transform: scale(0.95); }

/* ---------- شخصية الـ Mascot ---------- */
.mascot {
  font-size: 96px;
  display: inline-block;
  animation: float 3s ease-in-out infinite;
}
.mascot--big { font-size: 140px; }
.mascot--small { font-size: 56px; }
.mascot__bubble {
  position: relative;
  background: var(--bg-card);
  padding: var(--sp-4) var(--sp-5);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  max-width: 320px;
  margin: var(--sp-3) auto;
  font-weight: 600;
}
.mascot__bubble::after {
  content: '';
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  border: 10px solid transparent;
  border-bottom-color: var(--bg-card);
}

/* ---------- خريطة الدروس (شجرة) ---------- */
.lesson-tree {
  display: flex;
  flex-direction: column;
  gap: var(--sp-5);
  margin-top: var(--sp-5);
}
.lesson-node {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: var(--color-mint);
  color: white;
  font-size: 40px;
  display: grid;
  place-items: center;
  box-shadow: var(--shadow-press);
  cursor: pointer;
  position: relative;
  margin: 0 auto;
  transition: transform var(--t-normal) var(--ease-bounce);
}
.lesson-node:hover { transform: scale(1.08); }
.lesson-node.is-locked {
  background: rgba(45, 42, 74, 0.15);
  color: rgba(255,255,255,0.6);
  cursor: not-allowed;
}
.lesson-node.is-current {
  background: var(--color-coral);
  animation: pulse-current 2s ease-in-out infinite;
}
.lesson-node.is-done {
  background: var(--color-sun);
  color: var(--color-ink);
}
.lesson-node__label {
  position: absolute;
  bottom: -28px;
  font-size: var(--fs-sm);
  color: var(--text-strong);
  white-space: nowrap;
}

/* ترتيب متعرّج للعقد */
.lesson-tree .lesson-node:nth-child(odd) { transform: translateX(-40px); }
.lesson-tree .lesson-node:nth-child(even) { transform: translateX(40px); }
@media (min-width: 768px) {
  .lesson-tree .lesson-node:nth-child(odd) { transform: translateX(-80px); }
  .lesson-tree .lesson-node:nth-child(even) { transform: translateX(80px); }
}

/* ---------- شاشة المكافأة ---------- */
.reward {
  text-align: center;
  padding: var(--sp-7) var(--sp-4);
}
.reward__title {
  font-size: var(--fs-2xl);
  font-weight: 700;
  color: var(--color-coral);
  margin: var(--sp-4) 0;
}
.reward__stats {
  display: flex;
  justify-content: center;
  gap: var(--sp-5);
  margin: var(--sp-5) 0;
  flex-wrap: wrap;
}
.reward__stat {
  background: var(--bg-card);
  padding: var(--sp-4);
  border-radius: var(--radius-lg);
  min-width: 100px;
  box-shadow: var(--shadow-md);
}
.reward__stat-value {
  font-size: var(--fs-2xl);
  font-weight: 700;
  color: var(--color-mint);
}
.reward__stat-label {
  font-size: var(--fs-sm);
  color: var(--text-soft);
}

/* ---------- مفتاح اختيار اللغة ---------- */
.lang-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--sp-4);
  margin: var(--sp-5) 0;
}
@media (min-width: 600px) {
  .lang-grid { grid-template-columns: repeat(2, 1fr); max-width: 500px; margin-inline: auto; }
}
.lang-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: var(--sp-5) var(--sp-3);
  text-align: center;
  cursor: pointer;
  box-shadow: var(--shadow-press);
  transition: transform var(--t-fast) var(--ease-out);
  min-height: 140px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
}
.lang-card:hover { transform: translateY(-3px); }
.lang-card.is-selected {
  background: var(--color-mint);
  color: white;
  outline: 4px solid var(--color-success);
  outline-offset: 4px;
}
.lang-card__flag { font-size: 56px; }
.lang-card__name { font-weight: 700; font-size: var(--fs-md); }

/* ---------- العنوان الرئيسي ---------- */
.h1 {
  font-size: var(--fs-2xl);
  font-weight: 700;
  color: var(--color-ink);
  text-align: center;
  margin-bottom: var(--sp-2);
}
.h2 {
  font-size: var(--fs-xl);
  font-weight: 600;
  color: var(--color-ink);
}
.lead {
  text-align: center;
  font-size: var(--fs-md);
  color: var(--text-soft);
  margin-bottom: var(--sp-5);
}

/* ---------- المسافات المنسقة ---------- */
.stack > * + * { margin-top: var(--sp-4); }
.stack-lg > * + * { margin-top: var(--sp-6); }
.center { text-align: center; }
.spacer { flex: 1; }
