/* =========================================================
   نظام التصميم — الموقع الشخصي للأستاذ
   ========================================================= */
:root {
  --bg: #f7f6f2;
  --bg-alt: #efede6;
  --surface: #ffffff;
  --ink: #14202e;
  --ink-2: #344256;
  --muted: #667387;
  --line: #e3e0d6;
  --primary: #123b63;
  --primary-2: #1d5a8f;
  --primary-soft: #e6eef6;
  --accent: #b5562f;
  --accent-soft: #f7e9e2;
  --gold: #c99a3b;
  --green: #2a8c7f;
  --green-soft: #e1f2ef;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(16, 28, 45, .06);
  --shadow: 0 1px 2px rgba(16, 28, 45, .05), 0 10px 30px -10px rgba(16, 28, 45, .14);
  --shadow-lg: 0 30px 60px -20px rgba(16, 28, 45, .3);
  --font: "IBM Plex Sans Arabic", "Segoe UI", Tahoma, sans-serif;
  --font-display: "Noto Kufi Arabic", "IBM Plex Sans Arabic", sans-serif;
  --max: 1160px;
  --header-h: 72px;
}

[data-theme="dark"] {
  --bg: #0d141e;
  --bg-alt: #111a26;
  --surface: #162231;
  --ink: #e9edf2;
  --ink-2: #c3ccd8;
  --muted: #8d9aab;
  --line: #243244;
  --primary: #7fb2e5;
  --primary-2: #a4c8ee;
  --primary-soft: #1a2c42;
  --accent: #e58a63;
  --accent-soft: #33221c;
  --green: #5cc2b3;
  --green-soft: #15302d;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px -10px rgba(0, 0, 0, .5);
  --shadow-lg: 0 30px 60px -20px rgba(0, 0, 0, .7);
}

/* النسخة الإنجليزية (من اليسار لليمين) */
html[lang="en"] {
  --font: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  --font-display: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
}
html[lang="en"] body { font-size: 17px; line-height: 1.7; }
html[lang="en"] h1, html[lang="en"] h2 { letter-spacing: -.02em; }
html[lang="en"] .eyebrow { text-transform: uppercase; letter-spacing: .08em; font-size: .78rem; }

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 16px); }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 17.5px;
  line-height: 1.9;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  transition: background .25s, color .25s;
}
img { max-width: 100%; display: block; }
a { color: var(--primary-2); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 4px; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; border-radius: 6px; }
h1, h2, h3, h4 { font-family: var(--font-display); line-height: 1.45; margin: 0 0 .6em; color: var(--ink); letter-spacing: -.01em; }
h1 { font-size: clamp(2rem, 4.2vw, 3.1rem); font-weight: 800; }
h2 { font-size: clamp(1.5rem, 2.6vw, 2.05rem); font-weight: 700; }
h3 { font-size: 1.18rem; font-weight: 700; }
p { margin: 0 0 1em; }
ul, ol { margin: 0 0 1em; }
.container { max-width: var(--max); margin: 0 auto; padding: 0 24px; }
.narrow { max-width: 820px; }
.muted { color: var(--muted); }
.ltr { direction: ltr; unicode-bidi: isolate; }
.center { text-align: center; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.ph { background: var(--accent-soft); color: var(--accent); border-radius: 4px; padding: 0 4px; }
.icon { width: 22px; height: 22px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ===== الترويسة ===== */
.skip { position: absolute; top: -60px; inset-inline-start: 12px; background: var(--primary); color: #fff; padding: 8px 16px; border-radius: 8px; z-index: 100; }
.skip:focus { top: 12px; }
.site-header {
  position: sticky; top: 0; z-index: 50; height: var(--header-h);
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid transparent;
  transition: border-color .2s, box-shadow .2s;
}
.site-header.scrolled { border-bottom-color: var(--line); box-shadow: var(--shadow-sm); }
.site-header .container { display: flex; align-items: center; gap: 20px; height: 100%; }
.brand { display: flex; align-items: center; gap: 12px; color: var(--ink); font-weight: 700; }
.brand:hover { text-decoration: none; }
.brand-photo { display: none; }
.brand .mark {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
  background: var(--primary); color: #fff; font-family: var(--font-display); font-weight: 800;
}
[data-theme="dark"] .brand .mark { background: var(--primary-soft); color: var(--primary); }
.brand small { display: block; font-weight: 400; font-size: .78rem; color: var(--muted); line-height: 1.2; }
.brand span { line-height: 1.3; }
.nav { display: flex; gap: 4px; margin-inline-start: auto; }
.nav a { color: var(--ink-2); padding: 8px 14px; border-radius: 999px; font-weight: 500; font-size: .97rem; }
.nav a:hover { background: var(--primary-soft); color: var(--primary); text-decoration: none; }
.nav a.active { color: var(--primary); background: var(--primary-soft); font-weight: 700; }
.header-actions { display: flex; gap: 8px; align-items: center; }
.icon-btn {
  width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer;
}
.icon-btn:hover { border-color: var(--primary); color: var(--primary); }
.icon-btn .icon { width: 20px; height: 20px; }
.lang-btn { font-weight: 700; font-size: .85rem; text-decoration: none !important; font-family: "IBM Plex Sans", var(--font); }
.lang-btn:lang(ar) { font-family: "IBM Plex Sans Arabic", sans-serif; font-size: .95rem; }
.theme-toggle .moon { display: none; }
[data-theme="dark"] .theme-toggle .sun { display: none; }
[data-theme="dark"] .theme-toggle .moon { display: block; }
.nav-toggle { display: none; }

@media (max-width: 900px) {
  .nav-toggle { display: grid; }
  .header-actions { margin-inline-start: auto; }
  .header-actions .btn { display: none; }
  .brand small { display: none; }
  .nav {
    position: absolute; top: var(--header-h); inset-inline: 0; flex-direction: column;
    background: var(--bg); padding: 12px 24px 20px; border-bottom: 1px solid var(--line);
    box-shadow: var(--shadow); display: none;
  }
  .nav.open { display: flex; }
  .nav a { padding: 12px 16px; }
}

/* ===== الأزرار ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  padding: 12px 24px; border-radius: 12px; font-weight: 700; font-family: inherit; font-size: 1rem;
  border: 1.5px solid var(--primary); background: var(--primary); color: #fff; cursor: pointer;
  transition: transform .15s, box-shadow .15s, background .15s;
}
[data-theme="dark"] .btn { color: #0d141e; }
.btn:hover { text-decoration: none; transform: translateY(-1px); box-shadow: var(--shadow); }
.btn .icon { width: 19px; height: 19px; }
.btn.sm { padding: 8px 16px; font-size: .92rem; border-radius: 10px; }
.btn.ghost { background: transparent; color: var(--primary); border-color: var(--line); }
.btn.ghost:hover { border-color: var(--primary); }
.btn.accent { background: var(--accent); border-color: var(--accent); }
.btn-row { display: flex; gap: 12px; flex-wrap: wrap; }

/* ===== الأقسام ===== */
.section { padding: 96px 0; }
.section.alt { background: var(--bg-alt); }
.section-head { max-width: 680px; margin-bottom: 48px; }
.section-head.center { margin-inline: auto; }
.eyebrow {
  display: inline-flex; align-items: center; gap: 8px; font-size: .85rem; font-weight: 700;
  color: var(--accent); letter-spacing: .02em; margin-bottom: 10px;
}
.eyebrow::before { content: ""; width: 22px; height: 2px; background: currentColor; border-radius: 2px; }
.section-head p { color: var(--muted); font-size: 1.08rem; }

/* ===== البطاقة الرئيسية ===== */
.hero { padding: 72px 0 40px; position: relative; overflow: hidden; }
.hero::before {
  content: ""; position: absolute; inset: 0; z-index: -1; opacity: .5;
  background-image: radial-gradient(var(--line) 1px, transparent 1px);
  background-size: 22px 22px;
  mask-image: radial-gradient(ellipse 70% 70% at 30% 40%, #000 30%, transparent 75%);
}
.hero-grid { display: grid; grid-template-columns: 1.25fr .9fr; gap: 64px; align-items: center; }
.hero .badge {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px 6px 8px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line); font-size: .88rem; color: var(--ink-2);
  margin-bottom: 22px; box-shadow: var(--shadow-sm);
}
.hero .badge .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px var(--green-soft); }
.hero h1 { margin-bottom: .25em; }
.hero .role { font-size: 1.15rem; color: var(--primary-2); font-weight: 600; margin-bottom: 18px; }
.hero .lead { font-size: 1.12rem; color: var(--ink-2); max-width: 600px; margin-bottom: 30px; }
.socials { display: flex; gap: 10px; margin-top: 28px; flex-wrap: wrap; }
.socials a {
  display: inline-flex; align-items: center; gap: 8px; font-size: .88rem; font-weight: 500;
  color: var(--muted); padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px;
}
.socials a:hover { color: var(--primary); border-color: var(--primary); text-decoration: none; }

.portrait { position: relative; justify-self: center; width: min(380px, 100%); }
.portrait .frame {
  aspect-ratio: 4 / 5; border-radius: 28px; overflow: hidden; position: relative;
  background: linear-gradient(160deg, var(--primary) 0%, #1d5a8f 55%, var(--green) 130%);
  box-shadow: var(--shadow-lg); display: grid; place-items: center;
}
.portrait .frame img { width: 100%; height: 100%; object-fit: cover; }
.portrait .frame .initials { font-family: var(--font-display); color: rgba(255, 255, 255, .9); font-size: 6rem; font-weight: 800; }
.portrait::before {
  content: ""; position: absolute; inset: 22px -22px -22px 22px; border-radius: 28px;
  border: 2px solid var(--gold); z-index: -1; opacity: .6;
}

@media (max-width: 900px) {
  .hero-grid { grid-template-columns: 1fr; gap: 48px; }
  .portrait { width: min(300px, 80%); order: -1; }
}

/* ===== الشبكات والبطاقات ===== */
.grid { display: grid; gap: 24px; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(min(400px, 100%), 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 28px; box-shadow: var(--shadow-sm); transition: transform .2s, box-shadow .2s, border-color .2s;
}
.card h3 { margin-bottom: .4em; }
.card p:last-child { margin-bottom: 0; }
a.card { color: inherit; display: block; }
a.card:hover { transform: translateY(-4px); box-shadow: var(--shadow); border-color: color-mix(in srgb, var(--primary) 35%, var(--line)); text-decoration: none; }
.ic {
  width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; margin-bottom: 18px;
  background: var(--primary-soft); color: var(--primary);
}
.ic.accent { background: var(--accent-soft); color: var(--accent); }
.ic.green { background: var(--green-soft); color: var(--green); }
.card .more { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; color: var(--primary-2); margin-top: 8px; font-size: .95rem; }
.card.disabled { opacity: .62; }
.tag {
  display: inline-block; font-size: .76rem; font-weight: 700; padding: 3px 12px; border-radius: 999px;
  background: var(--primary-soft); color: var(--primary); line-height: 1.7;
}
.tag.soon { background: var(--accent-soft); color: var(--accent); }
.tag.ok { background: var(--green-soft); color: var(--green); }
.tags { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }

/* ===== حول ===== */
.about-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 64px; align-items: start; }
.about-grid .bio p { font-size: 1.06rem; color: var(--ink-2); }
.feature-list { display: grid; gap: 18px; }
.feature { display: flex; gap: 16px; align-items: flex-start; }
.feature .ic { margin: 0; width: 44px; height: 44px; }
.feature h3 { font-size: 1.05rem; margin-bottom: .15em; }
.feature p { color: var(--muted); margin: 0; font-size: .97rem; }
@media (max-width: 900px) { .about-grid { grid-template-columns: 1fr; gap: 40px; } }

/* ===== الخط الزمني ===== */
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before { content: ""; position: absolute; inset-inline-start: 7px; top: 8px; bottom: 8px; width: 2px; background: var(--line); }
.timeline li { position: relative; padding-inline-start: 36px; padding-bottom: 28px; }
.timeline li:last-child { padding-bottom: 0; }
.timeline li::before {
  content: ""; position: absolute; inset-inline-start: 0; top: 8px; width: 16px; height: 16px;
  border-radius: 50%; background: var(--surface); border: 3px solid var(--primary);
}
.timeline li:first-child::before { background: var(--primary); box-shadow: 0 0 0 5px var(--primary-soft); }
.timeline .when { font-size: .85rem; color: var(--accent); font-weight: 700; }
.timeline b { display: block; font-size: 1.05rem; }
.timeline .where { color: var(--muted); font-size: .95rem; }

/* ===== التدريس ===== */
.course { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 16px 0; border-bottom: 1px dashed var(--line); }
.course:last-child { border-bottom: 0; }
.course b { font-weight: 600; }
.course .lvl { font-size: .82rem; color: var(--muted); white-space: nowrap; }

/* ===== المنشورات ===== */
.pubs { list-style: none; padding: 0; margin: 0; display: grid; gap: 14px; }
.pubs li {
  display: grid; grid-template-columns: 70px 1fr; gap: 20px; align-items: baseline;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 18px 22px;
}
.pubs .yr { font-family: var(--font-display); font-weight: 700; color: var(--primary); font-size: 1.05rem; }
.pubs .title { font-weight: 600; display: block; }
.pubs .venue { color: var(--muted); font-size: .94rem; }
.pubs .type { font-size: .72rem; margin-inline-start: 8px; vertical-align: middle; }
a.title { color: var(--ink); }
a.title:hover { color: var(--primary-2); }
.pubs li[dir="ltr"] { font-family: "IBM Plex Sans", "Segoe UI", sans-serif; }
.pubs li[dir="ltr"] .venue { font-size: .9rem; }
.pub-head { margin: 36px 0 16px; display: flex; align-items: center; gap: 10px; }
.pub-head::before { content: ""; width: 4px; height: 20px; border-radius: 2px; background: var(--accent); }
.pub-group { margin-top: 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 4px 22px; }
.pub-group summary { cursor: pointer; font-family: var(--font-display); font-weight: 700; font-size: 1.1rem; padding: 14px 0; list-style: none; display: flex; align-items: center; gap: 10px; }
.pub-group summary::-webkit-details-marker { display: none; }
.pub-group summary .count { background: var(--primary-soft); color: var(--primary); border-radius: 999px; padding: 0 10px; font-size: .85rem; }
.pub-group summary::after { content: "+"; margin-inline-start: auto; font-size: 1.4rem; color: var(--primary); }
.pub-group[open] summary::after { content: "−"; }
.pub-group .pubs { padding-bottom: 18px; }
.pub-group .pubs li { background: var(--bg); }

/* ===== الدروس التفاعلية ===== */
.chapters { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr)); gap: 12px; }
.chapters a {
  display: flex; align-items: center; gap: 14px; padding: 14px 18px; border-radius: var(--radius-sm);
  background: var(--surface); border: 1px solid var(--line); color: var(--ink); height: 100%;
  transition: border-color .15s, transform .15s;
}
.chapters a:hover { border-color: var(--primary); transform: translateY(-2px); text-decoration: none; }
.chapters .num {
  flex: none; width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center;
  background: var(--primary-soft); color: var(--primary); font-weight: 700; font-family: "IBM Plex Sans", var(--font);
}
.chapters b { display: block; font-weight: 600; line-height: 1.5; }
.chapters small { color: var(--muted); font-size: .82rem; }
.lesson-card .lc-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.lesson-card .lc-num { flex: none; width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--primary); color: #fff; font-weight: 700; font-size: 1.15rem; font-family: "IBM Plex Sans", var(--font); }
[data-theme="dark"] .lesson-card .lc-num { color: #0d141e; }
.lesson-card p { font-size: .95rem; }
.part-label { font-family: var(--font-display); font-weight: 700; margin: 28px 0 12px; color: var(--ink-2); }
.part-label:first-of-type { margin-top: 0; }

.page-hero { padding: 72px 0 48px; }
.page-hero .lead { font-size: 1.15rem; color: var(--ink-2); max-width: 680px; }
.crumbs { font-size: .88rem; color: var(--muted); margin-bottom: 16px; }
.crumbs a { color: var(--muted); }
.lesson-meta { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 22px; }
.lesson-meta span {
  display: inline-flex; align-items: center; gap: 6px; font-size: .88rem; color: var(--ink-2);
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 5px 14px;
}
.lesson-meta .icon { width: 16px; height: 16px; }
.lesson { max-width: 820px; margin: 0 auto; padding-bottom: 40px; }
.lesson > section { padding: 28px 0; }
.lesson h2 { display: flex; gap: 14px; align-items: center; }
.lesson h2 .n {
  flex: none; width: 38px; height: 38px; border-radius: 11px; background: var(--primary); color: #fff;
  display: grid; place-items: center; font-size: 1.05rem;
}
[data-theme="dark"] .lesson h2 .n { color: #0d141e; }
.lesson p { color: var(--ink-2); }

.thumb {
  aspect-ratio: 16 / 9; border-radius: 12px; margin: -8px -8px 20px; overflow: hidden; border: 1px solid var(--line);
  background: #eef3f8; display: grid; place-items: center;
}
.thumb svg { width: 100%; height: 100%; }

/* الشكل يبقى فاتحًا في الوضعين لأن الرسوم مصممة على خلفية فاتحة */
.figure {
  background: #fff; color: #14202e; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; margin: 26px 0; box-shadow: var(--shadow);
}
.figure svg { width: 100%; height: auto; display: block; direction: ltr; }
.figure .caption { font-size: .88rem; color: #667387; margin-top: 10px; text-align: center; line-height: 1.8; }
.controls { display: grid; gap: 14px 28px; margin-top: 18px; padding-top: 18px; border-top: 1px solid #ece9e1; }
.controls.cols { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.control label { display: flex; align-items: baseline; gap: 6px; font-weight: 500; font-size: .93rem; color: #344256; }
.control output { margin-inline-start: auto; font-weight: 700; color: #123b63; unicode-bidi: isolate; background: #e6eef6; padding: 0 10px; border-radius: 6px; font-size: .88rem; }
input[type=range] { width: 100%; accent-color: #123b63; cursor: pointer; direction: ltr; }
.readout { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.readout .pill { background: #f3f5f8; border: 1px solid #e6eaf0; border-radius: 10px; padding: 6px 14px; font-size: .9rem; color: #344256; unicode-bidi: plaintext; }
.readout .pill b { color: #123b63; }
.figure .note, .figure .note.info { background: #e6eef6; border-color: #123b63; color: #344256; margin-top: 16px; }
.figure .note b { color: #123b63; }
.table-wrap { overflow-x: auto; margin-top: 16px; }
.data-table { width: 100%; border-collapse: collapse; font-size: .92rem; color: #344256; }
.data-table th, .data-table td { border-bottom: 1px solid #ece9e1; padding: 7px 10px; text-align: center; font-variant-numeric: tabular-nums; }
.data-table th { background: #f3f5f8; font-weight: 600; }
.data-table td { direction: ltr; }

.note {
  background: var(--accent-soft); border-inline-start: 4px solid var(--accent);
  padding: 16px 20px; border-radius: 10px; margin: 22px 0; color: var(--ink-2);
}
.note.info { background: var(--primary-soft); border-color: var(--primary); }
.note.source { display: flex; gap: 12px; align-items: flex-start; margin-top: 40px; }
.note.source .icon { color: var(--primary); margin-top: 6px; }

/* اختبار قصير */
.quiz { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px; box-shadow: var(--shadow-sm); }
.quiz .q { margin-bottom: 26px; }
.quiz .q:last-child { margin-bottom: 0; }
.quiz .q > p { font-weight: 600; color: var(--ink); }
.quiz .opts { display: grid; gap: 8px; }
.quiz button.opt {
  text-align: start; font: inherit; font-size: .97rem; padding: 10px 16px; border-radius: 10px; cursor: pointer;
  border: 1.5px solid var(--line); background: var(--bg); color: var(--ink);
}
.quiz button.opt:hover:not(:disabled) { border-color: var(--primary); }
.quiz button.opt.right { border-color: var(--green); background: var(--green-soft); }
.quiz button.opt.wrong { border-color: var(--accent); background: var(--accent-soft); }
.quiz button.opt:disabled { cursor: default; }
.quiz .why { display: none; margin-top: 10px; font-size: .95rem; color: var(--ink-2); padding: 10px 14px; border-radius: 8px; background: var(--bg-alt); }
.quiz .q.done .why { display: block; }
.quiz .score { font-weight: 700; color: var(--primary); margin-top: 18px; }


.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 40px 0 0; }
.pager a { display: block; padding: 18px 22px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink); }
.pager a:hover { border-color: var(--primary); text-decoration: none; }
.pager small { display: block; color: var(--muted); }
.pager .next { text-align: end; grid-column: 2; }

.katex { direction: ltr; unicode-bidi: isolate; font-size: 1.07em; }
.katex-display { margin: 1.2em 0; overflow-x: auto; overflow-y: hidden; padding: 4px 0; }

/* ===== التذييل ===== */
.site-footer { background: var(--bg-alt); border-top: 1px solid var(--line); padding: 64px 0 28px; color: var(--muted); font-size: .95rem; }
.footer-grid { display: grid; grid-template-columns: 1.6fr 1fr 1fr; gap: 48px; }
.site-footer h4 { font-size: .95rem; color: var(--ink); margin-bottom: 14px; }
.site-footer ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.site-footer a { color: var(--muted); }
.site-footer a:hover { color: var(--primary); }
.footer-bottom { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 12px; border-top: 1px solid var(--line); margin-top: 48px; padding-top: 24px; font-size: .88rem; }
@media (max-width: 800px) { .footer-grid { grid-template-columns: 1fr; gap: 32px; } }

/* ===== ظهور تدريجي ===== */
/* أُلغي الظهور التدريجي: يظهر المحتوى مباشرة */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal { opacity: 1; transform: none; transition: none; }
  * { transition: none !important; }
}

/* ===== فهرس المختبر: الموضوع وتقدّم الطالب ===== */
.lc-topic { font-size: .85rem; font-weight: 600; color: var(--muted); }
.lc-prog { margin-inline-start: auto; font-size: .8rem; font-weight: 600; color: var(--green); background: var(--green-soft); border-radius: 3px; padding: 1px 10px; white-space: nowrap; }
.lesson-card.done .lc-num { background: var(--green); }

/* ===== محاور البحث ===== */
#research .card h3 { margin-bottom: 8px; }
.axis-label { margin: 14px 0 6px; font-size: .82rem; font-weight: 700; color: var(--accent); }
.axis-pubs { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: .9rem; line-height: 1.6; }
.axis-pubs li { padding-inline-start: 14px; position: relative; color: var(--muted); }
.axis-pubs li::before { content: ""; position: absolute; inset-inline-start: 0; top: .7em; width: 6px; height: 6px; border-radius: 50%; background: var(--line); }
.axis-pubs a { color: var(--ink-2); }
.axis-pubs a[dir="ltr"] { unicode-bidi: isolate; }
.axis-yr { font-weight: 700; color: var(--primary); margin-inline-end: 8px; font-size: .82rem; }
.print-only { display: none; }

/* ===== الطباعة: الصفحة الرئيسية تُطبع كسيرة ذاتية ===== */
@media print {
  .print-only { display: block; }
  .print-contact { margin: 6px 0 0; font-size: 9.5pt; color: #344256; direction: ltr; unicode-bidi: isolate; }
  html[dir="rtl"] .print-contact { text-align: right; }
  #research .grid { grid-template-columns: 1fr 1fr; }
  .axis-label { margin-top: 6px; }
  .axis-pubs { font-size: 9pt; gap: 2px; }
  @page { margin: 14mm; }
  :root, :root[data-theme="dark"] {
    --bg: #fff; --bg-alt: #fff; --surface: #fff; --ink: #14202e; --ink-2: #344256; --muted: #5b6578;
    --line: #d9d5cb; --primary: #123b63; --primary-2: #1d5a8f; --primary-soft: #e6eef6;
    --accent: #b5562f; --accent-soft: #f7e9e2; --green: #2a8c7f; --green-soft: #e1f2ef;
  }
  body { font-size: 10.5pt; line-height: 1.6; background: #fff; color: #14202e; }
  .grid.cols-2 { grid-template-columns: 1fr 1fr; gap: 12px; }
  .grid.cols-3 { grid-template-columns: repeat(3, 1fr); gap: 12px; }
  .ic, .eyebrow, .section-head p, .hero .badge { display: none !important; }
  h2, h3, .section-head { break-after: avoid; page-break-after: avoid; }
  .feature-list { grid-template-columns: 1fr 1fr; gap: 6px 18px; margin-top: 10px; }
  .timeline li { padding-bottom: 10px; }
  .course { padding: 5px 0; }
  .pubs { gap: 6px; }
  .pubs li { padding: 6px 12px; }
  .pub-group { border: 0; padding: 0; }
  #cv .grid { display: block; }
  #cv .card { break-inside: auto; margin-bottom: 12px; }
  .timeline li, .course, .pubs li { break-inside: avoid; }
  .pub-group summary::after { display: none; }
  .site-header, .site-footer, .no-print, .btn, .socials, .portrait, .hero::before { display: none !important; }
  .section, .hero { padding: 14px 0 !important; }
  .section.alt { background: none; }
  .hero-grid, .about-grid { display: block; }
  .section-head { margin-bottom: 12px; }
  .card, .pubs li { box-shadow: none; break-inside: avoid; padding: 10px 14px; }
  .reveal { opacity: 1 !important; transform: none !important; }
  h1 { font-size: 22pt; } h2 { font-size: 15pt; }
  a { color: #000; }

  /* سيرة مدمجة: بلا إطارات، بأحجام خطّ أصغر وأسطر أقلّ */
  html { font-size: 11.5px; }
  body { font-size: 9.5pt; line-height: 1.5; }
  .pub-group summary, .pub-head { break-after: avoid; page-break-after: avoid; }
  h1 { font-size: 19pt; } h2 { font-size: 13pt; margin: 0; } h3 { font-size: 11pt; }
  #about .feature-list { display: none; }
  .card { border: 0 !important; border-radius: 0; padding: 0 !important; margin-bottom: 10px; }
  #cv .card h3, #research .card h3 { margin-bottom: 4px !important; padding-bottom: 2px; border-bottom: 1px solid #d9d5cb; }
  #research .grid { gap: 8px 20px; }
  #research .card { break-inside: avoid; }
  #research .muted { margin: 0; font-size: 9pt; }
  .timeline::before, .timeline li::before { display: none; }
  .timeline li { padding: 0 0 4px; }
  .timeline .when { display: inline; font-size: 8.5pt; margin-inline-end: 8px; }
  .timeline b { display: inline; font-size: 9.5pt; }
  .timeline .where { font-size: 8.5pt; }
  .course { padding: 2px 0; border-bottom: 0; }
  .course b, .pubs .title, a.title { font-size: 9.5pt; }
  .course .lvl { font-size: 8pt; }
  .bio p, #research .muted, .card > p { font-size: 9.5pt; }
  .tags .tag, .tag { padding: 0 6px; font-size: 8pt; }
  .pubs { gap: 3px; }
  .pubs li { border: 0 !important; border-radius: 0; padding: 2px 0 !important; grid-template-columns: 40px 1fr; gap: 8px; background: none !important; }
  .pubs .yr { font-size: 9pt; }
  .pubs .venue, .pubs li[dir="ltr"] .venue { font-size: 8.5pt; }
  .pub-head { margin: 12px 0 6px; }
  .pub-group summary { padding: 8px 0 4px; font-size: 11pt; }
  .pub-group .pubs { padding-bottom: 4px; }
  #contact { display: none; } /* البريد وORCID في سطر التواصل أعلى السيرة */
}

/* =========================================================
   الصفحة الرئيسية: الاتجاه «أكاديمي تحريري»
   (للشاشة فقط؛ الطباعة وملفات PDF تبقى على النمط السابق،
   والدروس لا تتأثّر لأن كل القواعد مقيّدة بـ data-page="home")
   ========================================================= */
@media screen {
  body[data-page="home"], body[data-page="learn"] {
    --bg: #f7f4ec;
    --bg-alt: #efeadf;
    --surface: #fbf9f4;
    --ink: #1e1b16;
    --ink-2: #3a352d;
    --muted: #5e584d;
    --line: #d9d2c3;
    --primary: #8a2d2d;
    --primary-2: #8a2d2d;
    --primary-soft: #f1e3df;
    --accent: #8a2d2d;
    --accent-soft: #f1e3df;
    --gold: #b08a3e;
    --font-display: "IBM Plex Sans Arabic", "Segoe UI", Tahoma, sans-serif;
    --shadow-sm: none;
    --shadow: 0 1px 2px rgba(30, 27, 22, .06);
  }
  [data-theme="dark"] body[data-page="home"], [data-theme="dark"] body[data-page="learn"] {
    --bg: #14120f;
    --bg-alt: #1b1814;
    --surface: #1d1a16;
    --ink: #ede7db;
    --ink-2: #d3ccbe;
    --muted: #a69e8f;
    --line: #34302a;
    --primary: #e0a196;
    --primary-2: #e0a196;
    --primary-soft: #3a2420;
    --accent: #e0a196;
    --accent-soft: #3a2420;
  }
  html[lang="en"] body[data-page="home"] { --font-display: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif; }

  [data-page="home"] h1, [data-page="home"] h2, [data-page="learn"] h1, [data-page="learn"] h2 { font-weight: 700; letter-spacing: 0; }
  [data-page="home"] h2, [data-page="learn"] h2 { font-size: clamp(1.6rem, 2.6vw, 2.1rem); line-height: 1.45; }
  html[lang="en"] [data-page="home"] h2 { font-size: clamp(1.7rem, 2.8vw, 2.2rem); letter-spacing: -.01em; }
  [data-page="home"] h3, [data-page="learn"] h3 { font-family: var(--font); font-weight: 600; }
  html[lang="en"] [data-page="home"] h3 { font-family: var(--font); }

  /* الترويسة: الاسم وحده بخطّ العناوين */
  [data-page="home"] .site-header, [data-page="learn"] .site-header { border-bottom: 1px solid var(--line); }
  [data-page="home"] .site-header.scrolled, [data-page="learn"] .site-header.scrolled { box-shadow: none; }
  [data-page="home"] .brand .mark, [data-page="learn"] .brand .mark { display: none; }
  [data-page="home"] .brand > span, [data-page="learn"] .brand > span { font-family: var(--font-display); font-size: 1.02rem; font-weight: 700; }
  [data-page="home"] .brand small, [data-page="learn"] .brand small { font-family: var(--font); font-size: .78rem; }
  [data-page="home"] .nav a, [data-page="learn"] .nav a { border-radius: 0; padding: 8px 12px; color: var(--ink); }
  [data-page="home"] .nav a:hover, [data-page="home"] .nav a.active, [data-page="learn"] .nav a:hover, [data-page="learn"] .nav a.active { background: none; color: var(--accent); }
  [data-page="home"] .icon-btn, [data-page="learn"] .icon-btn { border-radius: 4px; background: transparent; }

  /* الأزرار */
  [data-page="home"] .btn, [data-page="learn"] .btn { border-radius: 4px; font-weight: 600; }
  [data-page="home"] .btn:hover, [data-page="learn"] .btn:hover { transform: none; box-shadow: none; filter: brightness(1.08); }
  [data-page="home"] .btn.ghost, [data-page="learn"] .btn.ghost { color: var(--ink); border-color: var(--ink); }
  [data-page="home"] .btn.ghost:hover, [data-page="learn"] .btn.ghost:hover { color: var(--accent); border-color: var(--accent); filter: none; }

  /* صفحات المختبر: الهوية نفسها مع إبقاء البطاقات (أدوات الدرس تحتاج إطارها) */
  body[data-page="learn"] { --radius: 8px; --radius-sm: 6px; }
  [data-page="learn"] .eyebrow { font-size: .82rem; font-weight: 600; }
  [data-page="learn"] .eyebrow::before { display: none; }
  [data-page="learn"] .tag { border-radius: 3px; }
  [data-page="learn"] .hero::before { display: none; }
  [data-page="learn"] .site-footer { background: none; }

  /* البطاقة التعريفية */
  [data-page="home"] .hero { padding: 88px 0 72px; }
  [data-page="home"] .hero::before { display: none; }
  [data-page="home"] .hero h1 { font-size: clamp(2.1rem, 4.2vw, 3.2rem); line-height: 1.35; margin-bottom: .3em; }
  html[lang="en"] [data-page="home"] .hero h1 { font-size: clamp(2.1rem, 4.2vw, 3.2rem); letter-spacing: -.02em; }
  [data-page="home"] .hero .role { color: var(--muted); font-weight: 500; font-size: 1.08rem; line-height: 1.8; }
  [data-page="home"] .hero .lead { color: var(--ink); font-size: 1.15rem; }
  [data-page="home"] .socials { gap: 8px 26px; margin-top: 30px; }
  [data-page="home"] .socials a { border: 0; padding: 0; border-radius: 0; color: var(--accent); font-weight: 500; font-size: .95rem; }
  [data-page="home"] .socials a:hover { color: var(--ink); text-decoration: underline; }
  [data-page="home"] .hero-grid { grid-template-columns: 1fr; max-width: 820px; }
  /* صورة دائرية صغيرة في الترويسة بجانب الاسم */
  [data-page="learn"] .brand .mark { display: none; }
  [data-page="home"] .brand-photo, [data-page="learn"] .brand-photo {
    display: block; flex: none; width: 40px; height: 40px; border-radius: 50%; object-fit: cover; object-position: 50% 20%;
    border: 1px solid var(--line);
  }
  [data-page="home"] .portrait { width: min(340px, 100%); }
  [data-page="home"] .portrait::before { display: none; }
  [data-page="home"] .portrait .frame { border-radius: 0; box-shadow: none; background: var(--bg-alt); border: 1px solid var(--line); aspect-ratio: 6 / 7; }
  [data-page="home"] .portrait .frame img { filter: grayscale(.12); }

  /* الأقسام: فواصل دقيقة بدل الخلفيات المتناوبة */
  [data-page="home"] .section { padding: 80px 0; }
  [data-page="home"] .section.alt { background: none; }
  [data-page="home"] main > section + section { border-top: 1px solid var(--line); }
  [data-page="home"] .section-head { margin-bottom: 40px; }
  [data-page="home"] .eyebrow { font-size: .82rem; font-weight: 600; }
  [data-page="home"] .eyebrow::before { display: none; }

  /* البطاقات: بلا صناديق، بخطّ علوي */
  [data-page="home"] .card { background: none; border: 0; border-top: 2px solid var(--ink); border-radius: 0; padding: 20px 0 0; box-shadow: none; }
  [data-page="home"] a.card:hover { transform: none; box-shadow: none; border-color: var(--accent); }
  [data-page="home"] .ic { display: none; }
  [data-page="home"] .grid.cols-2 { gap: 44px 56px; }
  [data-page="home"] .grid.cols-3 { gap: 36px 48px; }
  [data-page="home"] .tag { border-radius: 3px; background: var(--bg-alt); color: var(--ink-2); font-weight: 500; }

  /* محاور البحث مرقّمة */
  [data-page="home"] #research .grid { counter-reset: axis; }
  [data-page="home"] #research .card { counter-increment: axis; }
  [data-page="home"] #research .card::before {
    content: counter(axis, arabic-indic); display: block; font-family: var(--font-display);
    font-size: 1.7rem; font-weight: 700; line-height: 1; color: var(--accent); margin-bottom: 12px;
  }
  html[lang="en"] [data-page="home"] #research .card::before { content: counter(axis, decimal); }
  [data-page="home"] #research .card h3 { font-size: 1.2rem; line-height: 1.6; }
  [data-page="home"] .axis-label { color: var(--muted); }
  [data-page="home"] .axis-yr { color: var(--accent); }

  /* الخط الزمني */
  [data-page="home"] .timeline li::before { border-color: var(--ink-2); border-width: 2px; width: 14px; height: 14px; top: 9px; }
  [data-page="home"] .timeline li:first-child::before { background: var(--accent); border-color: var(--accent); box-shadow: none; }
  [data-page="home"] .timeline .when { color: var(--accent); font-weight: 600; }

  /* المنشورات: أسطر بعمود للسنة */
  [data-page="home"] .pub-head { font-family: var(--font-display); font-size: 1.25rem; margin: 44px 0 6px; }
  [data-page="home"] .pub-head::before { display: none; }
  [data-page="home"] .pubs { gap: 0; }
  [data-page="home"] .pubs li { background: none !important; border: 0; border-top: 1px solid var(--line); border-radius: 0; padding: 18px 0; grid-template-columns: 76px 1fr; }
  [data-page="home"] .pubs .yr { font-family: var(--font-display); color: var(--accent); font-size: 1.02rem; font-weight: 600; }
  [data-page="home"] .pubs li[dir="ltr"] .title { font-size: 1.02rem; font-weight: 600; line-height: 1.55; }
  [data-page="home"] .pubs li:not([dir="ltr"]) .title { font-size: 1.04rem; font-weight: 600; line-height: 1.7; }
  [data-page="home"] .pub-group { background: none; border: 0; border-top: 2px solid var(--ink); border-radius: 0; padding: 0; margin-top: 36px; }
  [data-page="home"] .pub-group summary { font-size: 1.15rem; }
  [data-page="home"] .pub-group summary .count { background: var(--bg-alt); color: var(--ink-2); border-radius: 3px; }
  [data-page="home"] .pub-group summary::after { color: var(--accent); }

  /* التذييل */
  [data-page="home"] .site-footer { background: none; }
  [data-page="home"] .site-footer h4 { font-family: var(--font-display); font-size: 1rem; }

  /* ===== بطاقة المختبر (داكنة في الوضعين) ===== */
  .lab-feature {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(min(380px, 100%), 1fr)); gap: 40px; align-items: center;
    padding: 40px; border-radius: 6px; background: #0f1620; color: #e8edf3; text-decoration: none !important;
    background-image: linear-gradient(#18222e 1px, transparent 1px), linear-gradient(90deg, #18222e 1px, transparent 1px);
    background-size: 40px 40px; transition: box-shadow .2s;
  }
  [data-theme="dark"] .lab-feature { border: 1px solid #2a3646; }
  .lab-feature:hover { box-shadow: 0 20px 40px -20px rgba(15, 22, 32, .6); }
  .lab-feature:hover .lab-cta { text-decoration: underline; text-underline-offset: 5px; }
  .lab-kicker { font-size: .85rem; font-weight: 600; color: #6cb8d8; }
  .lab-text h3 { color: #e8edf3; font-family: var(--font-display); font-size: clamp(1.35rem, 2.2vw, 1.75rem); font-weight: 700; line-height: 1.5; margin: 10px 0 12px; }
  .lab-text p { color: #b8c3d0; margin-bottom: 20px; }
  .lab-qs { list-style: none; margin: 0 0 24px; padding: 0; display: grid; gap: 8px; }
  .lab-qs li { display: flex; gap: 12px; align-items: baseline; color: #e8edf3; font-size: .98rem; }
  .lab-qs li span { font-family: "IBM Plex Mono", ui-monospace, monospace; font-size: .8rem; color: #6cb8d8; direction: ltr; }
  .lab-cta { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; color: #e3a857; }
  .lab-cta .icon { width: 18px; height: 18px; }
  .lab-fig { margin: 0; background: #16202c; border: 1px solid #243244; border-radius: 6px; padding: 16px; }
  .lab-fig svg { width: 100%; height: auto; display: block; }
  .lab-read { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 8px; font-family: "IBM Plex Mono", ui-monospace, monospace; font-size: .8rem; color: #9aa7b6; direction: ltr; justify-content: flex-start; }
  .lab-read .ok { color: #7fd1a8; }
  @media (max-width: 600px) { .lab-feature { padding: 26px 20px; } }
}
@media print { .lab-feature { display: none; } }
