/* =========================================================
   مختبر الدروس التفاعلية: التجارب، التحدّيات، خلايا بايثون
   يُحمَّل بعد style.css و lesson.css.
   ========================================================= */

/* ----- رأس الدرس ----- */
.lab-hero .eyebrow { display: inline-flex; gap: 8px; align-items: center; }
.lab-map { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr)); gap: 12px; margin: 22px 0 8px; padding: 0; list-style: none; counter-reset: exp; }
.lab-map a {
  display: flex; gap: 12px; align-items: flex-start; height: 100%;
  padding: 14px 16px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface);
  color: var(--ink-2); text-decoration: none; transition: transform .15s, border-color .15s;
}
.lab-map a:hover { transform: translateY(-2px); border-color: var(--primary); text-decoration: none; }
.lab-map .n {
  flex: none; width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
  background: var(--primary-soft); color: var(--primary); font-weight: 800;
}
.lab-map b { display: block; color: var(--ink); font-size: .98rem; }
.lab-map small { color: var(--muted); font-size: .85rem; line-height: 1.6; }
.lab-map li.done .n { background: var(--green); color: #fff; }

/* ----- التجربة ----- */
.exp { scroll-margin-top: 130px; padding-top: 18px; }
.exp > .exp-head { display: flex; gap: 14px; align-items: center; margin: 34px 0 6px; }
.exp > .exp-head .n {
  flex: none; width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff; font-weight: 800; font-size: 1.15rem;
}
[data-theme="dark"] .exp > .exp-head .n { color: #0d141e; }
.exp > .exp-head h2 { margin: 0; font-size: 1.45rem; }
.exp > .exp-head .kicker { display: block; font-size: .82rem; color: var(--muted); font-weight: 600; letter-spacing: .02em; }
.exp .hook { font-size: 1.08rem; color: var(--ink-2); }
.exp-done { display: flex; justify-content: flex-end; margin-top: 8px; }
.exp-done label { display: inline-flex; gap: 8px; align-items: center; font-size: .9rem; color: var(--muted); cursor: pointer; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); }
.exp-done label:has(input:checked) { color: var(--green); border-color: var(--green); background: var(--green-soft); }
.exp-done input { accent-color: var(--green); }

/* ----- عرض كبير لرقم ----- */
.bignum { text-align: center; margin: 6px 0 2px; }
.bignum .v { font-family: "IBM Plex Sans", var(--font); font-weight: 800; font-size: clamp(1.9rem, 5vw, 2.8rem); color: #123b63; line-height: 1.2; unicode-bidi: isolate; }
.bignum .u { font-size: 1rem; color: #5b6578; margin-inline-start: 6px; }
.bignum .sub { font-size: .9rem; color: #667387; }

/* ----- أزرار داخل الشكل ----- */
.btnrow { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 14px; }
.figure .pr-btn { background: #fff; color: #123b63; border-color: #123b63; }
.figure .pr-btn:hover, .figure .pr-btn[aria-pressed="true"] { background: #123b63; color: #fff; }
.figure .seg { background: #f3f5f8; border-color: #e1e6ee; }
.figure .seg button { color: #344256; }
.figure .seg button[aria-pressed="true"] { background: #123b63; color: #fff; }
.figure .hint-line { font-size: .86rem; color: #667387; margin-top: 8px; }
.figure .two { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 900px) { .figure .two.side { grid-template-columns: 3fr 2fr; align-items: start; } }

/* ----- مسطرة القيم (سلّم لوغاريتمي) ----- */
.ladder text { font-family: "IBM Plex Sans Arabic", Tajawal, sans-serif; }

/* ----- التحدّي: مستويات ونجوم ----- */
.hud { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.hud .lv {
  font: inherit; font-size: .88rem; border: 1px solid #d9dfe8; background: #fff; color: #344256; border-radius: 10px;
  padding: 5px 12px; cursor: pointer; display: inline-flex; gap: 6px; align-items: center;
}
.hud .lv[aria-pressed="true"] { border-color: #123b63; background: #123b63; color: #fff; }
.hud .lv .st { color: #c99a2e; letter-spacing: -1px; font-size: .8rem; }
.hud .lv[aria-pressed="true"] .st { color: #ffd77a; }
.hud .total { margin-inline-start: auto; font-weight: 700; color: #123b63; font-size: .92rem; }
.challenge-q { font-size: 1.05rem; color: #14202e; margin: 4px 0 10px; }
.answer-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.answer-row input {
  font: inherit; width: 120px; padding: 7px 10px; border-radius: 8px; border: 1.5px solid #d9dfe8; direction: ltr; text-align: left; background: #fff; color: #14202e;
}
.verdict { margin-top: 12px; padding: 10px 14px; border-radius: 10px; font-size: .95rem; display: none; }
.verdict.on { display: block; }
.verdict.good { background: #e7f4ec; color: #1f6b3e; border: 1px solid #b9dfc7; }
.verdict.bad { background: #fbeceb; color: #9a3a2c; border: 1px solid #f0c9c2; }
.verdict .stars { font-size: 1.2rem; color: #c99a2e; margin-inline-end: 6px; }

/* ----- خليّة بايثون ----- */
.pycell { margin: 18px 0; border-radius: 14px; overflow: hidden; border: 1px solid #1f2a3a; background: #0f1724; box-shadow: var(--shadow-sm); }
.pycell textarea {
  display: block; width: 100%; min-height: 120px; resize: vertical; border: 0; outline: 0; padding: 16px 18px;
  background: #0f1724; color: #e6edf6; font: 14.5px/1.65 "JetBrains Mono", Consolas, "Courier New", monospace; tab-size: 4;
  text-align: left;
}
.pycell .pybar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 10px 14px; background: #162133; border-top: 1px solid #24324a; }
.pycell .pybar .pr-btn { background: transparent; color: #9cc3ff; border-color: #3b5577; }
.pycell .pybar .pr-btn:hover { background: #2b4366; color: #fff; }
.pycell .pystat { font-size: .85rem; color: #9fb0c6; }
.pycell .pylang { margin-inline-start: auto; font: 600 .78rem "IBM Plex Sans", sans-serif; color: #6f86a6; letter-spacing: .06em; }
.pycell .pyout { margin: 0; padding: 12px 18px; background: #0b111b; color: #b8f2c8; font: 14px/1.6 Consolas, monospace; white-space: pre-wrap; border-top: 1px solid #24324a; text-align: left; }
.pycell .pyout.err { color: #ffb4a8; }

/* ----- ما الذي تعلّمته؟ ----- */
.takeaway { border-radius: 14px; padding: 16px 20px; margin: 18px 0; background: linear-gradient(135deg, color-mix(in srgb, var(--green) 12%, var(--surface)), var(--surface)); border: 1px solid color-mix(in srgb, var(--green) 35%, var(--line)); }
.takeaway > .head { font-weight: 800; color: var(--green); margin-bottom: 4px; font-size: .95rem; }
.takeaway p:last-child { margin-bottom: 0; }

@media (max-width: 560px) {
  .exp > .exp-head h2 { font-size: 1.2rem; }
  .exp > .exp-head .n { width: 40px; height: 40px; }
  .pycell textarea { font-size: 13px; padding: 12px; }
}
@media print { .pycell .pybar, .hud, .answer-row, .btnrow { display: none !important; } }

/* ----- جدول داخل الشكل ----- */
.tbl { width: 100%; border-collapse: collapse; font-size: .9rem; color: #344256; }
.tbl th, .tbl td { padding: 6px 8px; border-bottom: 1px solid #ece9e1; text-align: center; unicode-bidi: plaintext; }
.tbl th { color: #123b63; font-weight: 700; background: #f3f5f8; }
.tbl tr.hl td { background: #fff4dc; font-weight: 700; color: #14202e; }
.tbl tr.lim td { color: #2a7a5f; font-weight: 700; border-top: 2px solid #d6dde7; }
