/* Java Basics — dark, friendly theme */

:root {
  --bg: #0a1929;
  --panel: #102a43;
  --panel-2: #0d2137;
  --border: #1e3a5f;
  --text: #e8f0fe;
  --muted: #8ca6c0;
  --accent: #4dabf7;
  --green: #43c465;
  --red: #ff6b6b;

  /* syntax colours */
  --c-kw: #c792ea;
  --c-type: #56ccf2;
  --c-class: #82aaff;
  --c-fn: #e879f9;
  --c-str: #a5e075;
  --c-num: #ffd76d;
  --c-bool: #ff9e64;
  --c-op: #89ddff;
  --c-pun: #d6deeb;
  --c-var: #e8f0fe;

  --mono: "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: "Nunito", system-ui, sans-serif;
}

/* Never merge characters like != into ≠ — learners must see every real
 * character they need to type. */
.editor, .bubble-code, .terminal-body, .explain-code, kbd {
  font-variant-ligatures: none;
  font-feature-settings: "liga" 0, "calt" 0;
}

/* Code shown on screen can't be selected: learners should type it out
 * themselves, not copy-paste it (paste is also blocked on the input). */
.editor, .bubble-code, .explain-code {
  user-select: none;
  -webkit-user-select: none;
}
/* ...but kids can still select their own typing to edit it */
#code-input {
  user-select: text;
  -webkit-user-select: text;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
}

#app { min-height: 100vh; display: flex; flex-direction: column; }

kbd {
  font-family: var(--mono);
  background: #16324e;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 0 6px;
  font-size: 0.95em;
}

/* ---------- syntax token colours ---------- */
.tok-kw   { color: var(--c-kw); }
.tok-type { color: var(--c-type); }
.tok-class{ color: var(--c-class); }
.tok-fn   { color: var(--c-fn); }
.tok-str  { color: var(--c-str); }
.tok-num  { color: var(--c-num); }
.tok-bool { color: var(--c-bool); }
.tok-op   { color: var(--c-op); }
.tok-pun  { color: var(--c-pun); }
.tok-var  { color: var(--c-var); }
.tok-ws   { }
.tok-ghost { opacity: 0.32; }
.tok-err {
  color: #fff;
  background: rgba(255, 90, 90, 0.4);
  border-radius: 3px;
  text-decoration: underline wavy var(--red) 1.5px;
  text-underline-offset: 3px;
}
.tok-mark {
  outline: 2px solid var(--c-num);
  outline-offset: 1px;
  border-radius: 3px;
}

/* ---------- top / bottom bars ---------- */
.top-bar {
  display: flex; align-items: center; gap: 18px;
  padding: 14px 26px;
  background: #071322;
  border-bottom: 1px solid var(--border);
}
.brand {
  font-weight: 800; font-size: 21px; color: var(--text);
  text-decoration: none; letter-spacing: 0.3px;
}
.top-lesson { font-weight: 700; color: var(--muted); flex: 1; }
.top-note { color: var(--muted); margin-left: auto; font-size: 14px; }

.bottom-bar {
  display: flex; align-items: center; gap: 16px;
  padding: 12px 26px;
  background: #071322;
  border-top: 1px solid var(--border);
  margin-top: auto;
}
.progress-label { font-weight: 700; font-size: 14px; color: var(--muted); white-space: nowrap; }
.bottom-actions { display: flex; gap: 10px; margin-left: auto; }

.bar {
  background: #16324e; border-radius: 99px; height: 12px; overflow: hidden;
}
.bar.mini { width: 180px; }
.bar .fill {
  background: linear-gradient(90deg, var(--accent), var(--green));
  height: 100%; border-radius: 99px; transition: width 0.6s ease;
}

/* ---------- buttons ---------- */
.btn {
  font-family: var(--sans); font-weight: 700; font-size: 15px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--panel); color: var(--text);
  padding: 9px 18px; cursor: pointer; text-decoration: none;
  display: inline-block; transition: background 0.15s, transform 0.1s;
}
.btn:hover { background: #16324e; }
.btn:active { transform: scale(0.97); }
.btn-primary {
  background: var(--green); border-color: var(--green); color: #04240d;
}
.btn-primary:hover { background: #55d477; }
.btn-ghost { background: transparent; }
.btn-big { font-size: 18px; padding: 13px 30px; }

/* ---------- home ---------- */
.home { max-width: 1060px; margin: 0 auto; padding: 40px 26px 70px; width: 100%; }
.hero { text-align: center; margin-bottom: 44px; }
.hero h1 { font-size: 38px; font-weight: 800; margin-bottom: 12px; }
.hero p { color: var(--muted); max-width: 620px; margin: 0 auto 22px; font-size: 17px; }
.hero-progress {
  display: flex; align-items: center; gap: 14px; justify-content: center;
  margin-bottom: 26px; color: var(--muted); font-weight: 700; font-size: 14px;
}
.hero-progress .bar { width: 260px; }

.section-title { font-size: 22px; font-weight: 800; margin: 8px 0 16px; }

.course-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px;
  margin-bottom: 40px;
}
.course-card {
  display: flex; gap: 16px; align-items: center;
  background: var(--panel); border: 1px solid var(--border); border-radius: 16px;
  padding: 20px; text-decoration: none; color: var(--text);
  transition: transform 0.12s, border-color 0.12s;
}
a.course-card:hover { transform: translateY(-2px); border-color: var(--accent); }
.course-icon {
  flex: none; width: 58px; height: 58px; border-radius: 16px;
  background: #16324e; display: grid; place-items: center; font-size: 30px;
}
.course-card-body { flex: 1; }
.course-card .lesson-card-title { font-size: 18px; }
.course-progress {
  display: flex; align-items: center; gap: 10px; margin-top: 10px;
  color: var(--muted); font-weight: 700; font-size: 13px;
}
.course-progress .bar { flex: 1; max-width: 170px; }
.course-card.coming-soon { opacity: 0.65; }
.soon-badge {
  display: inline-block; margin-top: 10px; font-size: 12px; font-weight: 800;
  color: var(--c-num); border: 1px solid var(--c-num); border-radius: 99px;
  padding: 2px 10px; letter-spacing: 0.4px;
}

.lesson-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px;
}
.lesson-card {
  display: flex; gap: 14px; align-items: center;
  background: var(--panel); border: 1px solid var(--border); border-radius: 14px;
  padding: 14px 16px; text-decoration: none; color: var(--text);
  transition: transform 0.12s, border-color 0.12s;
}
.lesson-card:hover { transform: translateY(-2px); border-color: var(--accent); }
.lesson-card-num {
  flex: none; width: 40px; height: 40px; border-radius: 50%;
  background: #16324e; display: grid; place-items: center;
  font-weight: 800; font-size: 17px;
}
.lesson-card.done .lesson-card-num { background: var(--green); color: #04240d; }
.lesson-card-title { font-weight: 800; }
.lesson-card-goal { color: var(--muted); font-size: 13px; margin-top: 2px; }

/* ---------- lesson layout ---------- */
.lesson {
  display: grid; grid-template-columns: minmax(430px, 5fr) minmax(380px, 5fr);
  gap: 22px; padding: 24px 26px; width: 100%; max-width: 1360px; margin: 0 auto;
  align-items: start; flex: 1;
}
@media (max-width: 940px) {
  .lesson { grid-template-columns: 1fr; padding: 16px 12px; }
  .editor { font-size: 13.5px; }
  .top-bar { padding: 10px 14px; gap: 10px; }
}
.editor { overflow-x: auto; }
.bubble-code, .explain-code { overflow-x: auto; }

.panel {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 14px; padding: 18px;
}
.panel-title {
  display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap;
  font-size: 22px; font-weight: 800; margin-bottom: 14px;
}
.panel-title .goal { font-size: 14px; font-weight: 600; color: var(--muted); }

/* ---------- editor ---------- */
.editor {
  font-family: var(--mono); font-size: 15.5px; line-height: 32px;
  background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 0; cursor: text;
}
.code-row { display: flex; align-items: center; padding: 0 14px 0 0; min-height: 32px; }
.code-row .ln {
  flex: none; width: 44px; text-align: right; padding-right: 16px;
  color: #3f5a78; font-size: 13px; user-select: none;
}
.code-row .code { white-space: pre; flex: 1; }
.code-row.future .code { border-bottom: 1px dashed #1e3a5f; opacity: 0.5; min-height: 20px; }
.code-row.active { background: #12304e; }

.input-wrap { position: relative; display: block; }
.input-wrap .overlay {
  position: absolute; inset: 0; pointer-events: none; white-space: pre;
  line-height: 32px;
}
#code-input {
  font: inherit; letter-spacing: inherit;
  display: block; width: 100%; height: 32px; padding: 0;
  background: transparent; border: none; outline: none;
  color: transparent; caret-color: var(--accent);
  white-space: pre;
}

/* ---------- instruction bubble ---------- */
.bubble {
  margin-top: 16px; background: #0b2038; border: 1px solid var(--border);
  border-radius: 12px; padding: 14px 16px; position: relative;
}
.bubble::before {
  content: ""; position: absolute; top: -8px; left: 34px;
  width: 14px; height: 14px; background: #0b2038;
  border-left: 1px solid var(--border); border-top: 1px solid var(--border);
  transform: rotate(45deg);
}
.bubble-label { font-weight: 700; color: var(--muted); font-size: 14px; margin-bottom: 8px; }
.bubble-code {
  font-family: var(--mono); font-size: 16.5px; background: var(--panel-2);
  padding: 10px 14px; border-radius: 8px; white-space: pre-wrap; word-break: break-all;
}
.bubble-hint { min-height: 24px; margin-top: 9px; font-size: 14.5px; font-weight: 600; }
.hint-ok { color: var(--green); }
.hint-err { color: var(--red); }
.hint-neutral { color: var(--muted); }
.char-name { color: var(--muted); }

.shake { animation: shake 0.35s; }
@keyframes shake {
  20% { transform: translateX(-5px); } 40% { transform: translateX(5px); }
  60% { transform: translateX(-3px); } 80% { transform: translateX(3px); }
}

.complete-bubble {
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  border-color: var(--green);
}
.complete-bubble::before { border-color: var(--green); }
.complete-msg { font-size: 20px; font-weight: 800; }

/* ---------- terminal ---------- */
.terminal {
  border: 1px solid var(--border); border-radius: 14px; overflow: hidden;
  margin-bottom: 22px;
}
.terminal-bar {
  background: #1b2b3d; padding: 8px 14px; font-weight: 700; font-size: 14px;
  color: var(--muted); display: flex; align-items: center; gap: 7px;
}
.terminal-bar .dot { width: 11px; height: 11px; border-radius: 50%; display: inline-block; }
.dot.r { background: #ff5f57; } .dot.y { background: #febc2e; } .dot.g { background: #28c840; }
.terminal-body {
  background: #04080d; font-family: var(--mono); font-size: 14.5px;
  padding: 14px 16px; min-height: 210px; max-height: 320px; overflow-y: auto;
  line-height: 1.75;
}
.term-line { white-space: pre-wrap; word-break: break-all; }
.term-dim { color: #3f5a78; }
.term-cmd { color: #8ca6c0; }
.term-out { color: #d8f3dc; }

/* ---------- explanation panel ---------- */
.chip-row {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 14px;
}
.chip-label { font-size: 13px; font-weight: 700; color: var(--muted); margin-right: 4px; }
.chip {
  width: 32px; height: 32px; border-radius: 50%;
  border: 2px solid var(--border); background: transparent; color: var(--text);
  font-family: var(--sans); font-weight: 800; font-size: 14px; cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}
.chip:hover:not(:disabled) { border-color: var(--accent); }
.chip:disabled { opacity: 0.3; cursor: default; }
.chip-active { background: var(--accent); border-color: var(--accent); color: #04121f; }

.explain-head {
  font-size: 17px; font-weight: 800; color: #ff8787; margin-bottom: 10px;
  line-height: 1.7;
}
.explain-code {
  font-family: var(--mono); font-size: 15.5px; font-weight: 400;
  background: var(--panel-2); padding: 3px 9px; border-radius: 6px;
  white-space: pre-wrap; word-break: break-all;
}
.explain-text { color: #cddcee; line-height: 1.75; font-size: 15.5px; }
