/* ===== design 2: paper-cut classroom. Sources: frontend-design (one memorable moment, deliberate type, non-default palette),
   improve-animations / interaction-design (motion answers actions; 150-300 ms; ease-out; reduced motion), better-ui (layered depth, hover only on hover pointers) ===== */
:root,:root[data-theme=light]{
  --ink:#0f1b4d;--teal:#12308f;--bg:#eef2ff;--bg2:#dfe7ff;--paper:#ffffff;--line:#0f1b4d;--muted:#46527f;
  --hue:#ff5c7a;--hue-soft:#ffd0d9;--blue:#3a86ff;--yellow:#ffd23f;--mint:#19c3a6;
  --ease:cubic-bezier(.2,.8,.2,1);--spring:cubic-bezier(.34,1.56,.64,1);
  --shadow-hard:10px 10px 0 var(--hue);
}
:root[data-theme=dark]{
  --ink:#f3f6ff;--teal:#ffd23f;--bg:#0b1230;--bg2:#101a45;--paper:#17214f;--line:#f3f6ff;--muted:#aab6e6;
  --hue-soft:#1b2a66;
}
body[data-step="0"]{--hue:#ff5c7a;--hue-soft:#ffd0d9}
body[data-step="1"]{--hue:#3a86ff;--hue-soft:#cfe0ff}
body[data-step="2"]{--hue:#19c3a6;--hue-soft:#c4f3ea}
body[data-step="3"]{--hue:#8b5cf6;--hue-soft:#e0d5ff}
body[data-step="4"]{--hue:#ff8a3d;--hue-soft:#ffe0c8}
body[data-step="5"]{--hue:#22c55e;--hue-soft:#ccf5d8}
body[data-step="6"]{--hue:#ffc21a;--hue-soft:#fff0b8}
:root[data-theme=dark] body[data-step]{--hue-soft:#1b2a66}
html,body{background:var(--bg2);color:var(--ink);transition:background .3s}
body{font-family:'Rubik','Noto Sans Hebrew','Heebo',Arial,sans-serif}
#app{background:var(--bg);transition:background .3s}
#app::before{content:"";position:absolute;right:-260px;top:-300px;width:900px;height:900px;border-radius:50%;background:var(--hue-soft);opacity:.9;transition:background .4s}
#app::after{content:"";position:absolute;left:-200px;bottom:-320px;width:760px;height:760px;border-radius:50%;background:var(--bg2);opacity:.9}
#stage,#ctl,#rail,#railTab,#bFull,#bTheme,#proto,#confetti{z-index:2}
/* type */
.en,.big,.ychip,.hero-sub,#rail h1{font-family:'Fredoka','Rubik',sans-serif;font-weight:700}
.en{color:var(--ink);letter-spacing:-.5px}
.en.c0,.en.c1,.en.c2,.en.c3,.en.c4,.en.c5{color:var(--ink)}
.he{font-weight:600;color:var(--muted)}
.hint{color:var(--muted);font-weight:500}
.en b,.ychip{background:var(--blue);color:#fff;border-radius:16px;box-shadow:4px 4px 0 var(--ink);font-family:'Fredoka',sans-serif}
.en b{padding:0 10px;margin-inline-end:6px;box-shadow:3px 3px 0 var(--ink)}
.ychip{padding:0 22px;box-shadow:5px 5px 0 var(--ink)}
.w.n1{color:#ff5c7a}.w.n2{color:#8b5cf6}.w.n3{color:#12a37f}.w.n4{color:#ff8a3d}
:root[data-theme=dark] .w.n3{color:#5eead4}:root[data-theme=dark] .w.n2{color:#c4b5fd}
.w.on{background:var(--yellow);color:#0f1b4d;box-shadow:0 0 0 5px var(--yellow);border-radius:12px;transform:translateY(-3px) rotate(-1deg)}
.en.ans{color:#12a37f}:root[data-theme=dark] .en.ans{color:#5eead4}
/* paper pieces: pictures and panels */
.t{background:var(--paper);border:5px solid var(--line);border-radius:38px;box-shadow:var(--shadow-hard),0 24px 40px rgba(15,27,77,.18);transition:transform .25s var(--ease),box-shadow .25s var(--ease)}
.t img{outline:0;border-radius:0}
.lbl{background:var(--ink);color:var(--bg);font-family:'Rubik',sans-serif}
.pic{cursor:pointer}
@media (hover:hover){.pic:hover{transform:translate(-4px,-4px);box-shadow:14px 14px 0 var(--hue),0 28px 46px rgba(15,27,77,.2)}}
.pic:active{transform:translate(6px,6px);box-shadow:3px 3px 0 var(--hue),0 6px 10px rgba(15,27,77,.2);transition-duration:.08s}
.pic.playing{animation:none;box-shadow:var(--shadow-hard),0 0 0 8px rgba(255,210,63,.9)}
.pic::after{background-color:var(--ink);border:3px solid var(--bg);box-shadow:3px 3px 0 var(--hue)}
.tilt{transform:rotate(-2.2deg)}
@media (hover:hover){.tilt.pic:hover{transform:rotate(-1deg) translate(-4px,-4px)}}
/* dock */
#ctl{bottom:30px}
.btn{width:150px;height:112px;background:var(--paper);color:var(--ink);border:4px solid var(--line);border-radius:30px;font-family:'Rubik',sans-serif;font-size:22px;font-weight:700;box-shadow:0 8px 0 var(--line);transition:transform .15s var(--ease),box-shadow .15s var(--ease),background .2s}
.btn.main{width:210px;background:var(--yellow);color:#0f1b4d;border-color:#0f1b4d;box-shadow:0 8px 0 #0f1b4d}
:root[data-theme=dark] .btn{box-shadow:0 8px 0 #000}
:root[data-theme=dark] .btn.main{box-shadow:0 8px 0 #000}
@media (hover:hover){.btn:hover{transform:translateY(-3px);box-shadow:0 11px 0 var(--line)}.btn.main:hover{box-shadow:0 11px 0 #0f1b4d}}
.btn:active,.btn.main:active{transform:translateY(7px);box-shadow:0 1px 0 var(--line);transition-duration:.06s}
.btns{gap:20px}
.opt,.sp{font-family:'Rubik',sans-serif;font-weight:700;background:var(--paper);color:var(--ink);border:3px solid var(--line);box-shadow:0 5px 0 var(--line);border-radius:20px;min-height:62px;transition:transform .15s var(--ease),box-shadow .15s var(--ease)}
.opt.on,.sp.on{background:var(--yellow);color:#0f1b4d}
.opt:active{transform:translateY(4px);box-shadow:0 1px 0 var(--line)}
.seg{border:3px solid var(--line);box-shadow:0 5px 0 var(--line);border-radius:20px;overflow:hidden}
.seg .sp{border:0;border-radius:0;box-shadow:none;border-inline-start:3px solid var(--line);min-height:56px}
.seg .sp:first-child{border-inline-start:0}
:root[data-theme=dark] .opt,:root[data-theme=dark] .seg{box-shadow:0 5px 0 #000}
/* chrome */
.crumb{background:var(--ink);color:var(--bg);font-family:'Rubik',sans-serif;box-shadow:3px 3px 0 var(--hue);top:20px;right:30px;font-size:21px}
.pbar{height:10px;background:transparent}
.pbar i{background:var(--hue);border-radius:0 6px 6px 0;transition:width .45s var(--ease),background .4s}
#proto{background:var(--yellow);color:#0f1b4d;border:2px solid #0f1b4d;left:150px;top:24px}
#bFull,#bTheme{position:absolute;top:18px;width:54px;height:54px;border-radius:18px;background:var(--paper);color:var(--ink);border:3px solid var(--line);box-shadow:3px 3px 0 var(--hue);display:flex;align-items:center;justify-content:center;cursor:pointer;transition:transform .15s var(--ease)}
#bFull{left:18px}#bTheme{left:84px}
@media (hover:hover){#bFull:hover,#bTheme:hover{transform:translate(-2px,-2px)}}
#bTheme:active,#bFull:active{transform:translate(3px,3px);box-shadow:0 0 0 var(--hue)}
#bTheme .sun{display:none}:root[data-theme=dark] #bTheme .sun{display:inline}:root[data-theme=dark] #bTheme .moon{display:none}
#proto{left:152px}
#rail{background:var(--ink);color:var(--bg);box-shadow:-18px 0 50px rgba(0,0,0,.35)}
#rail h1{color:var(--bg)}
.rs{background:rgba(255,255,255,.08);color:var(--bg);font-family:'Rubik',sans-serif;border:2px solid transparent}
:root[data-theme=dark] .rs{color:#f3f6ff;background:rgba(255,255,255,.07)}
.rs i{background:var(--hue);color:#0f1b4d;font-family:'Fredoka',sans-serif;box-shadow:none}
.rs.on{background:var(--yellow);color:#0f1b4d;border-color:#0f1b4d}
#railTab{background:var(--ink);color:var(--bg);border-radius:24px 0 0 24px;box-shadow:-4px 4px 0 var(--hue)}
/* opening hero */
.hero-yo{position:absolute;left:800px;top:-20px;width:200px;height:700px;pointer-events:none;z-index:1}
.hero-yo .yo-ball{animation:yo 2.4s cubic-bezier(.45,0,.2,1) infinite}
.hero-yo .yo-str{animation:str 2.4s cubic-bezier(.45,0,.2,1) infinite;transform-origin:100px 0}
@keyframes yo{0%,100%{transform:translateY(-250px)}50%{transform:translateY(0)}}
@keyframes str{0%,100%{transform:scaleY(.52)}50%{transform:scaleY(1)}}
.heroY{font-size:420px;line-height:.9;color:var(--hue);-webkit-text-stroke:8px var(--ink);paint-order:stroke fill;text-shadow:14px 14px 0 var(--ink);margin-top:150px;font-family:'Fredoka',sans-serif;font-weight:700;letter-spacing:-6px}
.hero-sub{font-size:58px;margin-top:24px;color:var(--ink);font-family:'Rubik',sans-serif;font-weight:800;line-height:1.5}
.hero-type{left:900px!important}
/* entrance: pieces land, one orchestrated move (improve-animations: ease-out, 450 ms) */
@keyframes land{from{opacity:0;transform:translateY(28px) rotate(1.5deg)}to{opacity:1;transform:none}}
#stage.enter>*:not(.crumb):not(.pbar){animation:land .5s var(--ease) both}
#stage.enter>.tilt{animation-name:landT}
@keyframes landT{from{opacity:0;transform:translateY(28px) rotate(2deg)}to{opacity:1;transform:rotate(-2.2deg)}}
@media (prefers-reduced-motion:reduce){.hero-yo .yo-ball,.hero-yo .yo-str{animation:none}.hero-yo .yo-ball{transform:translateY(-120px)}}
/* glyphs: Fredoka contours overlap, so use hard shadow instead of outline stroke */
.big,.heroY{-webkit-text-stroke:0!important;text-shadow:10px 10px 0 var(--ink)!important}
.heroY{color:var(--hue);text-shadow:14px 14px 0 var(--ink)!important}
.big[style*="color:#ff6b6b"]{color:#ff5c7a!important}
.big[style*="color:#3a86ff"]{color:#3a86ff!important}
.t.pic.wordpic img{object-fit:cover!important}
/* badge: fixed navy disc with white icon in both themes */
.pic::after{background-color:#0f1b4d!important;border:3px solid #fff!important;box-shadow:3px 3px 0 var(--hue)!important}
.pic.playing::after{background-color:#12a37f!important}
.w.on,.w.on.n1,.w.on.n2,.w.on.n3,.w.on.n4,:root[data-theme=dark] .w.on.n2,:root[data-theme=dark] .w.on.n3{color:#0f1b4d!important}
/* marker: no color/background fade (dark text must never sit on a dark canvas mid-fade) */
.w{transition:transform .12s var(--ease)!important}
.w.on{background:#ffd23f!important}
/* opening: explicit vertical stack so the giant Yy never touches the heading */
.heroY{font-size:360px!important;line-height:1!important;height:400px;margin-top:20px!important;letter-spacing:-4px}
.hero-sub{margin-top:56px!important;position:relative}
.hero-type .hint{margin-top:18px!important}
@keyframes yo{0%,100%{transform:translateY(-340px)}50%{transform:translateY(-160px)}}
@keyframes str{0%,100%{transform:scaleY(.35)}50%{transform:scaleY(.69)}}
.heroY{margin-top:10px!important}
.hero-sub{margin-top:76px!important}

#app{transition:transform .28s var(--ease),left .28s var(--ease),background .3s}
#rail{transform:translateX(105%)!important;opacity:0;transition:opacity .2s,transform 0s .28s}
#rail.open{transform:translateX(100%)!important;opacity:1;transition:opacity .2s .08s;box-shadow:none!important}
.railopen #app{overflow:visible}
#clock{-webkit-text-stroke:0!important;text-shadow:none!important;paint-order:normal!important;font-variant-numeric:tabular-nums;direction:ltr;letter-spacing:2px;color:#0f1b4d!important;line-height:1.05}

/* ===== mobile (portrait / narrow): body.mob, design frame 1100 px wide, scaled to the screen ===== */
body.mob{overflow:hidden;touch-action:manipulation}
body.mob #app{overflow:hidden}
body.mob #app::before{width:700px;height:700px;right:-250px;top:-250px}
body.mob #stage{position:absolute;top:130px;left:0;width:1100px;height:auto;bottom:370px;overflow-y:auto;overflow-x:hidden;display:flex;flex-direction:column;align-items:center;gap:34px;padding:10px 50px 40px;-webkit-overflow-scrolling:touch}
body.mob #stage>*{position:relative!important;left:auto!important;top:auto!important;right:auto!important;bottom:auto!important;width:100%!important;max-width:1000px;margin:0!important;flex:none}
body.mob #stage>.crumb{position:absolute!important;top:-112px!important;right:34px!important;width:auto!important;font-size:34px;padding:8px 24px}
body.mob #stage>.pbar{display:none}
body.mob .hero-yo{display:none}
body.mob .t.pic,body.mob .t{height:auto!important;aspect-ratio:4/3}
body.mob .t:has(svg.wr){aspect-ratio:auto;height:900px!important}
body.mob .t:has(#clock){aspect-ratio:auto}
body.mob .hero-type{text-align:center!important}
body.mob #stage .big{max-width:100%}
body.mob #ctl{position:absolute;left:30px;right:30px;bottom:26px;display:flex;flex-direction:column;gap:22px;align-items:stretch}
body.mob .pill{flex-wrap:wrap;justify-content:center;gap:16px}
body.mob .opt{font-size:38px;padding:18px 32px;border-radius:30px}
body.mob .seg{display:inline-flex}
body.mob .seg button{font-size:36px;padding:16px 26px}
body.mob .btns{width:100%;gap:16px}
body.mob .btn,body.mob .btn.main{flex:1;width:auto;height:170px;font-size:34px;border-radius:36px}
body.mob .btn.main{flex:1.25}
body.mob .btn .ic{width:60px;height:60px}
body.mob #bFull,body.mob #bTheme{top:22px;width:104px;height:104px;border-radius:30px}
body.mob #bFull{left:24px}body.mob #bTheme{left:152px}
body.mob #bFull svg,body.mob #bTheme svg{width:56px;height:56px}
body.mob #proto{left:290px;top:44px;font-size:34px;padding:6px 20px}
body.mob #railTab{width:96px;height:200px;top:48%}
body.mob #rail{width:640px;padding:50px 34px;overflow-y:auto;z-index:30}
body.mob #rail.open{transform:none!important;box-shadow:-30px 0 80px rgba(0,0,0,.45)!important}
body.mob #rail h1{font-size:60px}body.mob #rail p{font-size:38px}
body.mob .rs{height:150px;font-size:50px;margin-bottom:22px;border-radius:34px}
body.mob .rs i{width:90px;height:90px;font-size:48px;border-radius:26px}
body.mob .rs small{font-size:34px}

body.mob .t.pic{aspect-ratio:1/1;max-width:880px;align-self:center}
body.mob .t.pic.wordpic{aspect-ratio:1/1}
body.mob #stage{justify-content:safe center}
body.mob #stage>.crumb{position:relative!important;top:auto!important;right:auto!important;align-self:flex-end;order:-1;font-size:32px}
body.mob #stage>div[style*="display:flex"]{flex-direction:column!important;align-items:center}
body.mob #stage>div[style*="display:flex"]>.t.pic{width:100%!important;max-width:760px}
body.mob #stage .hint{font-size:40px}
body.mob #stage .he{font-size:64px!important}
body.mob #stage>div:has(.q){flex-direction:row!important;flex-wrap:wrap!important;justify-content:center!important;gap:24px!important}
body.mob .t.q{aspect-ratio:auto!important;width:300px!important;height:480px!important}
body.mob #stage>div:has(.q)+.hint{text-align:center}
body.mob #stage>div[style*="display:flex"]>.t.pic{max-width:640px;aspect-ratio:auto;height:600px!important}
body.mob #stage div[style*="font-size:56px;line-height:1.45"]{font-size:76px!important}

.rhome{display:block;font-size:24px;font-weight:700;color:var(--bg);opacity:.85;text-decoration:none;margin-bottom:14px;font-family:'Rubik',sans-serif}
.rhome:hover{opacity:1;text-decoration:underline}
body.mob .rhome{font-size:44px;margin-bottom:26px}

/* menu: fixed dark panel with light text in both themes */
#rail{background:#0f1b4d!important;color:#f3f6ff!important}
#rail h1,#rail p,#rail .rhome{color:#f3f6ff!important}
#rail .rs{background:rgba(255,255,255,.09)!important;color:#f3f6ff!important;border:2px solid transparent}
#rail .rs small{color:#f3f6ff!important;opacity:.75}
#rail .rs i{background:#9b7bff!important;color:#0f1b4d!important}
#rail .rs.on{background:#ffd23f!important;color:#0f1b4d!important;border-color:#fff!important}
#rail .rs.on small{color:#0f1b4d!important}
#rail .rs.on i{background:#ff6b81!important;color:#0f1b4d!important}
/* phone landscape: bigger dock labels and options */
@media (max-height:520px) and (min-aspect-ratio:1/1){
 .btn{font-size:30px}.opt{font-size:32px;padding:16px 26px}.seg button{font-size:30px}.crumb{font-size:28px}
}

/* flanking previous / next buttons beside the picture; dock keeps replay + play */
#bPrev,#bNext{display:none!important}
.flank{position:absolute;z-index:30;width:104px;height:104px;border-radius:50%;background:var(--paper);color:var(--ink);border:4px solid var(--line);box-shadow:0 6px 0 var(--line);display:flex;align-items:center;justify-content:center;cursor:pointer;padding:0;transition:transform .15s,opacity .2s}
.flank .ic{width:46px;height:46px}
.flank:active{transform:translateY(5px);box-shadow:0 1px 0 var(--line)}
.flank:disabled{opacity:.25;pointer-events:none}
:root[data-theme=dark] .flank{background:#1b2a6b;color:#fff;border-color:#fff;box-shadow:0 6px 0 #000}
body.mob #stage>.flank{position:absolute!important;width:132px!important;height:132px!important;max-width:none}
body.mob .flank .ic{width:60px;height:60px}
body.mob #stage>.t.pic{max-width:840px!important}
/* menu tab must always be tappable: above the flank buttons, and lower than the picture on phones */
#railTab{z-index:60!important}
body.mob #railTab{top:68%!important}
body.mob #rail{z-index:70!important}
@media (max-height:520px) and (min-aspect-ratio:1/1){
 #rail{overflow-y:auto}
 #rail .rs{min-height:104px;font-size:38px}#rail .rs small{font-size:28px;opacity:.9}#rail .rs i{width:64px;height:64px;font-size:38px}
 #rail h1{font-size:46px}#rail p{font-size:30px}#rail .rhome{font-size:30px}
 .flank{width:124px;height:124px}.flank .ic{width:56px;height:56px}
}
@media (max-height:520px) and (min-aspect-ratio:1/1){
 #rail .rs{font-size:30px;gap:8px;padding-inline:12px}#rail .rs small{font-size:21px;white-space:nowrap}#rail .rs i{width:52px;height:52px;font-size:30px}
 #rail h1{font-size:36px}
}
/* phone portrait: hamburger as a round button in the top-right corner, never over the text */
body.mob #railTab{top:14px!important;right:14px!important;width:112px!important;height:112px!important;border-radius:50%!important;box-shadow:0 5px 0 var(--hue)}
body.mob #stage>.crumb{right:170px!important}
/* dedicated home button in every lesson */
#bHome{position:absolute;z-index:61;left:150px;top:18px;height:54px;padding:0 20px 0 16px;border-radius:18px;background:var(--yellow);color:#0f1b4d;border:3px solid #0f1b4d;box-shadow:3px 3px 0 var(--hue);display:flex;align-items:center;gap:10px;font-family:'Rubik',sans-serif;font-weight:800;font-size:24px;text-decoration:none;cursor:pointer}
#bHome:active{transform:translate(3px,3px);box-shadow:0 0 0 var(--hue)}
#bHome:focus-visible{outline:4px solid var(--blue);outline-offset:3px}
#proto{left:340px!important}
body.mob #bHome{left:280px;top:22px;height:104px;padding:0 28px 0 22px;border-radius:30px;font-size:38px;gap:12px}
body.mob #bHome svg{width:52px;height:52px}
body.mob #proto{display:none}
@media (max-height:520px) and (min-aspect-ratio:1/1){#bHome{font-size:30px;height:62px}#proto{left:380px!important}}
body.mob #railTab{transform:none!important}
body.mob #railTab.hide{display:none!important}
body.mob .crumb .ct{display:none}
body.mob #stage>.crumb{right:auto!important;left:575px!important;top:-100px!important;font-size:38px!important}
/* short phones: smaller picture so the whole translation fits above the controls */
@media (max-height:720px){body.mob #stage>.t.pic{max-width:540px!important}body.mob #stage{gap:24px}}

.oltile{width:280px;height:340px;border-radius:44px;display:flex;align-items:center;justify-content:center;font:700 300px/1 Fredoka,Rubik,sans-serif;color:#fff;box-shadow:12px 12px 0 var(--ink);padding-bottom:30px}

/* contrast pass: light-paper cards keep their own ink palette in both themes */
.t[style*="#fffbe6"],.t[style*="#fff7d6"]{--ink:#0f1b4d;--line:#0f1b4d;--teal:#9a3412;--muted:#3b4670;--bg:#eef2ff;--paper:#fff;--hue:#d6204a;color:#0f1b4d}
.t[style*="#fffbe6"] [style*="color:#ccc"],.t[style*="#fffbe6"] .big[style*="ccc"]{color:#6a759a!important}
.t[style*="#fffbe6"] [style*="color:#ff6b6b"],.t[style*="#fff7d6"] [style*="color:#ff6b6b"],.t[style*="#fff7d6"] [style*="color:#ff5c7a"]{color:#d6204a!important}
.t[style*="#fff7d6"] [style*="color:#3a86ff"],.t[style*="#fffbe6"] [style*="color:#3a86ff"]{color:#2563eb!important}
:root{--blue:#2563eb}
.big[style*="color:#3a86ff"]{color:#2563eb!important}
:root[data-theme=light] .w.n1{color:#d6204a}:root[data-theme=light] .w.n2{color:#6d28d9}:root[data-theme=light] .w.n3{color:#0f766e}:root[data-theme=light] .w.n4{color:#c2410c}
:root[data-theme=light] .hint{color:#3b4670}
