/* ==========================================================================
   مدرسة تطوير التفكير — نظام التصميم

   ⚠️ الألوان والأبعاد أدناه **منقولة كما هي** من نظام الشطرنج القديم
   (`app/assets/css/play.css` · `board.css` · `style.css`). لم تُخترَع هنا:
   هي حصيلة شهور من التجربة، وبعضها يحمل ملاحظات مطابقة WCAG في مصدره.
   لا تُغيَّر قيمة منها إلا بقرار تصميمي واعٍ، لا بذوق لحظة.

   المصادر:
     play.css:19   body.learn-mode        → ألوان منطقة التعلّم
     play.css:2525 منطقة العمل           → أبعاد الأعمدة الثلاثة
     board.css:214 .theme-green           → ألوان الرقعة
     play.css:1361 .message               → فقاعات المحادثة
     play.css:2668 .board-challenge-card  → بطاقة المهمة
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Tajawal:wght@400;500;700;800;900&display=swap');

:root {
  /* --- إطار الصفحة الداكن (play.css:3) --- */
  --bg-1: #262b28;
  --bg-2: #1e2320;
  --bg-3: #111413;
  --panel: #202522;
  --panel-2: #1a1e1c;
  --line-dark: rgba(255, 255, 255, .08);
  --accent: #8bc34e;
  --accent-hover: #9ccc65;

  /* --- منطقة التعلّم الفاتحة (play.css:19 — معايَرة WCAG) --- */
  --paper:      #ffffff;
  --paper-2:    #faf6ee;   /* كريمي */
  --ink:        #0a1a13;   /* أسود مخضرّ — AAA على الكريمي */
  --ink-2:      #1c2e26;
  --muted:      #45564c;
  --line:       rgba(10, 26, 19, .22);
  --line-strong:rgba(10, 26, 19, .45);
  --green:      #155534;
  --green-strong: #0d3d24;
  --green-soft: #e6f1eb;
  --gold:       #a06d10;
  --blue:       #1f4d6b;
  --orange:     #d24a14;

  /* --- الأبعاد (play.css:2525) --- */
  --header-h: 46px;
  --gap:      12px;
  --col-path:  238px;   /* عمود خطة التعلّم */
  --col-tutor: 360px;   /* عمود الأستاذ */
  --radius:   14px;
  --radius-lg:16px;
  --shadow:   0 14px 34px rgba(31, 52, 40, .11);

  /* --- الرقعة (board.css:214 theme-green) --- */
  --sq-light: #e9f5db;
  --sq-dark:  #90a955;
  --sq-light-ink: #4f772d;
  --sq-dark-ink:  #f7fee7;
  --sq-selected:  #f6f669;
}

@media (max-width: 1180px) {
  :root { --col-path: 220px; --col-tutor: 330px; }
}

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

body {
  font-family: 'Tajawal', 'Segoe UI', Tahoma, system-ui, sans-serif;
  direction: rtl;
  line-height: 1.6;
  color: var(--ink);
  background: var(--paper-2);
  min-height: 100vh;
}

a { color: var(--green); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ====================================================== الترويسة الداكنة */

.topbar {
  height: var(--header-h);
  background: linear-gradient(180deg, var(--panel) 0%, var(--panel-2) 100%);
  border-bottom: 1px solid var(--line-dark);
  color: #edf5e9;
  position: sticky; top: 0; z-index: 40;
}
.topbar__in {
  height: 100%; max-width: 1680px; margin: 0 auto;
  padding: 0 16px; display: flex; align-items: center; gap: 12px;
}
.brand { font-weight: 900; font-size: .98rem; color: #edf5e9; }
.brand span { color: var(--accent); }
.brand:hover { text-decoration: none; }
.topbar__spacer { flex: 1; }
.topbar a { color: #c8d6bf; font-size: .82rem; }
.topbar__who {
  font-size: .8rem; color: #dbe8d3;
  background: rgba(255, 255, 255, .07);
  border: 1px solid var(--line-dark);
  padding: 3px 12px; border-radius: 999px;
}

/* ============================================================== عام */

.wrap { max-width: 1120px; margin: 0 auto; padding: 0 18px 60px; }

h1 { font-size: 1.5rem; margin: 26px 0 6px; font-weight: 900; letter-spacing: -.3px; }
h2 { font-size: 1.1rem; margin: 30px 0 12px; font-weight: 900; color: var(--ink-2); }
.lede { color: var(--muted); margin: 0 0 22px; }

.card {
  background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow);
}

.grid { display: grid; gap: 14px; }
.grid--3 { grid-template-columns: repeat(auto-fit, minmax(215px, 1fr)); }
.grid--4 { grid-template-columns: repeat(auto-fit, minmax(135px, 1fr)); }

.subject {
  display: flex; flex-direction: column; gap: 7px;
  border-radius: var(--radius); padding: 18px;
  background: var(--paper); border: 1px solid var(--line);
  box-shadow: var(--shadow); text-align: right; width: 100%;
  cursor: pointer; font: inherit; color: inherit;
  transition: transform .15s, border-color .15s;
}
.subject:hover { transform: translateY(-2px); border-color: var(--green); text-decoration: none; }
.subject__icon { font-size: 1.9rem; line-height: 1; }
.subject__title { font-weight: 900; font-size: 1.02rem; }
.subject__tag { color: var(--muted); font-size: .88rem; }

.bar { height: 7px; border-radius: 99px; background: var(--green-soft); overflow: hidden; }
.bar__fill { height: 100%; background: var(--green); border-radius: 99px; transition: width .4s; }

.stat { text-align: center; padding: 16px 10px; }
.stat__n { font-size: 1.9rem; font-weight: 900; letter-spacing: -1px; display: block; color: var(--green-strong); }
.stat__l { font-size: .8rem; color: var(--muted); }

.tag {
  display: inline-block; font-size: .72rem; font-weight: 700; padding: 2px 10px;
  border-radius: 999px; border: 1px solid var(--line);
  background: var(--paper-2); color: var(--muted);
}
.tag--ok   { background: var(--green-soft); color: var(--green);  border-color: transparent; }
.tag--warn { background: #fdf1dc;           color: var(--gold);   border-color: transparent; }
.tag--bad  { background: #fbe7e0;           color: var(--orange); border-color: transparent; }
.tag--acc  { background: var(--green-soft); color: var(--green-strong); border-color: transparent; }

.btn {
  font: inherit; font-weight: 700;
  padding: 10px 20px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--paper);
  color: var(--ink); cursor: pointer;
  transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--paper-2); }
.btn--primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn--primary:hover { background: var(--green-strong); border-color: var(--green-strong); }
.btn--ghost { background: transparent; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: right; padding: 9px 12px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 700; font-size: .8rem; }
td.num, th.num { text-align: left; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }

.muted { color: var(--muted); }
.small { font-size: .84rem; }
.center { text-align: center; }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }
.notice {
  border-inline-start: 3px solid var(--gold);
  background: #fdf1dc; color: #6b4708;
  padding: 12px 16px; border-radius: 10px; margin: 14px 0; font-size: .9rem;
}

/* ==========================================================================
   القاعة — ثلاثة أعمدة

   خطة التعلّم (238px) │ المنصة (مرنة ≥520px) │ الأستاذ (360px)

   في RTL: الخطة يميناً، المنصة وسطاً، الأستاذ يساراً — كما في النظام القديم.
   المنطقتان الجانبيتان لا تعرفان اسم المادة؛ الوسط وحده تسكنه الودجة.
   ========================================================================== */

.room {
  display: grid;
  grid-template-columns: var(--col-path) minmax(0, 1fr) var(--col-tutor);
  gap: var(--gap);
  align-items: start;
  max-width: 1680px; margin: 0 auto; padding: var(--gap) 16px 40px;
}

@media (max-width: 1240px) {
  .room { grid-template-columns: minmax(0, 1fr) var(--col-tutor); }
  .room__path { display: none; }
}
@media (max-width: 900px) {
  .room { grid-template-columns: 1fr; }
  .room__stage { order: -1; }
}

/* ------------------------------------------------- العمود 1: الخطة */

.path { display: flex; flex-direction: column; gap: 10px; position: sticky; top: calc(var(--header-h) + 12px); }

.path-card {
  background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow);
}
.path-card__eyebrow {
  font-size: .68rem; font-weight: 900; color: var(--green);
  letter-spacing: .3px; margin-bottom: 4px;
}
.path-card__title { font-weight: 900; font-size: .95rem; line-height: 1.45; }
.path-card__goal { color: var(--muted); font-size: .82rem; margin-top: 4px; }
.path-card__meta {
  display: flex; justify-content: space-between; align-items: center;
  font-size: .78rem; color: var(--muted); margin-top: 10px;
}
.path-card__pct { font-weight: 900; color: var(--green); }

/* خريطة الرحلة — ارتفاع يتكيّف مع الشاشة بدل قيمة ثابتة تقتطع البطاقات */
.jm {
  display: flex; flex-direction: column; gap: 6px;
  max-height: calc(100vh - var(--header-h) - 300px);
  min-height: 150px;
  overflow-y: auto;
  padding: 2px 2px 6px;   /* مساحة لظل آخر بطاقة ولحلقة «أنت هنا» */
}
.jm::-webkit-scrollbar { width: 6px; }
.jm::-webkit-scrollbar-thumb { background: var(--line); border-radius: 99px; }
.jm__stage {
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--paper); overflow: hidden;
}
.jm__head {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 12px; cursor: default;
}
.jm__code {
  font-size: .66rem; font-weight: 900; color: #fff; background: var(--green);
  border-radius: 6px; padding: 1px 7px; flex: none;
}
.jm__title { font-size: .82rem; font-weight: 700; flex: 1; min-width: 0;
             overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.jm__pct { font-size: .72rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.jm__bar { height: 4px; background: var(--green-soft); }
.jm__bar > i { display: block; height: 100%; background: var(--green); }

.jm__stage.is-locked { opacity: .5; }
.jm__stage.is-locked .jm__code { background: var(--muted); }
.jm__stage.is-here { border-color: var(--green); box-shadow: 0 0 0 2px var(--green-soft); }

.jm__lessons { padding: 4px 8px 8px; display: flex; flex-direction: column; gap: 2px; }
.jm__lesson {
  display: flex; align-items: center; gap: 7px;
  font-size: .78rem; color: var(--muted);
  padding: 3px 6px; border-radius: 7px; text-decoration: none;
}
.jm__lesson:hover { background: var(--paper-2); text-decoration: none; }
.jm__dot { width: 7px; height: 7px; border-radius: 50%; background: var(--line-strong); flex: none; }
.jm__lesson.is-done { color: var(--ink-2); }
.jm__lesson.is-done .jm__dot { background: var(--green); }
.jm__lesson.is-here { color: var(--green); font-weight: 900; background: var(--green-soft); }
.jm__lesson.is-here .jm__dot { background: var(--green); box-shadow: 0 0 0 3px rgba(21,85,52,.18); }

/* ------------------------------------------- العمود 2: منصة النشاط */

.room__stage { display: flex; flex-direction: column; gap: 10px; min-width: 0; }

/* بطاقة المهمة — منقولة من play.css:2668 */
.task-card {
  width: min(100%, 760px); margin: 0 auto;
  padding: 13px 16px; text-align: center;
  border: 2px solid rgba(21, 85, 52, .22);
  background: linear-gradient(135deg, #fffdf7 0%, #eef7ee 100%);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}
.task-card[hidden] { display: none !important; }
.task-card__kicker {
  margin: 0 0 3px; color: var(--green);
  font-size: .76rem; font-weight: 900;
}
.task-card__title {
  margin: 0 0 5px; color: var(--ink);
  font-size: clamp(1.05rem, 1.7vw, 1.45rem); font-weight: 900; line-height: 1.4;
}
.task-card__body { margin: 0; color: var(--muted); font-size: .9rem; }
.task-card__actions {
  display: flex; gap: 9px; flex-wrap: wrap; justify-content: center; margin-top: 11px;
}
.task-choice {
  min-height: 46px; padding: 0 18px;
  border: 1px solid rgba(21, 85, 52, .18);
  background: #fffaf0; color: var(--ink);
  border-radius: 12px; font: inherit; font-size: 1rem; font-weight: 900;
  cursor: pointer; transition: border-color .15s, background .15s;
}
.task-choice:hover { border-color: var(--green); background: var(--green-soft); }
.task-choice.is-correct { border-color: var(--green); background: var(--green-soft); color: var(--green); }
.task-choice.is-wrong   { border-color: var(--orange); background: #fbe7e0; color: var(--orange); }

.stage {
  background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; align-items: center;
}
.stage--idle { min-height: 220px; justify-content: center; color: var(--muted); font-size: 2rem; }

/* ---------------------------------------------- العمود 3: الأستاذ */

.tutor {
  background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  display: flex; flex-direction: column;
  position: sticky; top: calc(var(--header-h) + 12px);
  height: calc(100vh - var(--header-h) - 34px);
  max-height: 760px;
}
@media (max-width: 900px) { .tutor { position: static; height: auto; max-height: 560px; } }

.tutor__head {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px; border-bottom: 1px solid var(--line);
}
.tutor__ava {
  width: 38px; height: 38px; border-radius: 50%; flex: none;
  background: var(--green-soft); color: var(--green);
  display: grid; place-items: center; font-size: 1.15rem;
}
.tutor__name { font-weight: 900; font-size: .93rem; }
.tutor__state { font-size: .74rem; color: var(--muted); }
.tutor__skip {
  font: inherit; font-size: .7rem; font-weight: 700;
  padding: 4px 9px; border-radius: 7px; cursor: pointer;
  border: 1px solid var(--line); background: transparent; color: var(--muted);
}
.tutor__skip:hover { border-color: var(--line-strong); color: var(--ink-2); }

.tutor__body {
  flex: 1; overflow-y: auto; padding: 14px;
  display: flex; flex-direction: column; gap: 10px;
}

/* فقاعات المحادثة — منقولة من play.css:1361 */
.msg { display: flex; gap: 8px; align-items: flex-end; max-width: 94%; align-self: flex-start; }
.msg__ava {
  width: 26px; height: 26px; border-radius: 50%; flex: none;
  background: var(--green-soft); color: var(--green);
  display: grid; place-items: center; font-size: .8rem;
}
.msg__b {
  padding: 9px 13px; border-radius: 14px;
  background: linear-gradient(135deg, rgba(21, 85, 52, .08), rgba(21, 85, 52, .04));
  border: 1px solid rgba(21, 85, 52, .15);
  color: #0f2419; white-space: pre-wrap;
  font-size: .92rem; line-height: 1.65;
  border-bottom-right-radius: 4px;
  animation: msgIn .26s ease both;
}
@keyframes msgIn { from { opacity: 0; transform: translateY(6px); } }

.msg--me { align-self: flex-end; flex-direction: row-reverse; }
.msg--me .msg__b {
  background: #ffffff; border: 1px solid rgba(32, 51, 41, .12);
  color: #0f1f17; border-bottom-right-radius: 14px; border-bottom-left-radius: 4px;
}
.msg--me .msg__ava { background: var(--paper-2); color: var(--muted); }

.msg--ok  .msg__b { background: var(--green-soft); border-color: rgba(21,85,52,.3); color: var(--green); font-weight: 700; }
.msg--bad .msg__b { background: #fbe7e0; border-color: rgba(210,74,20,.28); color: var(--orange); }
.msg--hint .msg__b{ background: #fdf1dc; border-color: rgba(160,109,16,.28); color: #6b4708; }

/* زر المتابعة داخل الخيط — تحت الجملة مباشرة حيث تقف العين */
.msg--act {
  align-self: flex-start; margin-right: 34px;
  animation: msgIn .26s ease both;
}
.msg--act .btn { box-shadow: 0 2px 10px rgba(21, 85, 52, .22); }

.msg--note { align-self: center !important; max-width: 100%; }
.msg--note .msg__b {
  background: transparent; border: 0; color: var(--muted);
  font-size: .74rem; padding: 2px 0; text-align: center;
}

/* بطاقة ترحيب داخل الحوار — منقولة من mufid-welcome-card */
.welcome {
  border: 1px solid rgba(21, 85, 52, .18);
  background: linear-gradient(135deg, #fffdf7 0%, #eef7ee 100%);
  border-radius: var(--radius); padding: 14px; animation: msgIn .3s ease both;
}
.welcome__eyebrow { font-size: .68rem; font-weight: 900; color: var(--green); }
.welcome__title { font-size: 1.02rem; font-weight: 900; margin: 3px 0 6px; }
.welcome__body { font-size: .88rem; color: var(--ink-2); }
.welcome__chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.welcome__chip {
  font-size: .72rem; background: var(--paper); border: 1px solid var(--line);
  border-radius: 999px; padding: 3px 10px;
}
.welcome__chip strong { color: var(--green); }

/* مؤشر الكتابة */
.typing { display: flex; gap: 4px; padding: 12px 14px; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: blink 1.1s infinite; }
.typing i:nth-child(2) { animation-delay: .18s; }
.typing i:nth-child(3) { animation-delay: .36s; }
@keyframes blink { 0%,60%,100% { opacity: .25 } 30% { opacity: 1 } }

.tutor__foot { border-top: 1px solid var(--line); padding: 10px 14px; }
.tutor__note { font-size: .72rem; color: var(--muted); margin-top: 7px; }

/* الاقتراحات السريعة */
.quick { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.quick__btn {
  font: inherit; font-size: .76rem; font-weight: 700;
  padding: 5px 11px; border-radius: 999px; cursor: pointer;
  border: 1px solid rgba(21, 85, 52, .22); background: var(--green-soft); color: var(--green);
}
.quick__btn:hover { background: var(--paper); }

/* ---------------------------------------------------------- متفرقات */

.stepper { display: flex; gap: 3px; flex-wrap: wrap; }
.stepper i { width: 100%; max-width: 20px; height: 4px; border-radius: 99px; background: var(--green-soft); display: block; }
.stepper i.is-done { background: var(--green); }
.stepper i.is-now  { background: var(--gold); }

.chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: .7rem; color: var(--muted);
  background: var(--paper-2); border-radius: 999px; padding: 2px 9px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ── بطاقة القفل ── رسالتها مكان البيع الوحيد الذي يراه الطفل */
.locked-card{text-align:center;padding:38px 26px;max-width:420px;margin:32px auto;
  background:var(--paper-2);border:1px solid var(--line);border-radius:18px}
.locked-icon{font-size:2.6rem;margin-bottom:10px}
.locked-card h3{margin:0 0 8px;font-size:1.12rem;color:var(--ink)}
.locked-card p{margin:0 0 18px;color:var(--ink-2);line-height:1.75;font-size:.95rem}

/* ══ بطاقة الإنجاز ══════════════════════════════════════════════════
   تنزل من أعلى الشاشة، تبقى ثلاث ثوانٍ، ثم تنسحب.

   ⚠️ لا تُغطّي المحتوى ولا تحتاج ضغطة لإغلاقها: نافذة تطلب من الطفل
      إغلاقها تتحوّل إلى عائق يتعلّم تجاهله، والمكافأة تصير إزعاجاً. */
.ach-pop{
  position:fixed; inset-inline:0; top:14px; margin:0 auto; z-index:900;
  width:min(392px, calc(100% - 28px));
  display:flex; gap:14px; align-items:center;
  background:var(--paper); border:1px solid var(--green); border-radius:16px;
  padding:14px 17px; box-shadow:0 18px 44px rgba(21,85,52,.24);
  transform:translateY(-130%); opacity:0;
  transition:transform .42s cubic-bezier(.22,1.2,.36,1), opacity .3s ease;
}
.ach-pop.is-in{ transform:translateY(0); opacity:1 }
.ach-pop--rare{ border-color:#d97706; background:linear-gradient(150deg,#fff,#fffbeb) }
.ach-pop__ic{ font-size:2.15rem; line-height:1; flex:none;
  animation:achPop .6s cubic-bezier(.22,1.4,.36,1) .12s both }
@keyframes achPop{ from{transform:scale(.3) rotate(-18deg)} to{transform:scale(1) rotate(0)} }
.ach-pop__bd{ min-width:0 }
.ach-pop__kicker{ font-size:.68rem; font-weight:800; letter-spacing:.4px;
  color:var(--green); margin-bottom:2px }
.ach-pop--rare .ach-pop__kicker{ color:#b45309 }
.ach-pop__bd b{ display:block; color:var(--ink); font-size:1rem; margin-bottom:3px }
.ach-pop__bd p{ margin:0; color:var(--muted); font-size:.82rem; line-height:1.65 }

@media (prefers-reduced-motion: reduce){
  .ach-pop{ transition:opacity .2s ease; transform:none }
  .ach-pop__ic{ animation:none }
}

/* ── مرحلة بالاشتراك ── تُعرض ولا تُخفى: الرؤية تُغري أكثر من الإعلان */
.jm__stage.is-paid{opacity:.72;border-style:dashed}
.jm__stage.is-paid .jm__pct{color:var(--gold);font-weight:700;font-size:.72rem}
.jm__stage.is-paid .jm__bar{opacity:.4}
