/* Shared look for every Arabic lesson page (driven by engine.js). */
:root { --ink:#2B2118; --sun:#FFC94D; --leaf:#43A047; --no:#E53935; --shadow:0 7px 0 rgba(43,33,24,.22); }
* { box-sizing:border-box; -webkit-tap-highlight-color:transparent; }
html, body { margin:0; overflow-x:clip; }
/* tablets: no double-tap zoom when a child taps fast, no rubber-band jumps from a fixed background */
html { touch-action:manipulation; -webkit-text-size-adjust:100%; background:#E8F6DE; }
button, a, .card, .tile { touch-action:manipulation; }
body { font-family:"Baloo Bhaijaan 2", system-ui, sans-serif; color:var(--ink); background:linear-gradient(#E3F4FF 0 30%, #E8F6DE); min-height:100svh;
  padding:max(14px, env(safe-area-inset-top)) 16px max(28px, env(safe-area-inset-bottom)); }
#lesson { max-width:860px; margin:0 auto; }
.top { display:flex; align-items:center; gap:10px; margin-bottom:12px; }
.back { display:inline-grid; place-items:center; width:46px; height:46px; flex:0 0 auto; border-radius:16px; background:#fff; box-shadow:var(--shadow);
  text-decoration:none; color:var(--ink); font-size:24px; font-weight:800; }
h1 { margin:0; font-size:clamp(26px, 6.5vw, 40px); font-weight:800; line-height:1.3; }
.tag { display:inline-block; background:var(--sun); border-radius:999px; padding:2px 12px; font-size:14px; font-weight:800; }
section { background:#fff; border-radius:26px; box-shadow:var(--shadow); padding:16px; margin:18px 0; }
h2 { margin:0 0 8px; font-size:clamp(19px, 4.8vw, 25px); font-weight:800; display:flex; align-items:center; gap:8px; line-height:1.4; }
h2 .star { margin-inline-start:auto; font-size:26px; opacity:.2; transition:opacity .3s, transform .3s; }
h2 .star.on { opacity:1; transform:scale(1.15); }
.ins { margin:0 0 10px; font-size:clamp(16px, 4.2vw, 19px); font-weight:700; line-height:1.8; }
.goals { margin:0; padding-inline-start:20px; font-weight:600; color:#5a4c3d; line-height:1.9; }
.spk { border:0; background:var(--sun); width:38px; height:38px; min-width:38px; border-radius:50%; font-size:18px; cursor:pointer; box-shadow:0 4px 0 rgba(43,33,24,.2);
  display:inline-grid; place-items:center; padding:0; vertical-align:middle; margin-inline-end:6px; }
.novoice .spk, .novoice .playb { display:none; }
.spk.on { animation:pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { transform:scale(1.12); } }

/* story */
.stage { position:relative; border-radius:18px; overflow:hidden; background:#000; aspect-ratio:16/9; }
.stage img, .stage video { width:100%; height:100%; object-fit:cover; display:block; }
.stage img.kb { animation:kb 14s ease-in-out infinite alternate; }
@keyframes kb { from { transform:scale(1.02) translate(0, 0); } to { transform:scale(1.12) translate(-2%, -1.5%); } }
.stage .num { position:absolute; top:10px; right:10px; background:#fff; border-radius:999px; padding:2px 12px; font-weight:800; font-size:15px; }
.text { font-family:"Amiri", serif; font-size:clamp(21px, 5vw, 27px); line-height:2.05; margin:12px 4px 6px; min-height:4.2em; }
.controls { display:flex; gap:10px; justify-content:center; align-items:center; margin-top:6px; }
.round { width:60px; height:60px; border-radius:50%; border:0; background:var(--sun); font-size:26px; box-shadow:var(--shadow); cursor:pointer; color:var(--ink); }
.round.small { width:50px; height:50px; background:#fff; border:3px solid #eee3cf; font-size:22px; }
.round:disabled { opacity:.35; }
.dots { display:flex; gap:6px; justify-content:center; margin-top:10px; flex-wrap:wrap; }
.dots i { width:12px; height:12px; border-radius:50%; background:#e6dccb; cursor:pointer; }
.dots i.on { background:var(--sun); transform:scale(1.25); }
.note { font-size:13.5px; color:#7b6a55; text-align:center; margin:8px 0 0; font-weight:600; }

/* rule box, vocab */
.rule { background:#FFF7DD; border-radius:16px; padding:12px 14px; font-size:clamp(17px, 4.4vw, 20px); font-weight:700; line-height:1.9; }
.ex { list-style:none; padding:0; margin:10px 0 0; display:grid; gap:8px; }
.ex li { display:flex; align-items:center; gap:6px; background:#F4FAFF; border-radius:14px; padding:8px 10px; font-family:"Amiri", serif; font-size:clamp(19px, 4.6vw, 23px); }
.vocab { display:grid; grid-template-columns:repeat(auto-fill, minmax(150px, 1fr)); gap:10px; }
.vcard { border:3px solid #eadfcb; background:#fffaf0; border-radius:16px; padding:10px; cursor:pointer; font:inherit; color:var(--ink); display:grid; gap:4px; text-align:center; }
.vcard b { font-family:"Amiri", serif; font-size:24px; }
.vcard span { font-size:15px; font-weight:700; color:#3c6b2e; visibility:hidden; }
.vcard.open span { visibility:visible; } .vcard.open { border-color:var(--leaf); }

/* questions */
.q { border:3px solid #f1e8d8; border-radius:18px; padding:12px; margin:10px 0; }
.q.solved { border-color:#bfe3b8; }
.q p { margin:0 0 10px; font-size:clamp(17px, 4.4vw, 20px); font-weight:700; line-height:1.8; display:flex; align-items:flex-start; gap:4px; flex-wrap:wrap; }
.qimg { width:100%; max-width:320px; border-radius:12px; display:block; margin:4px 0 8px; }
.row { display:flex; gap:10px; flex-wrap:wrap; }
.pick { border:3px solid #eadfcb; background:#fffaf0; border-radius:16px; padding:8px 14px; font:700 17px "Baloo Bhaijaan 2"; cursor:pointer; color:var(--ink); }
.pick.sel { border-color:#1E88E5; background:#E3F2FD; }
.pick.right { background:#E3F5E1; border-color:var(--leaf); }
.pick.wrong, .bin.wrong { animation:wig .4s; border-color:var(--no); }
@keyframes wig { 30% { transform:rotate(-4deg); } 60% { transform:rotate(3deg); } }
.blank { display:inline-block; min-width:70px; border-bottom:3px dashed #c9b48f; text-align:center; color:#b3a083; margin:0 4px; }
.blank.filled { color:var(--leaf); border-bottom-color:var(--leaf); }
.why { margin-top:8px; font-size:15.5px; font-weight:600; color:#3c6b2e; display:none; line-height:1.8; }
.why.show { display:block; }
.match { display:grid; grid-template-columns:1fr 1fr; gap:12px; }
.match .col { display:grid; gap:8px; align-content:start; }
.slots { min-height:52px; border:3px dashed #e3d6bf; border-radius:14px; padding:6px; display:flex; flex-wrap:wrap; gap:6px; margin-bottom:8px; }
.slot { background:#E3F5E1; border-radius:12px; padding:6px 12px; font-weight:800; }
.mini { border:0; background:#f3ebdc; border-radius:999px; padding:4px 12px; font:700 14px "Baloo Bhaijaan 2"; cursor:pointer; margin-top:8px; color:var(--ink); }
.bins { display:grid; grid-template-columns:repeat(auto-fit, minmax(140px, 1fr)); gap:10px; margin-top:12px; }
.bin { border:3px solid #eadfcb; border-radius:16px; padding:10px; min-height:110px; cursor:pointer; background:#FFFDF7; }
.bin b { display:block; text-align:center; margin-bottom:6px; font-size:18px; }
.bin .in { display:flex; flex-wrap:wrap; gap:6px; }
.cards { display:grid; grid-template-columns:1fr; gap:10px; }
@media (min-width:640px) { .cards { grid-template-columns:1fr 1fr; } }
.card { border:4px solid #eadfcb; border-radius:18px; padding:12px; font:700 18px "Baloo Bhaijaan 2"; background:#fff; cursor:pointer; text-align:start; color:var(--ink);
  display:flex; gap:8px; align-items:center; transition:background .2s; }
.card.green { background:#C8EBC1; border-color:var(--leaf); }
.card .mark { margin-inline-start:auto; font-size:22px; }
textarea { width:100%; min-height:84px; border:3px solid #eadfcb; border-radius:16px; padding:10px; font:600 18px "Baloo Bhaijaan 2"; color:var(--ink); resize:vertical; }
.ideas { display:flex; gap:8px; flex-wrap:wrap; margin-top:8px; }
.chip { border:0; background:#FFF1C9; border-radius:999px; padding:6px 12px; font:700 15px "Baloo Bhaijaan 2"; cursor:pointer; color:var(--ink); }
.go { display:block; margin:14px auto 0; border:0; border-radius:999px; background:var(--leaf); color:#fff; font:800 19px "Baloo Bhaijaan 2"; padding:10px 28px;
  box-shadow:0 5px 0 #2e7031; cursor:pointer; }
.result { text-align:center; font-weight:800; font-size:18px; margin-top:10px; min-height:1.6em; }
footer { text-align:center; font-size:12.5px; font-weight:600; color:#7b6a55; margin-top:20px; line-height:1.9; }

/* ---------- game mode (game.js): one step on the screen at a time ---------- */
.gbar { position:sticky; top:0; z-index:20; display:flex; align-items:center; gap:10px; max-width:860px; margin:0 auto 10px; padding:8px 0;
  background:linear-gradient(#E3F4FF, rgba(227,244,255,.92)); }
.gmeta { flex:1; min-width:0; }
.gmeta b { display:block; font-size:16px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.pbar { height:14px; border-radius:999px; background:#fff; box-shadow:inset 0 2px 0 rgba(0,0,0,.08); overflow:hidden; margin-top:4px; }
.pbar i { display:block; height:100%; width:0; background:linear-gradient(90deg, #43A047, #8BC34A); border-radius:999px; transition:width .5s ease; }
.gstars { background:#fff; border-radius:999px; padding:6px 12px; font-weight:800; font-size:18px; box-shadow:var(--shadow); white-space:nowrap; }
.gstars.pop { animation:pop .5s; }
@keyframes pop { 40% { transform:scale(1.35); } }
.stage-card { max-width:860px; margin:0 auto; background:#fff; border-radius:28px; box-shadow:var(--shadow); padding:18px 16px 22px; min-height:58svh; overflow-anchor:none; }
.gnav { position:sticky; bottom:0; z-index:20; display:flex; align-items:center; justify-content:space-between; gap:10px; max-width:860px; margin:14px auto 0;
  padding:10px 0 max(10px, env(safe-area-inset-bottom)); background:linear-gradient(rgba(232,246,222,.6), #E8F6DE); }
.gnav[hidden] { display:none; }
.nbtn { border:0; border-radius:999px; padding:12px 22px; font:800 19px "Baloo Bhaijaan 2"; cursor:pointer; background:#fff; color:var(--ink); box-shadow:var(--shadow); }
.nbtn.next { background:#d9d2c4; color:#fff; }
.nbtn.next.ready { background:var(--leaf); box-shadow:0 6px 0 #2e7031; }
.nbtn.next.skip { background:#fff; color:#7b6a55; border:3px dashed #d9d2c4; box-shadow:none; }
.later { display:grid; gap:10px; margin:14px auto; max-width:520px; }
.later .go { width:100%; font-size:17px; line-height:1.5; }
@keyframes nudge { 50% { transform:translateX(-6px); } }
.nbtn:disabled { opacity:.4; animation:none; }
.where { font-weight:800; color:#7b6a55; }
.sect { margin:0 0 6px; font-size:14px; font-weight:800; color:#8a7a63; }
.question { font-size:clamp(21px, 5.4vw, 28px); font-weight:800; line-height:1.8; margin:6px 0 14px; display:flex; gap:6px; align-items:flex-start; flex-wrap:wrap; }
.answers { display:grid; grid-template-columns:repeat(auto-fit, minmax(150px, 1fr)); gap:12px; }
.ans { border:4px solid #eadfcb; background:#fffaf0; border-radius:20px; padding:14px 12px; font:800 clamp(19px, 4.8vw, 24px) "Baloo Bhaijaan 2"; cursor:pointer; color:var(--ink);
  box-shadow:0 5px 0 #eadfcb; transition:transform .1s; }
.ans:active { transform:translateY(3px); box-shadow:0 2px 0 #eadfcb; }
.ans.right { background:#C8EBC1; border-color:var(--leaf); box-shadow:0 5px 0 #2e7031; animation:yes .5s; }
@keyframes yes { 50% { transform:scale(1.08); } }
.ans.wrong, .bin.wrong, .go.wrong { animation:wig .45s; border-color:var(--no); }
.ans.dim { opacity:.35; }
.ans.sel { border-color:#1E88E5; background:#E3F2FD; }
.tile { padding:10px 16px; }
.pool { display:flex; flex-wrap:wrap; gap:10px; margin:8px 0; }
.slots.solved { border-color:var(--leaf); background:#F2FBEF; }
.hintbox { margin-top:14px; background:#FFF7DD; border-radius:16px; padding:10px 14px; font-weight:700; line-height:1.8; border-inline-start:6px solid var(--sun); }
.hintbox[hidden], .why[hidden] { display:none; }
.stage-card .why { display:block; margin-top:12px; font-size:17px; }
.concept { text-align:center; }
.concept .bulb { font-size:64px; line-height:1; animation:pop 1.2s ease-in-out infinite; }
.concept h2 { justify-content:center; }
.say { font-size:clamp(19px, 4.8vw, 24px); font-weight:700; line-height:1.9; margin:8px 0 12px; }
.concept .rule, .concept .ex { text-align:start; }
.start { text-align:center; }
.start .cover { width:100%; border-radius:20px; aspect-ratio:16/9; object-fit:cover; margin-bottom:10px; }
.start h1 { margin:8px 0 12px; }
.goalsbox { text-align:start; background:#F4FAFF; border-radius:16px; padding:8px 14px; margin:0 auto 14px; max-width:620px; }
.goalsbox summary { font-weight:800; cursor:pointer; }
.goalsbox ul { margin:6px 0 0; padding-inline-start:20px; line-height:1.9; font-weight:600; color:#5a4c3d; }
.bigplay { border:0; border-radius:999px; background:var(--leaf); color:#fff; font:800 clamp(24px, 6vw, 32px) "Baloo Bhaijaan 2"; padding:14px 40px;
  box-shadow:0 7px 0 #2e7031; cursor:pointer; animation:nudge 1.6s ease-in-out infinite; }
.trophy { font-size:110px; line-height:1.1; animation:pop 1.4s ease-in-out infinite; }
.row.center { justify-content:center; }
a.go { text-decoration:none; display:inline-block; }
.stage-card .qimg { max-width:100%; width:560px; aspect-ratio:16/9; object-fit:cover; border-radius:18px; margin:0 auto 6px; }
.spark { position:fixed; width:12px; height:12px; border-radius:3px; pointer-events:none; z-index:60; animation:fly 1s ease-out forwards; }
@keyframes fly { to { transform:translate(var(--dx), var(--dy)) rotate(540deg); opacity:0; } }
.ans.glow { animation:glow 1s ease-in-out infinite; border-color:var(--sun); }
@keyframes glow { 50% { transform:scale(1.08); box-shadow:0 0 0 10px rgba(255,201,77,.55); } }
.tile, .slots .slot { font-family:"Amiri", serif; font-size:clamp(24px, 6vw, 30px); font-weight:700; line-height:1.6; padding:6px 18px; }
/* one page per activity: each question is a small numbered card */
.gqs { display:grid; gap:14px; }
.gq { position:relative; border:3px solid #f1e8d8; border-radius:20px; padding:12px 14px 14px; padding-inline-start:46px; background:#fffdf8; }
.gq::before { content:attr(data-n); position:absolute; inset-inline-start:10px; top:12px; width:28px; height:28px; border-radius:50%; background:var(--sun);
  display:grid; place-items:center; font-weight:800; font-size:16px; }
.gq .question { font-size:clamp(18px, 4.6vw, 23px); margin:0 0 10px; }
.gq .answers { grid-template-columns:repeat(auto-fit, minmax(120px, 1fr)); gap:10px; }
.gq .ans { padding:10px; font-size:clamp(17px, 4.3vw, 21px); }
.gq .qimg { width:100%; max-width:420px; }
.gq textarea { min-height:64px; }
/* «أضع علامة ✓» as in the book: every choice card has a tick box that fills when chosen */
.card::before { content:""; flex:0 0 auto; width:34px; height:34px; border:3px solid #cbbfa8; border-radius:9px; background:#fff;
  display:inline-grid; place-items:center; font:800 26px/1 system-ui, sans-serif; color:var(--leaf); }
.card.green::before { content:"✓"; border-color:var(--leaf); }
/* تقييمات: choose المجموعة أ / ب / جـ */
.groups { display:grid; gap:12px; max-width:420px; margin:16px auto 4px; }
.groups .grp { width:100%; font-size:22px; padding:14px; }
.passage { font:400 22px/2.1 "Amiri", serif; background:#FFFAF0; border:3px solid #f1e8d8; border-radius:18px; padding:12px 16px; margin:6px 0 14px; }
.stage-card .qimg.whole { aspect-ratio:auto; object-fit:contain; width:min(100%, 620px); background:#BFE3F5; }   /* maps: show all of it */
/* sort games: smaller tiles so the boxes stay close to the words on a phone */
.pool:has(+ .bins) { display:flex; flex-wrap:wrap; gap:8px; justify-content:center; }
.pool:has(+ .bins) .tile { font:700 17px/1.5 "Baloo Bhaijaan 2", system-ui, sans-serif; padding:7px 12px; min-height:0; }

.soonvoice { background:#FFF3C4; border:2px dashed #FFC94D; border-radius:14px; padding:8px 12px; font-weight:700; font-size:15px; margin:10px auto; max-width:460px; }
/* KG: picture answers, drawing pages */
.opic { display:block; max-width:100%; max-height:clamp(90px, 22vh, 170px); margin:auto; border-radius:12px; object-fit:contain; }
.answers.pics { grid-template-columns:repeat(auto-fit, minmax(110px, 1fr)) !important; }
.answers.pics .ans, .match .opic, .bin .opic { padding:6px; background:#fff; }
.match .ans.m:has(.opic) { padding:4px; background:#fff; } .match .opic { max-height:110px; }
.pool .tile:has(.opic) { padding:4px; background:#fff; } .pool .tile .opic, .slots .slot .opic { max-height:100px; }
.bin b .opic { max-height:120px; } .bin .in .slot .opic { max-height:60px; }
.vcard .opic { max-height:130px; } .vcard b { font-size:22px; }
.cards.pics { grid-template-columns:repeat(auto-fit, minmax(130px, 1fr)); } .cards.pics .card { flex-direction:column; text-align:center; }
.saybox { text-align:center; font-weight:800; font-size:22px; color:#1E6FB8; margin:6px 0; }
.drawwrap { position:relative; touch-action:none; margin:6px auto; max-width:720px; }
.drawwrap img { display:block; width:100%; border-radius:16px; user-select:none; -webkit-user-drag:none; pointer-events:none; }
.drawwrap canvas { position:absolute; inset:0; width:100%; height:100%; }
.palette { display:flex; gap:10px; justify-content:center; align-items:center; flex-wrap:wrap; margin:8px 0; }
.palette [data-c] { width:42px; height:42px; border-radius:50%; border:4px solid #fff; box-shadow:0 2px 0 rgba(0,0,0,.2); cursor:pointer; }
.palette [data-c].on { transform:scale(1.2); border-color:#2B2118; }
.drawdone { display:block; margin:8px auto; }
.qimg[src^="/kg1/"] { max-height:28vh; width:auto; max-width:100%; object-fit:contain; display:block; margin-inline:auto; }
.turn { text-align:center; font-weight:800; color:#1E6FB8; margin:4px 0; }
/* KG: the book's pictures are small — show them whole and never zoom past their size */
.stage img[src^="/kg1/"] { object-fit:contain; background:#fff; animation:none; }
.start .cover[src^="/kg1/"] { object-fit:contain; background:#fff; max-height:42vh; }
.stage:has(img[src^="/kg1/"]) { background:#fff; max-height:46vh; margin-inline:auto; }
/* تقييمات / مراجعة pictures are cut from the books: always show the whole picture, never crop it to 16:9 */
.qimg[src*="/review1/"], .qimg[src*="tq/img/"] { aspect-ratio:auto; object-fit:contain; width:auto; max-width:100%; max-height:46vh; display:block; margin-inline:auto; background:#fff; }
/* تقييمات by book page (lesson.byPage): «📖 صفحة ١٣ في الكتاب», then each exercise of that page in order */
.pagehead { margin:0 0 12px; text-align:center; font-weight:800; font-size:clamp(17px, 4.6vw, 21px); background:#FFF3D6; border-radius:999px; padding:6px 14px; }
.pblocks { display:grid; gap:22px; }
.pblock { border-top:3px dashed #f1e8d8; padding-top:14px; }
.pblock:first-child { border-top:0; padding-top:0; }
.ptitle { margin:0 0 8px; font-size:clamp(16px, 4.3vw, 19px); font-weight:800; line-height:1.7; color:#5a3d00; }
.psect { margin:0 0 6px; font-size:clamp(17px, 4.6vw, 20px); font-weight:800; line-height:1.7; color:#2B2118; }
.pblock h4.ptitle { color:#5a3d00; }
/* the «free part is over» card: one big sign-up button, two quiet links under it */
.freebtns { display:grid; gap:12px; justify-items:center; margin-top:8px; }
.freebtns .go { min-width:240px; }
.freebtns .lnk { all:unset; cursor:pointer; color:#1E6FB8; font-weight:800; font-size:17px; text-decoration:underline; }
