/* G Code production build — brand: near-black #121110, gold #e8a317,
   cream #f7f3ec. Archivo for display, JetBrains Mono for code — both
   self-hosted (build sheet B3: zero third-party load-time calls). */

@font-face {
  font-family: 'Archivo';
  src: url('fonts/archivo-var.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Archivo Black';
  src: url('fonts/Archivo-Black.ttf') format('truetype');
  font-weight: 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'JetBrains Mono';
  src: url('fonts/jetbrains-mono-var.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #121110;
  --card: #1d1b18;
  --card-2: #262320;
  --line: #35312b;
  --gold: #e8a317;
  --gold-dim: #9a6d10;
  --cream: #f7f3ec;
  --muted: #b8b0a1;
  --good: #6fbf73;
  --bad: #e0685c;
  --radius: 14px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--cream);
  font-family: 'Archivo', 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.45;
}
#app { max-width: 480px; margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; }

/* ---------- top bar ---------- */
#topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px;
  background: rgba(18, 17, 16, 0.97);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-icon { width: 36px; height: 36px; border-radius: 8px; }
.brand-name { font-family: 'Archivo Black', 'Archivo', sans-serif; font-weight: 900; letter-spacing: 2px; font-size: 20px; color: var(--cream); }
.chips { display: flex; gap: 8px; }
.chip {
  background: var(--card-2); border: 1px solid var(--line); color: var(--gold);
  border-radius: 999px; padding: 4px 10px; font-size: 13px; font-weight: 700;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
}

/* ---------- layout ---------- */
#view { flex: 1; padding: 16px 16px 96px; }
h1.hero { font-family: 'Archivo Black', 'Archivo', sans-serif; font-weight: 900; font-size: 27px; line-height: 1.18; margin: 6px 0 8px; }
h1.hero .gold { color: var(--gold); }
h2.section { font-size: 19px; font-weight: 800; margin: 22px 0 10px; }
.sub { color: var(--muted); margin: 0 0 12px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; margin: 0 0 12px;
}
.card.gold-edge { border-color: var(--gold-dim); }

/* ---------- buttons ---------- */
button { font-family: inherit; cursor: pointer; }
.btn {
  display: inline-block; border: none; border-radius: 10px; padding: 12px 18px;
  font-size: 16px; font-weight: 800; background: var(--gold); color: #171410;
  transition: transform 0.06s ease, filter 0.15s ease;
}
.btn:active { transform: scale(0.97); }
.btn.secondary { background: var(--card-2); color: var(--cream); border: 1px solid var(--line); }
.btn.danger { background: transparent; color: var(--bad); border: 1px solid var(--bad); }
.btn.block { display: block; width: 100%; text-align: center; }
.btn:disabled { filter: grayscale(0.6) brightness(0.7); cursor: default; }

/* ---------- stats / progress ---------- */
.stats-row { display: flex; gap: 10px; }
.stat { flex: 1; text-align: center; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 4px; }
.stat .num { font-family: 'JetBrains Mono', monospace; font-size: 22px; font-weight: 700; color: var(--gold); }
.stat .lbl { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }
.progress-wrap { margin: 10px 0 4px; }
.progress-label { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); margin-bottom: 5px; }
.progress-bar { height: 10px; background: var(--card-2); border-radius: 999px; overflow: hidden; border: 1px solid var(--line); }
.progress-fill { height: 100%; background: var(--gold); border-radius: 999px; transition: width 0.4s ease; }

/* ---------- lesson cards ---------- */
.lesson-card { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 13px 14px; margin: 0 0 10px; color: var(--cream); transition: transform 0.06s ease; }
.lesson-card:active { transform: scale(0.985); }
.lesson-card .lc-main { flex: 1; min-width: 0; }
.lesson-card .lc-title { font-weight: 700; font-size: 16px; }
.lesson-card .lc-meta { font-size: 13px; color: var(--muted); font-family: 'JetBrains Mono', monospace; }
.lesson-card .lc-state { font-size: 20px; }
.lesson-card.done { border-color: var(--gold-dim); }
.lesson-card .lc-score { font-size: 12px; color: var(--gold); font-family: 'JetBrains Mono', monospace; }

/* ---------- tab bar ---------- */
#tabbar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 480px; z-index: 20;
  display: flex; background: rgba(24, 22, 20, 0.98); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
#tabbar .tab {
  flex: 1; background: none; border: none; color: var(--muted);
  padding: 8px 2px 10px; font-size: 12px; font-weight: 700;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
#tabbar .tab .tab-ico { font-size: 19px; line-height: 1; }
#tabbar .tab.active { color: var(--gold); }

/* ---------- lesson view ---------- */
#lesson-overlay {
  position: fixed; inset: 0; z-index: 40; background: var(--bg);
  overflow-y: auto; -webkit-overflow-scrolling: touch;
}
.lesson-inner { max-width: 480px; margin: 0 auto; padding: calc(14px + env(safe-area-inset-top, 0px)) 16px 48px; }
.lesson-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.lesson-head .back { background: var(--card-2); border: 1px solid var(--line); color: var(--cream); border-radius: 10px; padding: 8px 12px; font-weight: 800; }
.step-dots { display: flex; gap: 6px; margin: 10px 0 16px; }
.step-dots .dot { flex: 1; height: 6px; border-radius: 999px; background: var(--card-2); border: 1px solid var(--line); }
.step-dots .dot.on { background: var(--gold); border-color: var(--gold); }
.read p { margin: 0 0 12px; font-size: 17px; }
.term-card { background: var(--card); border-left: 4px solid var(--gold); border-radius: 8px; padding: 10px 12px; margin: 0 0 12px; }
.term-card .term-name { font-weight: 900; color: var(--gold); text-transform: lowercase; }
.code-block {
  background: #0b0a09; border: 1px solid var(--line); border-radius: 10px;
  padding: 12px; margin: 0 0 14px; overflow-x: auto;
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 14px; line-height: 1.55; white-space: pre; color: #efe9dc;
}
textarea.code-edit {
  width: 100%; min-height: 170px; resize: vertical;
  background: #0b0a09; color: #efe9dc; border: 1px solid var(--line); border-radius: 10px;
  padding: 12px; font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 15px; line-height: 1.55;
}
.output-box {
  background: #0b0a09; border: 1px solid var(--line); border-radius: 10px;
  padding: 12px; margin: 12px 0; min-height: 44px;
  font-family: 'JetBrains Mono', monospace; font-size: 14px; white-space: pre-wrap; word-break: break-word;
}
.output-box:empty::before { content: 'Output will show here.'; color: var(--muted); }
.feedback { border-radius: 10px; padding: 11px 12px; margin: 12px 0; font-weight: 700; display: none; }
.feedback.show { display: block; }
.feedback.good { background: rgba(111, 191, 115, 0.14); border: 1px solid var(--good); color: #a9dfae; }
.feedback.bad { background: rgba(224, 104, 92, 0.12); border: 1px solid var(--bad); color: #f0aca5; }
.err-text { color: var(--bad); }

/* ---------- quiz / options ---------- */
.q-text { font-size: 17px; font-weight: 700; margin: 4px 0 12px; }
.opt-btn {
  display: block; width: 100%; text-align: left; background: var(--card);
  border: 1px solid var(--line); color: var(--cream); border-radius: 10px;
  padding: 12px 14px; margin: 0 0 9px; font-size: 16px; transition: transform 0.06s ease;
}
.opt-btn:active { transform: scale(0.985); }
.opt-btn.picked-good { border-color: var(--good); background: rgba(111, 191, 115, 0.14); }
.opt-btn.picked-bad { border-color: var(--bad); background: rgba(224, 104, 92, 0.12); }
.opt-btn:disabled { opacity: 0.85; cursor: default; }
.explain { color: var(--muted); font-size: 15px; margin: 8px 0 14px; display: none; }
.explain.show { display: block; }

/* ---------- path / pricing ---------- */
.step-card { display: flex; gap: 12px; }
.step-num {
  flex: 0 0 38px; height: 38px; border-radius: 50%; background: var(--gold); color: #171410;
  font-family: 'Archivo Black', 'Archivo', sans-serif; font-weight: 900; font-size: 18px;
  display: flex; align-items: center; justify-content: center;
}
a.ext-link { color: var(--gold); font-weight: 700; text-decoration: none; }
a.ext-link:active { text-decoration: underline; }
.price-big { font-family: 'JetBrains Mono', monospace; font-size: 24px; color: var(--gold); font-weight: 700; }
.fine { font-size: 13px; color: var(--muted); }

/* ---------- profile / forms ---------- */
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 5px; }
.field input {
  width: 100%; background: var(--card-2); border: 1px solid var(--line); border-radius: 10px;
  color: var(--cream); padding: 11px 12px; font-size: 16px; font-family: inherit;
}
.saved-note { color: var(--good); font-size: 14px; font-weight: 700; display: none; margin-top: 8px; }
.saved-note.show { display: block; }

/* ---------- celebration ---------- */
#celebration {
  position: fixed; inset: 0; z-index: 60; background: rgba(10, 9, 8, 0.94);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
#celebration[hidden] { display: none; }
.cele-box { text-align: center; max-width: 360px; animation: pop 0.35s ease; }
.cele-box .big { font-size: 64px; }
.cele-box .xp { font-family: 'Archivo Black', 'Archivo', sans-serif; font-weight: 900; font-size: 44px; color: var(--gold); margin: 6px 0; }
.cele-box p { color: var(--muted); }
@keyframes pop { from { transform: scale(0.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.confetti { position: absolute; font-size: 22px; animation: fall 1.6s ease-in forwards; pointer-events: none; }
@keyframes fall { from { transform: translateY(-10vh) rotate(0deg); opacity: 1; } to { transform: translateY(60vh) rotate(300deg); opacity: 0; } }

.splash { text-align: center; padding: 18px 0 6px; }
.splash img { width: 92px; height: 92px; border-radius: 20px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.mt { margin-top: 14px; }
