/* DFD Academy — Linux command line. One accent, plain type, one dark
   terminal as the only object on the page. Mobile first (390 px). */

:root {
  --bg: #ffffff;
  --surface: #f4f5f7;
  --line: #e1e4e8;
  --ink: #15181c;
  --muted: #5d6570;
  --accent: #0b7a55;
  --accent-ink: #ffffff;
  --accent-soft: #e6f2ed;
  --bad: #b3261e;
  --bad-soft: #fbeceb;
  --term-bg: #111418;
  --term-line: #111418;
  --term-ink: #e4e7eb;
  --term-dim: #8b95a1;
  --term-ps: #6fd3a8;
  --sans: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --gutter: 16px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #0e1013;
    --surface: #171a1f;
    --line: #2a2f36;
    --ink: #e8eaed;
    --muted: #9aa3ae;
    --accent: #37c48b;
    --accent-ink: #06140e;
    --accent-soft: #11261d;
    --bad: #ff8a80;
    --bad-soft: #2a1514;
    --term-bg: #07080a;
    --term-line: #262b31;
    color-scheme: dark;
  }
}
:root[data-theme='dark'] {
  --bg: #0e1013;
  --surface: #171a1f;
  --line: #2a2f36;
  --ink: #e8eaed;
  --muted: #9aa3ae;
  --accent: #37c48b;
  --accent-ink: #06140e;
  --accent-soft: #11261d;
  --bad: #ff8a80;
  --bad-soft: #2a1514;
  --term-bg: #07080a;
  --term-line: #262b31;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}
button { font: inherit; color: inherit; }
code, .mono { font-family: var(--mono); }
code {
  font-size: 0.92em;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 0 4px;
  white-space: nowrap;
}

/* The app always fills the *visible* viewport, so when the on-screen
   keyboard opens the dock and the input stay above it. */
#app {
  position: fixed;
  left: 0;
  right: 0;
  top: var(--vv-top, 0px);
  height: var(--vv-h, 100dvh);
  display: flex;
  flex-direction: column;
  max-width: 640px;
  margin: 0 auto;
  background: var(--bg);
}
.scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 8px var(--gutter) 24px;
  overscroll-behavior: contain;
}
.scroll.center { display: flex; align-items: center; }

.eyebrow {
  margin: 0 0 6px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
h1 { font-size: 28px; line-height: 1.15; font-weight: 600; letter-spacing: -0.015em; margin: 0 0 10px; }
h2 { font-size: 21px; line-height: 1.25; font-weight: 600; letter-spacing: -0.01em; margin: 0 0 12px; }
.fine { font-size: 13px; color: var(--muted); margin: 8px 0 0; }

/* ---------- top bar (path) */
.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: max(10px, env(safe-area-inset-top)) var(--gutter) 6px;
}
.brand { font-weight: 600; letter-spacing: 0.01em; }
.ghost {
  background: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
}

.hero { padding: 14px 0 6px; }
.lede { margin: 0 0 18px; color: var(--muted); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.stat .v { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.2; }
.stat .k { font-size: 12px; color: var(--muted); }
.meter { display: block; height: 4px; border-radius: 4px; background: var(--line); margin-top: 6px; overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--accent); }

.card-ish {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  margin: 18px 0 8px;
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}
.review.quiet { background: var(--surface); border-color: transparent; }
.rv-t { margin: 0; font-weight: 600; }
.rv-s { margin: 2px 0 0; font-size: 14px; color: var(--muted); }
.secondary {
  flex: none;
  border: 1.5px solid var(--accent);
  color: var(--accent);
  background: none;
  border-radius: 10px;
  padding: 9px 14px;
  font-weight: 600;
  cursor: pointer;
}

/* ---------- the path */
.unit { margin-top: 26px; }
.path { list-style: none; margin: 0; padding: 0; position: relative; }
.node { position: relative; }
.node + .node::before {
  content: '';
  position: absolute;
  left: 21px;
  top: -10px;
  height: 20px;
  width: 2px;
  background: var(--line);
}
.node-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 0;
  background: none;
  border: 0;
  text-align: left;
  cursor: pointer;
}
.node-btn:disabled { cursor: default; }
.dot {
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 600;
  border: 2px solid var(--line);
  color: var(--muted);
  background: var(--bg);
  position: relative;
  z-index: 1;
}
.dot svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.node.done .dot { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.node.current .dot, .node.open .dot { border-color: var(--accent); color: var(--accent); }
.node.current .dot { box-shadow: 0 0 0 4px var(--accent-soft); }
.node.locked .dot { background: var(--surface); border-color: var(--surface); }
.txt { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.txt .t { font-weight: 600; }
.txt .c { font-family: var(--mono); font-size: 13px; color: var(--muted); }
.node.locked .t { color: var(--muted); }
.state { flex: none; font-size: 13px; color: var(--muted); }
.state.go {
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
  font-size: 14px;
  padding: 7px 14px;
  border-radius: 10px;
}

.settings { margin-top: 30px; padding-top: 18px; border-top: 1px solid var(--line); }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.seg button {
  border: 1.5px solid var(--line);
  background: none;
  border-radius: 10px;
  padding: 9px 4px;
  font-size: 14px;
  cursor: pointer;
}
.seg button[aria-pressed='true'] { border-color: var(--accent); color: var(--accent); font-weight: 600; background: var(--accent-soft); }
.foot { margin-top: 22px; }

/* ---------- lesson top bar */
.ltop {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: max(8px, env(safe-area-inset-top)) var(--gutter) 8px;
}
.icon-btn {
  flex: none;
  width: 36px;
  height: 36px;
  margin-left: -8px;
  border: 0;
  background: none;
  display: grid;
  place-items: center;
  color: var(--muted);
  cursor: pointer;
}
.icon-btn svg { width: 22px; height: 22px; stroke: currentColor; stroke-width: 2; fill: none; stroke-linecap: round; }
.bar { flex: 1; height: 8px; border-radius: 8px; background: var(--line); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 8px; transition: width 0.3s ease; }
.count { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 34px; text-align: right; }

/* ---------- concept card */
.concept { padding-top: 10px; }
.ctext { font-size: 17px; line-height: 1.6; margin: 0 0 18px; }
.docs { margin-top: 18px; display: flex; flex-direction: column; gap: 6px; }
.docs a { color: var(--accent); text-decoration: none; font-weight: 500; display: inline-flex; align-items: center; gap: 6px; }
.docs a:hover { text-decoration: underline; }
.ext { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- exercise */
.exercise { padding-top: 6px; }
.prompt { font-size: 20px; font-weight: 500; }
.again { color: var(--bad); }
.files, .filebox {
  background: var(--surface);
  border-radius: 10px;
  margin: 0 0 10px;
  font-size: 14px;
}
.files summary { padding: 8px 12px; cursor: pointer; color: var(--muted); font-size: 13px; font-weight: 500; }
.files pre, .filebox pre {
  margin: 0;
  padding: 2px 12px 10px;
  font: 13.5px/1.45 var(--mono);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.fname { margin: 0; padding: 8px 12px 2px; font: 500 13px var(--mono); color: var(--muted); }

/* the terminal: the one dark object */
.term {
  background: var(--term-bg);
  color: var(--term-ink);
  border: 1px solid var(--term-line);
  border-radius: 12px;
  padding: 12px 12px 12px 14px;
  font: 15px/1.5 var(--mono);
  min-height: 92px;
}
.term.static { min-height: 0; }
.tl { display: flex; flex-wrap: wrap; column-gap: 0.6ch; align-items: baseline; }
.ps { color: var(--term-ps); white-space: nowrap; }
.tc { white-space: pre-wrap; overflow-wrap: anywhere; }
.to { white-space: pre-wrap; overflow-wrap: anywhere; color: var(--term-ink); margin-bottom: 2px; }
.to.dim, .to.unknown { color: var(--term-dim); }
.to.note { color: var(--term-dim); font-family: var(--sans); font-size: 14px; font-style: italic; margin-top: 4px; }
.input-line input {
  flex: 1 1 12ch;
  min-width: 12ch;
  background: transparent;
  border: 0;
  outline: none;
  padding: 0;
  margin: 0;
  color: var(--term-ink);
  caret-color: var(--term-ps);
  font: 16px/1.5 var(--mono); /* 16 px: iOS does not zoom on focus */
}
.input-line input::placeholder { color: var(--term-dim); opacity: 0.7; }
.caret { display: inline-block; width: 0.6em; height: 1.1em; vertical-align: -0.2em; background: var(--term-ps); opacity: 0.8; animation: blink 1.1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .caret { animation: none; } .bar i { transition: none; } }

.options { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.opt {
  text-align: left;
  border: 1.5px solid var(--line);
  background: var(--bg);
  border-radius: 10px;
  padding: 11px 14px;
  font-size: 15px;
  cursor: pointer;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.opt[aria-checked='true'] { border-color: var(--accent); background: var(--accent-soft); }
.opt.is-right { border-color: var(--accent); background: var(--accent-soft); }
.opt.is-wrong { border-color: var(--bad); background: var(--bad-soft); }
.opt:disabled { cursor: default; }
.opt:disabled:not(.is-right):not(.is-wrong) { opacity: 0.55; }

.built { display: inline-flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.bank { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.chip {
  border: 1.5px solid var(--line);
  border-bottom-width: 3px;
  background: var(--bg);
  border-radius: 9px;
  padding: 7px 12px;
  font-size: 15px;
  cursor: pointer;
}
.chip:disabled { opacity: 0.25; cursor: default; }
.chip.in {
  background: #20252c;
  color: var(--term-ink);
  border-color: #353c45;
  padding: 2px 8px;
  border-bottom-width: 1.5px;
}

/* ---------- the dock with the big button */
.dock {
  flex: none;
  padding: 12px var(--gutter) max(12px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--bg);
}
.dock.ok { background: var(--accent-soft); border-top-color: transparent; }
.dock.bad { background: var(--bad-soft); border-top-color: transparent; }
#fb:empty { display: none; }
#fb { margin-bottom: 10px; max-height: 32vh; overflow-y: auto; }
.fb-t { margin: 0 0 4px; font-weight: 600; font-size: 18px; display: flex; align-items: center; gap: 6px; }
.dock.ok .fb-t { color: var(--accent); }
.dock.bad .fb-t { color: var(--bad); }
.fb-t svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.fb-b { margin: 4px 0 0; font-size: 15px; }
.fb-b.hint span { font-weight: 600; margin-right: 4px; }
.fb-b code { white-space: normal; }
.primary {
  width: 100%;
  min-height: 52px;
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
}
.primary:disabled { background: var(--line); color: var(--muted); cursor: default; }
.dock.bad .primary { background: var(--bad); color: var(--bg); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- lesson complete */
.done { width: 100%; text-align: left; }
.goal-line { font-weight: 500; margin: 16px 0 0; }

@media (min-width: 700px) {
  :root { --gutter: 24px; }
  h1 { font-size: 32px; }
}
