/* לימוד בינה – one stylesheet for every page. Material 3–style tokens, RTL-first, light + dark. */
:root {
  color-scheme: light dark;
  --primary: #3d5afe; --on-primary: #fff; --primary-container: #e6e9ff; --on-primary-container: #0b1a6b;
  --bg: #f7f8fc; --surface: #fff; --surface-2: #f0f2fa; --fg: #191c24; --muted: #5d6170; --line: #e1e4ee;
  --ok: #157a3e; --ok-container: #dcf5e4; --bad: #c62828; --bad-container: #fde7e7; --warn: #8a5a00;
  --accent: var(--primary); --card: var(--surface);
  --radius: 20px; --radius-sm: 12px;
  --shadow: 0 1px 2px rgb(16 24 64 / .06), 0 4px 16px rgb(16 24 64 / .06);
  --shadow-hover: 0 2px 4px rgb(16 24 64 / .08), 0 10px 28px rgb(16 24 64 / .10);
  --font: "Heebo", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
}
/* dark: the device setting, unless the page toggle forced light; or the toggle forced dark */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --primary: #b4bfff; --on-primary: #0b1a6b; --primary-container: #26337a; --on-primary-container: #e0e4ff;
    --bg: #0f1117; --surface: #181b23; --surface-2: #1f232d; --fg: #e6e8ef; --muted: #a2a7b6; --line: #2b303c;
    --ok: #6ee7a0; --ok-container: #143823; --bad: #ff8a80; --bad-container: #3d1616; --warn: #ffd166;
    --shadow: 0 1px 2px rgb(0 0 0 / .4); --shadow-hover: 0 4px 18px rgb(0 0 0 / .45);
  }
}
:root[data-theme="dark"] {
    --primary: #b4bfff; --on-primary: #0b1a6b; --primary-container: #26337a; --on-primary-container: #e0e4ff;
    --bg: #0f1117; --surface: #181b23; --surface-2: #1f232d; --fg: #e6e8ef; --muted: #a2a7b6; --line: #2b303c;
    --ok: #6ee7a0; --ok-container: #143823; --bad: #ff8a80; --bad-container: #3d1616; --warn: #ffd166;
    --shadow: 0 1px 2px rgb(0 0 0 / .4); --shadow-hover: 0 4px 18px rgb(0 0 0 / .45);
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 400 18px/1.75 var(--font); -webkit-font-smoothing: antialiased; }
main { max-width: 760px; margin: 0 auto; padding: 28px 20px 96px; }
a { color: var(--primary); text-underline-offset: 3px; }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; border-radius: 8px; }
@media (prefers-reduced-motion: no-preference) { a, button, .q label, .day, summary { transition: background-color .15s, border-color .15s, box-shadow .2s, translate .2s, color .15s; } }

/* type */
h1 { font-size: clamp(28px, 5vw, 38px); line-height: 1.2; font-weight: 800; letter-spacing: -.01em; margin: .25em 0 .4em; }
h2 { font-size: 23px; line-height: 1.35; font-weight: 700; margin: 2em 0 .5em; }
.lead { color: var(--muted); font-size: 19px; }
.muted, .hint { color: var(--muted); font-size: 15px; }
.tag { display: inline-block; background: var(--primary-container); color: var(--on-primary-container); font-weight: 600; font-size: 14px; padding: 4px 12px; border-radius: 999px; }
.home { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 14px; margin-bottom: 14px; border-radius: 999px; color: var(--muted); text-decoration: none; font-size: 15px; background: var(--surface); box-shadow: var(--shadow); }
.home:hover { color: var(--primary); }
hr { border: 0; border-top: 1px solid var(--line); margin: 3em 0 2em; }

/* surfaces */
.box { background: var(--primary-container); color: var(--on-primary-container); border-radius: var(--radius); padding: 18px 22px; margin: 1.4em 0; }
.box b { color: inherit; font-weight: 700; }
.card { background: var(--surface); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; font-size: 16px; margin: 1em 0; }
th, td { border-bottom: 1px solid var(--line); padding: 10px 8px; text-align: start; vertical-align: top; }
th { color: var(--muted); font-weight: 600; }

/* controls (48px targets) */
button { font: 600 16px/1 var(--font); min-height: 48px; padding: 0 26px; border: 0; border-radius: 999px; background: var(--primary); color: var(--on-primary); cursor: pointer; box-shadow: var(--shadow); }
button:hover:not(:disabled) { box-shadow: var(--shadow-hover); translate: 0 -1px; }
button:disabled { opacity: .38; cursor: not-allowed; box-shadow: none; }
button.ok { background: var(--ok-container); color: var(--ok); } button.bad { background: var(--bad-container); color: var(--bad); }
button.small, td button { min-height: 36px; padding: 0 14px; font-size: 14px; box-shadow: none; }
textarea, select { width: 100%; font: 400 16px/1.6 var(--font); background: var(--surface); color: var(--fg); border: 1.5px solid var(--line); border-radius: var(--radius-sm); padding: 12px 14px; margin: 6px 0 12px; }
select { width: auto; min-height: 40px; padding: 6px 12px; margin: 0; }
textarea:focus, select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 25%, transparent); }
label { font-weight: 500; }

/* lesson: experiment + quiz */
#expBox { background: var(--surface); color: var(--fg); box-shadow: var(--shadow); }
#expBox label { display: block; margin-top: 10px; }
.q { background: var(--surface); border: 2px solid transparent; border-radius: var(--radius); padding: 18px 20px; margin: 14px 0; box-shadow: var(--shadow); }
.q p { margin: 0 0 10px; font-weight: 700; }
.q label { display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 8px 14px; margin: 4px 0; border: 1.5px solid var(--line); border-radius: var(--radius-sm); cursor: pointer; font-weight: 400; }
.q label:hover { background: var(--surface-2); }
.q label:has(input:checked) { border-color: var(--primary); background: var(--primary-container); color: var(--on-primary-container); }
.q input { accent-color: var(--primary); width: 20px; height: 20px; margin: 0; flex: none; }
.q.right { border-color: var(--ok); } .q.wrong { border-color: var(--bad); }
.why { display: none; font-size: 15px; color: var(--muted); margin-top: 10px; padding: 10px 14px; background: var(--surface-2); border-radius: var(--radius-sm); }
.q.right .why, .q.wrong .why { display: block; }
#result { font-size: 22px; font-weight: 800; margin-top: 18px; }
#share { margin-top: 24px; padding: 22px; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); text-align: center; }
#finishBtn { min-width: 220px; min-height: 56px; font-size: 18px; }
.ask { margin: 8px 0 28px; }
.ask summary { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 14px; border-radius: 999px; cursor: pointer; color: var(--primary); font-size: 15px; font-weight: 600; list-style: none; }
.ask summary::before { content: "?"; display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--primary-container); color: var(--on-primary-container); font-size: 13px; }
.ask summary::-webkit-details-marker { display: none; }
.ask summary:hover { background: var(--primary-container); }
.ask[open] { background: var(--surface); border-radius: var(--radius); padding: 10px 16px 14px; box-shadow: var(--shadow); }
.ask button { min-height: 40px; }

/* home: lesson list */
.day { display: flex; gap: 16px; align-items: center; background: var(--surface); border-radius: var(--radius); padding: 16px 20px; margin: 12px 0; color: inherit; text-decoration: none; box-shadow: var(--shadow); min-height: 72px; }
a.day:hover { box-shadow: var(--shadow-hover); translate: 0 -2px; }
.num { display: grid; place-items: center; flex: none; width: 48px; height: 48px; border-radius: 14px; background: var(--primary-container); color: var(--on-primary-container); font-weight: 800; font-size: 14px; text-align: center; line-height: 1.1; }
.t { flex: 1; font-weight: 500; }
.done { background: var(--ok-container); color: var(--ok); font-weight: 700; font-size: 14px; padding: 4px 12px; border-radius: 999px; white-space: nowrap; }
.locked { opacity: .55; cursor: not-allowed; box-shadow: none; background: var(--surface-2); }
.lock { font-size: 18px; }
.need { background: var(--primary-container); color: var(--on-primary-container); border-radius: var(--radius); padding: 14px 18px; }

/* login */
.login { max-width: 440px; margin: 12vh auto 0; padding: 36px 28px; background: var(--surface); border-radius: 28px; box-shadow: var(--shadow-hover); text-align: center; }
.login .logo { font-size: 48px; line-height: 1; }
#btn { display: flex; justify-content: center; margin: 26px 0 8px; min-height: 44px; }

/* admin */
.admin main { max-width: 1160px; }
nav.tabs { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 8px 0 20px; }
nav.tabs a { display: inline-flex; align-items: center; min-height: 40px; padding: 0 16px; border-radius: 999px; text-decoration: none; color: var(--fg); background: var(--surface); box-shadow: var(--shadow); font-weight: 500; }
nav.tabs a.on { background: var(--primary); color: var(--on-primary); }
nav.tabs select { margin-inline-start: auto; }
.badge { background: var(--bad); color: #fff; border-radius: 999px; padding: 0 7px; font-size: 12px; margin-inline-start: 6px; line-height: 18px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; margin: 10px 0 22px; }
.cards .card b { display: block; font-size: 28px; font-weight: 800; line-height: 1.3; }
.cards .card span { color: var(--muted); font-size: 14px; }
.wrap { overflow-x: auto; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 22px; }
.wrap table { margin: 0; font-size: 15px; }
.wrap th { position: sticky; top: 0; background: var(--surface); white-space: nowrap; }
tr.click { cursor: pointer; } tr.click:hover td { background: var(--surface-2); }
.pass { color: var(--ok); font-weight: 700; } .fail { color: var(--bad); font-weight: 700; } .warn { color: var(--warn); font-weight: 600; }
.bar { height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden; min-width: 80px; display: inline-block; width: 90px; vertical-align: middle; margin-inline-end: 6px; }
.bar i { display: block; height: 100%; background: var(--ok); border-radius: 4px; }
.text { white-space: pre-wrap; max-width: 420px; font-size: 14px; }

@media (max-width: 520px) { body { font-size: 17px; } main { padding: 18px 16px 80px; } .q { padding: 14px; } .box { padding: 14px 16px; } }

/* theme toggle (theme.js) – floating, bottom corner */
.theme-toggle { position: fixed; bottom: 18px; inset-inline-end: 18px; z-index: 10; width: 48px; min-height: 48px; padding: 0; font-size: 20px; background: var(--surface); color: var(--fg); box-shadow: var(--shadow-hover); }
@media print { .theme-toggle { display: none; } }

/* scroll effects – pure CSS scroll-driven animations; browsers without support (or reduced motion) just show everything */
@keyframes fog-in { from { opacity: 0; filter: blur(12px); transform: translateY(28px); } to { opacity: 1; filter: none; transform: none; } }
@keyframes cube-flat { from { opacity: .2; transform: perspective(900px) rotateX(58deg) rotateZ(-4deg) translateY(48px) scale(.9); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: no-preference) {
  @supports (animation-timeline: view()) {
    body:not(.admin) main > :is(p, h2, ul, ol, table), body:not(.admin) :is(.q, .day, .ask, #share, #expBox) {
      animation: fog-in linear both; animation-timeline: view(); animation-range: entry 0% entry 70%;
    }
    /* the summary "cubes" at the end of sections tilt in 3D and land flat */
    body:not(.admin) .box:not(#expBox) {
      transform-origin: 50% 100%;
      animation: cube-flat linear both; animation-timeline: view(); animation-range: entry 0% cover 40%;
    }
  }
}

/* lesson listen bar (theme.js) */
.listen { position: sticky; top: 10px; z-index: 5; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 12px 0 22px; padding: 8px; background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-radius: 999px; box-shadow: var(--shadow); width: 100%; }
.listen .play { min-width: 150px; }
.listen input[type=range] { flex: 1; min-width: 120px; accent-color: var(--primary); }
.listen ~ * .w { cursor: pointer; }
.listen ~ * .w:hover { text-decoration: underline dotted; text-underline-offset: 4px; }
.w.word-now { background: color-mix(in srgb, var(--primary) 28%, transparent); border-radius: 4px; box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 28%, transparent); }
.listen .time { font-variant-numeric: tabular-nums; white-space: nowrap; }
.speaking { background: var(--primary-container) !important; color: var(--on-primary-container); border-radius: var(--radius-sm); box-shadow: 0 0 0 8px var(--primary-container); }


/* home page: two versions of one day; admin: group version picker */
.day:has(.pick) { flex-wrap: wrap; }
.day .pick { display: flex; gap: 8px; flex-wrap: wrap; flex-basis: 100%; order: 9; padding-inline-start: 56px; }
.day .pick a { padding: 6px 14px; border-radius: 999px; background: var(--primary-container); color: var(--on-primary-container); text-decoration: none; font-weight: 600; font-size: 15px; }
.day .pick a.kids, .day .pick .kids { background: #ffe1ee; color: #8a1450; }
.day .pick .off { padding: 6px 14px; border-radius: 999px; font-size: 15px; opacity: .55; }
.kinds label { margin-inline-end: 14px; }

/* ===== kids lessons ===== */
body.kids { --primary: #e8407a; --primary-container: #ffe1ee; --on-primary-container: #6d0f3c; --radius: 28px; font-size: 20px;
  background: radial-gradient(circle at 10% 0%, color-mix(in srgb, #ffd166 22%, var(--bg)), transparent 40%),
              radial-gradient(circle at 90% 20%, color-mix(in srgb, #7bdff2 22%, var(--bg)), transparent 40%), var(--bg); background-attachment: fixed; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) body.kids { --primary: #ff8fb5; --primary-container: #5a1834; --on-primary-container: #ffe1ee; } }
:root[data-theme="dark"] body.kids { --primary: #ff8fb5; --primary-container: #5a1834; --on-primary-container: #ffe1ee; }
body.kids h1 { color: var(--primary); }
body.kids h2 { display: inline-block; padding: 6px 18px; border-radius: 999px; background: var(--primary-container); color: var(--on-primary-container); font-size: 24px; }
body.kids .tag { background: linear-gradient(90deg, #ffd166, #ff8fb5, #7bdff2); color: #3a1030; }
body.kids .box.fun { background: color-mix(in srgb, #ffd166 25%, var(--surface)); border: 3px dashed #f4b400; }
body.kids .box.warn { background: color-mix(in srgb, #7bdff2 22%, var(--surface)); border: 3px solid #29a8c4; }
body.kids .q label { font-size: 19px; }
.mascot { color: var(--fg); width: 120px; margin: 4px auto -8px; }
.mascot .head { fill: var(--primary-container); stroke: currentColor; stroke-width: 4; }
.mascot .ear { fill: #7bdff2; stroke: currentColor; stroke-width: 3; }
.mascot .eyes circle { fill: currentColor; transform-box: fill-box; transform-origin: center; }
.mascot .bulb { fill: #ffd166; stroke: currentColor; stroke-width: 3; }
.cards2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin: 16px 0; }
.kcard { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px; padding: 18px; border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.kcard .big { font-size: 56px; line-height: 1.1; }
.game { margin: 18px 0; padding: 18px; border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); border: 3px solid var(--primary-container); }
.game-q { margin: 0 0 10px; font-weight: 600; }
.game-o { display: flex; flex-wrap: wrap; gap: 10px; }
.game-o button { font-size: 20px; padding: 10px 22px; border-radius: 999px; }
.game-o button.yes { background: var(--ok); color: #fff; }
.game-o button.no { background: var(--bad-container); color: var(--bad); }
.confetti { position: fixed; top: -40px; font-size: 28px; pointer-events: none; z-index: 50; animation: fall 3s ease-in forwards; }
@keyframes fall { to { translate: 0 110vh; rotate: 540deg; } }
@media (prefers-reduced-motion: no-preference) {
  .mascot svg { animation: float 3s ease-in-out infinite; }
  .mascot .eyes circle { animation: blink 4s infinite; }
  .mascot .bulb { animation: glow 1.6s ease-in-out infinite; }
  .kcard .big, body.kids h2 { animation: bob 2.6s ease-in-out infinite; }
  .game-o button.no { animation: shake .4s; }
  .game-o button.yes { animation: pop .4s; }
}
@keyframes float { 50% { translate: 0 -10px; } }
@keyframes blink { 0%, 92%, 100% { scale: 1 1; } 95% { scale: 1 .1; } }
@keyframes glow { 50% { fill: #ff8fb5; } }
@keyframes bob { 50% { translate: 0 -4px; } }
@keyframes shake { 25% { translate: -6px 0; } 75% { translate: 6px 0; } }
@keyframes pop { 50% { scale: 1.15; } }

/* learner switcher + family page */
.who { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; justify-content: center; padding: 8px 16px; background: var(--primary-container); color: var(--on-primary-container); font-size: 16px; }
.who select { font: inherit; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line); }
.who a { color: inherit; font-weight: 600; }
.fam { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; background: var(--surface); border-radius: var(--radius); padding: 14px 18px; margin: 12px 0; box-shadow: var(--shadow); }
.fam input { flex: 1; min-width: 140px; font: inherit; padding: 8px 12px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface-2); color: inherit; }
.fam .reach { font-weight: 600; color: var(--primary); }

.links { text-align: center; margin-top: 28px; font-weight: 600; }

/* home: track switch (groups that see both courses) */
.track { display: flex; gap: 6px; padding: 4px; margin: 8px 0 14px; background: var(--surface-2); border-radius: 999px; }
.track button { flex: 1; border-radius: 999px; background: transparent; color: var(--fg); box-shadow: none; }
.track button[aria-selected="true"] { background: var(--primary); color: var(--on-primary); }
.kidtopic .pick { flex-direction: column; align-items: flex-start; }
