/* المعلم الرقمي — شاشة الصف: صفحة الكتاب في الوسط على ارضية هادئة، ولوح الحل اخضر كالسبورة بخط الطباشير.
   خط واحد (Noto Sans Arabic) باوزان ثلاثة، مستضاف مع التطبيق ليعمل بلا انترنت. */

@font-face { font-family: "Noto Sans Arabic App"; src: url("fonts/noto-sans-arabic-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Noto Sans Arabic App"; src: url("fonts/noto-sans-arabic-600.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Noto Sans Arabic App"; src: url("fonts/noto-sans-arabic-700.woff2") format("woff2"); font-weight: 700; font-display: swap; }

:root {
  --paper: #eef2f0; --sheet: #ffffff; --ink: #15201b; --muted: #57675f; --line: #cfd9d4;
  --accent: #1d6b55; --accent-ink: #ffffff; --stage: #dde4e0;
  --board: #1f3b31; --chalk: #f3f0e4; --chalk-dim: #aebfb6; --mark: #e7b93f;
  --k-open: #4b5d70; --k-concept: #1f5fa8; --k-example: #6a45a8; --k-steps: #a35f00; --k-text: #13784a; --k-info: #0d7487; --k-practice: #b0324f;
  --font: "Noto Sans Arabic App", "Noto Sans Arabic", "Segoe UI", Tahoma, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --paper: #0e1512; --sheet: #17201c; --ink: #e2ebe6; --muted: #9db0a6; --line: #2a3832;
  --accent: #5cc29c; --accent-ink: #0b1a14; --stage: #0a0f0d;
  --board: #13281f; --chalk: #f3f0e4; --chalk-dim: #a3b6ac; --mark: #f0c552;
  --k-open: #a9b8c8; --k-concept: #7fb0ef; --k-example: #b79cf0; --k-steps: #f0b25a; --k-text: #6fd19c; --k-info: #66c9db; --k-practice: #f0869e;
  color-scheme: dark } }
:root[data-theme="dark"] {
  --paper: #0e1512; --sheet: #17201c; --ink: #e2ebe6; --muted: #9db0a6; --line: #2a3832;
  --accent: #5cc29c; --accent-ink: #0b1a14; --stage: #0a0f0d;
  --board: #13281f; --chalk: #f3f0e4; --chalk-dim: #a3b6ac; --mark: #f0c552;
  --k-open: #a9b8c8; --k-concept: #7fb0ef; --k-example: #b79cf0; --k-steps: #f0b25a; --k-text: #6fd19c; --k-info: #66c9db; --k-practice: #f0869e;
  color-scheme: dark }

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--paper); color: var(--ink); font-family: var(--font); font-size: 17px; line-height: 1.75; -webkit-tap-highlight-color: transparent; }
button, a.btn { font: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.3; text-wrap: balance; }
p { margin: 0; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 18px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--sheet); color: var(--ink); text-decoration: none; cursor: pointer; font-weight: 600; white-space: nowrap; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: .45; cursor: default; }
.btn .ic { font-size: 1.25em; line-height: 1; }

/* ── الصفحات: المواد والدروس والحلول ── */
.page { max-width: 980px; margin: 0 auto; padding-block: 28px 64px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); display: grid; gap: 24px; }
.top { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.top h1 { font-size: 1.7rem; font-weight: 700; }
.eyebrow { color: var(--accent); font-weight: 600; font-size: .95rem; }
.muted { color: var(--muted); }
.cards { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); }
.card { background: var(--sheet); border: 1px solid var(--line); border-radius: 14px; padding: 18px; display: grid; gap: 10px; color: inherit; text-decoration: none; }
a.card:hover { border-color: var(--accent); }
.card h2 { font-size: 1.3rem; }
.lessons { display: grid; gap: 12px; }
.lesson { background: var(--sheet); border: 1px solid var(--line); border-radius: 14px; padding: 16px; display: grid; gap: 12px; }
@media (min-width: 720px) { .lesson { grid-template-columns: minmax(0, 1fr) auto; align-items: center; } }
.lesson .num { color: var(--accent); font-weight: 700; font-variant-numeric: tabular-nums; }
.lesson h2 { font-size: 1.2rem; font-weight: 700; }
.lesson .acts { display: flex; flex-wrap: wrap; gap: 8px; }
.saved { color: var(--accent); font-weight: 600; }
.progress { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.progress i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }

.sol-index { display: grid; gap: 14px; }
.sol-page { background: var(--sheet); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; display: grid; gap: 10px; }
.sol-page h2 { font-size: 1.1rem; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { min-width: 56px; min-height: 48px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--paper); color: var(--ink);
  display: inline-flex; align-items: center; justify-content: center; font-weight: 600; text-decoration: none; cursor: pointer; font-variant-numeric: tabular-nums; }
.chip:hover { border-color: var(--accent); }
.chip[aria-pressed="true"] { background: var(--mark); border-color: var(--mark); color: #1b1606; }

/* ── العرض: شريط علوي، ومسرح، وشريط تحكم ── */
.deck { height: 100dvh; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; background: var(--stage); }
.bar, .ctl { background: var(--paper); display: flex; align-items: center; gap: 10px; padding-block: 8px;
  padding-left: max(12px, env(safe-area-inset-left, 0px)); padding-right: max(12px, env(safe-area-inset-right, 0px)); }
.bar { border-bottom: 1px solid var(--line); padding-top: max(8px, env(safe-area-inset-top, 0px)); }
.ctl { border-top: 1px solid var(--line); padding-bottom: max(8px, env(safe-area-inset-bottom, 0px)); }
.bar .where { min-width: 0; flex: 1; display: grid; line-height: 1.35; }
.bar .where b { font-size: .95rem; color: var(--accent); }
.bar .where span { font-weight: 700; font-size: 1.05rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sect { display: flex; align-items: center; gap: 8px; color: var(--muted); font-weight: 600; white-space: nowrap; }
.kind { font-size: .85rem; font-weight: 600; border-radius: 6px; padding: 1px 10px; color: var(--sheet); }
.k-open { background: var(--k-open); } .k-concept { background: var(--k-concept); } .k-example { background: var(--k-example); } .k-steps { background: var(--k-steps); }
.k-text { background: var(--k-text); } .k-info { background: var(--k-info); } .k-practice { background: var(--k-practice); }
.tools { display: flex; gap: 8px; }
@media (max-width: 760px) { .sect { display: none; } .tools .label { display: none; } }

.main { position: relative; min-height: 0; display: flex; }
.main.split { flex-direction: row; }
@media (max-aspect-ratio: 5/4) { .main.split { flex-direction: column; } }
.stage { flex: 1; min-width: 0; min-height: 0; display: grid; place-items: center; padding: 14px; touch-action: pan-y; }
.slide { display: grid; gap: 10px; justify-items: center; }
.part { position: relative; background: #fff; box-shadow: 0 1px 2px rgb(0 0 0 / .12), 0 6px 24px rgb(0 0 0 / .08); border-radius: 4px; overflow: hidden; }
.part img { position: absolute; display: block; max-width: none; user-select: none; -webkit-user-drag: none; }
.veil { position: absolute; inset-inline: 0; bottom: 0; background: #fff; border-top: 3px dashed var(--accent);
  display: flex; align-items: flex-start; justify-content: center; padding-top: 6px; color: var(--accent); font-weight: 600; font-size: clamp(13px, 1.1vw, 22px); }

.ctl .mid { flex: 1; min-width: 0; display: flex; justify-content: center; align-items: center; gap: 10px; flex-wrap: wrap; }
.short { display: none; }
/* الجوال: ازرار الكشف بنص قصير كي لا يتسع الشريط عن الشاشة */
@media (max-width: 560px) { .long { display: none; } .short { display: inline; } .ctl { gap: 6px; } .ctl .mid { gap: 6px; } .ctl .mid .btn { padding: 0 12px; } }
.pos { color: var(--muted); font-weight: 600; font-variant-numeric: tabular-nums; min-width: 5ch; text-align: center; }
.nav { min-width: 64px; min-height: 64px; font-size: 1.05rem; }
.nav .ic { font-size: 1.6em; }
@media (max-width: 760px) { .nav .label { display: none; } }
.ctl .btn.solve { background: var(--board); border-color: var(--board); color: var(--chalk); min-height: 56px; padding: 0 22px; }

/* ── لوح الحل: سبورة خضراء بخط الطباشير ── */
.board { background: var(--board); color: var(--chalk); display: grid; grid-template-rows: auto minmax(0, 1fr) auto; min-width: 0; min-height: 0; }
.main.split .board { flex: 0 0 42%; }
@media (max-aspect-ratio: 5/4) { .main.split .board { flex: 0 0 48%; } }
.board header { display: grid; gap: 10px; padding: 14px 16px 10px; border-bottom: 1px solid rgb(255 255 255 / .12); }
.board .head { display: flex; align-items: center; gap: 10px; }
.board .head h2 { flex: 1; font-size: clamp(18px, 1.5vw, 30px); font-weight: 700; }
.board .chip { background: transparent; color: var(--chalk); border-color: rgb(255 255 255 / .28); }
.board .chip[aria-pressed="true"] { background: var(--mark); border-color: var(--mark); color: #1b1606; }
.board .x { background: transparent; color: var(--chalk); border-color: rgb(255 255 255 / .28); min-width: 48px; padding: 0; }
.steps { overflow: auto; padding: 16px 20px; display: grid; align-content: start; gap: .35em; font-size: clamp(22px, 1.6vw + 10px, 60px); line-height: 1.6; }
.steps p { unicode-bidi: plaintext; }
.steps p.new { animation: chalk .25s ease-out; }
.steps .answer { margin-top: .3em; padding: .15em .5em; border: 2px solid var(--mark); border-radius: 10px; color: var(--mark); font-weight: 700; justify-self: start; }
.steps .hint { color: var(--chalk-dim); font-size: .7em; }
@keyframes chalk { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .steps p.new { animation: none; } .progress i { transition: none; } }
.board footer { display: flex; gap: 10px; padding: 12px 16px; border-top: 1px solid rgb(255 255 255 / .12); flex-wrap: wrap; }
.board footer .btn { background: transparent; color: var(--chalk); border-color: rgb(255 255 255 / .3); min-height: 56px; }
.board footer .btn.primary { background: var(--chalk); color: var(--board); border-color: var(--chalk); }

/* ── خريطة الدرس ── */
.map { position: fixed; inset: 0; z-index: 20; background: rgb(0 0 0 / .45); display: flex; justify-content: flex-start; }
.map .sheet { width: min(460px, 100%); height: 100%; background: var(--paper); overflow: auto; display: grid; align-content: start; gap: 4px;
  padding: max(14px, env(safe-area-inset-top, 0px)) 14px max(14px, env(safe-area-inset-bottom, 0px)); }
.map .sheet header { display: flex; align-items: center; gap: 10px; padding-bottom: 8px; position: sticky; top: 0; background: var(--paper); }
.map .sheet header h2 { flex: 1; font-size: 1.2rem; }
.map a { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; align-items: center; min-height: 52px; padding: 6px 10px; border-radius: 10px;
  color: inherit; text-decoration: none; border: 1px solid transparent; }
.map a:hover { border-color: var(--line); }
.map a[aria-current="true"] { background: var(--sheet); border-color: var(--accent); }
.map a .t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.map a .p { color: var(--muted); font-size: .9rem; font-variant-numeric: tabular-nums; }
.map h3 { font-size: .95rem; color: var(--accent); padding: 10px 10px 2px; }
