/* ============================================================
   منصة معلم من فلسطين — نظام التصميم (وفق 25_ENTERPRISE_DESIGN_SYSTEM)
   ألوان وظيفية، RTL، مناسب للأطفال وصعوبات التعلم
   ============================================================ */
/* 🍉 ثيم البطيخ: أحمر البطيخ + أخضر القشرة + بذور داكنة + خلفية وردية فاتحة */
:root {
  --primary: #d9304f;          /* أحمر البطيخ — الأزرار والعناصر النشطة */
  --primary-dark: #a81e38;
  --primary-light: #fde9ee;
  --secondary: #1e7d3e;        /* أخضر القشرة — العناوين والسبورة */
  --secondary-dark: #14532d;
  --success: #2a9d3a;
  --success-light: #e6f6e8;
  --warning: #d98324;
  --warning-light: #fdf1e0;
  --error: #c22f45;
  --error-light: #fbe9ec;
  --info: #3a7ca5;
  --new-idea: #7d5ba6;         /* البنفسجي: الأفكار الجديدة */
  --seed: #2b2b2b;             /* بذور البطيخ */
  --bg: #fdf7f5;
  --surface: #ffffff;
  --ink: #2b2b2b;
  --ink-soft: #6b5b5e;
  --line: #f0dde0;
  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 2px 10px rgba(168, 30, 56, .08);
  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px;
  --space-5: 24px; --space-6: 32px; --space-7: 48px;
  --font: "Cairo", "Rubik", "Segoe UI", Tahoma, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  direction: ltr;
  line-height: 1.9;
  font-size: 17px;
  -webkit-font-smoothing: antialiased;
}

/* ---------- الترويسة ---------- */
.topbar {
  background: linear-gradient(135deg, var(--secondary-dark), var(--secondary) 55%, var(--primary));
  color: #fff;
  padding: var(--space-4) var(--space-5);
  display: flex; align-items: center; gap: var(--space-4);
  flex-wrap: wrap;
  box-shadow: var(--shadow);
  position: sticky; top: 0; z-index: 50;
}
.topbar .logo {
  width: 46px; height: 46px; border-radius: 12px;
  background: #fff; color: var(--primary);
  display: grid; place-items: center;
  font-size: 26px; font-weight: 800; flex: none;
}
.topbar h1 { font-size: 1.15rem; font-weight: 700; }
.topbar .sub { font-size: .8rem; opacity: .85; }
.topbar .spacer { flex: 1; }
.badge-pwa {
  background: rgba(255,255,255,.15); border: 1px solid rgba(255,255,255,.35);
  border-radius: 999px; padding: 2px 12px; font-size: .75rem;
}

/* ---------- الحاويات ---------- */
.wrap { max-width: 1100px; margin: 0 auto; padding: var(--space-5); }
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: var(--space-5); margin-bottom: var(--space-5);
}
.card > h2, .card > h3 { margin-bottom: var(--space-3); }
h2 { font-size: 1.35rem; color: var(--primary-dark); }
h3 { font-size: 1.1rem; color: var(--secondary); }
p.lead { color: var(--ink-soft); }

/* شارات المصدر: وارد في الـ Outline أو مستنتج */
.src {
  display: inline-block; font-size: .68rem; border-radius: 999px;
  padding: 1px 10px; vertical-align: middle; margin-inline-start: 6px;
}
.src.outline { background: var(--primary-light); color: var(--primary-dark); }
.src.inferred { background: var(--warning-light); color: var(--warning); }

/* ---------- تبويبات الصفوف ---------- */
.tabs { display: flex; gap: var(--space-2); flex-wrap: wrap; margin-bottom: var(--space-4); }
.tab {
  border: 2px solid var(--line); background: var(--surface);
  border-radius: 999px; padding: 8px 20px; cursor: pointer;
  font-family: inherit; font-size: 1rem; font-weight: 600; color: var(--ink-soft);
  transition: all .15s ease; min-height: 48px;
}
.tab:hover { border-color: var(--primary); color: var(--primary); }
.tab.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ---------- الوحدات والدروس ---------- */
.unit {
  border: 1px solid var(--line); border-radius: var(--radius);
  margin-bottom: var(--space-4); overflow: hidden; background: var(--surface);
}
.unit > summary {
  cursor: pointer; padding: var(--space-4) var(--space-5);
  font-weight: 700; color: var(--primary-dark);
  background: var(--primary-light);
  display: flex; align-items: center; gap: var(--space-3); list-style: none;
}
.unit > summary::-webkit-details-marker { display: none; }
.unit > summary .num {
  background: var(--primary); color: #fff; border-radius: 10px;
  width: 34px; height: 34px; display: grid; place-items: center; flex: none;
  font-size: .9rem;
}
.unit > summary .meta { font-size: .78rem; color: var(--ink-soft); font-weight: 400; }
.unit .unit-body { padding: var(--space-4) var(--space-5); }

.lesson-row {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-3); border-bottom: 1px dashed var(--line);
  flex-wrap: wrap;
}
.lesson-row:last-child { border-bottom: none; }
.lesson-row .dot {
  width: 14px; height: 14px; border-radius: 50%; flex: none;
  background: #cfd8dc;
}
.lesson-row .dot.done { background: var(--success); }
.lesson-row .dot.active { background: var(--warning); }
.lesson-row .title { font-weight: 600; flex: 1; min-width: 180px; }
.lesson-row .skills { font-size: .78rem; color: var(--ink-soft); width: 100%; }
.lesson-row a.go, .lesson-row span.soon {
  border-radius: 999px; padding: 6px 18px; font-size: .85rem; text-decoration: none;
  min-height: 40px; display: inline-flex; align-items: center;
}
.lesson-row a.go { background: var(--primary); color: #fff; }
.lesson-row a.go.locked { background: #b8c4bd; pointer-events: none; }
.lesson-row span.soon { background: var(--bg); color: var(--ink-soft); border: 1px dashed var(--line); }

/* ---------- شجرة المهارات ---------- */
.skilltree { overflow-x: auto; padding-bottom: var(--space-3); }
.skilltree .level-row { display: flex; gap: var(--space-3); align-items: stretch; margin-bottom: var(--space-3); }
.skilltree .lvl-label {
  flex: none; width: 130px; border-radius: var(--radius-sm);
  background: var(--secondary); color: #fff; display: grid; place-items: center;
  font-size: .8rem; text-align: center; padding: var(--space-2);
}
.skilltree .nodes { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.skill-node {
  border: 2px solid var(--line); border-radius: var(--radius-sm);
  padding: 6px 14px; font-size: .82rem; background: var(--surface);
  position: relative;
}
.skill-node.essential { border-color: var(--primary); }
.skill-node .dep { display: block; font-size: .68rem; color: var(--ink-soft); }

/* ---------- جدول Scope & Sequence ---------- */
.table-scroll { overflow-x: auto; }
table.scope { border-collapse: collapse; width: 100%; min-width: 760px; font-size: .88rem; }
table.scope th, table.scope td { border: 1px solid var(--line); padding: 8px 12px; text-align: right; vertical-align: top; }
table.scope th { background: var(--primary-light); color: var(--primary-dark); }
table.scope tr:nth-child(even) td { background: #fbfaf7; }

/* ---------- أزرار عامة ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--primary); color: #fff; border: none; cursor: pointer;
  border-radius: 999px; padding: 12px 28px; font-family: inherit;
  font-size: 1rem; font-weight: 700; min-height: 48px;
  transition: transform .1s ease, background .15s;
  text-decoration: none;
}
.btn:hover { background: var(--primary-dark); }
.btn:active { transform: scale(.97); }
.btn.secondary { background: var(--surface); color: var(--primary); border: 2px solid var(--primary); }
.btn.small { padding: 6px 18px; min-height: 40px; font-size: .85rem; }
.btn:disabled { background: #b8c4bd; cursor: not-allowed; }

/* ---------- صفحة الدرس ---------- */
.lesson-nav {
  display: flex; gap: var(--space-2); flex-wrap: wrap; margin-bottom: var(--space-5);
  position: sticky; top: 78px; z-index: 40; background: var(--bg); padding: var(--space-2) 0;
}
.lesson-nav button {
  border: 2px solid var(--line); background: var(--surface); border-radius: 999px;
  padding: 7px 16px; font-family: inherit; font-size: .85rem; font-weight: 600;
  cursor: pointer; color: var(--ink-soft); min-height: 42px;
}
.lesson-nav button.active { background: var(--secondary); border-color: var(--secondary); color: #fff; }
.panel { display: none; }
.panel.show { display: block; animation: fadeIn .25s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; } }

.info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--space-3); }
.info-item { background: var(--primary-light); border-radius: var(--radius-sm); padding: var(--space-3) var(--space-4); }
.info-item b { display: block; color: var(--primary-dark); font-size: .8rem; margin-bottom: 2px; }

.obj-list { list-style: none; }
.obj-list li { padding: var(--space-2) 0; border-bottom: 1px dashed var(--line); }
.obj-list li::before { content: "✓ "; color: var(--success); font-weight: 800; }

/* سيناريو الحصة */
.scenario-step {
  border-inline-start: 4px solid var(--primary); background: var(--surface);
  border-radius: var(--radius-sm); padding: var(--space-4);
  margin-bottom: var(--space-3); box-shadow: var(--shadow);
}
.scenario-step .time {
  display: inline-block; background: var(--secondary); color: #fff;
  border-radius: 999px; padding: 1px 14px; font-size: .75rem; margin-bottom: 6px;
}
.scenario-step h4 { color: var(--primary-dark); margin-bottom: 4px; }
.say { background: #f2f7ff; border-radius: var(--radius-sm); padding: 8px 14px; margin: 6px 0; }
.say b { color: var(--secondary); }
.say.student b { color: var(--new-idea); }
.act-note { font-size: .82rem; color: var(--warning); }

/* السبورة التفاعلية */
.board-wrap { text-align: center; }
canvas.board {
  width: 100%; max-width: 820px; background: #fdfdf8;
  border: 3px solid #8d6e63; border-radius: 10px; touch-action: manipulation;
}
.board-controls { display: flex; gap: var(--space-2); justify-content: center; margin-top: var(--space-3); flex-wrap: wrap; }
.board-caption {
  min-height: 54px; margin-top: var(--space-3); font-weight: 600;
  color: var(--secondary); background: var(--primary-light);
  border-radius: var(--radius-sm); padding: var(--space-3);
}

/* الأنشطة والتمارين */
.activity {
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: var(--space-4); margin-bottom: var(--space-4); background: var(--surface);
}
.activity h4 { color: var(--primary-dark); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.activity .tag {
  font-size: .7rem; border-radius: 999px; padding: 2px 12px;
  background: var(--primary-light); color: var(--primary-dark);
}
.activity .tag.remedial { background: var(--warning-light); color: var(--warning); }
.activity .tag.enrich { background: #efe6f9; color: var(--new-idea); }
.q-box { margin-top: var(--space-3); }
.q-box .q-text { font-weight: 700; margin-bottom: var(--space-3); font-size: 1.05rem; }
.choices { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.choice {
  border: 2px solid var(--line); background: var(--surface); border-radius: var(--radius-sm);
  padding: 10px 22px; cursor: pointer; font-family: inherit; font-size: 1.15rem; font-weight: 700;
  min-width: 64px; min-height: 52px; transition: all .12s;
}
.choice:hover { border-color: var(--primary); }
.choice.correct { background: var(--success-light); border-color: var(--success); color: var(--success); }
.choice.wrong { background: var(--error-light); border-color: var(--error); color: var(--error); }
.feedback { min-height: 34px; margin-top: var(--space-2); font-weight: 700; }
.feedback.good { color: var(--success); }
.feedback.retry { color: var(--warning); }

.counter-objects { font-size: 2.2rem; letter-spacing: 6px; margin: var(--space-2) 0; }

/* اللعبة */
canvas.game {
  width: 100%; max-width: 820px; background: linear-gradient(#dff1ff, #f0fff2);
  border-radius: var(--radius); border: 2px solid var(--line); touch-action: manipulation;
}
.game-hud { display: flex; gap: var(--space-4); justify-content: center; margin: var(--space-3) 0; font-weight: 700; flex-wrap: wrap; }
.game-hud span { background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 4px 16px; }

/* التقييم */
.quiz-progress { height: 10px; background: var(--line); border-radius: 999px; overflow: hidden; margin-bottom: var(--space-4); }
.quiz-progress > div { height: 100%; background: var(--success); width: 0%; transition: width .3s; }
.result-box { text-align: center; padding: var(--space-5); }
.result-box .big { font-size: 3rem; }
.stars { font-size: 2rem; letter-spacing: 6px; }

/* Rubric */
table.rubric { border-collapse: collapse; width: 100%; font-size: .85rem; }
table.rubric th, table.rubric td { border: 1px solid var(--line); padding: 8px 10px; }
table.rubric th { background: var(--primary-light); }

/* التقارير */
.report {
  background: #fffdf5; border: 1px solid #eadfa8; border-radius: var(--radius);
  padding: var(--space-5); margin-bottom: var(--space-4);
}
.report h4 { color: var(--warning); margin-bottom: var(--space-2); }

/* ---------- استجابة ---------- */
@media (max-width: 640px) {
  body { font-size: 16px; }
  .wrap { padding: var(--space-3); }
  .lesson-nav { top: 70px; }
  .topbar h1 { font-size: 1rem; }
}
/* ---------- الزر العائم: تلميحات المعلم (Zoom) ---------- */
.fab {
  position: fixed; bottom: 22px; left: 22px; z-index: 90;
  width: 62px; height: 62px; border-radius: 50%;
  background: var(--primary); color: #fff; border: 3px solid #fff;
  font-size: 26px; cursor: pointer; box-shadow: 0 4px 16px rgba(168,30,56,.4);
  display: grid; place-items: center; transition: transform .12s;
}
.fab:hover { transform: scale(1.08); background: var(--primary-dark); }
.fab .fab-label {
  position: absolute; bottom: 70px; left: 0; white-space: nowrap;
  background: var(--seed); color: #fff; font-size: .72rem;
  border-radius: 999px; padding: 3px 12px; opacity: 0; pointer-events: none;
  transition: opacity .15s; font-family: var(--font);
}
.fab:hover .fab-label { opacity: 1; }

.hint-overlay {
  position: fixed; inset: 0; background: rgba(43,43,43,.55); z-index: 95;
  display: none; align-items: flex-end; justify-content: center; padding: 16px;
}
.hint-overlay.open { display: flex; }
.hint-modal {
  background: var(--surface); border-radius: var(--radius);
  max-width: 640px; width: 100%; max-height: 75vh; overflow-y: auto;
  padding: var(--space-5); box-shadow: 0 -6px 30px rgba(0,0,0,.25);
  border-top: 6px solid var(--primary);
}
.hint-modal h3 { color: var(--primary-dark); display: flex; align-items: center; gap: 8px; margin-bottom: var(--space-3); }
.hint-modal .zoom-tip {
  background: var(--success-light); border-radius: var(--radius-sm);
  padding: var(--space-3) var(--space-4); margin-top: var(--space-3);
  font-size: .9rem; border-inline-start: 4px solid var(--secondary);
}
.hint-modal ul { padding-inline-start: 18px; }
.hint-modal li { margin-bottom: 6px; }
.hint-close { margin-top: var(--space-4); width: 100%; }

/* ---------- شريط وضع الطالب (الدراسة الذاتية) ---------- */
.student-banner {
  background: linear-gradient(90deg, var(--primary-light), #e6f6e8);
  border: 2px dashed var(--primary); border-radius: var(--radius);
  padding: var(--space-3) var(--space-4); margin-bottom: var(--space-4);
  font-weight: 700; color: var(--primary-dark); text-align: center;
}

/* بطاقات بوابة الطالب */
.portal-card {
  display: flex; align-items: center; gap: var(--space-4);
  border: 2px solid var(--line); border-radius: var(--radius);
  padding: var(--space-4); margin-bottom: var(--space-3); background: var(--surface);
  text-decoration: none; color: var(--ink); transition: border-color .15s, transform .1s;
  flex-wrap: wrap;
}
.portal-card:hover { border-color: var(--primary); transform: translateY(-2px); }
.portal-card .emoji { font-size: 2.2rem; }
.portal-card .p-title { font-weight: 800; flex: 1; min-width: 200px; }
.portal-card .p-steps { width: 100%; font-size: .8rem; color: var(--ink-soft); }

/* تقليل الحركة */
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ---------- 🔊 Pronunciation tooltips (Arabic letters) ---------- */
.pron { position: relative; cursor: help; border-bottom: 1px dotted rgba(217,48,79,.35); }
.pron:hover { background: rgba(255,201,77,.28); border-radius: 4px; }
.pron::after {
  content: attr(data-pron);
  position: absolute; bottom: calc(100% + 7px); left: 50%;
  transform: translateX(-50%) translateY(4px);
  background: #123f21; color: #ffd166;
  font-family: "Cairo", sans-serif; font-size: .88rem; font-weight: 700;
  padding: 3px 12px; border-radius: 9px; white-space: nowrap; direction: rtl;
  opacity: 0; pointer-events: none; transition: opacity .15s, transform .15s; z-index: 99;
  box-shadow: 0 6px 16px rgba(0,0,0,.3);
}
.pron::before {
  content: ""; position: absolute; bottom: calc(100% + 1px); left: 50%; transform: translateX(-50%);
  border: 6px solid transparent; border-top-color: #123f21;
  opacity: 0; pointer-events: none; transition: opacity .15s; z-index: 99;
}
.pron:hover::after, .pron:hover::before { opacity: 1; transform: translateX(-50%) translateY(0); }
