/* هوية الموقع: أزرق (حسب طلب المعلمة) مع لمسة ذهبية للشرف، خط Tajawal للواجهة وخط نسخ للنص المشكَّل */
:root {
  --bg: #f3f6fb;
  --surface: #ffffff;
  --ink: #1c2533;
  --sub: #5a6678;
  --line: #dbe3ee;
  --primary: #1f5fa8;
  --primary-d: #164a85;
  --primary-soft: #e3eefa;
  --accent: #8a5a00;
  --accent-soft: #fdf1d8;
  --gold: #e0a526;
  --hl: #ffe08a;
  --on-primary-soft: #ffe2a8;
  --ok: #2e7d32;
  --bad: #b3432e;
  --ui: "Tajawal", Tahoma, sans-serif;
  --motto: "Aref Ruqaa", "Noto Naskh Arabic", serif;
  --read: "Noto Naskh Arabic", "Traditional Arabic", serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--ui); font-size: 18px; line-height: 1.7; }
.wrap {
  max-width: 720px; margin: 0 auto;
  padding-block: max(16px, env(safe-area-inset-top, 0px)) max(40px, env(safe-area-inset-bottom, 0px));
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}

/* الترويسة: تدرّج أزرق، حروف تطفو في الخلفية، أدوات الكتابة تتمايل، وخط ذهبي يُرسم تحت الشعار */
.top {
  position: relative; overflow: hidden; isolation: isolate; text-align: center; color: #fff;
  padding: 20px 20px 26px; border-radius: 24px;
  background:
    radial-gradient(120% 80% at 100% 0%, rgba(255, 255, 255, .18), transparent 55%),
    radial-gradient(90% 70% at 0% 100%, rgba(120, 190, 255, .30), transparent 60%),
    linear-gradient(135deg, #2b74c9 0%, var(--primary) 45%, #173e7a 100%);
  box-shadow: 0 10px 28px -12px rgba(23, 62, 122, .55);
}
.top::after { content: ""; position: absolute; inset: auto 0 0 0; height: 7px; background: linear-gradient(90deg, var(--gold), #f6cd6a, var(--gold)); }

.sky { position: absolute; inset: 0; z-index: -1; pointer-events: none; }
.sky span {
  position: absolute; bottom: -40px; font-family: var(--motto); font-size: 34px; color: rgba(255, 255, 255, .13);
  animation: drift 14s linear infinite;
}
.sky span:nth-child(1)  { right: 4%;  animation-delay: 0s;   font-size: 30px; }
.sky span:nth-child(2)  { right: 15%; animation-delay: -9s;  font-size: 44px; }
.sky span:nth-child(3)  { right: 26%; animation-delay: -3s; }
.sky span:nth-child(4)  { right: 37%; animation-delay: -12s; font-size: 26px; }
.sky span:nth-child(5)  { right: 48%; animation-delay: -6s;  font-size: 40px; }
.sky span:nth-child(6)  { right: 59%; animation-delay: -1s;  font-size: 28px; }
.sky span:nth-child(7)  { right: 70%; animation-delay: -10s; }
.sky span:nth-child(8)  { right: 80%; animation-delay: -4s;  font-size: 46px; }
.sky span:nth-child(9)  { right: 89%; animation-delay: -7s;  font-size: 30px; }
.sky span:nth-child(10) { right: 95%; animation-delay: -13s; font-size: 24px; }
@keyframes drift {
  0%   { transform: translateY(0) rotate(0deg); opacity: 0; }
  10%  { opacity: 1; }
  90%  { opacity: 1; }
  100% { transform: translateY(-260px) rotate(25deg); opacity: 0; }
}

.tools { display: flex; justify-content: center; gap: 18px; font-size: 30px; line-height: 1; }
.tools span { display: inline-block; animation: bob 3.2s ease-in-out infinite; filter: drop-shadow(0 3px 4px rgba(0, 0, 0, .18)); }
.tools span:nth-child(2) { animation-delay: -.6s; }
.tools span:nth-child(3) { animation: bob 3.2s ease-in-out infinite -1.2s, twinkle 2.4s ease-in-out infinite; }
.tools span:nth-child(4) { animation-delay: -1.8s; }
.tools span:nth-child(5) { animation-delay: -2.4s; }
@keyframes bob { 0%, 100% { transform: translateY(0) rotate(-6deg); } 50% { transform: translateY(-7px) rotate(6deg); } }
@keyframes twinkle { 0%, 100% { scale: 1; } 50% { scale: 1.18; } }

.motto { margin: 12px 0 0; font-family: var(--motto); font-weight: 700; font-size: 34px; line-height: 1.7; text-shadow: 0 2px 10px rgba(10, 30, 70, .35); }
.motto .ml { display: block; opacity: 0; animation: rise .6s ease-out forwards; }
.motto .ml:nth-child(1) { animation-delay: .1s; }
.motto .ml:nth-child(2) { animation-delay: .35s; color: var(--on-primary-soft); }
.motto .ml:nth-child(3) { animation-delay: .6s; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.stroke { display: block; width: 180px; height: 18px; margin: 2px auto 10px; overflow: visible; }
.stroke path { fill: none; stroke: var(--gold); stroke-width: 4; stroke-linecap: round; stroke-dasharray: 260; stroke-dashoffset: 260; animation: draw 1.4s ease-out .9s forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }

.subject { display: inline-block; background: rgba(255, 255, 255, .16); border: 1px solid rgba(255, 255, 255, .25); border-radius: 99px; padding: 2px 14px; font-size: 15px; backdrop-filter: blur(2px); }

@media (prefers-reduced-motion: reduce) {
  .sky span, .tools span { animation: none; }
  .sky span { bottom: auto; top: 30%; }
  .motto .ml { animation: none; opacity: 1; }
  .stroke path { animation: none; stroke-dashoffset: 0; }
}
.demo { background: var(--accent-soft); color: var(--accent); border: 1px dashed var(--accent); border-radius: 12px; padding: 8px 12px; margin: 12px 0 0; font-size: 15px; }

/* البطاقات */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 16px; margin-top: 14px; }
.card h2 { margin: 0 0 6px; font-size: 21px; color: var(--primary-d); }
label { font-weight: 700; }
input[type="text"] { width: 100%; font: inherit; padding: 10px 14px; border: 2px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--ink); margin-top: 6px; }
input[type="text"]:focus { outline: 3px solid var(--primary-soft); border-color: var(--primary); }
.hint { color: var(--sub); font-size: 15px; margin: 6px 0 0; }
.hint.warn { color: var(--bad); }

/* قائمة الدروس */
.unit { margin: 14px 0 4px; font-size: 16px; color: var(--accent); }
.lesson-link {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  min-height: 56px; margin-top: 8px; padding: 10px 14px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--surface);
  color: var(--ink); text-decoration: none; font-family: var(--read); font-size: 20px; font-weight: 700;
}
.lesson-link .lt { min-width: 0; }
.badge { flex: none; font-family: var(--ui); font-size: 14px; font-weight: 700; padding: 2px 10px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); }
.badge.done { background: var(--primary-soft); color: var(--primary-d); }

/* لوحة الشرف */
.board { list-style: none; margin: 8px 0 0; padding: 0; }
.board li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.board li:last-child { border-bottom: 0; }
.rank { flex: none; width: 30px; height: 30px; border-radius: 99px; background: var(--primary-soft); color: var(--primary-d); font-weight: 800; text-align: center; line-height: 30px; font-size: 15px; }
.rank.medal { background: none; font-size: 24px; line-height: 30px; }
.board li.lead { background: linear-gradient(90deg, transparent, var(--accent-soft)); border-radius: 12px; padding-inline: 8px; }
.bn { flex: 1; min-width: 0; font-weight: 700; overflow-wrap: anywhere; }
.bc { flex: none; display: flex; flex-direction: column; align-items: flex-end; line-height: 1.3; text-align: end; }
.bp { color: var(--primary-d); font-size: 16px; }
.bl { color: var(--sub); font-size: 13px; }

/* الدرس */
.back { display: inline-block; margin: 14px 0 4px; padding: 6px 0; color: var(--primary-d); font-weight: 700; text-decoration: none; }
.eyebrow { margin: 6px 0 0; color: var(--accent); font-weight: 700; font-size: 15px; }
.ltitle { margin: 2px 0 10px; font-family: var(--read); font-size: 28px; line-height: 1.8; }
.points { margin: 0; padding: 14px 16px; padding-inline-start: 38px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; font-family: var(--read); font-size: 23px; line-height: 2.2; }
.points li { margin: 4px 0; }
.w { border-radius: 6px; transition: background-color .12s; }
.w.hl { background: var(--hl); box-shadow: 0 0 0 3px var(--hl); }
@media (prefers-reduced-motion: reduce) { .w { transition: none; } }
.tip { margin-top: 14px; padding: 12px 16px; background: var(--accent-soft); border: 1px solid var(--line); border-inline-start: 5px solid var(--gold); border-radius: 16px; }
.tip-h { margin: 0; color: var(--accent); font-weight: 800; font-size: 16px; }
.tip-t { margin: 4px 0 0; font-family: var(--read); font-size: 21px; line-height: 2; }
.points li::marker { color: var(--primary); }

/* الاختبار */
.quiz h3 { margin: 22px 0 6px; font-size: 21px; color: var(--primary-d); }
.q { margin-top: 10px; padding: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; }
.qt { margin: 0 0 10px; font-family: var(--read); font-size: 21px; line-height: 2; font-weight: 700; }
.opts { display: flex; flex-direction: column; gap: 8px; }
.opts.tf { flex-direction: row; }
.opts.tf .opt { flex: 1; justify-content: center; }
.opt {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 52px; padding: 8px 14px;
  border: 2px solid var(--line); border-radius: 12px; background: var(--bg); color: var(--ink);
  font: inherit; font-family: var(--read); font-size: 20px; text-align: start; cursor: pointer;
}
.opt:disabled { cursor: default; opacity: 1; }
.ol { flex: none; width: 24px; font-family: var(--ui); font-weight: 800; font-size: 16px; color: var(--accent); }
.opt.right { background: var(--ok); border-color: var(--ok); color: #fff; }
.opt.wrong { background: var(--bad); border-color: var(--bad); color: #fff; }
.opt.right .ol, .opt.wrong .ol { color: #fff; }

/* النتيجة */
.result { margin-top: 16px; padding: 16px; text-align: center; background: var(--primary-soft); border: 2px solid var(--primary); border-radius: 16px; }
.result:empty { display: none; }
.score { margin: 0; font-size: 26px; font-weight: 800; color: var(--primary-d); }
.cheer { margin: 4px 0 0; font-size: 20px; font-weight: 700; }
.status { margin: 10px 0 0; font-size: 16px; color: var(--sub); }
.status.ok { color: var(--ok); font-weight: 700; }
.status.err { color: var(--bad); }
.inline-name { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.inline-name input { flex: 1 1 160px; margin: 0; }
.actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 14px; }

/* الأزرار */
.btn {
  display: inline-flex; align-items: center; justify-content: center; min-height: 48px; padding: 8px 20px;
  border: 2px solid var(--primary); border-radius: 12px; background: var(--primary); color: #fff;
  font: inherit; font-weight: 700; text-decoration: none; cursor: pointer;
}
.btn.ghost { background: var(--surface); color: var(--primary-d); }
.btn.listen { margin: 0 0 12px; }
.btn.small { min-height: 38px; padding: 4px 12px; font-size: 15px; }
.lesson-link:focus-visible, .btn:focus-visible, .opt:focus-visible, .back:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

footer { margin-top: 28px; text-align: center; color: var(--sub); font-size: 15px; }
