/* ===== רוחניות ללא הגדרות — app.css =====
   Semantic colour legend, used everywhere in the app:
     תיוג / הגדרה   = כתום  (--label)
     חוויה ישירה     = כחול  (--direct)
     תרגול / פעולה   = ירוק  (--practice)
   Every colour is a CSS variable so inline SVG stays legible in both themes. */

:root {
  --bg: #f5f6f4;
  --card: #ffffff;
  --text: #1f2430;
  --muted: #6c7382;
  --accent: #5b7a8c;
  --accent-soft: #e6edf1;
  --good: #3f8f63;
  --good-soft: #e4f2ea;
  --bad: #c9793a;
  --bad-soft: #fbeee2;
  --gold: #d9a730;
  --border: #dfe2df;
  --shadow: 0 2px 10px rgba(40, 50, 45, 0.07);

  /* semantic legend */
  --label:    #c2701c;   /* תיוג / הגדרה — כתום */
  --direct:   #2f6ea8;   /* חוויה ישירה — כחול */
  --practice: #2e7d52;   /* תרגול / פעולה — ירוק */
  --neutral:  #6c7382;
  --label-soft:    #fbeada;
  --direct-soft:   #dceaf7;
  --practice-soft: #dcf0e5;
  --neutral-soft:  #ececee;

  --radius: 18px;
}

[data-theme="dark"] {
  --bg: #14171a;
  --card: #1e2226;
  --text: #edeff0;
  --muted: #9aa2ad;
  --accent: #8fb0c2;
  --accent-soft: #253138;
  --good: #57bf87;
  --good-soft: #16311f;
  --bad: #e09a63;
  --bad-soft: #382718;
  --gold: #e0bd5c;
  --border: #333a40;
  --shadow: 0 2px 10px rgba(0, 0, 0, 0.4);

  --label:    #eda65c;
  --direct:   #79b3e6;
  --practice: #6fd39c;
  --neutral:  #9aa2ad;
  --label-soft:    #3d2c17;
  --direct-soft:   #1a2c3d;
  --practice-soft: #16311f;
  --neutral-soft:  #272c31;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html { font-size: 18px; }
@media (min-width: 700px) { html { font-size: 19px; } }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Assistant", "Arial Hebrew", Arial, sans-serif;
  line-height: 1.6;
  min-height: 100vh;
}

#screen {
  max-width: 640px;
  margin: 0 auto;
  padding: 12px 14px 90px;
  min-height: 100vh;
}

button { font-family: inherit; color: inherit; }

/* Latin (or any LTR) text islands inside the RTL page */
.ltr { direction: ltr; unicode-bidi: isolate; display: inline-block; font-weight: 600; }
.translit { color: var(--muted); font-size: 0.88rem; direction: rtl; }

/* ===== Buttons ===== */
.btn {
  display: block; width: 100%;
  min-height: 54px; padding: 12px 18px;
  border: none; border-radius: var(--radius);
  background: var(--accent); color: #fff;
  font-size: 1.1rem; font-weight: 700;
  cursor: pointer; box-shadow: var(--shadow);
  transition: transform 0.12s, filter 0.12s;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn-secondary { background: var(--card); color: var(--text); border: 2px solid var(--border); }
.btn-good { background: var(--good); }
.btn-row { display: flex; gap: 10px; margin-top: 12px; }
.btn-row .btn { margin-top: 0; }

/* ===== Cards ===== */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin: 12px 0;
}

/* ===== Home header ===== */
.home-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 2px; gap: 6px; }
.home-title { font-size: 1.2rem; font-weight: 800; }
.gear-btn { background: none; border: none; font-size: 1.5rem; cursor: pointer; min-width: 44px; min-height: 44px; }
.stats-row { display: flex; gap: 8px; margin: 4px 0 10px; }
.stat-chip {
  flex: 1; background: var(--card); border-radius: 14px;
  padding: 8px 6px; text-align: center; box-shadow: var(--shadow);
  font-size: 0.82rem; color: var(--muted);
}
.stat-chip b { display: block; font-size: 1.1rem; color: var(--text); }

.review-card { display: flex; align-items: center; gap: 12px; border: 2px solid var(--accent); }
.review-card .btn { width: auto; flex-shrink: 0; min-height: 48px; }
.review-emoji { font-size: 2rem; }

.banner {
  background: var(--bad-soft); border-radius: var(--radius);
  padding: 12px 16px; margin: 10px 0;
  display: flex; align-items: center; gap: 10px; font-size: 0.95rem;
}
.banner .btn { width: auto; min-height: 44px; font-size: 0.95rem; }

/* ===== Stage map ===== */
.stage-sec { margin: 18px 0; }
.stage-head {
  display: flex; align-items: center; gap: 10px;
  background: var(--card); border-radius: var(--radius);
  padding: 12px 16px; box-shadow: var(--shadow);
}
.stage-head.locked { opacity: 0.65; }
.stage-head h2 { font-size: 1.02rem; margin: 0; flex: 1; }
.stage-pct { font-size: 0.85rem; color: var(--muted); white-space: nowrap; }
.stage-bar { height: 8px; background: var(--border); border-radius: 4px; margin-top: 6px; overflow: hidden; }
.stage-bar > div { height: 100%; background: var(--good); border-radius: 4px; transition: width 0.4s; }

.unit-title { margin: 16px 4px 6px; font-size: 0.95rem; font-weight: 700; color: var(--muted); }
.node-path { display: flex; flex-wrap: wrap; gap: 6px 10px; padding: 4px 2px; }
.node { width: 86px; text-align: center; background: none; border: none; cursor: pointer; padding: 4px 0; }
.node-circle {
  width: 60px; height: 60px; margin: 0 auto;
  border-radius: 50%; background: var(--card);
  border: 3px solid var(--border); box-shadow: var(--shadow);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.6rem; transition: transform 0.15s;
}
.node:active .node-circle { transform: scale(0.93); }
.node.done .node-circle { border-color: var(--good); background: var(--good-soft); }
.node.available .node-circle { border-color: var(--accent); animation: pulse 2.2s infinite; }
.node.locked .node-circle, .node.missing .node-circle { opacity: 0.5; filter: grayscale(0.6); }
.node.live .node-circle { border-style: double; border-width: 5px; }
.node-label { font-size: 0.72rem; color: var(--muted); margin-top: 3px; line-height: 1.25; min-height: 2.4em; }
.node-stars { font-size: 0.7rem; letter-spacing: 1px; min-height: 1em; }
.node-stars .off { opacity: 0.25; }

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(91, 122, 140, 0.4); }
  50% { box-shadow: 0 0 0 9px rgba(91, 122, 140, 0); }
}

/* ===== Lesson chrome ===== */
.lesson-top { display: flex; align-items: center; gap: 10px; padding: 4px 0 10px; }
.exit-btn { background: none; border: none; font-size: 1.4rem; color: var(--muted); cursor: pointer; min-width: 44px; min-height: 44px; }
.lesson-steps { flex: 1; display: flex; gap: 5px; }
.lesson-step { flex: 1; height: 8px; border-radius: 4px; background: var(--border); }
.lesson-step.on { background: var(--accent); }
.lesson-title { font-size: 0.85rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 34vw; }

/* ===== Teach screens ===== */
.hook-emoji { font-size: 4rem; text-align: center; margin: 26px 0 6px; }
.hook-title { font-size: 1.35rem; font-weight: 800; text-align: center; margin: 0 0 10px; }
.hook-text { font-size: 1.08rem; text-align: center; color: var(--text); margin-bottom: 26px; }

.teach-text { font-size: 1.06rem; margin-bottom: 12px; }

/* semantic chips + the one legend */
.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 12px 0 4px; }
.chip {
  padding: 7px 13px; border-radius: 12px; font-weight: 700; font-size: 1rem;
  border: 2px solid transparent;
}
.chip.label    { background: var(--label-soft);    color: var(--label); }
.chip.direct   { background: var(--direct-soft);   color: var(--direct); }
.chip.practice { background: var(--practice-soft); color: var(--practice); }
.chip.neutral  { background: var(--neutral-soft);  color: var(--neutral); }
.legend { display: flex; gap: 8px; justify-content: center; margin: 4px 0 14px; flex-wrap: wrap; }
.legend .chip { font-size: 0.74rem; padding: 3px 9px; font-weight: 600; }

.quote-card {
  background: var(--accent-soft); border-radius: var(--radius);
  padding: 14px 16px; margin: 14px 0 4px; font-size: 1rem; font-style: italic;
}
.quote-by { display: block; font-style: normal; font-size: 0.85rem; color: var(--muted); margin-top: 6px; }

/* common-mistake screen: כך טועים ❌ / כך נכון ✔ */
.mistake-wrap { margin: 18px 0; }
.mistake-row {
  border-radius: var(--radius); padding: 14px 16px; margin-bottom: 12px; font-size: 1.04rem;
}
.mistake-row.wrong { background: var(--bad-soft); border-inline-start: 5px solid var(--bad); }
.mistake-row.right { background: var(--good-soft); border-inline-start: 5px solid var(--good); }
.mistake-row b { display: block; margin-bottom: 4px; }

/* concept card (mini) shown on teach screens */
.concept-mini {
  display: flex; align-items: center; gap: 12px;
  background: var(--bg); border: 1px dashed var(--border);
  border-radius: 14px; padding: 10px 12px; margin-top: 10px;
}
.concept-mini .cm-emoji { font-size: 1.9rem; flex-shrink: 0; }
.concept-mini .cm-term { font-weight: 800; }
.concept-mini .cm-meaning { font-size: 0.88rem; color: var(--muted); }
.concept-mini .cm-orig { font-size: 0.8rem; color: var(--muted); }

/* full-screen concept card (concepts intro step) */
.concept-card { text-align: center; padding: 24px 18px; }
.concept-emoji { font-size: 4rem; line-height: 1.2; }
.concept-term { font-size: 1.9rem; font-weight: 800; margin: 6px 0 2px; }
.concept-orig { font-size: 0.95rem; color: var(--muted); }
.concept-meaning { font-size: 1.15rem; margin: 12px 0 0; }
.concept-example { border-top: 1px dashed var(--border); margin-top: 14px; padding-top: 12px; font-size: 1rem; color: var(--muted); }
.concept-count { color: var(--muted); font-size: 0.85rem; margin-bottom: 6px; text-align: center; }

/* ===== Live practice brick ===== */
.live-step { font-size: 1.15rem; text-align: center; margin: 26px 0; }
.live-step-num { color: var(--muted); font-size: 0.9rem; text-align: center; margin-bottom: 8px; }
.timer-wrap { text-align: center; margin: 26px 0 18px; }
.timer-ring { display: block; margin: 0 auto; width: 200px; max-width: 62vw; height: auto; }
.timer-ring circle { fill: none; stroke-width: 8; }
.timer-ring .track { stroke: var(--border); }
.timer-ring .prog { stroke: var(--practice); stroke-linecap: round; transition: stroke-dashoffset 1s linear; }
.timer-num { font-size: 2.6rem; font-weight: 800; letter-spacing: 1px; }
.timer-hint { color: var(--muted); font-size: 0.95rem; margin-top: 10px; }
.reflection-q { font-size: 1.15rem; font-weight: 700; text-align: center; margin: 20px 0 6px; }

/* ===== Quiz ===== */
.quiz-progress { height: 10px; background: var(--border); border-radius: 5px; margin: 6px 0 16px; overflow: hidden; }
.quiz-progress-bar { height: 100%; background: var(--good); border-radius: 5px; transition: width 0.3s; }

.q-instr { color: var(--muted); font-size: 0.9rem; text-align: center; margin-bottom: 8px; }
.q-prompt { font-size: 1.25rem; font-weight: 800; text-align: center; margin: 10px 0 4px; }
.q-prompt.big { font-size: 1.5rem; }
.q-emoji { font-size: 4rem; text-align: center; margin: 12px 0; }
.q-center { text-align: center; margin-bottom: 10px; }

.choice-grid { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.choice-btn {
  min-height: 54px; padding: 12px 16px;
  background: var(--card); border: 2px solid var(--border); border-radius: var(--radius);
  font-size: 1.05rem; font-weight: 600; cursor: pointer; text-align: start;
  box-shadow: var(--shadow); transition: transform 0.1s, border-color 0.15s, background 0.15s;
}
.choice-btn:active { transform: scale(0.985); }
.choice-btn.correct { border-color: var(--good); background: var(--good-soft); }
.choice-btn.wrong { border-color: var(--bad); background: var(--bad-soft); }
.choice-btn:disabled { cursor: default; }
.choice-btn:disabled:not(.correct):not(.wrong) { opacity: 0.55; }

/* practice escape hatch — appears after two misses, never in quiz mode */
.reveal-btn {
  margin-top: 14px;
  font-size: 0.98rem;
  min-height: 48px;
  border-style: dashed;
  color: var(--muted);
}

/* true / false + why */
.tf-statement {
  background: var(--card); border: 2px solid var(--border); border-radius: var(--radius);
  padding: 16px; font-size: 1.12rem; margin: 14px 0 4px; box-shadow: var(--shadow);
}
.tf-row { display: flex; gap: 10px; margin-top: 14px; }
.tf-row .choice-btn { flex: 1; text-align: center; font-size: 1.15rem; font-weight: 800; }

/* fill blank */
.fb-sentence {
  display: flex; flex-wrap: wrap; gap: 7px;
  justify-content: center; align-items: center;
  font-size: 1.18rem; font-weight: 600; margin: 16px 0 6px;
}
.fb-blank {
  min-width: 90px; text-align: center; border-bottom: 3px solid var(--accent);
  color: var(--accent); border-radius: 4px; padding: 0 6px;
}
.fb-blank.good { color: var(--good); border-color: var(--good); }
.q-he-line { text-align: center; color: var(--muted); margin: 4px 0 10px; }
.options-row { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 14px; }
.options-row .choice-btn { min-width: 96px; text-align: center; }

/* step builder (ordering) */
.bld-answer {
  min-height: 62px; display: flex; flex-direction: column; gap: 8px;
  background: var(--card); border: 2px dashed var(--border); border-radius: var(--radius);
  padding: 10px; margin: 12px 0;
}
.bld-answer.good { border-color: var(--good); background: var(--good-soft); }
.bld-bank { display: flex; flex-direction: column; gap: 8px; margin: 10px 0 14px; min-height: 50px; }
.tile {
  min-height: 46px; padding: 10px 14px;
  background: var(--card); border: 2px solid var(--border); border-radius: 12px;
  font-size: 1rem; font-weight: 600; cursor: pointer; text-align: start;
  box-shadow: var(--shadow); transition: transform 0.1s;
}
.tile:active { transform: scale(0.97); }
.bld-answer .tile { background: var(--accent-soft); border-color: var(--accent); }
.bld-num { color: var(--muted); font-weight: 800; margin-inline-end: 6px; }
.bld-correct { text-align: start; font-size: 1rem; margin-top: 8px; }
.bld-correct ol { margin: 6px 0 0; padding-inline-start: 22px; }

/* matching */
.match-wrap { display: flex; gap: 10px; margin-top: 14px; }
.match-col { flex: 1; display: flex; flex-direction: column; gap: 9px; }
.match-btn {
  min-height: 56px; padding: 8px 10px;
  background: var(--card); border: 2px solid var(--border); border-radius: 14px;
  font-size: 0.95rem; font-weight: 600; cursor: pointer; box-shadow: var(--shadow);
}
.match-btn.sel { border-color: var(--accent); background: var(--accent-soft); }
.match-btn.locked { border-color: var(--good); background: var(--good-soft); opacity: 0.75; cursor: default; }
.match-btn.wrong { border-color: var(--bad); background: var(--bad-soft); }

/* feedback bar */
.fb {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  padding: 14px 16px calc(14px + env(safe-area-inset-bottom));
  animation: slideup 0.22s ease-out;
}
.fb-inner { max-width: 640px; margin: 0 auto; }
.fb.fb-good { background: var(--good-soft); }
.fb.fb-bad { background: var(--bad-soft); }
.fb-msg { font-size: 1.1rem; font-weight: 800; margin-bottom: 4px; }
.fb.fb-good .fb-msg { color: var(--good); }
.fb.fb-bad .fb-msg { color: var(--bad); }
.fb-answer { font-size: 1rem; margin-bottom: 4px; }
.fb-why { font-size: 0.92rem; color: var(--muted); margin-bottom: 6px; }
.fb .btn { margin-top: 8px; }
@keyframes slideup { from { transform: translateY(100%); } to { transform: translateY(0); } }

/* ===== Reward ===== */
.reward { text-align: center; padding-top: 30px; }
.reward-stars { font-size: 3.2rem; letter-spacing: 6px; margin: 16px 0; }
.reward-stars .off { opacity: 0.2; filter: grayscale(1); }
.reward-title { font-size: 1.35rem; font-weight: 800; }
.reward-sub { color: var(--muted); margin: 6px 0 18px; }
.reward-chips { display: flex; gap: 8px; justify-content: center; margin-bottom: 22px; flex-wrap: wrap; }
.reward-chip { background: var(--card); border-radius: 14px; padding: 8px 14px; box-shadow: var(--shadow); font-weight: 700; font-size: 0.95rem; }
.pop { animation: pop 0.45s ease-out; }
@keyframes pop { 0% { transform: scale(0.4); opacity: 0; } 70% { transform: scale(1.12); } 100% { transform: scale(1); opacity: 1; } }

/* ===== Settings ===== */
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 2px; border-bottom: 1px solid var(--border); }
.set-row:last-child { border-bottom: none; }
.set-label { font-size: 1rem; }
.set-label small { display: block; color: var(--muted); font-size: 0.8rem; }
.seg { display: flex; background: var(--border); border-radius: 12px; padding: 3px; }
.seg button { border: none; background: none; padding: 7px 12px; border-radius: 10px; font-size: 0.9rem; cursor: pointer; min-height: 44px; }
.seg button.on { background: var(--card); font-weight: 700; box-shadow: var(--shadow); }
.switch { position: relative; width: 52px; height: 30px; flex-shrink: 0; }
.switch input { opacity: 0; width: 100%; height: 100%; position: absolute; margin: 0; cursor: pointer; z-index: 2; }
.switch .knob { position: absolute; inset: 0; background: var(--border); border-radius: 15px; transition: background 0.2s; }
.switch .knob::after {
  content: ""; position: absolute; top: 3px; right: 3px; width: 24px; height: 24px;
  background: #fff; border-radius: 50%; transition: transform 0.2s; box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.switch input:checked + .knob { background: var(--good); }
.switch input:checked + .knob::after { transform: translateX(-22px); }
textarea.io { width: 100%; min-height: 110px; border-radius: 12px; border: 2px solid var(--border); background: var(--bg); color: var(--text); padding: 10px; font-size: 0.8rem; direction: ltr; }
input.io { width: 100%; border-radius: 12px; border: 2px solid var(--border); background: var(--bg); color: var(--text); padding: 10px; font-size: 1rem; }

/* ===== Animations & misc ===== */
.flash-good { animation: flashgood 0.5s; }
@keyframes flashgood { 0% { background: transparent; } 30% { background: var(--good-soft); } 100% { background: transparent; } }
.shake { animation: shake 0.4s; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(5px); }
  50% { transform: translateX(-5px); }
  75% { transform: translateX(3px); }
}

#toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: var(--bg);
  padding: 11px 20px; border-radius: 14px; font-size: 0.95rem;
  z-index: 99; box-shadow: var(--shadow); max-width: 88vw; text-align: center;
}

.center { text-align: center; }
.muted { color: var(--muted); }
.spacer { height: 16px; }
.big-emoji { font-size: 3.6rem; text-align: center; margin: 20px 0 4px; }
.svg-wrap { text-align: center; margin: 12px 0 4px; }
.svg-wrap svg { max-width: 100%; height: auto; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
