/* ============================================================
   比特学院 Bit Academy — design system
   Mobile-first, zero-dependency. Track accent set via [data-track].
   ============================================================ */

:root {
  /* brand */
  --brand: #6c5ce7;
  --brand-2: #a29bfe;
  --ink: #1e2235;
  --ink-soft: #4a4f6a;
  --muted: #8a8fa6;
  --line: #e9eaf3;
  --bg: #f6f7fb;
  --card: #ffffff;
  --ok: #00b894;
  --warn: #fdcb6e;
  --bad: #ff7675;
  --gold: #ffb800;

  /* track accents (overridden by [data-track]) */
  --accent: #6c5ce7;
  --accent-2: #a29bfe;
  --accent-soft: #efeefe;

  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 10px 30px -12px rgba(40, 38, 80, 0.25);
  --shadow-sm: 0 4px 14px -6px rgba(40, 38, 80, 0.2);
  --maxw: 880px;
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei",
    "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}

[data-track="kids"] {
  --accent: #ff7a59;
  --accent-2: #ffb259;
  --accent-soft: #fff0ea;
}
[data-track="teens"] {
  --accent: #0aa6ff;
  --accent-2: #5ad1ff;
  --accent-soft: #e6f6ff;
}
[data-track="adults"] {
  --accent: #16a085;
  --accent-2: #5fd4b6;
  --accent-soft: #e4f6f1;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.7;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
img, svg { max-width: 100%; }

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 18px; }
.hidden { display: none !important; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line);
}
.topbar .wrap { display: flex; align-items: center; gap: 12px; height: 60px; }
.logo { display: flex; align-items: center; gap: 9px; font-weight: 800; font-size: 19px; letter-spacing: .2px; }
.logo .bot { width: 30px; height: 30px; }
.logo small { font-weight: 600; color: var(--muted); font-size: 12px; }
.topbar .spacer { flex: 1; }
.xp-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: linear-gradient(135deg, var(--gold), #ffd24d);
  color: #5b4300; font-weight: 800; font-size: 13px;
  padding: 6px 12px; border-radius: 999px; box-shadow: var(--shadow-sm);
}
.btn-ghost {
  display: inline-flex; align-items: center; justify-content: center;
  border: 1.5px solid var(--line); color: var(--ink-soft);
  padding: 7px 14px; border-radius: 999px; font-weight: 700; font-size: 13px;
  background: #fff; transition: .15s;
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; font-weight: 800; font-size: 15px;
  padding: 13px 24px; border-radius: 999px;
  box-shadow: var(--shadow-sm); transition: transform .15s, box-shadow .15s;
}
.btn:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.btn:active { transform: translateY(0); }
.btn.big { padding: 16px 32px; font-size: 17px; }
.btn.block { width: 100%; }
.btn-soft {
  background: var(--accent-soft); color: var(--accent);
  font-weight: 800; padding: 12px 22px; border-radius: 999px;
}

/* ---------- hero ---------- */
.hero { position: relative; padding: 46px 0 30px; overflow: hidden; }
.hero .wrap { position: relative; z-index: 2; }
.hero h1 { font-size: 38px; line-height: 1.2; margin: 0 0 14px; letter-spacing: -.5px; }
.hero h1 .grad {
  background: linear-gradient(120deg, var(--brand), #ff7a59 60%, #0aa6ff);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero p.lead { font-size: 17px; color: var(--ink-soft); margin: 0 0 24px; max-width: 540px; }
.hero .cta-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.hero .cta-row .btn-ghost { padding: 15px 26px; font-size: 16px; }
.blob { position: absolute; border-radius: 50%; filter: blur(36px); opacity: .5; z-index: 1; }
.blob.b1 { width: 260px; height: 260px; background: #a29bfe; top: -60px; right: -40px; }
.blob.b2 { width: 200px; height: 200px; background: #ffb259; bottom: -40px; left: -50px; }
.blob.b3 { width: 180px; height: 180px; background: #5ad1ff; top: 40px; left: 40%; opacity: .35; }

.hero-bot { width: 132px; height: 132px; display: block; margin: 4px auto 8px; }
@media (min-width: 720px) {
  .hero .wrap { display: grid; grid-template-columns: 1.3fr .7fr; align-items: center; gap: 20px; }
  .hero-bot { width: 200px; height: 200px; }
  .hero h1 { font-size: 46px; }
}
.float { animation: float 4s ease-in-out infinite; }
@keyframes float { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-12px); } }

/* ---------- section heading ---------- */
.sec { padding: 26px 0; }
.sec-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 16px; }
.sec-head h2 { font-size: 24px; margin: 0; }
.sec-head .sub { color: var(--muted); font-size: 14px; }

/* ---------- track chooser ---------- */
.tracks { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .tracks { grid-template-columns: repeat(3, 1fr); } }
.track-card {
  position: relative; border-radius: var(--radius); padding: 22px 20px;
  color: #fff; overflow: hidden; box-shadow: var(--shadow); transition: transform .18s;
  min-height: 168px; display: flex; flex-direction: column; justify-content: flex-end;
}
.track-card:hover { transform: translateY(-4px); }
.track-card .emoji { font-size: 44px; position: absolute; top: 16px; right: 18px; opacity: .95; }
.track-card h3 { margin: 0 0 4px; font-size: 22px; }
.track-card .age { font-size: 13px; opacity: .9; font-weight: 700; }
.track-card p { margin: 8px 0 0; font-size: 13.5px; opacity: .95; line-height: 1.6; }
.tc-kids { background: linear-gradient(135deg, #ff7a59, #ffb259); }
.tc-teens { background: linear-gradient(135deg, #0aa6ff, #5ad1ff); }
.tc-adults { background: linear-gradient(135deg, #16a085, #5fd4b6); }
.track-card .pill {
  display: inline-block; margin-top: 10px; background: rgba(255,255,255,.25);
  padding: 4px 12px; border-radius: 999px; font-size: 12px; font-weight: 800; backdrop-filter: blur(4px);
}

/* ---------- course list ---------- */
.track-banner {
  border-radius: var(--radius); padding: 22px 22px; color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: var(--shadow); margin-bottom: 8px; position: relative; overflow: hidden;
}
.track-banner h2 { margin: 0 0 4px; font-size: 26px; }
.track-banner p { margin: 0; opacity: .95; font-size: 14px; }
.track-banner .emoji { position: absolute; right: 16px; top: 10px; font-size: 60px; opacity: .9; }

.course-grid { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 600px) { .course-grid { grid-template-columns: 1fr 1fr; } }
.course-card {
  background: var(--card); border-radius: var(--radius); padding: 18px;
  box-shadow: var(--shadow-sm); border: 1px solid var(--line);
  display: flex; gap: 14px; align-items: flex-start; transition: transform .15s, box-shadow .15s;
  position: relative;
}
.course-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.course-card .ic {
  flex: none; width: 52px; height: 52px; border-radius: 14px; font-size: 27px;
  display: grid; place-items: center; background: var(--accent-soft);
}
.course-card .meta { flex: 1; min-width: 0; }
.course-card .ord { font-size: 12px; font-weight: 800; color: var(--accent); letter-spacing: .5px; }
.course-card h3 { margin: 2px 0 4px; font-size: 17px; }
.course-card p { margin: 0; font-size: 13px; color: var(--ink-soft); line-height: 1.55; }
.course-card .prog {
  margin-top: 10px; height: 7px; border-radius: 999px; background: var(--line); overflow: hidden;
}
.course-card .prog > i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); border-radius: 999px; transition: width .5s; }
.course-card .prog-label { font-size: 11px; color: var(--muted); margin-top: 5px; font-weight: 700; }
.course-card .done-badge { position: absolute; top: 12px; right: 14px; color: var(--ok); font-weight: 900; font-size: 18px; }
.locked { opacity: .6; }

/* ---------- lesson list inside course ---------- */
.lesson-row {
  display: flex; align-items: center; gap: 13px; padding: 14px 16px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm); margin-bottom: 10px; transition: transform .12s;
}
.lesson-row:hover { transform: translateX(3px); }
.lesson-row .num {
  flex: none; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  font-weight: 800; background: var(--accent-soft); color: var(--accent); font-size: 14px;
}
.lesson-row.done .num { background: var(--ok); color: #fff; }
.lesson-row .li-meta { flex: 1; min-width: 0; }
.lesson-row .li-meta b { font-size: 15px; display: block; }
.lesson-row .li-meta span { font-size: 12px; color: var(--muted); }
.lesson-row .go { color: var(--muted); font-size: 20px; }

/* ---------- lesson reading view ---------- */
.reader { padding-bottom: 90px; }
.reader-head { padding: 18px 0 6px; }
.crumb { font-size: 13px; color: var(--muted); font-weight: 700; margin-bottom: 8px; display: flex; align-items: center; gap: 6px; }
.crumb a:hover { color: var(--accent); }
.reader h1 { font-size: 28px; margin: 4px 0 6px; }
.reader .l-sub { color: var(--ink-soft); font-size: 14px; }
.reader .topbar-prog { height: 5px; background: var(--line); border-radius: 999px; overflow: hidden; margin: 14px 0 6px; }
.reader .topbar-prog > i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); width: 0; transition: width .4s; }

/* blocks */
.block { margin: 22px 0; animation: rise .5s both; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.b-text { font-size: 16.5px; color: var(--ink); }
.b-text p { margin: 0 0 12px; }
.b-text strong { color: var(--brand); }
.b-text code, .inline-code {
  background: #2d2b3a; color: #ffd9a8; padding: 2px 7px; border-radius: 6px;
  font-size: .88em; font-family: ui-monospace, "SF Mono", Menlo, monospace;
}

.narrator { display: flex; gap: 12px; align-items: flex-start; }
.narrator .bot { flex: none; width: 46px; height: 46px; }
.narrator .bubble {
  background: var(--accent-soft); border-radius: 4px 16px 16px 16px;
  padding: 13px 16px; font-size: 15.5px; color: var(--ink); position: relative; flex: 1;
}
.narrator .bubble b { color: var(--accent); }

.card-block { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 18px; }

.analogy {
  display: flex; gap: 14px; align-items: flex-start;
  background: linear-gradient(135deg, #fff, var(--accent-soft));
  border: 1px solid var(--line); border-left: 4px solid var(--accent);
  border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow-sm);
}
.analogy .em { font-size: 34px; flex: none; }
.analogy h4 { margin: 0 0 5px; font-size: 16px; color: var(--accent); }
.analogy p { margin: 0; font-size: 14.5px; color: var(--ink-soft); }

.term {
  background: var(--card); border: 1px dashed var(--accent); border-radius: var(--radius);
  padding: 15px 18px; box-shadow: var(--shadow-sm);
}
.term .t-top { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.term .t-zh { font-size: 19px; font-weight: 900; }
.term .t-en { font-size: 13px; color: var(--muted); font-weight: 700; letter-spacing: .3px; }
.term .t-py { font-size: 12px; color: var(--accent); font-weight: 700; }
.term .t-def { margin: 8px 0 0; font-size: 14.5px; color: var(--ink-soft); }
.term .t-tag { display: inline-block; background: var(--accent-soft); color: var(--accent); font-size: 11px; font-weight: 800; padding: 2px 9px; border-radius: 999px; }

.callout { border-radius: var(--radius); padding: 14px 18px; font-size: 14.5px; display: flex; gap: 11px; }
.callout .em { font-size: 22px; flex: none; }
.callout.tip { background: #fff8e6; border: 1px solid #ffe7a8; }
.callout.warn { background: #fff0ee; border: 1px solid #ffd4cd; }
.callout.fun { background: var(--accent-soft); border: 1px solid var(--line); }

/* "深入一点" expandable for adults */
.deep { border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; background: var(--card); }
.deep > summary {
  list-style: none; cursor: pointer; padding: 13px 16px; font-weight: 800; font-size: 14px;
  display: flex; align-items: center; gap: 8px; color: var(--ink-soft);
}
.deep > summary::-webkit-details-marker { display: none; }
.deep > summary::before { content: "🔍"; }
.deep[open] > summary { border-bottom: 1px solid var(--line); color: var(--accent); }
.deep .deep-body { padding: 6px 16px 16px; font-size: 14.5px; color: var(--ink-soft); }

/* ---------- interactive widgets ---------- */
.widget { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 18px; }
.widget .w-title { font-weight: 800; font-size: 14px; color: var(--accent); margin-bottom: 4px; display: flex; align-items: center; gap: 7px; }
.widget .w-hint { font-size: 12.5px; color: var(--muted); margin-bottom: 14px; }

/* quiz */
.quiz .q { font-size: 16px; font-weight: 700; margin-bottom: 12px; }
.quiz .opts { display: grid; gap: 10px; }
.quiz .opt {
  text-align: left; border: 1.5px solid var(--line); background: #fff; border-radius: var(--radius-sm);
  padding: 13px 16px; font-size: 15px; font-weight: 600; transition: .15s; display: flex; gap: 10px; align-items: center;
}
.quiz .opt:hover { border-color: var(--accent); }
.quiz .opt .k { flex: none; width: 24px; height: 24px; border-radius: 7px; background: var(--accent-soft); color: var(--accent); font-weight: 800; display: grid; place-items: center; font-size: 13px; }
.quiz .opt.correct { border-color: var(--ok); background: #eafaf4; }
.quiz .opt.correct .k { background: var(--ok); color: #fff; }
.quiz .opt.wrong { border-color: var(--bad); background: #fff0ee; }
.quiz .opt.wrong .k { background: var(--bad); color: #fff; }
.quiz .opt:disabled { cursor: default; }
.quiz .explain { margin-top: 12px; font-size: 14px; padding: 12px 14px; background: var(--accent-soft); border-radius: var(--radius-sm); display: none; }
.quiz .explain.show { display: block; animation: rise .3s both; }

/* request-flow diagram */
.flow { position: relative; }
.flow .stage { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 14px; }
.flow .node {
  flex: 1; text-align: center; padding: 14px 6px; border-radius: var(--radius-sm);
  border: 2px solid var(--line); background: #fff; transition: .25s; position: relative;
}
.flow .node .nem { font-size: 30px; }
.flow .node .nl { font-size: 12.5px; font-weight: 800; margin-top: 4px; }
.flow .node .nd { font-size: 10.5px; color: var(--muted); }
.flow .node.active { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); transform: translateY(-3px); }
.flow .arrow { flex: none; color: var(--muted); font-size: 18px; }
.flow .packet {
  position: absolute; top: 26px; left: 0; width: 30px; height: 30px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff;
  display: grid; place-items: center; font-size: 14px; box-shadow: var(--shadow-sm);
  opacity: 0; transition: left .7s cubic-bezier(.5,.05,.3,1), opacity .2s; z-index: 5;
}
.flow .log { font-size: 13px; min-height: 40px; padding: 10px 14px; background: #2d2b3a; color: #d8ffe9; border-radius: var(--radius-sm); font-family: ui-monospace, Menlo, monospace; }

/* match / connect */
.match .cols { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.match .mcol { display: grid; gap: 8px; }
.match .mitem {
  border: 1.5px solid var(--line); border-radius: var(--radius-sm); padding: 11px 12px; font-size: 13.5px;
  font-weight: 700; background: #fff; transition: .15s; text-align: center;
}
.match .mitem.sel { border-color: var(--accent); background: var(--accent-soft); }
.match .mitem.matched { border-color: var(--ok); background: #eafaf4; color: var(--ok); cursor: default; }
.match .mitem.bad { animation: shake .35s; }
@keyframes shake { 0%,100%{transform:none} 25%{transform:translateX(-5px)} 75%{transform:translateX(5px)} }

/* flip cards (server types / stack) */
.flips { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
@media (min-width: 560px) { .flips { grid-template-columns: repeat(3,1fr); } }
.flip { perspective: 900px; height: 150px; }
.flip-inner { position: relative; width: 100%; height: 100%; transition: transform .55s; transform-style: preserve-3d; }
.flip.open .flip-inner { transform: rotateY(180deg); }
.flip-face {
  position: absolute; inset: 0; backface-visibility: hidden; border-radius: var(--radius);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  padding: 12px; text-align: center; box-shadow: var(--shadow-sm); border: 1px solid var(--line);
}
.flip-front { background: var(--accent-soft); }
.flip-front .fem { font-size: 38px; }
.flip-front .fl { font-weight: 800; font-size: 14px; }
.flip-front .tap { font-size: 11px; color: var(--muted); }
.flip-back { background: #fff; transform: rotateY(180deg); font-size: 12.5px; color: var(--ink-soft); }
.flip-back b { color: var(--accent); display: block; margin-bottom: 4px; font-size: 13.5px; }

/* stack picker */
.stack .layer { margin-bottom: 12px; }
.stack .layer > label { font-size: 12.5px; font-weight: 800; color: var(--ink-soft); display: block; margin-bottom: 6px; }
.stack .chips { display: flex; gap: 8px; flex-wrap: wrap; }
.stack .chip {
  border: 1.5px solid var(--line); border-radius: 999px; padding: 8px 14px; font-size: 13px; font-weight: 700;
  background: #fff; transition: .15s;
}
.stack .chip.on { border-color: var(--accent); background: var(--accent); color: #fff; }
.stack .result { margin-top: 14px; padding: 14px; border-radius: var(--radius-sm); background: var(--accent-soft); font-size: 14px; }
.stack .result b { color: var(--accent); }

/* build-a-website stacker */
.builder .slot {
  border: 2px dashed var(--line); border-radius: var(--radius-sm); padding: 14px; margin-bottom: 10px;
  display: flex; align-items: center; gap: 12px; transition: .2s; background: #fff;
}
.builder .slot.filled { border-style: solid; border-color: var(--accent); background: var(--accent-soft); }
.builder .slot .sem { font-size: 26px; }
.builder .slot .sl b { font-size: 14px; } .builder .slot .sl span { font-size: 12px; color: var(--muted); }
.builder .pieces { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.builder .piece { border: 1.5px solid var(--accent); color: var(--accent); border-radius: 999px; padding: 8px 14px; font-weight: 800; font-size: 13px; background: #fff; }
.builder .piece.used { opacity: .35; pointer-events: none; }
.builder .done-msg { margin-top: 12px; font-weight: 800; color: var(--ok); display: none; }

/* ai-decode */
.decode .code-card { background: #221f30; border-radius: var(--radius-sm); padding: 16px; font-family: ui-monospace, Menlo, monospace; font-size: 13.5px; color: #e7e3ff; line-height: 1.9; }
.decode .tok { color: #ffd9a8; border-bottom: 1.5px dashed #8d7bff; cursor: pointer; padding: 0 1px; }
.decode .tok:hover { background: rgba(141,123,255,.25); }
.decode .reveal { margin-top: 12px; padding: 13px 15px; border-radius: var(--radius-sm); background: var(--accent-soft); font-size: 14px; display: none; }
.decode .reveal.show { display: block; animation: rise .3s both; }
.decode .reveal b { color: var(--accent); }

/* ---------- lesson footer nav ---------- */
.lesson-foot {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
  background: rgba(255,255,255,.9); backdrop-filter: blur(12px); border-top: 1px solid var(--line);
  padding: 10px 0;
}
.lesson-foot .wrap { display: flex; gap: 10px; align-items: center; }
.lesson-foot .btn { flex: 1; }

/* complete celebration */
.celebrate { text-align: center; padding: 30px 18px; }
.celebrate .big { font-size: 64px; }
.celebrate h2 { margin: 8px 0; }
.celebrate p { color: var(--ink-soft); }

/* badges */
.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px,1fr)); gap: 12px; }
.badge { text-align: center; }
.badge .bdg { width: 64px; height: 64px; margin: 0 auto; border-radius: 50%; display: grid; place-items: center; font-size: 30px; background: var(--accent-soft); border: 2px solid var(--line); }
.badge.earned .bdg { background: linear-gradient(135deg, var(--gold), #ffd24d); border-color: var(--gold); box-shadow: var(--shadow-sm); }
.badge.earned .bdg.lock { filter: none; }
.badge .bn { font-size: 11.5px; margin-top: 5px; font-weight: 700; color: var(--ink-soft); }
.badge:not(.earned) .bdg { filter: grayscale(1) opacity(.45); }

/* confetti */
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 99; overflow: hidden; }
.confetti i { position: absolute; width: 9px; height: 14px; top: -20px; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(540deg); opacity: .9; } }

/* footer */
.foot { text-align: center; color: var(--muted); font-size: 12.5px; padding: 30px 18px 24px; }

/* reduced motion */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
  .block { animation: none; }
}
