/* DataViz Portfolio — dark chapter template */
:root {
  --bg: #070d1a;
  --panel: rgba(17, 29, 52, .86);
  --panel-solid: #0c1528;
  --line: rgba(255, 255, 255, .08);
  --text: #eaf1ff;
  --muted: #93a4c3;
  --dim: #667593;
  --cyan: #4de2ff;
  --purple: #a78bfa;
  --pink: #ff6b7a;
  --orange: #ff9f45;
  --green: #00c2a8;
  --blue: #5aa9ff;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  min-height: 100vh;
  overflow-x: hidden;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    radial-gradient(900px 520px at 82% -8%, rgba(77, 226, 255, .13), transparent 65%),
    radial-gradient(760px 480px at 12% 18%, rgba(167, 139, 250, .12), transparent 62%),
    radial-gradient(700px 520px at 55% 110%, rgba(255, 107, 168, .08), transparent 65%),
    #070d1a;
}
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: .16;
  background-image:
    linear-gradient(rgba(255, 255, 255, .05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, .05) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: linear-gradient(to bottom, #000, transparent 75%);
}
.wrap { max-width: 1200px; margin: 0 auto; padding: 0 28px; }
a { color: inherit; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(7, 13, 26, .82);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--line);
}
.topbar .wrap { height: 64px; display: flex; align-items: center; gap: 22px; }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 11px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, #4de2ff, #a78bfa);
  box-shadow: 0 8px 24px rgba(77, 226, 255, .22);
}
.brand-mark svg { width: 20px; height: 20px; stroke: #07101f; fill: none; stroke-width: 2; }
.brand b { display: block; font-size: .98rem; letter-spacing: .2px; }
.brand small { display: block; font-size: .6rem; letter-spacing: .24em; color: var(--muted); }
.nav { display: flex; gap: 26px; margin-left: auto; }
.nav a { color: var(--muted); text-decoration: none; font-size: .86rem; position: relative; padding: 6px 0; }
.nav a:hover, .nav a.active { color: var(--text); }
.nav a.active::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -2px;
  height: 2px; border-radius: 2px; background: var(--cyan);
}
.top-pill {
  white-space: nowrap;
  border: 1px solid rgba(77, 226, 255, .35);
  background: rgba(77, 226, 255, .08);
  color: #bff3ff;
  padding: 7px 16px;
  border-radius: 999px;
  font-size: .76rem;
}

/* ---------- hero ---------- */
.hero { padding: 30px 0 16px; position: relative; }
.crumb { font-size: .68rem; letter-spacing: .18em; color: var(--dim); text-transform: uppercase; }
.crumb a { text-decoration: none; color: var(--muted); }
.hero h1 {
  margin-top: 10px;
  max-width: 940px;
  font-size: clamp(1.9rem, 3.6vw, 2.9rem);
  line-height: 1.12;
  font-weight: 800;
  letter-spacing: -.02em;
  background: linear-gradient(100deg, #fff 5%, #c8dcff 48%, #7ce9ff 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero p { margin-top: 12px; max-width: 760px; color: var(--muted); font-size: .86rem; }
.hero-meta { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.chip {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .035);
  color: #b9c8e2;
  border-radius: 999px;
  padding: 5px 13px;
  font-size: .72rem;
}
.hero-meta .chip:first-child { border-style: dashed; border-color: rgba(0, 194, 168, .5); background: rgba(0, 194, 168, .07); color: #bff8e8; }
.chip.ready { color: #bff8e8; border-color: rgba(0, 194, 168, .35); background: rgba(0, 194, 168, .08); }
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; margin-right: 7px; background: var(--green); box-shadow: 0 0 10px var(--green); }
.dot.wait { background: var(--dim); box-shadow: none; }

.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin: 32px 0 20px; }
.section-head h2 { font-size: 1.3rem; letter-spacing: .2px; }
.section-head p { color: var(--muted); font-size: .84rem; margin-top: 4px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; }
.filter-btn {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .04);
  color: var(--muted);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: .76rem;
  cursor: pointer;
  transition: .2s;
}
.filter-btn:hover { color: var(--text); }
.filter-btn.active { background: rgba(77, 226, 255, .13); border-color: rgba(77, 226, 255, .4); color: #c9f4ff; }

/* ---------- chapter cards ---------- */
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; padding-bottom: 54px; }
.card {
  --accent: var(--cyan);
  --accent2: var(--purple);
  position: relative;
  overflow: hidden;
  min-height: 286px;
  display: flex;
  flex-direction: column;
  padding: 22px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: linear-gradient(160deg, rgba(22, 36, 64, .92), rgba(10, 17, 32, .95));
  color: var(--text);
  text-decoration: none;
  transition: transform .28s ease, box-shadow .28s ease, border-color .28s ease;
  animation: rise .55s both;
}
.card::before {
  content: ""; position: absolute; top: 0; left: 10%; right: 10%; height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
}
.card::after {
  content: ""; position: absolute; width: 200px; height: 200px; right: -80px; top: -90px;
  border-radius: 50%; background: var(--accent); opacity: .06; filter: blur(24px);
}
.card:hover { transform: translateY(-5px); border-color: rgba(255, 255, 255, .2); box-shadow: 0 20px 48px rgba(0, 0, 0, .5); }
.card-top { display: flex; align-items: flex-start; justify-content: space-between; position: relative; z-index: 1; }
.card-num {
  font-size: 2.7rem; font-weight: 800; line-height: 1;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.card-icon {
  width: 40px; height: 40px; border-radius: 11px;
  display: grid; place-items: center;
  border: 1px solid var(--line); background: rgba(255, 255, 255, .035);
}
.card-icon svg { width: 21px; height: 21px; fill: none; stroke: var(--accent); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.card-kicker { margin-top: 16px; font-size: .64rem; letter-spacing: .24em; font-weight: 700; color: var(--accent); }
.card h3 { margin-top: 7px; font-size: 1.02rem; line-height: 1.4; font-weight: 700; }
.card p { margin-top: 8px; flex: 1; color: var(--muted); font-size: .79rem; line-height: 1.6; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.tag {
  font-size: .66rem; padding: 3px 8px; border-radius: 6px;
  background: rgba(255, 255, 255, .045); border: 1px solid var(--line); color: #b9c8e2;
}
.card-foot {
  margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line);
  display: flex; justify-content: space-between; align-items: center;
  font-size: .73rem; color: var(--dim); position: relative; z-index: 1;
}
.card-foot .ready { color: var(--green); }
.card-foot .go { color: var(--accent); font-weight: 700; }
.card[hidden] { display: none; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* ---------- chapter page ---------- */
.chapter-hero { padding: 58px 0 18px; position: relative; }
.chapter-hero .ghost {
  position: absolute; right: 22px; top: 16px; z-index: -1;
  font-size: clamp(7rem, 15vw, 12rem); font-weight: 900; line-height: 1;
  color: rgba(255, 255, 255, .035); pointer-events: none;
}
.chapter-hero h1 { margin-top: 18px; font-size: clamp(1.9rem, 3.6vw, 3rem); line-height: 1.25; max-width: 900px;
  background: linear-gradient(100deg, #fff, #c8dcff 55%, #7ce9ff); -webkit-background-clip: text; background-clip: text; color: transparent; }
.chapter-hero p { margin-top: 16px; max-width: 800px; color: var(--muted); }
.chapter-hero .tags { margin-top: 18px; }

.works { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; padding: 4px 0 30px; }
.work {
  border: 1px solid var(--line); border-radius: 16px; overflow: hidden;
  background: linear-gradient(160deg, rgba(21, 33, 59, .86), rgba(10, 17, 32, .92));
}
.work .frame { aspect-ratio: 16 / 10; background: #fff; display: grid; place-items: center; overflow: hidden; }
.work .frame img { width: 100%; height: 100%; object-fit: contain; cursor: zoom-in; }
.work .frame svg { width: 100%; height: 100%; display: block; background: #0b1222; }
.work .caption { padding: 15px 18px 17px; }
.work .caption b { display: block; font-size: .94rem; }
.work .caption span { display: block; color: var(--muted); font-size: .8rem; margin-top: 4px; }

.code-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; padding-bottom: 34px; }
.code-card { border: 1px solid var(--line); border-radius: 16px; padding: 20px;
  background: linear-gradient(160deg, rgba(21, 33, 59, .84), rgba(10, 17, 32, .9)); }
.code-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.code-head h4 { font-size: .92rem; }
.copy-btn { border: 1px solid var(--line); background: rgba(255, 255, 255, .045); color: var(--muted);
  border-radius: 8px; padding: 4px 11px; font-size: .72rem; cursor: pointer; }
.copy-btn:hover { color: var(--text); }
pre { background: #060a14; border: 1px solid var(--line); border-radius: 12px; padding: 16px; overflow: auto;
  font-size: .76rem; line-height: 1.75; color: #cfe3ff; }
code { font-family: "Cascadia Code", Consolas, "Microsoft YaHei", monospace; }
.kw { color: #ff8fb1; } .fn { color: #7ce9ff; } .st { color: #ffd58a; } .cm { color: #6c7d99; }

.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; padding: 8px 0 66px; }
.pager a { border: 1px solid var(--line); border-radius: 14px; padding: 18px 20px; text-decoration: none;
  background: rgba(255, 255, 255, .03); transition: .25s; }
.pager a:hover { border-color: rgba(77, 226, 255, .45); background: rgba(77, 226, 255, .06); }
.pager small { display: block; color: var(--dim); font-size: .72rem; }
.pager strong { display: block; margin-top: 5px; font-size: .95rem; }
.pager .next { text-align: right; }
.pager .home-only { grid-column: 1 / -1; text-align: center; }

footer { border-top: 1px solid var(--line); padding: 26px 0 44px; color: var(--dim); font-size: .76rem; }
footer .wrap { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
footer a { color: var(--muted); text-decoration: none; }

.lightbox { position: fixed; inset: 0; z-index: 100; display: none; align-items: center; justify-content: center;
  background: rgba(3, 6, 14, .88); padding: 24px; cursor: zoom-out; }
.lightbox.show { display: flex; }
.lightbox img { max-width: 94vw; max-height: 88vh; border-radius: 12px; box-shadow: 0 24px 70px rgba(0, 0, 0, .6); }

@media (max-width: 980px) { .grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 760px) {
  .nav { display: none; }
  .works, .code-grid { grid-template-columns: 1fr; }
  .hero { padding-top: 54px; }
  .section-head { align-items: flex-start; flex-direction: column; }
}
@media (max-width: 620px) {
  .grid { grid-template-columns: 1fr; }
  .wrap { padding: 0 18px; }
  .top-pill { display: none; }
}
