/* =========================================================
   المعادلة الكيميائية التفاعلية

   كل جزء فيها عنصر مستقل بيتضغط. الألوان جاية من `chem-data.js`
   inline لأنها بيانات مش تنسيق — نفس العنصر بنفس اللون في كل معادلة.
   ========================================================= */

.chem {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-family: 'Times New Roman', Cambria, serif;
  font-size: 27px;
  font-weight: 700;
  line-height: 1.5;
  padding: 6px 0;
}

/* كل جزء قابل للضغط */
.chem .cb,
.chem .cs {
  cursor: pointer;
  transition:
    background 0.12s,
    box-shadow 0.12s;
}

/* الأجزاء المستقلة (معامل · حالة · سهم · رمز): صندوق عادي */
.chem .cn,
.chem .cst,
.chem .cop,
.chem .csy,
.chem .ccond,
.chem .carw {
  border-radius: 7px;
  padding: 1px 3px;
}

/**
 * 🔴 المركّب وحدة واحدة — الذرات جوّاه **ملزوقة**.
 *
 * أول نسخة كانت بتحط حشو وخلفية حوالين كل ذرة، فـ«HgO» كانت
 * بتبان «Hg O» — يعني حاجتين مش مركّب واحد. ده تشويش على معنى
 * أساسي في الكيمياء.
 *
 * الحل: الذرة **مالهاش حشو ولا صندوق** — بتتعلّم بخط تحتها بلونها.
 * الصندوق بيفضل للمركّب كله، فالولد يشوف الوحدة والأجزاء مع بعض.
 */
.chem .cs {
  display: inline-flex;
  align-items: baseline;
  border-radius: 8px;
  padding: 1px 4px;
  margin: 0 1px;
}
.chem .ce {
  padding: 0;
  border-radius: 0;
  box-shadow: none;
}

/**
 * التعليم بيفرّق بين المستويين عشان الولد يعرف هو واقف على إيه:
 * **المركّب** بياخد صندوق بلون البرنامج (`--brand`) — لون محايد ثابت،
 * لأن اللون الموروث هنا لون النص فالتظليل منه بيطلع رمادي باهت.
 * **الذرة** بتاخد خط تحتها بلون العنصر نفسه — من غير حشو ولا خلفية،
 * عشان مايبانش إن فيه فاصل بين ذرات المركّب الواحد.
 */

/* المرور: المركّب بياخد خلفية، والذرة خط تحتها */
.chem .cs:hover,
.chem .cs:focus-visible,
.chem .cb:not(.ce):hover,
.chem .cb:not(.ce):focus-visible {
  background: var(--bg-soft);
  outline: none;
}
.chem .ce:hover,
.chem .ce:focus-visible {
  background: none;
  box-shadow: inset 0 -3px 0 currentColor;
  outline: none;
}

/* المختار */
.chem .cs.is-on,
.chem .cb:not(.ce).is-on {
  background: var(--brand-soft);
  box-shadow: 0 0 0 2px var(--brand);
}
.chem .ce.is-on {
  background: none;
  box-shadow: inset 0 -4px 0 currentColor;
}

.chem sub {
  font-size: 0.62em;
  vertical-align: -0.22em;
  margin-inline-start: 1px;
}

/* المعامل قدام المادة */
.chem .cn {
  color: var(--text);
  margin-inline-end: 1px;
}
/* حالة المادة (s) (aq) */
.chem .cst {
  font-size: 0.6em;
  color: var(--text-dim);
  vertical-align: -0.15em;
}
/* + بين المواد */
.chem .cop {
  color: var(--text-dim);
  margin: 0 5px;
}
/* ↑ الغاز و↓ الراسب */
.chem .csy {
  color: var(--text-dim);
  font-size: 0.8em;
}
/* الأقواس في الصيغة */
.chem .cp {
  color: var(--text-soft);
}

/* السهم مع ظروفه فوقه */
.chem .car {
  display: inline-grid;
  justify-items: center;
  margin: 0 10px;
}
.chem .cc {
  font-size: 0.5em;
  line-height: 1;
  color: var(--warn);
}
.chem .carw {
  color: var(--text-soft);
  line-height: 1;
}
.chem .ccond {
  color: var(--warn);
}

/* لوحة الشرح تحت المعادلة */
.chem-info {
  margin-top: 10px;
  background: var(--brand-soft);
  border-radius: 14px;
  padding: 11px 15px;
  font-size: 14.5px;
  line-height: 1.75;
  animation: chem-in 0.18s var(--ease-3, ease-out);
}
.chem-info b {
  color: var(--brand);
  font-weight: 800;
  font-size: 15.5px;
}
.chem-info span {
  display: block;
  margin-top: 3px;
  color: var(--text);
  font-weight: 400;
}
@keyframes chem-in {
  from {
    opacity: 0;
    transform: translateY(-5px);
  }
}

/* تلميح للولد إن المعادلة بتتضغط — مرة واحدة فوق أول معادلة */
.chem-hint {
  text-align: center;
  font-size: 12.5px;
  color: var(--text-dim);
  font-weight: 700;
  margin-bottom: 4px;
}

@media (max-width: 520px) {
  .chem {
    font-size: 22px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .chem-info {
    animation: none;
  }
}

/* =========================================================
   المصطلحات في نص الدرس

   التعليم لازم يقول «دي كلمة تنفع تدوس عليها» من غير ما يقطّع
   القراءة — عشان كده خط منقّط تحت الكلمة مش صندوق ولا لون تاني.
   ========================================================= */

.gloss {
  cursor: pointer;
  border-bottom: 2px dotted var(--brand);
  padding-bottom: 1px;
  transition: background 0.12s;
}
.gloss:hover,
.gloss:focus-visible {
  background: var(--brand-soft);
  border-radius: 5px;
  outline: none;
}
.gloss.is-on {
  background: var(--brand-soft);
  border-radius: 5px;
  border-bottom-style: solid;
}

/* لوحة شرح المصطلح — بتظهر في آخر النقطة */
.gloss-info {
  margin-top: 14px;
  background: var(--bg-soft);
  border-inline-start: 4px solid var(--brand);
  border-radius: 12px;
  padding: 12px 15px;
  font-size: 14.5px;
  line-height: 1.85;
  animation: chem-in 0.18s var(--ease-3, ease-out);
}
.gloss-info b {
  color: var(--brand);
  font-weight: 800;
  font-size: 16px;
}
.gloss-info span {
  display: block;
  margin-top: 5px;
  color: var(--text);
}
.gloss-info .gloss-how {
  color: var(--text-soft);
  font-size: 13.5px;
}
.gloss-info .gloss-ex {
  font-family: 'Times New Roman', Cambria, serif;
  font-weight: 700;
  color: var(--text-dim);
  font-size: 15px;
  text-align: start;
}

@media (prefers-reduced-motion: reduce) {
  .gloss-info {
    animation: none;
  }
}
