/* ---------------------------------------------------------------------------
   Woxi Academy — styles
   --------------------------------------------------------------------------- */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --ink: #1f2933;
  --ink-soft: #52606d;
  --ink-faint: #9aa5b1;
  --border: #e4e7eb;
  --brand: #e8590c;        /* orange */
  --brand-dark: #c2410c;
  --accent: #2f6fed;
  --ok: #2f9e44;
  --ok-bg: #ebfbee;
  --bad: #e03131;
  --bad-bg: #fff5f5;
  --code-bg: #f1f3f5;
  --code-ink: #1f2933;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 4px 12px rgba(15, 23, 42, 0.05);
  --mono: "SFMono-Regular", "JetBrains Mono", "Fira Code", Menlo, Consolas, monospace;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

html.dark {
  --bg: #0f1419;
  --surface: #161b22;
  --ink: #e6edf3;
  --ink-soft: #aeb9c5;
  --ink-faint: #768491;
  --border: #2a313c;
  --brand: #ff922b;
  --brand-dark: #f76707;
  --accent: #6ea8fe;
  --ok: #4ad17c;
  --ok-bg: #143321;
  --bad: #ff7b72;
  --bad-bg: #3a1d1d;
  --code-bg: #0b1020;
  --code-ink: #e2e8f0;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 4px 12px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--sans);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* --- Navbar --------------------------------------------------------------- */

.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--ink);
  font-weight: 700;
}

.brand:hover {
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: var(--brand);
  color: #fff;
  font-weight: 800;
}

.nav-links {
  display: flex;
  gap: 1.25rem;
  font-size: 0.95rem;
}

.nav-links a {
  color: var(--ink-soft);
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.theme-toggle {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink-soft);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  transition: border-color 0.12s ease, color 0.12s ease;
}

.theme-toggle:hover {
  border-color: var(--ink-faint);
  color: var(--ink);
}

/* --- Buttons -------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  border: 1px solid transparent;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s ease, opacity 0.12s ease;
}

.btn:hover {
  text-decoration: none;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--brand);
  color: #fff;
}

.btn-primary:hover {
  background: var(--brand-dark);
}

.btn-run {
  background: var(--surface);
  border-color: var(--border);
  color: var(--ink);
}

.btn-run:hover:not(:disabled) {
  border-color: var(--ink-faint);
}

.btn-ghost {
  background: transparent;
  color: var(--ink-soft);
  border-color: var(--border);
}

.btn-ghost:hover {
  background: #f0f2f5;
}

/* --- Home ----------------------------------------------------------------- */

.home {
  max-width: 760px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
}

.hero {
  text-align: center;
  padding: 2rem 0 2.5rem;
}

.hero-title {
  font-size: 2.4rem;
  line-height: 1.15;
  margin: 0 0 0.75rem;
}

.hero-sub {
  color: var(--ink-soft);
  max-width: 38rem;
  margin: 0 auto 1.75rem;
}

.hero-cta {
  font-size: 1.05rem;
  padding: 0.7rem 1.5rem;
}

.track {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
}

.track-header {
  margin-bottom: 1.25rem;
}

.track-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}

.track-title {
  margin: 0;
  font-size: 1.3rem;
}

.track-count {
  color: var(--ink-faint);
  font-size: 0.9rem;
  white-space: nowrap;
}

.progress {
  margin-top: 0.75rem;
  height: 8px;
  background: #eef1f4;
  border-radius: 999px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: var(--ok);
  transition: width 0.3s ease;
}

.track-section {
  margin-top: 1.75rem;
}

.track-section:first-of-type {
  margin-top: 0;
}

.section-title {
  margin: 0 0 0.75rem;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-faint);
}

.lesson-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.lesson-link {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--ink);
  background: var(--surface);
  transition: border-color 0.12s ease, transform 0.06s ease;
}

.lesson-link:hover {
  text-decoration: none;
  border-color: var(--accent);
}

.lesson-num {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #eef1f4;
  color: var(--ink-soft);
  font-weight: 700;
  font-size: 0.9rem;
}

.lesson-num.done {
  background: var(--ok);
  color: #fff;
}

.lesson-info {
  flex: 1 1 auto;
}

.lesson-title {
  font-weight: 600;
}

.lesson-go {
  color: var(--ink-faint);
  font-size: 1.1rem;
}

/* --- Lesson layout -------------------------------------------------------- */

.lesson-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
  gap: 0;
  min-height: calc(100vh - 57px);
}

.instructions {
  padding: 2rem 2.25rem;
  border-right: 1px solid var(--border);
  background: var(--surface);
  overflow-y: auto;
}

.lesson-progress {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.85rem;
  margin-bottom: 1.25rem;
}

.lesson-step {
  color: var(--ink-faint);
}

.lesson-heading {
  font-size: 1.8rem;
  margin: 0 0 1rem;
}

.task {
  margin-top: 1.5rem;
  padding: 1rem 1.25rem;
  background: #f0f5ff;
  border: 1px solid #d7e3fb;
  border-radius: 8px;
}

.task .md-h {
  margin-top: 0;
  color: var(--accent);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* --- Workspace ------------------------------------------------------------ */

.workspace {
  display: flex;
  flex-direction: column;
  background: #fbfbfc;
  overflow-y: auto;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 5;
}

.toolbar-status {
  margin-left: auto;
  color: var(--ink-faint);
  font-size: 0.85rem;
}

.editor-host {
  border-bottom: 1px solid var(--border);
}

/* CodeMirror */
.cm-editor {
  font-family: var(--mono);
  font-size: 0.95rem;
  min-height: 220px;
}

.cm-editor.cm-focused {
  outline: none;
}

.cm-scroller {
  padding: 0.5rem 0;
}

.cm-gutters {
  background: #f7f8fa;
  border-right: 1px solid var(--border);
  color: var(--ink-faint);
}

/* --- Console -------------------------------------------------------------- */

.console {
  padding: 1.25rem;
}

.console-label,
.hints-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-faint);
  font-weight: 700;
  margin-bottom: 0.6rem;
}

.console-empty {
  color: var(--ink-faint);
  font-style: italic;
  margin: 0;
}

.console-items {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.out-box {
  margin: 0;
  padding: 0.7rem 0.9rem;
  border-radius: 8px;
  font-family: var(--mono);
  font-size: 0.92rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.out-text {
  background: var(--code-bg);
  color: var(--code-ink);
}

.out-print {
  background: #e9edf2;
  color: #52606d;
}

.out-warning {
  background: #fff8e1;
  color: #8a6d00;
  border: 1px solid #ffe7a0;
}

.out-error {
  background: var(--bad-bg);
  color: var(--bad);
  border: 1px solid #ffc9c9;
}

.out-graphics,
.out-box.has-svg {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 0.75rem;
  display: flex;
  justify-content: center;
}

.out-box.has-svg svg {
  max-width: 100%;
  height: auto;
}

/* --- Feedback ------------------------------------------------------------- */

.feedback {
  margin: 0 1.25rem 1.5rem;
  padding: 1.1rem 1.25rem;
  border-radius: 10px;
  border: 1px solid;
}

.feedback.pass {
  background: var(--ok-bg);
  border-color: #b2f2bb;
}

.feedback.fail {
  background: var(--bad-bg);
  border-color: #ffc9c9;
}

.feedback-title {
  margin: 0 0 0.5rem;
  font-size: 1.1rem;
}

.feedback.pass .feedback-title {
  color: var(--ok);
}

.feedback.fail .feedback-title {
  color: var(--bad);
}

.check-line {
  margin: 0.25rem 0;
  font-size: 0.92rem;
}

.check-line.ok {
  color: var(--ok);
}

.check-line.bad {
  color: var(--bad);
}

.test-list {
  list-style: none;
  margin: 0.75rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.test-row {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  font-size: 0.9rem;
}

.test-icon {
  font-weight: 800;
}

.test-row.ok .test-icon {
  color: var(--ok);
}

.test-row.bad .test-icon {
  color: var(--bad);
}

.test-expr {
  font-family: var(--mono);
  background: rgba(15, 23, 42, 0.06);
  padding: 0.05rem 0.35rem;
  border-radius: 4px;
}

.test-detail {
  color: var(--ink-soft);
}

.next-btn {
  margin-top: 1rem;
}

.feedback-nudge {
  margin: 0.5rem 0 0;
  color: var(--ink-soft);
  font-size: 0.9rem;
}

/* --- Hints ---------------------------------------------------------------- */

.hints {
  margin-top: 2rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

.hints-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.hint {
  padding: 0.6rem 0.9rem;
  background: #fffaf0;
  border: 1px solid #ffe8cc;
  border-radius: 8px;
  font-size: 0.92rem;
}

.hint .md-p {
  margin: 0;
}

/* --- Markdown ------------------------------------------------------------- */

.md-p {
  margin: 0.75rem 0;
}

.md-h {
  margin: 1.25rem 0 0.5rem;
  font-size: 1.05rem;
}

.md-list {
  margin: 0.5rem 0;
  padding-left: 1.25rem;
}

.md-list li {
  margin: 0.2rem 0;
}

.md-code {
  background: var(--code-bg);
  color: var(--code-ink);
  padding: 0.8rem 1rem;
  border-radius: 8px;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 0.88rem;
  line-height: 1.5;
}

.md-inline-code {
  font-family: var(--mono);
  font-size: 0.88em;
  background: rgba(15, 23, 42, 0.07);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
}

/* --- Not found ------------------------------------------------------------ */

.not-found {
  max-width: 30rem;
  margin: 5rem auto;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  align-items: center;
}

/* --- Responsive ----------------------------------------------------------- */

@media (max-width: 880px) {
  .lesson-layout {
    grid-template-columns: 1fr;
    min-height: 0;
  }

  .instructions {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
}

/* --- Dark-mode fixups for elements with hard-coded light colors ----------- */

html.dark .workspace {
  background: #10151c;
}

html.dark .task {
  background: #13233f;
  border-color: #1d3a6b;
}

html.dark .hint {
  background: #2a2410;
  border-color: #4a3f1a;
}

html.dark .progress,
html.dark .lesson-num {
  background: #222a35;
}

html.dark .btn-ghost:hover {
  background: #222a35;
}

html.dark .test-expr {
  background: rgba(255, 255, 255, 0.09);
}

html.dark .cm-gutters {
  background: #0b1020;
  border-right-color: var(--border);
}

html.dark .out-print {
  background: #0b1020;
  color: #cbd5e1;
}

html.dark .out-warning {
  background: #3a3414;
  color: #f5d57a;
  border-color: #5a4f1f;
}

/* The Woxi kernel renders SVG output with dark-friendly colors once told to,
   but give graphics boxes a light backdrop in light mode and a neutral one in
   dark mode. */
html.dark .out-box.has-svg,
html.dark .out-graphics {
  background: #0d1117;
}
