/* ==========================================================
   PyPath · Python 学习路线图  样式表
   ========================================================== */

:root {
  --bg: #f4f6fb;
  --bg-soft: #ffffff;
  --card: #ffffff;
  --card-2: #f8fafc;
  --text: #1e293b;
  --text-2: #64748b;
  --text-3: #94a3b8;
  --line: #e5e9f2;
  --brand: #3776ab;
  --brand-2: #ffd43b;
  --ok: #16a34a;
  --warn: #f59e0b;
  --danger: #ef4444;
  --l1: #3b82f6;
  --l2: #8b5cf6;
  --l3: #f59e0b;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 8px 24px -12px rgba(15, 23, 42, .12);
  --shadow-lg: 0 24px 60px -28px rgba(15, 23, 42, .3);
  --mono: "JetBrains Mono", "Cascadia Code", "SFMono-Regular", Consolas, "Courier New", monospace;
}

html[data-theme="dark"] {
  --bg: #0b1120;
  --bg-soft: #111827;
  --card: #131c31;
  --card-2: #0f1729;
  --text: #e6edf7;
  --text-2: #9aa8bf;
  --text-3: #6b7a94;
  --line: #22304b;
  --brand: #63a4d8;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px -16px rgba(0, 0, 0, .6);
  --shadow-lg: 0 30px 70px -30px rgba(0, 0, 0, .8);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { margin: 0 0 .5em; line-height: 1.3; font-weight: 700; letter-spacing: -.01em; }
p { margin: 0 0 1em; }

.container { width: min(1180px, 100% - 40px); margin: 0 auto; }
.narrow { width: min(880px, 100% - 40px); margin: 0 auto; }

/* ---------------- 顶部导航 ---------------- */
.nav {
  position: sticky; top: 0; z-index: 50;
  background: var(--bg-soft);
  background: color-mix(in srgb, var(--bg-soft) 88%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line);
}
.nav-inner {
  display: flex; align-items: center; gap: 10px;
  height: 62px;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 800; font-size: 17px; color: var(--text);
  margin-right: 8px; white-space: nowrap;
}
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 9px;
  display: grid; place-items: center; font-size: 17px;
  background: linear-gradient(135deg, var(--brand), #245b8a);
  box-shadow: 0 6px 16px -8px var(--brand);
}
.brand small { display: block; font-size: 11px; font-weight: 500; color: var(--text-3); letter-spacing: .06em; }
.nav-links { display: flex; gap: 4px; margin-left: auto; flex-wrap: wrap; }
.nav-links a {
  padding: 7px 13px; border-radius: 999px; font-size: 14px;
  color: var(--text-2); font-weight: 600;
}
.nav-links a:hover { background: var(--card-2); color: var(--text); text-decoration: none; }
.nav-links a.active { background: var(--brand); color: #fff; }
.icon-btn {
  border: 1px solid var(--line); background: var(--card); color: var(--text-2);
  width: 36px; height: 36px; border-radius: 10px; cursor: pointer;
  font-size: 15px; display: grid; place-items: center; flex: none;
}
.icon-btn:hover { color: var(--text); border-color: var(--text-3); }

/* ---------------- 通用组件 ---------------- */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 22px;
}
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 10px 18px; border-radius: 999px; border: 1px solid transparent;
  background: var(--brand); color: #fff; font-weight: 700; font-size: 14px;
  cursor: pointer; font-family: inherit; transition: transform .12s, box-shadow .12s, background .12s;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 10px 24px -12px var(--brand); text-decoration: none; }
.btn:active { transform: translateY(0); }
.btn.ghost { background: var(--card); color: var(--text); border-color: var(--line); }
.btn.ghost:hover { border-color: var(--brand); color: var(--brand); box-shadow: none; }
.btn.sm { padding: 7px 13px; font-size: 13px; }
.btn.ok { background: var(--ok); }
.btn.ok:hover { box-shadow: 0 10px 24px -12px var(--ok); }
.btn[disabled] { opacity: .5; cursor: not-allowed; transform: none !important; box-shadow: none !important; }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700;
  background: var(--card-2); color: var(--text-2); border: 1px solid var(--line);
}
.badge.b1 { background: rgba(59,130,246,.12); color: var(--l1); border-color: rgba(59,130,246,.25); }
.badge.b2 { background: rgba(139,92,246,.12); color: var(--l2); border-color: rgba(139,92,246,.25); }
.badge.b3 { background: rgba(245,158,11,.14); color: var(--l3); border-color: rgba(245,158,11,.3); }
.badge.ok { background: rgba(22,163,74,.12); color: var(--ok); border-color: rgba(22,163,74,.25); }

.bar { height: 9px; border-radius: 999px; background: var(--card-2); overflow: hidden; border: 1px solid var(--line); }
.bar > i { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--brand), #5aa9e6); transition: width .5s ease; }
.bar.l1 > i { background: linear-gradient(90deg, var(--l1), #7cb0fb); }
.bar.l2 > i { background: linear-gradient(90deg, var(--l2), #b394fb); }
.bar.l3 > i { background: linear-gradient(90deg, var(--l3), #fbc768); }

.muted { color: var(--text-2); }
.tiny { font-size: 12.5px; }
.center { text-align: center; }
.row { display: flex; gap: 14px; flex-wrap: wrap; }
.grid { display: grid; gap: 18px; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }

/* ---------------- 首页 Hero ---------------- */
.hero {
  position: relative; overflow: hidden;
  padding: 64px 0 52px;
  background:
    radial-gradient(900px 380px at 12% -10%, rgba(55,118,171,.18), transparent 60%),
    radial-gradient(700px 320px at 88% 0%, rgba(255,212,59,.22), transparent 62%);
}
.hero h1 { font-size: clamp(28px, 4.4vw, 46px); margin-bottom: 14px; }
.hero h1 em { font-style: normal; color: var(--brand); }
.hero .lead { font-size: clamp(15px, 1.6vw, 17.5px); color: var(--text-2); max-width: 660px; }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 26px; }
.hero-stats { display: flex; gap: 34px; flex-wrap: wrap; margin-top: 38px; }
.hero-stats b { display: block; font-size: 27px; letter-spacing: -.02em; }
.hero-stats span { font-size: 13px; color: var(--text-2); }

/* ---------------- 等级卡片 ---------------- */
.levels { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 20px; }
.level-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 24px; position: relative; overflow: hidden;
  box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 14px;
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}
.level-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.level-card::before {
  content: ""; position: absolute; inset: 0 0 auto; height: 4px;
  background: var(--accent, var(--brand));
}
.level-card .lc-top { display: flex; align-items: center; gap: 12px; }
.level-card .lc-ico {
  width: 46px; height: 46px; border-radius: 13px; display: grid; place-items: center;
  font-size: 23px; background: rgba(55, 118, 171, .12);
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  flex: none;
}
.level-card h3 { margin: 0; font-size: 19px; }
.level-card .lc-sub { font-size: 12.5px; color: var(--accent); font-weight: 700; letter-spacing: .04em; }
.level-card ul { margin: 0; padding-left: 20px; color: var(--text-2); font-size: 14px; }
.level-card li { margin-bottom: 4px; }
.lc-meta { display: flex; gap: 8px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-2); }
.lc-meta span { background: var(--card-2); border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; }
.level-card .lc-foot { margin-top: auto; }

/* ---------------- 课程列表 ---------------- */
.lesson-list { display: grid; gap: 10px; }
.lesson {
  display: flex; align-items: center; gap: 14px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 13px 16px; cursor: pointer; transition: border-color .14s, transform .14s, background .14s;
}
.lesson:hover { border-color: var(--accent, var(--brand)); transform: translateX(3px); }
.lesson.done { background: rgba(22, 163, 74, .07); background: color-mix(in srgb, var(--ok) 7%, var(--card)); }
.lesson .no {
  width: 38px; height: 38px; flex: none; border-radius: 10px;
  display: grid; place-items: center; font-weight: 800; font-size: 13px;
  background: var(--card-2); border: 1px solid var(--line); color: var(--text-2);
}
.lesson.done .no { background: var(--ok); border-color: var(--ok); color: #fff; }
.lesson .li-main { min-width: 0; flex: 1; }
.lesson .li-title { font-weight: 700; font-size: 14.5px; }
.lesson .li-sub { font-size: 12.5px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lesson .li-right { font-size: 12.5px; color: var(--text-3); white-space: nowrap; }

/* ---------------- 课程详情 ---------------- */
.detail-head { display: flex; align-items: flex-start; gap: 18px; flex-wrap: wrap; }
.detail-head h2 { font-size: clamp(21px, 2.6vw, 28px); margin-bottom: 6px; }
.sec { margin-top: 26px; }
.sec-title {
  display: flex; align-items: center; gap: 9px;
  font-size: 15px; font-weight: 800; margin-bottom: 12px;
}
.sec-title::before {
  content: ""; width: 4px; height: 17px; border-radius: 3px;
  background: var(--accent, var(--brand));
}
.points { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.points li {
  display: flex; gap: 10px; align-items: flex-start;
  background: var(--card-2); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 10px 13px; font-size: 14px;
}
.points li::before { content: "▸"; color: var(--accent, var(--brand)); font-weight: 800; }

/* 代码块 */
.code-wrap {
  border-radius: 12px; overflow: hidden; border: 1px solid #1e293b;
  background: #0f172a; box-shadow: var(--shadow);
}
.code-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 14px; background: #16213a; border-bottom: 1px solid #20304f;
  font-size: 12.5px; color: #93a4c4; font-family: var(--mono);
}
.dots { display: flex; gap: 5px; }
.dots i { width: 10px; height: 10px; border-radius: 50%; display: block; }
.dots i:nth-child(1) { background: #ff5f57; }
.dots i:nth-child(2) { background: #febc2e; }
.dots i:nth-child(3) { background: #28c840; }
.code-bar .fname { margin-left: 4px; }
.code-bar .copy {
  margin-left: auto; background: #22304b; color: #cfe0f5; border: 0;
  border-radius: 7px; padding: 4px 11px; font-size: 12px; cursor: pointer;
  font-family: inherit; font-weight: 600;
}
.code-bar .copy:hover { background: #2d4066; }
pre {
  margin: 0; padding: 16px; overflow: auto; max-height: 460px;
  font-family: var(--mono); font-size: 13px; line-height: 1.65;
  color: #d6e4f7; tab-size: 4;
}
pre code { font-family: inherit; }
/* 简易语法高亮 */
.tk-key { color: #ff7b9c; }
.tk-str { color: #a5e075; }
.tk-com { color: #6b7fa8; font-style: italic; }
.tk-num { color: #ffcb6b; }
.tk-def { color: #82d2ff; }
.tk-bi  { color: #c792ea; }

.note {
  border-left: 3px solid var(--accent, var(--brand));
  background: rgba(55, 118, 171, .07);
  background: color-mix(in srgb, var(--accent, var(--brand)) 7%, var(--card));
  padding: 12px 15px; border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 14px; color: var(--text);
}
.tip {
  display: flex; gap: 10px; align-items: flex-start;
  background: rgba(255, 212, 59, .13); border: 1px solid rgba(255, 212, 59, .4);
  border-radius: var(--radius-sm); padding: 12px 15px; font-size: 14px;
}
.tip b { flex: none; }

/* 任务勾选 */
.task {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--card); cursor: pointer; transition: background .14s, border-color .14s;
  user-select: none;
}
.task:hover { border-color: var(--accent, var(--brand)); }
.task input { display: none; }
.task .box {
  width: 21px; height: 21px; flex: none; margin-top: 2px;
  border: 2px solid var(--text-3); border-radius: 6px;
  display: grid; place-items: center; color: #fff; font-size: 12px; font-weight: 900;
  transition: background .14s, border-color .14s;
}
.task input:checked + .box { background: var(--ok); border-color: var(--ok); }
.task input:checked + .box::after { content: "✓"; }
.task input:checked ~ .t-text { color: var(--text-3); text-decoration: line-through; }
.task .t-text { font-size: 14px; }

.quiz {
  background: var(--card-2); border: 1px dashed var(--line);
  border-radius: var(--radius-sm); padding: 14px 16px; font-size: 14px;
}
.quiz summary { cursor: pointer; font-weight: 700; color: var(--accent, var(--brand)); }
.quiz p { margin: 10px 0 0; }

/* 上/下一课 */
.pager { display: flex; justify-content: space-between; gap: 12px; margin-top: 30px; flex-wrap: wrap; }

/* ---------------- 今日任务页 ---------------- */
.today-hero {
  border-radius: var(--radius); padding: 26px; color: #fff;
  background: linear-gradient(135deg, #24557f, #3776ab 55%, #4f9dd6);
  box-shadow: var(--shadow-lg); position: relative; overflow: hidden;
}
.today-hero::after {
  content: ""; position: absolute; right: -40px; top: -50px; width: 220px; height: 220px;
  border-radius: 50%; background: rgba(255, 212, 59, .22);
}
.today-hero h2 { font-size: clamp(20px, 2.6vw, 26px); }
.today-hero .muted { color: rgba(255,255,255,.78); }
.today-hero .btn { background: #fff; color: var(--brand); }
.today-hero .btn.ghost { background: rgba(255,255,255,.14); color: #fff; border-color: rgba(255,255,255,.4); }
.today-hero .btn.ghost:hover { color: #fff; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 14px; }
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 15px 16px;
}
.stat b { display: block; font-size: 24px; letter-spacing: -.02em; }
.stat span { font-size: 12.5px; color: var(--text-2); }

/* 打卡热力图 */
.heat { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 1fr); gap: 4px; overflow-x: auto; padding-bottom: 6px; }
.heat i {
  width: 13px; height: 13px; border-radius: 3px; display: block;
  background: var(--card-2); border: 1px solid var(--line);
}
.heat i.lv1 { background: rgba(22, 163, 74, .3); background: color-mix(in srgb, var(--ok) 30%, var(--card)); border-color: transparent; }
.heat i.lv2 { background: rgba(22, 163, 74, .6); background: color-mix(in srgb, var(--ok) 60%, var(--card)); border-color: transparent; }
.heat i.lv3 { background: var(--ok); border-color: transparent; }
.heat i.today { outline: 2px solid var(--brand); outline-offset: 1px; }

/* 表单 */
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 13px; font-weight: 700; color: var(--text-2); }
input[type="date"], select, input[type="number"] {
  font-family: inherit; font-size: 14px; padding: 9px 12px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--card); color: var(--text); width: 100%;
}
input:focus, select:focus { outline: 2px solid color-mix(in srgb, var(--brand) 40%, transparent); border-color: var(--brand); }

/* 今日课程块 */
.day-block { border-left: 4px solid var(--accent, var(--brand)); }
.day-block + .day-block { margin-top: 16px; }

.empty {
  text-align: center; padding: 46px 20px; color: var(--text-2);
  border: 1px dashed var(--line); border-radius: var(--radius); background: var(--card);
}

/* 页脚 */
.footer {
  margin-top: 60px; padding: 30px 0 44px; border-top: 1px solid var(--line);
  color: var(--text-3); font-size: 13px;
}
.footer .container { display: flex; justify-content: space-between; gap: 14px; flex-wrap: wrap; }

/* 回到顶部 */
.totop {
  position: fixed; right: 22px; bottom: 22px; z-index: 40;
  width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--card); color: var(--text-2); cursor: pointer;
  box-shadow: var(--shadow); display: none; place-items: center; font-size: 16px;
}
.totop.show { display: grid; }

/* 打印 */
@media print {
  .nav, .totop, .hero-actions, .pager, .code-bar .copy { display: none !important; }
  body { background: #fff; }
  pre { max-height: none; }
}

@media (max-width: 640px) {
  .container, .narrow { width: calc(100% - 28px); }
  .hero { padding: 40px 0 34px; }
  .card { padding: 17px; }
  .nav-links a { padding: 6px 10px; font-size: 13px; }
  .brand small { display: none; }
  .lesson .li-right { display: none; }
}
