/* LearnTerminal: dark "neon terminal" look. Lime = success/accent, pink = errors, amber = hints, silver = text. */
:root {
  --bg: #07080a;
  --panel: #0c0e11;
  --panel-2: #111418;
  --line: #1f242b;
  --line-2: #2a3038;
  --text: #E4E7EC;
  --silver: #D4D8E0;
  --dim: #8b929c;
  --faint: #5b626c;
  --lime: #CCFF00;
  --lime-soft: rgba(204, 255, 0, 0.10);
  --pink: #FF2D95;
  --amber: #f59e0b;
  --on-light: #0a0a0a;
  --term: #05070a;
  --mono: 'JetBrains Mono', Consolas, 'Courier New', monospace;
  --sans: 'Inter', 'Segoe UI', system-ui, sans-serif;
  --ui-size: 13px;
  --ui-weight: 600;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
}
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
code {
  font-family: var(--mono);
  font-size: 0.92em;
  color: var(--lime);
  background: var(--lime-soft);
  border: 1px solid rgba(204, 255, 0, 0.18);
  padding: 1px 6px;
  border-radius: 5px;
  display: inline-block;
  max-width: 100%;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-all;
}

/* ---------- buttons & pills (one size / weight everywhere) ---------- */
.btn, .pill {
  font-family: var(--sans);
  font-size: var(--ui-size);
  font-weight: var(--ui-weight);
  line-height: 1;
  padding: 9px 14px;
  border-radius: 999px;
  border: 1px solid var(--line-2);
  color: var(--silver);
  background: var(--panel-2);
  transition: border-color .15s, background .15s, color .15s, transform .1s;
  white-space: nowrap;
}
.btn:hover, .pill:hover { border-color: var(--silver); color: var(--text); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--lime); border-color: var(--lime); color: var(--on-light); }
.btn.primary:hover { background: #d9ff4d; color: var(--on-light); }
.btn.warn { border-color: var(--pink); color: var(--pink); }
.icon-btn {
  width: 36px; height: 36px; border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--silver); border: 1px solid var(--line-2); background: var(--panel-2);
}
.icon-btn:hover { border-color: var(--silver); }

/* ---------- top bar ---------- */
.top {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}
.logo { font-family: var(--mono); font-weight: 700; font-size: 17px; letter-spacing: .5px; display: flex; align-items: center; gap: 8px; }
.logo-mark {
  color: var(--on-light); background: var(--lime);
  padding: 2px 6px; border-radius: 6px; font-size: .85em;
  box-shadow: 0 0 14px rgba(204, 255, 0, .45);
}
.pills { display: inline-flex; gap: 4px; padding: 4px; border: 1px solid var(--line-2); border-radius: 999px; background: var(--bg); margin-left: 8px; }
.pills .pill { border-color: transparent; background: transparent; padding: 7px 14px; }
.pills .pill.on { background: var(--lime); color: var(--on-light); border-color: var(--lime); }
.top-actions { margin-left: auto; display: flex; gap: 8px; }

/* ---------- layout ---------- */
.layout {
  display: grid;
  grid-template-columns: 230px minmax(340px, 440px) 1fr;
  min-height: 0;
}
body.side-collapsed .layout { grid-template-columns: 0 minmax(340px, 480px) 1fr; }
body.side-collapsed .sidebar { visibility: hidden; border: none; padding: 0; }

/* ---------- sidebar ---------- */
.sidebar {
  border-right: 1px solid var(--line);
  padding: 18px 12px;
  overflow: auto;
  display: flex; flex-direction: column;
  background: var(--panel);
}
.side-title { font-size: 12px; font-weight: 700; letter-spacing: 1.5px; text-transform: uppercase; color: var(--dim); padding: 0 8px 10px; }
.lesson-list { list-style: none; display: flex; flex-direction: column; gap: 2px; }
.lesson-list button {
  width: 100%; text-align: left;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 8px; border-radius: 10px;
  font-size: 14px; font-weight: 500; color: var(--dim);
  border: 1px solid transparent;
}
.lesson-list button:hover { color: var(--text); background: var(--panel-2); }
.lesson-list .n {
  flex: 0 0 24px; height: 24px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; border: 1px solid var(--line-2); color: var(--dim);
}
.lesson-list li.done .n { background: var(--lime); border-color: var(--lime); color: var(--on-light); }
.lesson-list li.done button { color: var(--silver); }
.lesson-list li.current button { color: var(--text); background: var(--lime-soft); border-color: rgba(204, 255, 0, .35); }
.lesson-list li.current .n { border-color: var(--lime); color: var(--lime); }
.lesson-list li.current.done .n { color: var(--on-light); }
.side-progress { margin-top: auto; padding: 14px 8px 0; font-size: 13px; color: var(--dim); }
.bar { height: 6px; border-radius: 99px; background: var(--line); margin-top: 8px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--lime); box-shadow: 0 0 10px rgba(204, 255, 0, .6); transition: width .5s ease; }

/* ---------- lesson panel ---------- */
.lesson {
  border-right: 1px solid var(--line);
  overflow: auto;
  padding: 24px 22px 40px;
  line-height: 1.6;
  font-size: 15px;
}
.kicker { font-size: 12px; font-weight: 700; letter-spacing: 1.5px; text-transform: uppercase; color: var(--lime); }
.lesson h2 { font-size: 26px; line-height: 1.2; margin: 6px 0 6px; }
.goal { color: var(--dim); margin-bottom: 18px; }
.part { padding: 14px 0; border-top: 1px solid var(--line); }
.part h3 { font-size: 16px; display: flex; align-items: center; gap: 10px; }
.part .num, .part .tick {
  flex: 0 0 22px; height: 22px; border-radius: 6px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
}
.part .num { border: 1px solid var(--line-2); color: var(--dim); }
.part.active .num { border-color: var(--lime); color: var(--lime); }
.part .tick { background: var(--lime); color: var(--on-light); }
.part.done h3, .part.todo h3 { color: var(--dim); font-weight: 600; }
.part > p { margin: 8px 0 12px; color: var(--silver); }
.part .extra { font-size: 14px; color: var(--dim); }

.tasks { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.task { display: grid; grid-template-columns: 22px 1fr; gap: 10px; padding: 8px 10px; border-radius: 10px; border: 1px solid transparent; color: var(--dim); }
.task .box { width: 18px; height: 18px; margin-top: 3px; border-radius: 5px; border: 1.5px solid var(--line-2); display: inline-flex; align-items: center; justify-content: center; }
.task.current { color: var(--text); border-color: rgba(204, 255, 0, .35); background: var(--lime-soft); }
.task.current .box { border-color: var(--lime); }
.task.done { color: var(--dim); }
.task.done .box { background: var(--lime); border-color: var(--lime); animation: pop .35s ease; }
.task.done .box::after { content: '✓'; color: var(--on-light); font-size: 12px; font-weight: 800; }
.task.done code { color: var(--dim); background: transparent; border-color: var(--line-2); }
@keyframes pop { 0% { transform: scale(.4); } 70% { transform: scale(1.2); } 100% { transform: scale(1); } }

.help { grid-column: 2; }
.help-row { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.hint, .answer { margin-top: 8px; font-size: 14px; padding: 8px 10px; border-radius: 8px; }
.hint { color: var(--amber); border-left: 3px solid var(--amber); background: rgba(245, 158, 11, .07); }
.answer { color: var(--silver); border-left: 3px solid var(--lime); background: rgba(204, 255, 0, .05); }
.paste { cursor: pointer; }
.paste:hover { background: var(--lime); color: var(--on-light); }

.complete { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--line); }
.complete h3 { font-size: 20px; color: var(--lime); text-shadow: 0 0 16px rgba(204, 255, 0, .45); }
.complete p { color: var(--silver); margin: 6px 0 14px; }
.complete .row { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }

/* ---------- terminal ---------- */
.term { position: relative; display: flex; flex-direction: column; min-height: 0; background: var(--term); }
.term-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; border-bottom: 1px solid var(--line);
  font-size: 13px; font-weight: 600; color: var(--dim); background: var(--panel);
}
.term-btn { margin-left: auto; }
.term-btn.on { border-color: var(--amber); color: var(--amber); }
.term.admin .term-dot { background: var(--amber); box-shadow: 0 0 10px var(--amber); }
.input-line.busy .prompt { display: none; }
.term-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--lime); box-shadow: 0 0 10px var(--lime); animation: breathe 2.4s ease-in-out infinite; }
@keyframes breathe { 50% { opacity: .35; } }
.screen {
  position: relative; flex: 1; overflow: auto;
  padding: 16px 18px 24px;
  font-family: var(--mono); font-size: 14.5px; line-height: 1.55;
  color: var(--silver); cursor: text;
}
.term::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: repeating-linear-gradient(to bottom, rgba(255, 255, 255, .025) 0 1px, transparent 1px 3px);
}
#output .l { white-space: pre-wrap; word-break: break-word; min-height: 1.55em; }
.l.cmdline { color: var(--text); }
.l.cmdline .p { color: var(--lime); }
.l.err { color: var(--pink); }
.l.tip { color: var(--amber); }
.l.ok { color: var(--lime); font-weight: 600; text-shadow: 0 0 10px rgba(204, 255, 0, .5); }
.l.sys { color: var(--dim); }
.l .dir { color: var(--lime); font-weight: 600; }
.l.opts { color: var(--dim); }
.input-line { display: flex; align-items: baseline; white-space: pre; }
.prompt { color: var(--lime); }
#cmd {
  flex: 1; min-width: 40px;
  background: transparent; border: none; outline: none;
  font: inherit; color: var(--text); caret-color: var(--lime);
}

/* ---------- cheat sheet drawer ---------- */
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(460px, 100vw);
  background: var(--panel); border-left: 1px solid var(--line-2);
  padding: 20px; overflow: auto; z-index: 20;
  transform: translateX(105%); transition: transform .25s ease;
}
.drawer.open { transform: none; box-shadow: -20px 0 50px rgba(0, 0, 0, .6); }
.drawer-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.drawer-head h2 { font-size: 20px; }
.drawer-note { color: var(--dim); font-size: 13px; margin-bottom: 12px; }
.cheat-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.cheat-table td { padding: 8px 4px; border-bottom: 1px solid var(--line); vertical-align: top; }
.cheat-table td:first-child { color: var(--silver); width: 45%; padding-right: 12px; }
.cheat-table .also { color: var(--faint); font-size: 12px; }

/* ---------- onboarding ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 30;
  display: flex; align-items: center; justify-content: center;
  background: rgba(3, 4, 6, .82); padding: 20px;
}
.overlay[hidden] { display: none; }
.card {
  width: min(560px, 100%);
  background: var(--panel); border: 1px solid var(--line-2); border-radius: 18px;
  padding: 28px; box-shadow: 0 0 60px rgba(204, 255, 0, .08);
  animation: rise .35s ease;
}
@keyframes rise { from { transform: translateY(14px); opacity: 0; } }
.logo.big { font-size: 24px; margin-bottom: 10px; }
.lead { color: var(--silver); margin-bottom: 22px; line-height: 1.6; }
.field-label { display: block; font-weight: 600; font-size: 14px; margin: 14px 0 8px; }
.text-input {
  width: 100%; padding: 12px 14px; border-radius: 10px;
  border: 1px solid var(--line-2); background: var(--bg); color: var(--text);
  font: 500 16px var(--sans); outline: none;
}
.text-input:focus { border-color: var(--lime); }
.field-error { color: var(--pink); font-size: 13px; margin-top: 6px; }
.shell-choices { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.choice {
  text-align: left; padding: 12px; border-radius: 12px;
  border: 1px solid var(--line-2); background: var(--bg);
  display: flex; flex-direction: column; gap: 4px;
}
.choice b { font-family: var(--mono); font-size: 15px; }
.choice span { font-size: 12.5px; color: var(--dim); line-height: 1.4; }
.choice:hover { border-color: var(--silver); }
.choice.on { border-color: var(--lime); background: var(--lime-soft); }
.choice.on b { color: var(--lime); }
.small-note { font-size: 12.5px; color: var(--dim); margin-top: 8px; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 22px; }

#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 40; width: 100vw; height: 100vh; }

/* ---------- narrow screens: lesson above terminal ---------- */
@media (max-width: 1000px) {
  .layout, body.side-collapsed .layout { grid-template-columns: 1fr; grid-template-rows: minmax(0, 45%) 1fr; }
  .lesson { border-right: none; border-bottom: 1px solid var(--line); }
  .sidebar {
    position: fixed; top: var(--top-h, 57px); left: 0; bottom: 0; width: 260px; z-index: 15;
    visibility: visible; transform: translateX(-102%); transition: transform .25s ease;
  }
  body.side-open .sidebar { transform: none; box-shadow: 20px 0 50px rgba(0, 0, 0, .6); }
  body.side-collapsed .sidebar { visibility: visible; border-right: 1px solid var(--line); padding: 18px 12px; }
  .top { flex-wrap: wrap; }
  .shell-choices { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .top-actions .btn { padding: 8px 10px; }
  .pills { margin-left: 0; }
}
