/* هوية «حجر ونقش» — ألوان محاضرات الخط العربي: بازلت ورمل ومُغرة ولازورد */

@font-face { font-family: "Readex Pro"; font-weight: 160 700; font-display: swap;
  src: url(../fonts/readexpro-var-arabic.woff2) format("woff2");
  unicode-range: U+0600-065F, U+066D-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC; }
@font-face { font-family: "Readex Pro"; font-weight: 160 700; font-display: swap;
  src: url(../fonts/readexpro-var-latin.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Amiri"; font-weight: 400; font-display: swap;
  src: url(../fonts/amiri-400-arabic.woff2) format("woff2");
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC; }
@font-face { font-family: "Amiri"; font-weight: 400; font-display: swap;
  src: url(../fonts/amiri-400-latin.woff2) format("woff2"); unicode-range: U+0000-00FF, U+2000-206F; }
@font-face { font-family: "Amiri"; font-weight: 700; font-display: swap;
  src: url(../fonts/amiri-700-arabic.woff2) format("woff2");
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC; }
@font-face { font-family: "Amiri"; font-weight: 700; font-display: swap;
  src: url(../fonts/amiri-700-latin.woff2) format("woff2"); unicode-range: U+0000-00FF, U+2000-206F; }
/* أرقام ريدكس الهندية ملتبسة في الأحجام الصغيرة (٢٦ تُقرأ رمزاً واحداً)؛ تُؤخذ الأرقام وحدها من أميري */
@font-face { font-family: "Num"; font-weight: 100 500; font-display: swap;
  src: url(../fonts/amiri-400-arabic.woff2) format("woff2"); unicode-range: U+0660-066C; }
@font-face { font-family: "Num"; font-weight: 501 900; font-display: swap;
  src: url(../fonts/amiri-700-arabic.woff2) format("woff2"); unicode-range: U+0660-066C; }

:root {
  --bg: #F4EEE2;
  --surface: #FBF8F2;
  --surface-2: #EFE6D6;
  --ink: #1F1B17;
  --muted: #6E6457;
  --line: #E2D4BC;
  --basalt: #25262A;
  --ochre: #A86F24;
  --lapis: #24507F;
  --rust: #A23F25;
  --ok: #2F7A4D;
  --gold: #D9B26F;      /* المُغرة الفاتحة: ثابتة على الخلفيات الداكنة في الوضعين */
  --sand: #EFE6D6;      /* نص فاتح على الداكن */
  --accent: var(--ochre);
  --tint: color-mix(in srgb, var(--accent) 12%, var(--surface));
  --shadow: 0 1px 2px rgb(31 27 23 / .05), 0 12px 32px -18px rgb(31 27 23 / .28);
  --shadow-lift: 0 2px 4px rgb(31 27 23 / .06), 0 22px 40px -20px rgb(31 27 23 / .38);
  --r: 20px;
  --tb: 56px;           /* ارتفاع الشريط العلوي */
  --serif: "Amiri", "Traditional Arabic", serif;
  --sans: "Num", "Readex Pro", "Segoe UI", Tahoma, sans-serif;
  --star: polygon(50% 0%, 64.6% 14.6%, 85.4% 14.6%, 85.4% 35.4%, 100% 50%, 85.4% 64.6%, 85.4% 85.4%, 64.6% 85.4%, 50% 100%, 35.4% 85.4%, 14.6% 85.4%, 14.6% 64.6%, 0% 50%, 14.6% 35.4%, 14.6% 14.6%, 35.4% 14.6%);
  --octagon: polygon(29% 0, 71% 0, 100% 29%, 100% 71%, 71% 100%, 29% 100%, 0 71%, 0 29%);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161719;
    --surface: #202124;
    --surface-2: #2A2B2F;
    --ink: #EFE6D6;
    --muted: #A99F90;
    --line: #34353A;
    --ochre: #D9B26F;
    --lapis: #8FB3DC;
    --rust: #E0866C;
    --ok: #7FCB9C;
    --tint: color-mix(in srgb, var(--accent) 10%, var(--surface));
    --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 14px 34px -18px rgb(0 0 0 / .7);
    --shadow-lift: 0 2px 4px rgb(0 0 0 / .35), 0 24px 44px -20px rgb(0 0 0 / .8);
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: calc(var(--tb) + 56px); }
body {
  margin: 0; min-height: 100vh; display: flex; flex-direction: column;
  background: var(--bg); color: var(--ink);
  font: 400 17px/1.85 var(--sans);
  -webkit-font-smoothing: antialiased;
}
body.no-scroll { overflow: hidden; }
main { flex: 1; padding-bottom: 64px; }
a { color: inherit; }
img { max-width: 100%; height: auto; }
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { line-height: 1.35; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.kicker { display: block; color: var(--muted); font-size: .84rem; }
.ico { width: 22px; height: 22px; flex: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }

/* ---------- أزرار ---------- */
.btn-primary, .btn-ghost {
  display: inline-flex; align-items: center; gap: 10px; min-height: 48px; padding: 10px 22px;
  border-radius: 99px; text-decoration: none; cursor: pointer; font-weight: 500; white-space: nowrap;
  transition: transform .2s, background .2s, border-color .2s, box-shadow .2s;
}
.btn-primary { background: var(--gold); color: #1F1B17; border: 0; box-shadow: 0 8px 24px -10px rgb(217 178 111 / .7); }
.btn-primary:hover { transform: translateY(-2px); background: #E5C287; }
.btn-ghost { background: transparent; color: inherit; border: 1px solid color-mix(in srgb, currentColor 28%, transparent); }
.btn-ghost:hover { border-color: var(--gold); background: color-mix(in srgb, currentColor 6%, transparent); }
.btn-primary .ico, .btn-ghost .ico { width: 20px; height: 20px; }

/* ---------- الشريط العلوي ---------- */
.topbar {
  position: sticky; top: 0; z-index: 60; height: var(--tb);
  background: rgb(30 31 34 / .86); color: var(--sand);
  backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid rgb(217 178 111 / .28);
}
.topbar-in { display: flex; align-items: center; gap: 18px; height: 100%; }
.brand { display: inline-flex; align-items: center; gap: 10px; flex: none; text-decoration: none; font: 700 1.15rem var(--serif); }
.brand-star { width: 26px; height: 26px; color: var(--gold); transition: transform .8s; }
.brand:hover .brand-star { transform: rotate(45deg); }
.crumbs {
  display: flex; align-items: center; min-width: 0; overflow-x: auto; white-space: nowrap;
  font-size: .84rem; color: #BDB3A2; scrollbar-width: none;
  mask-image: linear-gradient(to left, #000 85%, transparent); -webkit-mask-image: linear-gradient(to left, #000 85%, transparent);
}
.crumbs::-webkit-scrollbar { display: none; }
.crumbs > *:not(:last-child)::after { content: "/"; margin: 0 .6em; opacity: .4; }
.crumbs a { text-decoration: none; }
.crumbs a:hover { color: var(--gold); }
.crumbs [aria-current] { color: var(--sand); padding-inline-end: 24px; }
@media (max-width: 640px) { .brand span { display: none; } }

/* ---------- العناوين ---------- */
.sec-title { display: flex; align-items: center; gap: 12px; font: 700 clamp(1.5rem, 3.6vw, 2rem) var(--serif); margin: 0 0 18px; }
.sec-title::before { content: ""; width: 14px; height: 14px; flex: none; background: var(--accent); clip-path: var(--star); }
.sec-title small { font: 400 .9rem var(--sans); color: var(--muted); }
.page-head { padding: 40px 0 8px; }
.page-title { font: 700 clamp(2.2rem, 6vw, 3.4rem)/1.25 var(--serif); }
.empty-note { color: var(--muted); padding: 22px; border: 1px dashed var(--line); border-radius: var(--r); text-align: center; }

/* ---------- البلاطات والبطاقات (bento) ---------- */
.tile, .card {
  position: relative; overflow: hidden; isolation: isolate;
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  text-decoration: none; color: inherit; box-shadow: var(--shadow);
  transition: transform .3s cubic-bezier(.2, .7, .2, 1), box-shadow .3s, border-color .3s;
}
a.tile:hover, a.card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lift); border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); }
.card { padding: 22px; gap: 4px; }
.card.is-empty { background: transparent; box-shadow: none; border-style: dashed; color: var(--muted); }
.emblem { position: absolute; z-index: -1; width: 160px; height: 160px; inset-inline-end: -46px; bottom: -50px; color: var(--accent); opacity: .12; transition: transform 1s cubic-bezier(.2, .7, .2, 1), opacity .3s; }
a.card:hover .emblem { transform: rotate(45deg) scale(1.08); opacity: .22; }

/* ================= الرئيسية ================= */
.mast { position: relative; overflow: hidden; isolation: isolate; background: var(--basalt); color: var(--sand); }
.mast::before {
  content: ""; position: absolute; inset: 0; z-index: -1; background: var(--gold); opacity: .1;
  -webkit-mask: url(../img/pattern.svg) center / 72px; mask: url(../img/pattern.svg) center / 72px;
}
.mast::after { content: ""; position: absolute; inset: 0; z-index: -1; background: radial-gradient(ellipse 70% 90% at 70% 50%, var(--basalt) 30%, transparent 80%); }
.mast-star { position: absolute; z-index: -1; width: min(70vw, 620px); height: auto; aspect-ratio: 1; inset-inline-end: -12%; top: 50%; translate: 0 -50%; color: var(--gold); opacity: .09; animation: spin 160s linear infinite; }
@keyframes spin { to { rotate: 360deg; } }
.mast-in { display: grid; grid-template-columns: 1.25fr 1fr; gap: 40px; align-items: center; padding-top: 72px; padding-bottom: 72px; }
.mast-kicker { color: var(--gold); letter-spacing: .25em; font-size: .9rem; }
.mast-name { font: 700 clamp(2.8rem, 8vw, 5.2rem)/1.2 var(--serif); margin: 6px 0 10px; }
.mast-org { color: #CFC5B4; font-size: clamp(.95rem, 2.4vw, 1.1rem); }
.mast-org b { color: var(--gold); font-weight: 400; margin: 0 .5em; }
.feature {
  display: grid; grid-template-rows: auto 1fr; border-radius: var(--r); overflow: hidden; text-decoration: none; color: inherit;
  background: rgb(255 255 255 / .06); border: 1px solid rgb(255 255 255 / .12);
  backdrop-filter: blur(10px); transition: transform .3s, border-color .3s;
}
.feature:hover { transform: translateY(-4px); border-color: var(--gold); }
.feature img { width: 100%; aspect-ratio: 16 / 8; object-fit: cover; display: block; }
.feature div { padding: 16px 18px 18px; }
.feature small { color: var(--gold); font-size: .8rem; }
.feature strong { display: block; font: 700 1.5rem/1.4 var(--serif); margin: 2px 0; }
.feature span { color: #CFC5B4; font-size: .88rem; }
@media (max-width: 820px) { .mast-in { grid-template-columns: 1fr; padding-top: 52px; padding-bottom: 44px; gap: 28px; } }

.dept { padding-top: 56px; scroll-margin-top: 16px; }
.dept-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.dept-head .sec-title { margin: 0; }
.stages { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.stage-card { min-height: 230px; padding: 22px; }
.stage-card .big-num {
  position: absolute; z-index: -1; inset-inline-end: 10px; bottom: -.32em;
  font: 700 9rem/1 var(--serif); color: var(--accent); opacity: .1;
  transition: opacity .3s, transform .5s;
}
a.stage-card:hover .big-num { opacity: .2; transform: translateY(-6px); }
.stage-card .ord { font: 700 2.2rem/1.3 var(--serif); color: var(--accent); }
.stage-card.is-empty { min-height: 0; }
.stage-card.is-empty .ord { color: var(--muted); font-size: 1.6rem; }
.stage-card.is-empty .big-num { color: var(--muted); opacity: .07; }
.chips-list { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.chips-list li { display: flex; align-items: center; gap: 8px; font-size: .9rem; line-height: 1.5; }
.chips-list .ico { width: 20px; height: 20px; color: var(--accent); }
.count { margin-top: auto; padding-top: 12px; font-size: .84rem; color: var(--muted); }
@media (max-width: 900px) { .stages { grid-template-columns: repeat(2, 1fr); } .stage-card { min-height: 190px; } }

/* ================= المرحلة والفصل ================= */
.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 760px) { .grid.two { grid-template-columns: 1fr; } }
.sem-card { min-height: 190px; }
.sem-card .ord { font: 700 2.3rem/1.3 var(--serif); color: var(--accent); }
.course-card { min-height: 230px; gap: 8px; }
.course-icon { display: grid; place-items: center; width: 58px; height: 58px; padding: 11px; border-radius: 16px; color: var(--accent); background: var(--tint); }
.course-icon .ico { width: 100%; height: 100%; }
.course-name { font: 700 1.6rem/1.4 var(--serif); }
.hours { font-size: .88rem; color: var(--muted); }
.weeks-dots { display: flex; gap: 7px; margin-top: 4px; flex-wrap: wrap; }
.weeks-dots i { width: 9px; height: 9px; transform: rotate(45deg); background: var(--line); }
.weeks-dots i.on { background: var(--accent); }
.weeks-dots i.exam { background: none; outline: 1.5px solid var(--muted); outline-offset: -1.5px; }

/* ================= صفحة المادة ================= */
.c-hero { position: relative; isolation: isolate; overflow: hidden; background: var(--basalt); color: var(--sand); padding: 48px 0 40px; }
.c-hero::before { content: ""; position: absolute; inset: 0; z-index: -1; background: var(--gold); opacity: .08; -webkit-mask: url(../img/pattern.svg) center / 72px; mask: url(../img/pattern.svg) center / 72px; }
.c-hero-in { display: flex; gap: 22px; align-items: center; }
.c-hero .course-icon { width: 84px; height: 84px; padding: 16px; background: rgb(217 178 111 / .14); color: var(--gold); flex: none; }
.c-hero .kicker { color: #BDB3A2; }
.c-hero h1 { font: 700 clamp(2rem, 5.5vw, 3.2rem)/1.3 var(--serif); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; font-size: .84rem; list-style: none; padding: 0; }
.chips li { padding: 3px 12px; border-radius: 99px; border: 1px solid rgb(255 255 255 / .16); background: rgb(255 255 255 / .05); }
@media (max-width: 560px) { .c-hero-in { flex-direction: column; align-items: flex-start; } }
.timeline { display: grid; grid-template-columns: repeat(15, 1fr); gap: 6px; margin-top: 30px; }
.timeline a, .timeline span {
  display: grid; place-items: center; aspect-ratio: 1; min-width: 0; border-radius: 10px; font-size: .86rem; text-decoration: none;
  background: rgb(255 255 255 / .05); border: 1px solid rgb(255 255 255 / .1); color: #BDB3A2;
}
.timeline a { background: var(--gold); color: #1F1B17; border-color: var(--gold); font-weight: 600; }
.timeline a:hover { transform: translateY(-2px); }
.timeline .exam { border-style: dashed; background: none; }
@media (max-width: 640px) { .timeline { grid-template-columns: repeat(8, 1fr); } }
.c-section { padding-top: 48px; }
.lectures { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 18px; }
.lecture-card { min-height: 320px; justify-content: flex-end; color: #fff; border: 0; background: var(--basalt); }
.lecture-card img { position: absolute; inset: 0; z-index: -2; width: 100%; height: 100%; object-fit: cover; transition: transform .8s cubic-bezier(.2, .7, .2, 1); }
.lecture-card::after { content: ""; position: absolute; inset: 0; z-index: -1; background: linear-gradient(to top, rgb(18 18 20 / .94) 15%, rgb(18 18 20 / .35) 65%, rgb(18 18 20 / .1)); }
.lecture-card:hover img { transform: scale(1.05); }
.lecture-card .lc-body { padding: 22px; }
.lecture-card .kicker { color: var(--gold); }
.lecture-card .lc-title { display: block; font: 700 1.7rem/1.35 var(--serif); margin: 2px 0 6px; }
.lecture-card .lc-meta { font-size: .84rem; color: #CFC5B4; }
.weeks { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.weeks li { display: flex; align-items: center; gap: 14px; padding: 11px 18px; border-bottom: 1px solid var(--line); }
.weeks li:last-child { border-bottom: 0; }
.wk { flex: none; width: 34px; height: 34px; display: grid; place-items: center; clip-path: var(--octagon); background: var(--surface-2); font-size: .92rem; }
.weeks li.is-on .wk { background: var(--accent); color: var(--surface); }
.weeks li.is-on a { font-weight: 500; text-decoration: none; }
.weeks li.is-on a:hover { color: var(--accent); }
.weeks li.is-exam { color: var(--muted); background: repeating-linear-gradient(-45deg, transparent 0 9px, color-mix(in srgb, var(--line) 50%, transparent) 9px 10px); }
.weeks li.is-exam .wk { background: none; outline: 1.5px dashed var(--muted); outline-offset: -3px; clip-path: none; border-radius: 50%; }
.tag { margin-inline-start: auto; flex: none; font-size: .78rem; padding: 2px 10px; border-radius: 99px; color: var(--accent); background: var(--tint); }

/* ================= صفحة المحاضرة ================= */
.l-hero { position: relative; isolation: isolate; overflow: hidden; display: grid; align-items: end; min-height: min(88svh, 780px); background: var(--basalt); color: #fff; }
.l-hero-img { position: absolute; inset: 0; z-index: -2; width: 100%; height: 100%; object-fit: cover; animation: kenburns 30s ease-out both; }
@keyframes kenburns { from { scale: 1.12; } to { scale: 1; } }
.l-hero::after { content: ""; position: absolute; inset: 0; z-index: -1; background: linear-gradient(to top, rgb(16 16 18 / .96) 12%, rgb(16 16 18 / .62) 48%, rgb(16 16 18 / .2) 85%); }
.l-hero-in { padding-top: 110px; padding-bottom: 60px; width: 100%; }
.l-hero-kicker { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.l-hero-kicker span { padding: 4px 14px; border-radius: 99px; font-size: .86rem; background: rgb(255 255 255 / .1); border: 1px solid rgb(255 255 255 / .16); backdrop-filter: blur(8px); }
.l-hero-title { font: 700 clamp(2.7rem, 8.5vw, 5.6rem)/1.15 var(--serif); max-width: 15ch; text-wrap: balance; text-shadow: 0 2px 30px rgb(0 0 0 / .35); }
.l-hero-sub { margin-top: 12px; font-size: clamp(1rem, 2.6vw, 1.25rem); color: #E4DACA; }
.l-hero-meta { list-style: none; padding: 0; margin: 20px 0 0; display: flex; flex-wrap: wrap; gap: 8px 22px; color: #D7CDBC; font-size: .92rem; }
.l-hero-meta li { display: flex; align-items: center; gap: 8px; }
.l-hero-meta .ico { width: 19px; height: 19px; color: var(--gold); }
.l-hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 28px; position: relative; z-index: 2; }
.dl { position: relative; }
.dl summary { list-style: none; }
.dl summary::-webkit-details-marker { display: none; }
.dl-menu {
  position: absolute; z-index: 5; top: calc(100% + 8px); inset-inline-start: 0; min-width: 270px; padding: 6px;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow-lift);
}
.dl-menu a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; text-decoration: none; }
.dl-menu a:hover { background: var(--tint); }
.dl-menu .ico { width: 26px; height: 26px; color: var(--accent); }
.dl-menu small { margin-inline-start: auto; color: var(--muted); font-size: .8rem; }
.resume { display: inline-flex; align-items: center; gap: 10px; margin-top: 18px; padding: 8px 16px; border-radius: 99px; text-decoration: none; background: rgb(217 178 111 / .16); color: var(--gold); border: 1px solid rgb(217 178 111 / .4); font-size: .92rem; }
.resume .ico { width: 18px; height: 18px; }
.l-hero-cap { position: absolute; bottom: 10px; left: 16px; font-size: .7rem; color: rgb(255 255 255 / .55); max-width: 60%; line-height: 1.5; }

/* شريط التقدّم: يظهر تحت الشريط العلوي بعد تجاوز الغلاف */
.l-progress {
  position: fixed; z-index: 55; top: var(--tb); left: 0; right: 0; height: 40px;
  background: color-mix(in srgb, var(--surface) 88%, transparent); border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  translate: 0 -110%; transition: translate .35s;
}
.l-progress.is-on { translate: 0 0; }
.l-progress .wrap { display: flex; align-items: center; height: 100%; }
.l-progress-t { font-size: .86rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.l-progress i { position: absolute; bottom: -1px; right: 0; height: 3px; width: calc(var(--p, 0) * 100%); background: var(--accent); border-radius: 3px 0 0 3px; }

.l-layout { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 56px; padding-top: 48px; }
.l-toc { position: sticky; top: calc(var(--tb) + 60px); align-self: start; max-height: calc(100vh - var(--tb) - 80px); overflow-y: auto; }
.l-toc ol { list-style: none; margin: 10px 0 0; padding: 0; }
.l-toc a { display: flex; gap: 10px; align-items: baseline; padding: 7px 14px; border-inline-start: 2px solid var(--line); text-decoration: none; font-size: .92rem; color: var(--muted); line-height: 1.5; transition: color .2s, border-color .2s; }
.l-toc a:hover { color: var(--ink); }
.l-toc a.is-cur { color: var(--accent); border-color: var(--accent); font-weight: 500; }
.l-toc b { flex: none; width: 20px; height: 20px; display: inline-grid; place-items: center; border-radius: 50%; border: 1px solid currentColor; font-size: .72rem; font-weight: 500; }
.l-toc a.is-seen b { background: var(--accent); border-color: var(--accent); color: var(--surface); }
@media (max-width: 1000px) { .l-layout { grid-template-columns: minmax(0, 1fr); padding-top: 32px; } .l-toc { display: none; } }

.block { margin-top: 72px; }

/* خريطة المحاضرة */
.bento { display: grid; grid-template-columns: repeat(6, 1fr); gap: 14px; }
.tile-goals { grid-column: span 3; grid-row: span 2; padding: 24px; }
.tile-h { font: 700 1.7rem var(--serif); }
.tile-goals .muted { margin: 2px 0 8px; }
.tile-ch { grid-column: span 3; min-height: 170px; }
.tile-ch:nth-of-type(n+3) { grid-column: span 2; }
.tile-visual { position: relative; display: flex; align-items: center; justify-content: center; gap: 14px; flex: 1; min-height: 110px; padding: 16px; background: var(--tint); overflow: hidden; }
.tile-photo .tile-visual { padding: 0; }
.tile-photo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transition: transform .8s; }
a.tile:hover .tile-visual img { transform: scale(1.06); }
.glyph { width: 58px; height: 52px; background: var(--accent); -webkit-mask: var(--g) center / contain no-repeat; mask: var(--g) center / contain no-repeat; }
.glyph-end { font: 700 3rem/1 var(--serif); color: var(--accent); }
.tile-words .tile-visual { gap: 16px; }
.w-a { font: 400 1.7rem var(--serif); color: var(--muted); }
.w-ne { color: var(--muted); font-size: 1.4rem; }
.w-b { font: 700 2.5rem var(--serif); color: var(--accent); }
.route { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 4px; font-size: .78rem; }
.route span { display: inline-flex; align-items: center; gap: 4px; }
.route span:not(:last-child)::after { content: ""; width: 14px; border-top: 2px dotted var(--accent); }
.route span:first-child, .route span:last-child { font-weight: 600; color: var(--accent); }
.tile-body { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 12px; align-items: center; padding: 12px 16px 14px; }
.tile-num { grid-row: span 2; font: 700 2rem/1 var(--serif); color: var(--accent); }
.tile-t { font-weight: 600; line-height: 1.5; }
.tile-meta { font-size: .8rem; color: var(--muted); }
@media (max-width: 760px) {
  .bento { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .tile-goals, .tile-ch:nth-of-type(1) { grid-column: span 2; grid-row: auto; }
  .tile-ch, .tile-ch:nth-of-type(n+3) { grid-column: span 1; min-height: 150px; }
  .tile-visual { min-height: 90px; gap: 8px; }
  .glyph { width: 38px; height: 36px; }
}

ol.num { list-style: none; margin: 0; padding: 0; counter-reset: n; }
ol.num > li { counter-increment: n; position: relative; padding: 8px 44px 8px 0; }
ol.num > li::before {
  content: counter(n, arabic-indic); position: absolute; right: 0; top: 9px;
  width: 30px; height: 30px; display: grid; place-items: center; clip-path: var(--octagon);
  background: var(--tint); color: var(--accent); font: 700 1rem/1 var(--serif);
}
ol.num > li + li { border-top: 1px dashed var(--line); }

/* مفاتيح المحاضرة: بطاقات تنقلب */
.terms { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; margin-top: 14px; }
.term { position: relative; height: 176px; padding: 0; border: 0; background: none; cursor: pointer; perspective: 900px; text-align: center; }
.term-f, .term-b {
  position: absolute; inset: 0; display: grid; place-items: center; padding: 16px; border-radius: 18px;
  backface-visibility: hidden; -webkit-backface-visibility: hidden; transition: transform .6s cubic-bezier(.2, .7, .2, 1);
}
.term-f { background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); font: 700 1.6rem/1.35 var(--serif); color: var(--accent); }
.term-f::after { content: ""; position: absolute; top: 12px; inset-inline-start: 12px; width: 12px; height: 12px; background: var(--line); clip-path: var(--star); }
.term-b { background: var(--accent); color: var(--surface); transform: rotateY(180deg); font-size: .86rem; line-height: 1.65; }
.term[aria-pressed="true"] .term-f { transform: rotateY(-180deg); }
.term[aria-pressed="true"] .term-b { transform: rotateY(0); }
@media (max-width: 480px) { .terms { grid-template-columns: repeat(2, 1fr); } .term { height: 200px; } .term-b { font-size: .8rem; padding: 12px; } }

/* الفصول */
.chapter { margin-top: 88px; }
.ch-head { display: grid; grid-template-columns: auto 1fr; gap: 6px 20px; align-items: center; margin-bottom: 26px; }
.ch-num { font: 700 clamp(5rem, 13vw, 7.5rem)/.85 var(--serif); color: var(--accent); text-shadow: 0 10px 30px color-mix(in srgb, var(--accent) 30%, transparent); }
.ch-title { font: 700 clamp(1.9rem, 4.8vw, 2.8rem)/1.3 var(--serif); }
.ch-goal { margin-top: 8px; padding: 8px 14px; border-radius: 12px; background: var(--tint); font-size: .92rem; line-height: 1.7; }
.ch-goal b { color: var(--accent); font-weight: 600; }

.slides { display: grid; gap: 22px; }
.slide { margin: 0; }
.slide-open { display: block; width: 100%; padding: 0; border: 0; border-radius: 14px; overflow: hidden; background: var(--surface-2); cursor: zoom-in; box-shadow: var(--shadow); }
.slide-open img { display: block; width: 100%; height: auto; transition: transform .5s; }
.slide-open:hover img { transform: scale(1.012); }
.slide figcaption { display: flex; gap: 10px; align-items: baseline; margin-top: 8px; font-size: .84rem; color: var(--muted); line-height: 1.5; }
.slide figcaption span { flex: none; min-width: 26px; padding: 0 6px; border-radius: 6px; background: var(--surface-2); text-align: center; }
/* الهاتف عمودياً: الشرائح العمودية ملء العرض؛ وما عداه: الأفقية */
.slides-v, .fmt-v { display: none !important; }
@media (max-width: 820px) and (orientation: portrait) {
  .slides-h, .fmt-h { display: none !important; }
  .fmt-v { display: flex !important; }
  .slides-v { display: grid !important; gap: 14px; margin-inline: calc(50% - 50vw); }
  .slides-v .slide-open { width: min(100vw, calc((100svh - var(--tb) - 48px) * 9 / 16)); margin-inline: auto; border-radius: 0; box-shadow: none; }
  .slides-v figcaption { display: none; }
}

/* توقّف وتذكّر */
.check {
  margin-top: 30px; padding: 22px; border-radius: var(--r);
  background: linear-gradient(140deg, var(--tint), var(--surface) 70%);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--line));
  transition: border-color .3s;
}
.check.is-yes { border-color: var(--ok); }
.check.is-no { border-color: var(--rust); }
.check-k { display: flex; align-items: center; gap: 8px; color: var(--accent); font-weight: 600; font-size: .86rem; letter-spacing: .04em; }
.check-star { width: 18px; height: 18px; color: var(--accent); }
.check-q { font: 700 clamp(1.3rem, 3.4vw, 1.6rem)/1.5 var(--serif); margin: 6px 0 16px; }
.check-reveal { width: 100%; min-height: 54px; padding: 12px; border: 1.5px dashed var(--accent); border-radius: 14px; background: transparent; color: var(--accent); cursor: pointer; transition: background .2s; }
.check-reveal:hover { background: var(--tint); }
.check-a p { padding: 14px 16px; border-radius: 12px; background: var(--surface); border-inline-start: 3px solid var(--accent); line-height: 1.9; animation: rise .35s ease-out; }
@keyframes rise { from { opacity: 0; translate: 0 8px; } }
.check-rate { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 14px; font-size: .9rem; }
.check-rate span { margin-inline-end: auto; color: var(--muted); }
.check-rate button { display: inline-flex; align-items: center; gap: 6px; min-height: 42px; padding: 6px 16px; border-radius: 99px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; transition: background .2s, color .2s, border-color .2s; }
.check-rate .ico { width: 18px; height: 18px; }
.check-rate [data-rate="yes"][aria-pressed="true"] { background: var(--ok); border-color: var(--ok); color: var(--surface); }
.check-rate [data-rate="no"][aria-pressed="true"] { background: var(--rust); border-color: var(--rust); color: var(--surface); }

/* الخلاصة */
.summary-grid { list-style: none; margin: 0; padding: 0; counter-reset: s; display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.summary-grid li { counter-increment: s; padding: 18px 20px; border-radius: 18px; background: var(--surface); border: 1px solid var(--line); line-height: 1.8; }
.summary-grid li::before { content: counter(s, arabic-indic); display: block; font: 700 2.2rem/1 var(--serif); color: var(--accent); margin-bottom: 8px; }

/* الجانب العملي */
.practice { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.practice .tile { padding: 22px; }
.activity h3 { font: 700 1.5rem var(--serif); color: var(--accent); margin: 2px 0 8px; }
.steps { margin: 0; padding-inline-start: 1.4em; list-style: arabic-indic; }
.steps li { padding: 3px 0; }
.steps li::marker { color: var(--accent); font-family: var(--serif); font-weight: 700; }
.tile-note { background: var(--tint); box-shadow: none; }
.tile-note h3 { font-size: .95rem; color: var(--accent); margin-bottom: 4px; }
@media (max-width: 700px) { .practice { grid-template-columns: 1fr; } }

/* بطاقة المراجعة */
.review-score { margin-bottom: 14px; }
.review { list-style: none; margin: 0 0 14px; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.review li + li { border-top: 1px solid var(--line); }
.review a { display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: center; padding: 13px 18px; text-decoration: none; }
.review a:hover { background: var(--tint); }
.review small { color: var(--muted); font-size: .8rem; }
.r-state { width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%; border: 1.5px dashed var(--muted); font-size: .8rem; color: var(--surface); }
.review li.is-yes .r-state { background: var(--ok); border: 0; }
.review li.is-yes .r-state::after { content: "✓"; }
.review li.is-no .r-state { background: var(--rust); border: 0; }
.review li.is-no .r-state::after { content: "✕"; }
.review li.is-no .r-q { color: var(--rust); }

.next-note { margin-top: 64px; padding: 22px 0; text-align: center; font: 700 1.3rem var(--serif); color: var(--accent); border-block: 1px solid var(--line); }

.refs details summary { cursor: pointer; list-style: none; }
.refs details summary::-webkit-details-marker { display: none; }
.refs summary .sec-title { margin: 0; }
.refs summary .sec-title::after { content: "+"; margin-inline-start: auto; font: 400 1.5rem var(--sans); color: var(--accent); }
.refs details[open] summary .sec-title::after { content: "−"; }
.refs .byline { margin-top: 12px; font-size: .9rem; color: var(--muted); }
.refs h3 { font-size: 1rem; margin: 14px 0 4px; color: var(--accent); }
.refs ul { margin: 0; padding-inline-start: 1.2em; font-size: .92rem; line-height: 1.8; }
.refs .credits { font-size: .86rem; color: var(--muted); }

.pager { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin-top: 40px; }
.pager .tile { padding: 16px 18px; }
.pager small { color: var(--muted); font-size: .78rem; }

/* وضع العرض */
.present { position: fixed; inset: 0; z-index: 100; display: grid; grid-template-rows: minmax(0, 1fr) auto; background: #0C0C0E; color: var(--sand); animation: fade .25s; }
@keyframes fade { from { opacity: 0; } }
.p-stage { position: relative; display: grid; place-items: center; min-height: 0; padding: 16px; }
.present.is-v .p-stage { padding: 0; }
.p-img { width: 100%; height: 100%; object-fit: contain; user-select: none; -webkit-user-drag: none; }
.p-hit { position: absolute; top: 0; bottom: 0; width: 35%; border: 0; padding: 0; background: none; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.p-hit-prev { right: 0; }
.p-hit-next { left: 0; }
.p-bar { display: flex; align-items: center; gap: 8px; padding: 8px 14px calc(8px + env(safe-area-inset-bottom)); border-top: 1px solid rgb(255 255 255 / .08); }
.p-title { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: .92rem; }
.p-pos { font-size: .9rem; color: #BDB3A2; min-width: 64px; text-align: center; }
.p-btn { flex: none; display: grid; place-items: center; width: 44px; height: 44px; padding: 10px; border-radius: 50%; border: 1px solid rgb(239 230 214 / .18); background: none; cursor: pointer; }
.p-btn:hover { border-color: var(--gold); }
.p-btn:disabled { opacity: .3; cursor: default; }
.p-btn .ico { width: 100%; height: 100%; }
@media (max-width: 560px) { .p-title { display: none; } .p-bar { justify-content: space-between; } }

/* ---------- التذييل ---------- */
.foot { border-top: 1px solid var(--line); padding: 22px 0 26px; font-size: .84rem; color: var(--muted); }
.foot .wrap { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 18px; }
.foot span:first-child { font: 700 1.05rem var(--serif); color: var(--ink); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  html { scroll-behavior: auto; }
}
