/* هوية كل مادة: خط عناوين، شكل نوتس، وحركة. الشرح نفسه بيفضل IBM Plex. بيتحمّل بعد zk.css */
[data-s=math] { --fh: 'Readex Pro', var(--fb, sans-serif) }
[data-s=sci] { --fh: 'Baloo Bhaijaan 2', var(--fb) }
[data-s=his] { --fh: 'Noto Kufi Arabic', var(--fb) }
[data-s=phi] { --fh: 'Alexandria', var(--fb) }
[data-s=ara] { --fh: 'Cairo', var(--fb) }

/* --soft لازم يتحسب هنا عشان ياخد لون المادة، مش لون الصفحة العام */
body[data-s]:not([data-s=math]) { --soft: color-mix(in srgb, var(--a) 9%, var(--card)) }
body[data-s] .steps li::before { content: counter(st, arabic-indic) }

/* ألوان سادة من غير زجاج */
body[data-s] .top, body[data-s] .nav { background: var(--card); backdrop-filter: none; -webkit-backdrop-filter: none }

body[data-s] :is(article > h1, .hero h1, .card h2, .stage h2, .sname, .num, .fact b, .win, .big-score) { font-family: var(--fh) }
.toc a[data-s] .line b, .toc a[data-s] .no { font-family: var(--fh) }

/* ===== العربي: كراسة مسطّرة بهامش أحمر وقلم بوص ===== */
body[data-s=ara] { --bg: #FAF6EA; --card: #FFFDF6; --ink: #17201B; --line: #DCD2B8; --a: #0E6B4E; --on-a: #fff; --pen: #B23A34; }
body[data-s=ara] { --fb: 'Cairo', 'Segoe UI', sans-serif; font-family: var(--fb); font-size: 17.5px; line-height: 2.05 }
body[data-s=ara] :is(.btn, .options button, .fc) { font-family: var(--fb) }
body[data-s=ara] .card { border-radius: 14px; border-block-start: 4px solid var(--a) }
body[data-s=ara] article > h1, body[data-s=ara] .hero h1 { line-height: 1.7 }
body[data-s=ara] .card h2 { font-size: 1.45rem; width: fit-content; position: relative; padding-block-end: 4px }
body[data-s=ara] .card h2::after { content: ""; position: absolute; inset-inline: 0; bottom: 0; height: 3px; border-radius: 99px 2px; background: var(--pen); transform-origin: right }
body[data-s=ara] .rv.in h2::after { animation: pen .7s .35s ease-out both }
body[data-s=ara] .num { background: none; color: var(--a); position: relative; isolation: isolate }
body[data-s=ara] .num::before { content: ""; position: absolute; inset: 5px; border: 2px solid var(--a); transform: rotate(45deg); z-index: -1 }
body[data-s=ara] .verse blockquote { font: 700 1.3rem/2.3 'Noto Naskh Arabic', serif; text-align: center; border: 0; border-block: 1px solid var(--line); border-radius: 0; background: none }
body[data-s=ara] .verse blockquote::after { content: "۞"; display: block; font-size: 1rem; color: var(--pen) }
body[data-s=ara] .verse cite { font-family: var(--fb); font-weight: 400 }
body[data-s=ara] .rules li::before { transform: rotate(45deg) }
body[data-s=ara] .rv.in { animation: write .6s ease-out both }

/* ===== التاريخ: ملف متحف، بردي وخرطوش ===== */
body[data-s=his] { --bg: #F0E6D0; --card: #FBF5E6; --ink: #2A1F14; --muted: #6B5942; --line: #CDB98F; --a: #93431A; --on-a: #FFF8EA; --nile: #1F5F7A }
body[data-s=his] .card { border-radius: 2px; outline: 1px solid var(--line); outline-offset: -6px; padding: 24px 22px }
body[data-s=his] .card h2 { padding-block-end: 6px; border-block-end: 4px double var(--a); width: fit-content }
body[data-s=his] .hero { border-block-start: 0; padding-block-start: 30px; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='12'%3E%3Cpath d='M0 12L12 1l12 11z' fill='%23a8672f'/%3E%3C/svg%3E") repeat-x top }
body[data-s=his] .num { width: 42px; height: 56px; border-radius: 99px; background: var(--card); color: var(--a); border: 3px double var(--a); box-shadow: 0 7px 0 -3px var(--a) }
body[data-s=his] .stage .sn, body[data-s=his] .node .pin { border-radius: 99px 99px 6px 6px }
body[data-s=his] .tl { border-color: var(--nile); border-inline-end-width: 3px }
body[data-s=his] .tl li::before { background: var(--nile); border-radius: 2px; transform: rotate(45deg) }
body[data-s=his] .tl time, body[data-s=his] .fact b { color: var(--nile) }
body[data-s=his] .fact { border-radius: 99px 99px 4px 4px; padding-block-start: 22px; border: 1px solid var(--line) }
body[data-s=his] .rv.in { animation: unearth .8s cubic-bezier(.2, .7, .2, 1) both }

/* ===== العلوم: كشكول معمل مربعات ولزق ===== */
body[data-s=sci] { --bg: #EFF7F6; --card: #FCFFFE; --ink: #0F2326; --line: #BFDCDA; --a: #08707F; --tape: #F2C94C;
  background: var(--bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22'%3E%3Cpath d='M22 0H0V22' fill='none' stroke='%232a9aa5' stroke-opacity='.17'/%3E%3C/svg%3E") }
body[data-s=sci] .card { position: relative; border-radius: 20px; border-width: 2px; margin-block-start: 24px }
body[data-s=sci] .card::before { content: ""; position: absolute; top: -9px; inset-inline-start: 26px; width: 66px; height: 18px; background: var(--tape); transform: rotate(3deg); border-radius: 2px }
body[data-s=sci] .card:nth-of-type(even)::before { background: #E8816B; transform: rotate(-4deg) }
body[data-s=sci] .card h2 { font-size: 1.35rem; color: var(--a) }
body[data-s=sci] .num { border-radius: 0; width: 50px; height: 54px; clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%) }
body[data-s=sci] .steps li { position: relative }
body[data-s=sci] .steps li:not(:last-child)::after { content: ""; position: absolute; inset-inline-start: 13px; top: 44px; bottom: -10px; width: 4px; border-radius: 9px; background: var(--line) }
body[data-s=sci] .rules li::before { border-radius: 50%; width: 10px; height: 10px; background: none; border: 2.5px solid var(--a) }
body[data-s=sci] .btn { border-radius: 99px }
body[data-s=sci] .rv.in { animation: bubble .55s cubic-bezier(.3, 1.5, .5, 1) both }

/* ===== الفلسفة: حوار، كل فكرة دور في الكلام ===== */
body[data-s=phi] { --bg: #F5F2EA; --card: #FFFDF8; --ink: #1D1B18; --line: #D9D2C2; --a: #8C2F39; --on-a: #fff }
body[data-s=phi] .card { position: relative; border-radius: 22px 4px 22px 22px }
body[data-s=phi] .card:nth-of-type(even) { border-radius: 4px 22px 22px 22px }
body[data-s=phi] .card h2 { font-size: 1.35rem; padding-inline-start: 14px; border-inline-start: 5px solid var(--a) }
body[data-s=phi] .card.hook::after { content: "؟"; position: absolute; inset-inline-end: 14px; top: -26px; font: 700 4.5rem/1 var(--fh); color: var(--a) }
body[data-s=phi] .card.simple { border: 2px solid var(--a); background: var(--card); margin-block-end: 30px }
body[data-s=phi] .card.simple::after { content: ""; position: absolute; inset-inline-start: 34px; bottom: -11px; width: 18px; height: 18px; background: var(--card); border: solid var(--a); border-width: 0 2px 2px 0; transform: rotate(45deg) }
body[data-s=phi] .num { border-radius: 50%; border: 2px solid var(--card); box-shadow: 0 0 0 2px var(--a) }
body[data-s=phi] .rules li::before { content: "∴"; background: none; width: auto; height: auto; top: .2em; color: var(--a); font-weight: 700 }
body[data-s=phi] .rv.in { animation: from-right .6s ease-out both }
body[data-s=phi] .card.rv.in:nth-of-type(even) { animation-name: from-left }

@media (prefers-color-scheme: dark) {
  body[data-s=ara] { --bg: #101512; --card: #18201B; --ink: #E9EFE9; --line: #2E3B32; --a: #4CC79A; --on-a: #07140E; --pen: #E8847C }
  body[data-s=his] { --bg: #17120C; --card: #221B12; --ink: #F1E7D3; --muted: #BBAA8D; --line: #4A3D29; --a: #E6A062; --on-a: #1C1006; --nile: #7CC0D8 }
  body[data-s=sci] { --bg: #0B1618; --card: #122225; --ink: #E3F4F4; --line: #24464A; --a: #58CEDD; --tape: #B8943A }
  body[data-s=phi] { --bg: #141311; --card: #1E1C19; --ink: #F0ECE3; --line: #3A352D; --a: #E9969B; --on-a: #210A0D }
}

/* حركة */
.rv { opacity: 0 } .rv.in { opacity: 1 }
@keyframes pen { from { transform: scaleX(0) } }
@keyframes write { from { clip-path: inset(0 0 0 100%) } to { clip-path: inset(-12px) } }
@keyframes unearth { from { transform: translateY(34px); opacity: 0 } }
@keyframes bubble { from { transform: scale(.88) translateY(16px); opacity: 0 } }
@keyframes from-right { from { transform: translateX(38px); opacity: 0 } }
@keyframes from-left { from { transform: translateX(-38px); opacity: 0 } }
/* حركة الرسومات */
.g-draw { stroke-dasharray: 100; animation: draw 5s ease-in-out infinite } .g-draw.d2 { animation-delay: .8s } .g-draw.d3 { animation-delay: 1.6s }
@keyframes draw { 0% { stroke-dashoffset: 100 } 45%, 100% { stroke-dashoffset: 0 } }
.g-sun { animation: sunup 7s ease-in-out infinite alternate } @keyframes sunup { from { transform: translateY(22px) } }
.g-flow { animation: flow 4s linear infinite } @keyframes flow { to { transform: translateX(-24px) } }
@media (prefers-reduced-motion: reduce) { *::after { animation: none !important; transition: none !important } .rv { opacity: 1 } }

/* ===== الرياضيات: ورق رسم بياني ===== */
body[data-s=math] { background: var(--paper) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='80'%3E%3Cpath d='M16 0V80M32 0V80M48 0V80M64 0V80M0 16H80M0 32H80M0 48H80M0 64H80' stroke='%234a6ad0' stroke-opacity='.09'/%3E%3Cpath d='M80 0H0V80' fill='none' stroke='%234a6ad0' stroke-opacity='.2'/%3E%3C/svg%3E") !important }
body[data-s=math] :is(h1, h2, h3, .brand) { font-family: var(--fh) !important }
body[data-s=math] .top .brand { background: none; color: var(--u1) }
body[data-s=math] .card { position: relative; border-radius: 4px; box-shadow: none; border: 1.5px solid var(--line) }
body[data-s=math] .card::before { content: ""; position: absolute; top: -2px; inset-inline-start: -2px; width: 22px; height: 22px; border: solid var(--u1); border-width: 3px 0 0; border-inline-start-width: 3px; pointer-events: none }
:root { --u4: #5C6B16 !important }
:root[data-theme=dark] { --u4: #C5D46A !important }
@media (prefers-color-scheme: dark) { :root:not([data-theme=light]) { --u4: #C5D46A !important } }

/* ===== أغلفة بلون المادة: عنوان واضح ورسمة كبيرة ===== */
[data-s=math] { --panel: #2745C7 } [data-s=sci] { --panel: #0A6272 } [data-s=his] { --panel: #7C3915 } [data-s=phi] { --panel: #7A2831 } [data-s=ara] { --panel: #0C5A42 }

body[data-s]:not([data-s=math]) .hero { grid-template-columns: 1fr; gap: 6px; background-color: var(--panel); color: #fff; border: 0; border-radius: 22px; padding: 26px 20px 22px; animation: unearth .6s ease-out both }
body[data-s]:not([data-s=math]) .hero .heroart { order: -1; width: min(220px, 62%); margin-inline: auto; color: #fff }
body[data-s]:not([data-s=math]) .hero :is(h1, p, .muted) { color: #fff }
body[data-s]:not([data-s=math]) .hero h1 { font-size: 2.2rem }
body[data-s] .hero .progress { background: rgb(255 255 255 / .28) } body[data-s] .hero .progress i { background: #fff }
body[data-s]:not([data-s=math]) .hero .btn { background: #fff; border-color: #fff; color: var(--panel) }
body[data-s=his] .hero { padding-block-start: 30px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='12'%3E%3Cpath d='M0 12L12 1l12 11z' fill='%23F0C45C'/%3E%3C/svg%3E"); background-repeat: repeat-x; background-position: top; border-radius: 4px }
body[data-s=ara] .hero { border-radius: 4px; border-inline-start: 8px solid #E8B4A8 }
body[data-s=phi] .hero { border-radius: 40px 6px 40px 40px }

body[data-s]:not([data-s=math]) article > h1 { background: var(--panel); color: #fff; border-radius: 16px; padding: 16px; line-height: 1.6; font-size: clamp(1.45rem, 6vw, 2.1rem); animation: unearth .5s ease-out both }
body[data-s=sci] article > h1 .num, body[data-s=phi] article > h1 .num, body[data-s=his] article > h1 .num { background: #fff; color: var(--panel); border-color: #fff; box-shadow: none }
body[data-s=ara] article > h1 .num { color: #fff } body[data-s=ara] article > h1 .num::before { border-color: #fff }

/* الرئيسية: كل مادة غلاف بلونها */
body.hub .tochead { border: 0 }
body.hub .toc { display: grid; gap: 14px }
body.hub .toc a[data-s] { grid-template-columns: 1fr 104px; align-items: center; gap: 12px; padding: 20px 18px; color: #fff; background-color: var(--panel); border: 0; border-radius: 18px; transition: transform .15s }
body.hub .toc a[data-s]:active { transform: scale(.98) }
body.hub .toc :is(.no, .lead) { display: none }
body.hub .toc .line { flex-direction: column; align-items: flex-start; gap: 0 } body.hub .toc .line b { font-size: 1.45rem; font-weight: 700; white-space: normal; line-height: 1.6 }
body.hub .toc :is(.count, .tag) { color: #fff } body.hub .toc .count { font-weight: 600 }
body.hub .toc .segs i { background: rgb(255 255 255 / .3) } body.hub .toc .segs i.on { background: #FFD166 }
body.hub .toc .glyph { width: 104px; color: #fff; opacity: 1 }
body.hub .toc a[data-s=math] { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22'%3E%3Cpath d='M22 0H0V22' fill='none' stroke='%23fff' stroke-opacity='.14'/%3E%3C/svg%3E") }
body.hub .toc a[data-s=sci] { border-radius: 28px }
body.hub .toc a[data-s=his] { border-radius: 4px; padding-block-start: 26px; background: var(--panel) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='10'%3E%3Cpath d='M0 10L12 1l12 9z' fill='%23F0C45C'/%3E%3C/svg%3E") repeat-x top }
body.hub .toc a[data-s=phi] { border-radius: 36px 4px 36px 36px }
body.hub .toc a[data-s=ara] { border-radius: 4px; border-inline-start: 8px solid #E8B4A8; }
body.hub .toc li { animation: unearth .55s ease-out both } body.hub .toc li:nth-child(2) { animation-delay: .08s } body.hub .toc li:nth-child(3) { animation-delay: .16s } body.hub .toc li:nth-child(4) { animation-delay: .24s } body.hub .toc li:nth-child(5) { animation-delay: .32s }

body[data-s=math] .hero { background: var(--panel) !important; color: #fff !important; border: 0 !important; border-radius: 22px !important; padding: 26px 20px !important }
body[data-s=math] .hero :is(h1, p) { color: #fff !important } body[data-s=math] .hero em { color: #FFD166 !important }
body[data-s=math] .hero .btn.big { background: #fff !important; border-color: #fff !important; color: var(--panel) !important }
body[data-s=math] .hero .btn.ghost:not(.big) { background: transparent !important; border-color: #fff !important; color: #fff !important }
@media (prefers-reduced-motion: reduce) { body.hub .toc li, body[data-s] .hero, body[data-s] article > h1 { animation: none !important } }

/* ===== خطة الشهر ===== */
.planbox { margin-block: 18px 6px; padding: 18px 16px; border: 2px solid var(--ink); border-radius: 18px; background: var(--card) }
.planbox h2 { margin: 0; font: 700 1.5rem/1.5 var(--fb) } .planbox h3 { margin: 14px 0 8px; font-size: 1.05rem } .planbox p { margin-block: 4px }
.planbox .bar { height: 10px; margin-block: 10px 2px; border-radius: 99px; background: var(--line); overflow: hidden } .planbox .bar i { display: block; height: 100%; background: var(--good) }
.planbox :is(.go, .reset) { min-height: 44px; font: 700 1rem var(--fb); border-radius: 10px; border: 2px solid var(--ink); padding: 6px 18px; cursor: pointer; background: var(--ink); color: var(--card) }
.planbox .reset { background: none; color: var(--muted); border-color: var(--line); font-weight: 600; font-size: .9rem }
.tasks { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px }
.task { --c: var(--panel, #8A1C5C); display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-inline-start: 6px solid var(--c); border-radius: 10px }
.task > :is(a, .body) { flex: 1; min-width: 0; display: flex; flex-direction: column; color: var(--ink); text-decoration: none; line-height: 1.6 } .task small { color: var(--muted); font-size: .8rem } .task [dir=auto] { text-align: right; font-weight: 600 }
.task .tick { flex: none; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; border: 2px solid var(--line); background: none; color: #fff; font: 700 1rem var(--fb) }
.task button.tick { cursor: pointer; border-style: dashed; border-color: var(--muted); border-radius: 8px }
.task.done .tick { background: var(--good); border: 2px solid var(--good) } .task.done [dir=auto] { text-decoration: line-through; color: var(--muted) }
.planbox details { margin-block-start: 10px } .planbox summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; font-weight: 700 } .planbox summary::before { content: "‹"; margin-inline-end: 8px; transition: transform .15s } .planbox details[open] > summary::before { transform: rotate(-90deg) }
.planbox details details { margin: 0; padding-inline-start: 8px; border-block-start: 1px solid var(--line) } .planbox details details summary { font-weight: 600 }

/* ===== الإنجليزي: كروت قاموس ===== */
[data-s=eng] { --fh: 'Rubik', var(--fb); --panel: #2F4858 }
body[data-s=eng] { --bg: #F4F5F2; --card: #FFFEFB; --ink: #17212A; --line: #D5D9D2; --a: #A8481B; --on-a: #fff }
body[data-s=eng] :is(h3, p, li, button, span, td, th, b) { unicode-bidi: plaintext }
body[data-s=eng] .card { border-radius: 8px; border-inline-start: 10px solid var(--panel) }
body[data-s=eng] .card h2 { padding-block-end: 4px; border-block-end: 2px dashed var(--line) }
body[data-s=eng] .num { border-radius: 8px; transform: rotate(-4deg) }
body[data-s=eng] article > h1 .num { background: #fff; color: var(--panel) }
body[data-s=eng] .rules li { line-height: 2.1 }
body[data-s=eng] .rv.in { animation: flipin .5s ease-out both }
body.hub .toc a[data-s=eng] { border-radius: 8px; border-inline-start: 10px solid #E8A87C }
.task[data-s=eng] { --c: #2F4858 }
@media (prefers-color-scheme: dark) { body[data-s=eng] { --bg: #101316; --card: #191E23; --ink: #E8EDF0; --line: #333C44; --a: #F0A070; --on-a: #1E0E04 } }
body[data-s=eng] :is(.question, .example) h3 bdi { display: block; text-align: left; margin-block-start: 4px }

/* ===== قصة عنترة: ليل الصحرا ===== */
[data-s=antara] { --fh: 'Noto Kufi Arabic', var(--fb); --fb: 'Cairo', sans-serif; --panel: #33305E }
body[data-s=antara] { --bg: #F6EEDC; --card: #FFFBF2; --ink: #231C12; --line: #DECBA0; --a: #8A4A12; --on-a: #fff; font-family: var(--fb) }
body[data-s=antara] .card { border-radius: 4px 4px 20px 20px; border-block-end: 5px solid var(--panel) }
body[data-s=antara] .card h2 { padding-inline-start: 26px; position: relative } body[data-s=antara] .card h2::before { content: ""; position: absolute; inset-inline-start: 0; top: .45em; width: 14px; height: 14px; background: var(--a); clip-path: polygon(50% 0, 100% 100%, 0 100%) }
body[data-s=antara] .num { border-radius: 99px 99px 0 0; height: 50px }
body[data-s=antara] .rv.in { animation: unearth .7s ease-out both }
body.hub .toc a[data-s=antara] { border-radius: 4px 4px 26px 26px; border-block-end: 8px solid #F0C45C }

/* ===== The Old Man and the Sea: موج ===== */
[data-s=sea] { --fh: 'Rubik', var(--fb); --panel: #0F3D5E }
body[data-s=sea] { --bg: #EAF4F8; --card: #FCFEFF; --ink: #0E2130; --line: #C2DCE8; --a: #0B6A8F; --on-a: #fff }
body[data-s=sea] :is(h3, p, li, button, b) { unicode-bidi: plaintext }
body[data-s=sea] .card { border-radius: 18px; padding-block-start: 28px; background: var(--card) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='12'%3E%3Cpath d='M0 6q8-7 16 0t16 0' fill='none' stroke='%232a8fb5' stroke-width='2.5'/%3E%3C/svg%3E") repeat-x left 6px top 6px }
body[data-s=sea] article > h1 { direction: ltr }
body[data-s=sea] .num { border-radius: 50% 50% 50% 4px }
body[data-s=sea] .rv.in { animation: wave .8s ease-out both }
body.hub .toc a[data-s=sea] { border-radius: 30px; border-block-end: 8px solid #7CC8E4 }
body.hub .toc a[data-s=sea] .line b { unicode-bidi: plaintext; font-size: 1.15rem }
@keyframes wave { 0% { transform: translateY(26px); opacity: 0 } 60% { transform: translateY(-5px); opacity: 1 } }
@media (prefers-color-scheme: dark) {
  body[data-s=antara] { --bg: #131120; --card: #1D1A2E; --ink: #EFE9DA; --line: #3B365A; --a: #F0C45C; --on-a: #1D1405 }
  body[data-s=sea] { --bg: #081620; --card: #0F222F; --ink: #E2F1F8; --line: #1F4256; --a: #62C4E8; --on-a: #04131B }
}

/* ===== شعار مذاكرة ===== */
body.hub .hubhead { display: grid; justify-items: center; text-align: center; padding-block: 28px 4px }
body.hub .logo { display: grid; justify-items: center; gap: 10px; font: 700 2.5rem/1.5 'Cairo', var(--fb) }
body.hub .logo img { border-radius: 18px }
