/* site.css — all styles for AlifBaaTales */
:root{
  box-sizing:border-box;padding-top:env(safe-area-inset-top,0px);padding-bottom:env(safe-area-inset-bottom,0px);
  --bg:#D9F0FB;--panel:#FFFFFF;--ink:#1D2A44;--muted:#52607D;--line:#C9D6E6;--soft:#EEF3F9;
  --hero:#8FD3F4;--accent:#F4903B;--accent-dk:#C96E22;--berry:#E0487A;--berry-dk:#B3325D;
  --hl:#FFE08A;--star-off:#DDE3EC;--plank:#C98A55;--plank-dk:#A86B3B;--edge1:#E4F3FB;--edge2:#C4E5F5;--dot:#BFD9E8;
}
@media (prefers-color-scheme: dark){:root:not([data-theme="light"]){
  --bg:#0F1E33;--panel:#1B2B45;--ink:#F1F5FF;--muted:#A8B6D3;--line:#34486A;--soft:#233656;--hero:#23456E;
  --hl:#7A6420;--star-off:#3A4D6E;--edge1:#16253C;--edge2:#122036;--dot:#34486A;}}
:root[data-theme="dark"]{--bg:#0F1E33;--panel:#1B2B45;--ink:#F1F5FF;--muted:#A8B6D3;--line:#34486A;--soft:#233656;--hero:#23456E;
  --hl:#7A6420;--star-off:#3A4D6E;--edge1:#16253C;--edge2:#122036;--dot:#34486A;}
html{scroll-padding-top:env(safe-area-inset-top,0px)}
*{box-sizing:border-box}
body{margin:0;background:var(--bg);color:var(--ink);font-family:"Baloo Bhaijaan 2","Noto Naskh Arabic",system-ui,-apple-system,"Segoe UI",sans-serif;-webkit-tap-highlight-color:transparent}
a{color:inherit}
button{font:inherit;color:inherit}
button:focus-visible,a:focus-visible,input:focus-visible{outline:4px solid var(--ink);outline-offset:3px}
.ar,.line,.rq,.cover-title,.card .ar,.start,h1[dir="rtl"]{font-family:"Noto Naskh Arabic","Geeza Pro","Arial",serif}

/* header */
.top{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:12px clamp(16px,4vw,56px);background:var(--panel)}
.brand{display:flex;align-items:center;gap:10px;text-decoration:none;font-weight:800;font-size:clamp(1.1rem,3.4vw,1.6rem)}
.brand small{font-family:"Noto Naskh Arabic",serif;font-weight:700;font-size:1.1rem;color:var(--muted)}
.tools{display:flex;align-items:center;gap:10px}
.stars{display:flex;align-items:center;gap:6px;background:#FFF1C9;color:#1D2A44;border-radius:999px;padding:6px 14px;font-weight:800;min-height:44px}
.toggle{border:2px solid var(--ink);background:transparent;border-radius:999px;padding:6px 14px;font-weight:700;cursor:pointer;min-height:44px}
.toggle[aria-pressed="true"]{background:var(--ink);color:var(--panel)}
.back{display:flex;align-items:center;gap:4px;text-decoration:none;font-weight:800;padding:6px 14px 6px 8px;border-radius:999px;background:var(--soft);min-height:44px}
@media (max-width:560px){.brand small{display:none}.brand span{display:none}}

/* library */
.lib{padding-bottom:40px}
.hero{margin:0 clamp(8px,2.5vw,32px);padding:clamp(20px,4vw,36px) clamp(20px,5vw,64px);background:var(--hero);border-radius:0 0 clamp(28px,4vw,48px) clamp(28px,4vw,48px);display:flex;align-items:center;justify-content:space-between;gap:32px}
.hero h1{margin:0;font-size:clamp(3.2rem,9vw,6rem);line-height:1.2;font-weight:700;text-align:left}
.hero p{margin:4px 0 16px;font-size:clamp(1.1rem,2.4vw,1.6rem);line-height:1.4;font-weight:600;max-width:36ch}
.hero-art{flex-shrink:0;width:min(34vw,360px)}
.hero-art svg{width:100%;height:auto;display:block}
@media (max-width:700px){.hero-art{display:none}}
.cta{display:inline-block;text-decoration:none;border:0;cursor:pointer;background:var(--accent);color:#1D2A44;font-weight:800;font-size:1.2rem;border-radius:999px;padding:10px 26px;box-shadow:0 5px 0 var(--accent-dk)}
.cta:active{transform:translateY(3px);box-shadow:0 2px 0 var(--accent-dk)}
.controls{margin:28px clamp(12px,4vw,56px) 0;padding:20px clamp(16px,2.5vw,32px);background:var(--panel);border-radius:28px;display:flex;flex-wrap:wrap;align-items:flex-end;gap:20px 28px}
.field{display:flex;flex-direction:column;gap:8px}
.field:first-child{flex:1 1 300px}
.field label,.flabel{font-size:1.1rem;font-weight:700}
.search{display:flex;align-items:center;gap:10px;border:3px solid var(--line);border-radius:18px;padding:0 14px;height:56px;color:var(--muted)}
.search input{border:0;outline:none;font:inherit;font-size:1.2rem;flex:1;min-width:0;background:transparent;color:var(--ink)}
.search:focus-within{border-color:var(--ink)}
.chips{display:flex;gap:10px;flex-wrap:wrap}
.chip{height:52px;padding:0 18px;border-radius:999px;border:3px solid var(--line);background:var(--panel);font-weight:700;font-size:1.05rem;cursor:pointer}
.chip[aria-pressed="true"]{background:var(--c);border-color:var(--c);color:#fff;font-weight:800}
.seg{display:flex;background:var(--soft);border-radius:999px;padding:4px}
.seg button{height:46px;padding:0 18px;border-radius:999px;border:0;background:transparent;font-weight:700;font-size:1.05rem;cursor:pointer}
.seg button[aria-pressed="true"]{background:var(--ink);color:var(--panel);font-weight:800}
.shelves{margin:28px clamp(12px,4vw,56px) 0;display:flex;flex-direction:column;gap:28px}
.shelf{background:var(--panel);border-radius:28px;padding:24px 0 30px;display:flex;flex-direction:column;gap:20px}
.shelf-head{display:flex;flex-wrap:wrap;align-items:center;gap:6px 14px;padding:0 clamp(16px,3vw,40px)}
.pill{color:#fff;font-weight:800;font-size:1.05rem;border-radius:999px;padding:3px 14px}
.shelf-head .ar{font-weight:700;font-size:1.4rem}
.sname{font-size:1.4rem;font-weight:800}
.sdesc{font-size:1.1rem;color:var(--muted)}
.count{margin-left:auto;font-weight:700;color:var(--muted)}
.shelf-scroll{overflow-x:auto;padding:0 clamp(16px,3vw,40px) 8px}
.track{display:flex;flex-direction:column;width:max-content;min-width:100%;--bw:clamp(140px,17vw,190px)}
.covers,.captions{display:flex;gap:clamp(18px,3.5vw,48px);padding:0 clamp(10px,2.5vw,36px)}
.cover{position:relative;display:flex;flex-direction:column;width:var(--bw);border-radius:10px 16px 16px 10px;overflow:hidden;text-decoration:none;box-shadow:inset 10px 0 0 rgba(0,0,0,.14),0 8px 16px rgba(29,42,68,.22);transition:transform .15s}
.cover:hover{transform:translateY(-4px) rotate(-1deg)}
.cover-art svg{display:block;width:100%;height:auto}
.cover-title{color:#fff;font-weight:700;font-size:calc(var(--bw) * .11);line-height:1.5;padding:8px 10px 12px;text-align:center;min-height:calc(var(--bw) * .5);display:flex;align-items:center;justify-content:center}
.done{position:absolute;top:8px;left:8px;width:34px;height:34px;border-radius:50%;background:#fff;display:grid;place-items:center;box-shadow:0 2px 6px rgba(0,0,0,.2)}
.plank{height:18px;background:var(--plank);border-radius:8px;box-shadow:0 8px 0 var(--plank-dk)}
.captions{padding-top:20px}
.cap{width:var(--bw);display:flex;flex-direction:column;gap:4px}
.cap a{font-weight:700;font-size:1.1rem;text-decoration:none;line-height:1.3}
.cap a:hover{text-decoration:underline}
.rating{display:flex;align-items:center;flex-wrap:wrap;gap:2px}
.rating b{margin-left:6px}
.rating span{margin-left:6px;color:var(--muted);font-size:.95rem}
.rating.muted span{margin-left:6px}
.empty{background:var(--panel);border-radius:28px;padding:48px 24px;text-align:center;display:flex;flex-direction:column;align-items:center;gap:10px}
.empty p{margin:0;font-size:1.2rem;color:var(--muted)}
.empty .big{font-size:1.7rem;font-weight:800;color:var(--ink)}
.foot{margin:36px clamp(12px,4vw,56px) 0;color:var(--muted);font-size:1rem}

/* reader */
.reader{max-width:680px;margin:0 auto;padding:14px 16px 16px;display:flex;flex-direction:column;gap:14px;min-height:calc(100svh - 70px)}
.book{flex:1;display:flex;flex-direction:column;background:var(--panel);border-radius:30px;box-shadow:0 7px 0 var(--edge1),0 14px 0 var(--edge2);overflow:hidden;touch-action:pan-y;transform-origin:left center}
.book.turn-next{animation:turnNext .45s cubic-bezier(.2,.8,.3,1)}
.book.turn-prev{animation:turnPrev .45s cubic-bezier(.2,.8,.3,1)}
@keyframes turnNext{from{transform:perspective(1400px) rotateY(-22deg) translateX(-4%);opacity:.3}to{transform:none;opacity:1}}
@keyframes turnPrev{from{transform:perspective(1400px) rotateY(22deg) translateX(4%);opacity:.3}to{transform:none;opacity:1}}
.art{padding:14px 14px 0}
.art svg{width:100%;height:auto;display:block;max-height:52svh}
.text{padding:8px 22px 20px;text-align:center}
.line{font-weight:700;margin:0;color:var(--ink);font-size:clamp(1.9rem,7.4vw,2.8rem);line-height:1.95}
.book[data-level="2"] .story .line,.book[data-level="2"].story .line{font-size:clamp(1.5rem,5.4vw,2.1rem);line-height:2}
.book[data-level="3"].story .line{font-size:clamp(1.25rem,4.4vw,1.7rem);line-height:2.05;text-align:right}
.book.cover .line{font-size:clamp(2.2rem,9vw,3.4rem);line-height:1.6}
.w{cursor:pointer;border-radius:10px;padding:0 .08em;transition:background-color .15s}
.w.on{background:var(--hl)}
.gloss{margin:.3rem 0 0;color:var(--muted);font-size:1.1rem;font-weight:500;direction:ltr}
.book[data-level="3"] .gloss{text-align:left}
.gloss[hidden],.card .en[hidden]{display:none}
.lvl-note{margin:.2rem 0 0;color:var(--muted);font-weight:700}
.start{margin-top:10px;display:inline-block;text-decoration:none;font-weight:700;font-size:1.5rem;background:var(--accent);color:#1D2A44;border:0;border-radius:999px;padding:4px 30px 10px;cursor:pointer;box-shadow:0 5px 0 var(--accent-dk)}
.start.alt{background:var(--soft);color:var(--ink);box-shadow:0 5px 0 var(--line)}
.start:active{transform:translateY(3px)}
.endwrap{display:flex;flex-direction:column;align-items:center;padding:12px 16px 22px;gap:6px}
.endwrap .text{padding-bottom:0}
.rate{text-align:center;padding:4px 0 8px}
.rq{margin:0;font-weight:700;font-size:1.45rem;line-height:1.8}
.rstars{display:flex;justify-content:center;gap:2px}
.rstars button{border:0;background:transparent;padding:2px;cursor:pointer;border-radius:12px;min-width:48px;min-height:48px}
.vocab{width:100%;display:grid;grid-template-columns:repeat(auto-fit,minmax(118px,1fr));gap:10px;padding:6px 4px}
.card{border:0;background:var(--edge1);border-radius:22px;padding:8px 6px 4px;cursor:pointer;display:flex;flex-direction:column;align-items:center}
.card svg{width:100%;max-width:120px;height:auto}
.card .ar{font-weight:700;font-size:1.4rem;line-height:1.7}
.card .en{font-size:.95rem;color:var(--muted);margin-top:-6px}
.card.on{background:var(--hl)}
.hint{margin:0;color:var(--muted)}
.endbtns{display:flex;gap:14px;flex-wrap:wrap;justify-content:center}
.rnav{display:grid;grid-template-columns:1fr auto 1fr;align-items:center;gap:10px;padding-bottom:6px}
.dots{grid-column:1/-1;display:flex;justify-content:center;gap:6px;margin:0 0 4px;padding:0;list-style:none}
.dots li{width:9px;height:9px;border-radius:999px;background:var(--dot);transition:width .2s,background-color .2s}
.dots li.cur{width:26px;background:var(--accent)}
.round{width:62px;height:62px;border-radius:50%;border:0;cursor:pointer;display:grid;place-items:center;background:var(--panel);color:var(--ink);box-shadow:0 4px 0 rgba(29,42,68,.18)}
.round:disabled{opacity:.35;cursor:default}
.round svg{width:30px;height:30px}
.next{justify-self:start;background:var(--accent);color:#fff;box-shadow:0 4px 0 var(--accent-dk)}
.prev{justify-self:end}
.listen{width:78px;height:78px;background:var(--berry);color:#fff;box-shadow:0 5px 0 var(--berry-dk)}
.listen.playing{animation:pulse 1s ease-in-out infinite}
.listen svg{width:38px;height:38px}
@keyframes pulse{50%{transform:scale(1.07)}}
.toast{position:fixed;left:50%;bottom:calc(env(safe-area-inset-bottom,0px) + 110px);transform:translateX(-50%);background:var(--ink);color:var(--panel);padding:8px 16px;border-radius:14px;font-size:.95rem;max-width:88vw;text-align:center;opacity:0;pointer-events:none;transition:opacity .25s;z-index:10}
.toast.show{opacity:1}
@media (prefers-reduced-motion: reduce){.book.turn-next,.book.turn-prev,.listen.playing{animation:none}.cover,.dots li,.w{transition:none}}
.pic svg{display:block;width:100%;height:auto;max-height:56svh;border-radius:22px}
.pic.pcover svg{max-height:62svh}
.cover-art svg[preserveAspectRatio]{aspect-ratio:4/3}
.card .wsvg{display:block;width:100%;max-width:120px;aspect-ratio:1;border-radius:18px;overflow:hidden;background:#fff;margin-bottom:4px}
.card .wsvg svg{width:100%;height:100%;display:block}

/* picture-book series */
.shelf.series{box-shadow:inset 0 0 0 4px #BFE3A8}
.lvtag{font-size:.9rem;font-weight:700;color:var(--muted)}
.cover-art img{display:block;width:100%;aspect-ratio:4/3;object-fit:cover}
.book.picture{background:var(--tint,#EAF6DF)}
.book.picture.story .text{flex:1;display:flex;flex-direction:column;justify-content:center}
.pic{padding:14px 14px 0}
.pic img{display:block;width:100%;height:auto;max-height:56svh;object-fit:cover;object-position:top;border-radius:22px}
.pic.pcover img{max-height:62svh;object-position:center top}
.book.picture .line{font-family:"Baloo Bhaijaan 2","Noto Naskh Arabic",sans-serif;font-weight:800;font-size:clamp(2.2rem,8.6vw,3.2rem);line-height:1.75;color:var(--pc,#2E7D32);
  --s:var(--ps,#fff);text-shadow:3px 0 var(--s),-3px 0 var(--s),0 3px var(--s),0 -3px var(--s),2px 2px var(--s),-2px -2px var(--s),2px -2px var(--s),-2px 2px var(--s),0 6px 0 rgba(0,0,0,.12)}
.book.picture.cover .line{font-size:clamp(1.8rem,6.6vw,2.6rem);color:#2E7D32;--s:#fff}
.book.picture.end .line{color:#E07A28}
.book.picture .gloss{color:#3D5A2E}
.card .wimg{width:100%;max-width:120px;aspect-ratio:1;object-fit:cover;border-radius:18px;margin-bottom:4px}

/* new-words page */
.wordswrap{display:flex;flex-direction:column;align-items:center;padding:10px 14px 18px;gap:4px}
.wordswrap .text{padding-bottom:0}
.book.picture.words .line{color:#C2185B;font-size:clamp(2rem,7.4vw,2.8rem)}
.wsub{margin:-6px 0 6px;font-weight:800;color:var(--muted);font-size:1.1rem}
.wordsgrid{width:100%;display:grid;grid-template-columns:repeat(auto-fill,minmax(150px,1fr));gap:12px}
.wcard{border:0;background:#fff;border-radius:22px;padding:10px 8px 10px;cursor:pointer;display:flex;flex-direction:column;align-items:center;box-shadow:0 4px 0 rgba(29,42,68,.1);color:#1D2A44}
.wcard .wpic{display:block;width:100%;max-width:120px;aspect-ratio:1}
.wcard .wpic svg{width:100%;height:100%;display:block}
.wcard .ar{font-family:"Baloo Bhaijaan 2","Noto Naskh Arabic",sans-serif;font-weight:800;font-size:1.6rem;line-height:1.6;color:#1D4FA8}
.wcard .wen{font-weight:700;font-size:1.05rem;color:#52607D;margin-top:-4px;text-align:center}
.wcard.on{background:var(--hl)}
.book.picture[data-level="2"].story .line{font-size:clamp(1.7rem,6.4vw,2.5rem);line-height:1.8}

.brand .wm{font-family:"Baloo 2","Baloo Bhaijaan 2",system-ui,sans-serif;font-weight:800;letter-spacing:-.01em}
.brand .wm b{font-weight:800;color:#D6336C}
@media (prefers-color-scheme: dark){.brand .wm b{color:#FF8FB1}}

/* the small gap inside زَ يْنَة; make the width bigger or smaller to taste */
.line i,.cover-title i,.ar i,.sname i,.wcard .ar i{display:inline-block;width:.14em}
