/* ================================================================
   main.css  —  教学网站全局样式 v2
   风格：鲜艳活泼 · 大屏投屏友好 · 手机自适应
   Python 课：青绿渐变    MySQL 课：珊瑚橙渐变
   设计参考：ardot design system
================================================================ */

/* ── CSS 变量 ─────────────────────────────────────── */
:root {
  /* === Python 品牌色（青绿系）=== */
  --py-primary:   #06D6A0;
  --py-light:     #ECFDF5;
  --py-mid:       #0CB0D6;
  --py-dark:      #047857;
  --py-grad:      linear-gradient(135deg, #06D6A0 0%, #0CB0D6 50%, #6366F1 100%);
  --py-grad-subtle: linear-gradient(135deg, rgba(6,214,160,.12) 0%, rgba(12,176,214,.12) 100%);

  /* === MySQL 品牌色（珊瑚橙系）=== */
  --sql-primary:  #FF6B6B;
  --sql-light:    #FFF5F5;
  --sql-mid:      #FF8E53;
  --sql-dark:     #E03131;
  --sql-grad:     linear-gradient(135deg, #FF6B6B 0%, #FF8E53 50%, #FFD166 100%);
  --sql-grad-subtle: linear-gradient(135deg, rgba(255,107,107,.12) 0%, rgba(255,142,83,.12) 100%);

  /* === 强调色 === */
  --accent-green:  #06D6A0;
  --accent-orange: #FF8E53;
  --accent-yellow: #FFD166;
  --accent-blue:   #0CB0D6;
  --accent-pink:   #F472B6;

  /* === 中性色 === */
  --gray-50:  #F8FAFC;
  --gray-100: #F1F5F9;
  --gray-200: #E2E8F0;
  --gray-300: #CBD5E1;
  --gray-400: #94A3B8;
  --gray-500: #64748B;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1E293B;
  --gray-900: #0F172A;

  /* === 代码区 === */
  --code-bg:  #1A1B2E;
  --code-fg:  #CDD6F4;

  /* === 圆角 === */
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --radius-full: 9999px;

  /* === 阴影 === */
  --shadow-sm: 0 1px 4px rgba(0,0,0,.06), 0 2px 4px rgba(0,0,0,.04);
  --shadow-md: 0 4px 16px rgba(0,0,0,.08), 0 2px 8px rgba(0,0,0,.04);
  --shadow-lg: 0 12px 36px rgba(0,0,0,.10), 0 4px 16px rgba(0,0,0,.05);

  /* === 布局（希沃 16:9 宽屏适配）=== */
  --max-w: 1600px;
  --nav-h: 88px;

  /* === 字体大小（放大，适配投屏）=== */
  --fs-h1:   clamp(2.6rem, 6vw, 3.8rem);
  --fs-h2:   2.0rem;
  --fs-h3:   1.45rem;
  --fs-h4:   1.25rem;
  --fs-body: 1.15rem;
  --fs-sm:   0.95rem;
  --fs-xs:   0.88rem;
  --fs-code: 1.15rem;

  /* === 动画 === */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ── 重置 ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  scroll-behavior: smooth;
  font-size: 22px;  /* 桌面端基准放大 */
}

body {
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", "Noto Sans SC", "Helvetica Neue", Arial, sans-serif;
  color: var(--gray-700);
  background: linear-gradient(180deg, #F8FAFC 0%, #F1F5F9 100%);
  line-height: 1.8;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
ul, ol { list-style: none; }
button { cursor: pointer; font: inherit; border: none; background: none; }

/* ── 顶部导航 ─────────────────────────────────────── */
.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--nav-h);
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
}

.nav-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 28px;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
}

.nav-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--gray-900);
  white-space: nowrap;
}

.nav-logo .logo-icon {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, #06D6A0 0%, #0CB0D6 50%, #6366F1 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.2rem;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(6,214,160,.3);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 6px;
}

.nav-links a {
  padding: 8px 18px;
  border-radius: var(--radius-full);
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--gray-600);
  transition: all .25s var(--ease-out);
}

.nav-links a:hover {
  background: var(--gray-100);
  color: var(--gray-900);
}

.nav-links a.active {
  background: var(--gray-100);
  color: var(--gray-900);
}

.nav-links a.py-link:hover,
.nav-links a.py-link.active {
  background: var(--py-light);
  color: var(--py-dark);
}

.nav-links a.sql-link:hover,
.nav-links a.sql-link.active {
  background: #FFF5F5;
  color: var(--sql-dark);
}

/* ── 汉堡菜单按钮（仅移动端显示） ───────────────── */
.hamburger {
  display: none;
  flex-direction: column;
  gap: 5px;
  padding: 6px;
  cursor: pointer;
  z-index: 110;
}

.hamburger span {
  display: block;
  width: 26px;
  height: 3px;
  background: var(--gray-700);
  border-radius: 3px;
  transition: all .3s var(--ease-out);
}

.hamburger.open span:nth-child(1) {
  transform: rotate(45deg) translate(5px, 6px);
}
.hamburger.open span:nth-child(2) {
  opacity: 0;
}
.hamburger.open span:nth-child(3) {
  transform: rotate(-45deg) translate(5px, -6px);
}

/* ── 面包屑 ───────────────────────────────────────── */
.breadcrumb {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 16px 28px 0;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--fs-xs);
  color: var(--gray-400);
  flex-wrap: wrap;
}

.breadcrumb a { color: var(--gray-500); transition: color .2s; }
.breadcrumb a:hover { color: var(--py-primary); }
.breadcrumb .sep { color: var(--gray-300); }

/* ── Hero 区（首页） ───────────────────────────────── */
.hero {
  padding: 80px 28px 90px;
  text-align: center;
  background:
    radial-gradient(ellipse at 20% 20%, rgba(6,214,160,.15) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(12,176,214,.15) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 80%, rgba(255,107,107,.10) 0%, transparent 50%),
    linear-gradient(180deg, #F8FAFC 0%, #EEF2FF 50%, #FFF5F5 100%);
  border-bottom: 1px solid var(--gray-200);
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background:
    radial-gradient(circle at 30% 30%, rgba(6,214,160,.08) 0%, transparent 30%),
    radial-gradient(circle at 70% 70%, rgba(255,107,107,.08) 0%, transparent 30%);
  animation: heroDrift 20s ease-in-out infinite;
  pointer-events: none;
}

@keyframes heroDrift {
  0%, 100% { transform: translate(0, 0); }
  33% { transform: translate(1%, -0.5%); }
  66% { transform: translate(-0.5%, 1%); }
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: white;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-full);
  padding: 6px 18px;
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--gray-600);
  margin-bottom: 24px;
  position: relative;
  z-index: 1;
}

.hero h1 {
  font-size: var(--fs-h1);
  font-weight: 800;
  color: var(--gray-900);
  line-height: 1.25;
  margin-bottom: 20px;
  position: relative;
  z-index: 1;
}

.hero h1 .highlight-py {
  background: var(--py-grad);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero h1 .highlight-sql {
  background: var(--sql-grad);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero p {
  font-size: var(--fs-body);
  color: var(--gray-500);
  max-width: 720px;
  margin: 0 auto 40px;
  position: relative;
  z-index: 1;
}

.hero-stats {
  display: flex;
  justify-content: center;
  gap: 36px;
  flex-wrap: wrap;
  position: relative;
  z-index: 1;
}

.hero-stats .stat {
  text-align: center;
  background: white;
  padding: 16px 28px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-100);
}

.hero-stats .stat-num {
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--gray-900);
  line-height: 1;
  background: var(--py-grad);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-stats .stat-label {
  font-size: var(--fs-xs);
  color: var(--gray-400);
  margin-top: 6px;
  font-weight: 500;
}

/* ── 页面主体容器 ─────────────────────────────────── */
.page-body {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 48px 28px 90px;
}

/* ── 章节标题区 ───────────────────────────────────── */
.section-header {
  margin-bottom: 32px;
}

.section-header h2 {
  font-size: var(--fs-h2);
  font-weight: 800;
  color: var(--gray-900);
  margin-bottom: 8px;
  letter-spacing: -0.02em;
}

.section-header p {
  font-size: var(--fs-body);
  color: var(--gray-500);
}

/* ── 通用卡片网格 ─────────────────────────────────── */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 24px;
}

.card-grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(440px, 1fr));
  gap: 28px;
}

/* ── 课程大卡片（首页） ──────────────────────────── */
.course-card {
  border-radius: var(--radius-xl);
  overflow: hidden;
  background: white;
  box-shadow: var(--shadow-md);
  transition: transform .3s var(--ease-spring), box-shadow .3s;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--gray-100);
}

.course-card:hover {
  transform: translateY(-8px);
  box-shadow: var(--shadow-lg);
}

.course-card-header {
  padding: 36px 32px 28px;
  position: relative;
  overflow: hidden;
}

.course-card-header::before {
  content: '';
  position: absolute;
  right: -40px;
  bottom: -40px;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  opacity: .15;
  background: white;
}

.course-card-header::after {
  content: '';
  position: absolute;
  right: 20px;
  top: -30px;
  width: 100px;
  height: 100px;
  border-radius: 50%;
  opacity: .08;
  background: white;
}

.course-card.py .course-card-header { background: var(--py-grad); }
.course-card.sql .course-card-header { background: var(--sql-grad); }

.course-icon {
  width: 60px;
  height: 60px;
  background: rgba(255,255,255,.25);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  margin-bottom: 16px;
  position: relative;
  z-index: 1;
}

.course-card-header h3 {
  font-size: 1.5rem;
  font-weight: 800;
  color: white;
  margin-bottom: 8px;
  position: relative;
  z-index: 1;
}

.course-card-header p {
  font-size: var(--fs-sm);
  color: rgba(255,255,255,.85);
  line-height: 1.6;
  position: relative;
  z-index: 1;
}

.course-card-body {
  padding: 24px 32px 32px;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.course-meta {
  display: flex;
  gap: 24px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.meta-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--fs-sm);
  color: var(--gray-500);
  font-weight: 500;
}

.meta-item .meta-icon {
  font-size: 1.2rem;
}

.course-tags {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 28px;
  flex: 1;
}

.tag {
  background: var(--gray-100);
  color: var(--gray-600);
  border-radius: var(--radius-full);
  padding: 5px 14px;
  font-size: var(--fs-xs);
  font-weight: 600;
}

.tag.py { background: var(--py-light); color: var(--py-dark); }
.tag.sql { background: var(--sql-light); color: var(--sql-dark); }

.btn-course {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 15px 24px;
  border-radius: var(--radius-md);
  font-size: 1rem;
  font-weight: 700;
  transition: all .25s var(--ease-out);
}

.btn-course.py {
  background: var(--py-light);
  color: var(--py-dark);
}
.btn-course.py:hover {
  background: var(--py-grad);
  color: white;
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(6,214,160,.3);
}

.btn-course.sql {
  background: var(--sql-light);
  color: var(--sql-dark);
}
.btn-course.sql:hover {
  background: var(--sql-grad);
  color: white;
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(255,107,107,.3);
}

/* ── 章节卡片（课程首页） ────────────────────────── */
.chapter-card {
  background: white;
  border-radius: var(--radius-lg);
  border: 1.5px solid var(--gray-200);
  padding: 24px 26px;
  transition: all .25s var(--ease-out);
  display: flex;
  flex-direction: column;
  gap: 14px;
  cursor: pointer;
}

.chapter-card:hover {
  border-color: transparent;
  box-shadow: var(--shadow-md);
  transform: translateY(-3px);
}

.chapter-card.py:hover {
  border-color: var(--py-mid);
  background: linear-gradient(135deg, white 0%, var(--py-light) 100%);
}

.chapter-card.sql:hover {
  border-color: var(--sql-mid);
  background: linear-gradient(135deg, white 0%, var(--sql-light) 100%);
}

.chapter-num {
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: .06em;
  color: var(--gray-400);
  text-transform: uppercase;
}

.chapter-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--gray-900);
  line-height: 1.4;
}

.chapter-desc {
  font-size: var(--fs-sm);
  color: var(--gray-500);
  line-height: 1.6;
}

.chapter-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 6px;
}

.chapter-progress {
  flex: 1;
  height: 5px;
  background: var(--gray-100);
  border-radius: var(--radius-full);
  margin-right: 12px;
  overflow: hidden;
}

.chapter-progress-bar {
  height: 100%;
  border-radius: var(--radius-full);
  background: var(--gray-300);
  width: 0%;
  transition: width .5s var(--ease-out);
}

.chapter-card.py .chapter-progress-bar { background: var(--py-grad); }
.chapter-card.sql .chapter-progress-bar { background: var(--sql-grad); }

.chapter-badge {
  font-size: var(--fs-xs);
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-weight: 600;
  white-space: nowrap;
}

.badge-new { background: #ECFDF5; color: #047857; }
.badge-doing { background: #EFF6FF; color: #1D4ED8; }
.badge-done { background: var(--gray-100); color: var(--gray-500); }

/* ── 章节4功能入口卡片 ───────────────────────────── */
.entry-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
  margin-top: 32px;
}

.entry-card {
  background: white;
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  border: 1.5px solid var(--gray-200);
  transition: all .25s var(--ease-out);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  cursor: pointer;
}

.entry-card:hover {
  border-color: transparent;
  box-shadow: var(--shadow-md);
  transform: translateY(-3px);
}

.entry-icon {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}

.entry-icon.green  { background: #ECFDF5; }
.entry-icon.blue   { background: #E0F2FE; }
.entry-icon.yellow { background: #FEF9C3; }
.entry-icon.purple { background: #EDE9FE; }

.entry-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--gray-900);
}

.entry-desc {
  font-size: var(--fs-sm);
  color: var(--gray-500);
  line-height: 1.6;
}

/* ── 讲义页布局 ───────────────────────────────────── */
.lecture-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 40px;
  align-items: start;
}

.toc-sidebar {
  position: sticky;
  top: calc(var(--nav-h) + 24px);
  background: white;
  border-radius: var(--radius-lg);
  border: 1px solid var(--gray-200);
  padding: 24px;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
}

.toc-title {
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--gray-400);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 16px;
}

.toc-list { display: flex; flex-direction: column; gap: 2px; }

.toc-item a {
  display: block;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  font-size: var(--fs-sm);
  color: var(--gray-600);
  transition: all .2s;
  font-weight: 500;
}

.toc-item a:hover,
.toc-item a.active {
  background: var(--py-light);
  color: var(--py-dark);
  font-weight: 600;
}

.toc-item.h3 a { padding-left: 26px; font-size: var(--fs-xs); color: var(--gray-500); }

/* ── 讲义正文 ─────────────────────────────────────── */
.lecture-content {
  background: white;
  border-radius: var(--radius-lg);
  border: 1px solid var(--gray-200);
  padding: 48px 60px;
  min-height: 600px;
}

.lecture-content h2 {
  font-size: var(--fs-h2);
  font-weight: 800;
  color: var(--gray-900);
  margin: 40px 0 16px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--gray-100);
  letter-spacing: -0.02em;
}

.lecture-content h2:first-child { margin-top: 0; }

.lecture-content h3 {
  font-size: var(--fs-h3);
  font-weight: 700;
  color: var(--gray-800);
  margin: 28px 0 12px;
}

.lecture-content p {
  font-size: var(--fs-body);
  color: var(--gray-700);
  margin-bottom: 16px;
  line-height: 1.9;
}

.lecture-content ul, .lecture-content ol {
  margin: 12px 0 20px 24px;
  list-style: disc;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.lecture-content ol { list-style: decimal; }

.lecture-content li {
  font-size: var(--fs-body);
  color: var(--gray-700);
  line-height: 1.8;
}

.lecture-content strong { color: var(--gray-900); font-weight: 700; }

.lecture-content blockquote {
  border-left: 4px solid var(--py-primary);
  background: var(--py-light);
  padding: 16px 24px;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  margin: 20px 0;
  color: var(--py-dark);
  font-size: var(--fs-body);
  font-weight: 500;
}

/* ── 代码块（放大 + 鲜艳）────────────────────────── */
.code-block-wrap {
  margin: 20px 0;
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  border: 1px solid rgba(255,255,255,.05);
}

.code-block-header {
  background: #232438;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.code-lang-badge {
  font-size: var(--fs-xs);
  font-weight: 700;
  color: #06D6A0;
  text-transform: uppercase;
  letter-spacing: .06em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.code-lang-badge::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #06D6A0;
}

.code-lang-badge.sql {
  color: #FF8E53;
}
.code-lang-badge.sql::before {
  background: #FF8E53;
}

.copy-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-xs);
  font-weight: 500;
  color: #94A3B8;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid #3A3A4E;
  background: transparent;
  cursor: pointer;
  transition: all .2s;
}

.copy-btn:hover {
  background: #32324A;
  color: #E2E8F0;
  border-color: #5A5A7A;
}

.copy-btn.copied {
  color: #06D6A0;
  border-color: #06D6A0;
  background: rgba(6,214,160,.08);
}

.code-block-wrap pre {
  margin: 0;
  background: var(--code-bg);
  padding: 24px 24px;
  overflow-x: auto;
}

.code-block-wrap pre code {
  font-family: "JetBrains Mono", "Fira Code", "SF Mono", "Consolas", "Courier New", monospace;
  font-size: var(--fs-code);
  line-height: 1.8;
  color: var(--code-fg);
}

/* ── 例题卡片 ─────────────────────────────────────── */
.example-card {
  background: white;
  border-radius: var(--radius-lg);
  border: 1.5px solid var(--gray-200);
  overflow: hidden;
  margin-bottom: 24px;
  transition: box-shadow .25s;
}

.example-card:hover { box-shadow: var(--shadow-md); }

.example-card-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  align-items: flex-start;
  gap: 16px;
}

.example-num {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--py-grad);
  color: white;
  font-size: var(--fs-xs);
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}

.sql .example-num { background: var(--sql-grad); }

.example-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--gray-900);
  line-height: 1.5;
}

.example-desc {
  font-size: var(--fs-sm);
  color: var(--gray-500);
  margin-top: 6px;
  line-height: 1.7;
}

.example-card-body { padding: 0; }

/* ── 习题卡片 ─────────────────────────────────────── */
.exercise-card {
  background: white;
  border-radius: var(--radius-lg);
  border: 1.5px solid var(--gray-200);
  margin-bottom: 20px;
  overflow: hidden;
  transition: box-shadow .25s;
}

.exercise-card:hover { box-shadow: var(--shadow-sm); }

.exercise-question {
  padding: 22px 24px;
  display: flex;
  align-items: flex-start;
  gap: 16px;
  cursor: pointer;
  user-select: none;
}

.exercise-question:hover { background: var(--gray-50); }

.q-num {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--gray-100);
  color: var(--gray-500);
  font-size: var(--fs-xs);
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}

.q-text {
  flex: 1;
  font-size: var(--fs-body);
  color: var(--gray-800);
  line-height: 1.7;
}

.q-arrow {
  font-size: 1rem;
  color: var(--gray-400);
  transition: transform .3s var(--ease-out);
  flex-shrink: 0;
  margin-top: 6px;
}

.exercise-card.open .q-arrow { transform: rotate(180deg); }

.exercise-answer {
  max-height: 0;
  overflow: hidden;
  transition: max-height .4s var(--ease-out);
  background: var(--py-grad-subtle);
  border-top: 1px solid transparent;
}

/* max-height 由 JS 动态设置为 scrollHeight，支持任意长度答案 */
.exercise-card.open .exercise-answer {
  border-top-color: rgba(6,214,160,.2);
}

.exercise-answer-inner {
  padding: 20px 24px 24px 72px;
}

.answer-label {
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--py-dark);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.answer-label::before {
  content: '✓';
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  background: var(--py-primary);
  color: white;
  border-radius: 50%;
  font-size: .7rem;
}

/* ── 全局答案开关 ─────────────────────────────────── */
.toggle-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: white;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--gray-200);
  padding: 16px 24px;
  margin-bottom: 28px;
}

.toggle-bar span {
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--gray-600);
}

.toggle-switch {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: var(--fs-sm);
  font-weight: 600;
}

.switch {
  width: 52px;
  height: 28px;
  background: var(--gray-300);
  border-radius: var(--radius-full);
  position: relative;
  cursor: pointer;
  transition: background .3s;
  flex-shrink: 0;
}

.switch::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 2px 6px rgba(0,0,0,.15);
  transition: left .3s var(--ease-out);
}

.switch.on {
  background: var(--py-primary);
}
.switch.on::after { left: 27px; }

/* ── 上机练习页 ───────────────────────────────────── */
.lab-card {
  background: white;
  border-radius: var(--radius-lg);
  border: 2px solid var(--gray-200);
  padding: 32px 36px;
  margin-bottom: 24px;
  transition: all .25s var(--ease-out);
}

.lab-card:hover {
  border-color: var(--py-mid);
  box-shadow: var(--shadow-sm);
  transform: translateX(4px);
}

.lab-card.sql:hover { border-color: var(--sql-mid); }

.lab-num {
  font-size: var(--fs-xs);
  font-weight: 800;
  color: var(--py-primary);
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-bottom: 12px;
}

.lab-card.sql .lab-num { color: var(--sql-dark); }

.lab-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: 10px;
  line-height: 1.5;
}

.lab-desc {
  font-size: var(--fs-body);
  color: var(--gray-600);
  line-height: 1.8;
}

.lab-hint {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 16px;
  font-size: var(--fs-xs);
  color: var(--gray-400);
  background: var(--gray-50);
  padding: 6px 14px;
  border-radius: var(--radius-full);
  border: 1px solid var(--gray-200);
  font-weight: 500;
}

/* ── 课程标题 Banner ─────────────────────────────── */
.course-banner {
  padding: 52px 28px 44px;
  color: white;
  position: relative;
  overflow: hidden;
}

.course-banner::before {
  content: '';
  position: absolute;
  inset: 0;
  background: inherit;
  z-index: -1;
}

.course-banner.py { background: var(--py-grad); }
.course-banner.sql { background: var(--sql-grad); }

.course-banner-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 28px;
}

.course-banner h1 {
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  font-weight: 800;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.course-banner p {
  font-size: var(--fs-body);
  opacity: .9;
  max-width: 760px;
  line-height: 1.7;
}

.course-banner-stats {
  display: flex;
  gap: 32px;
  margin-top: 28px;
  flex-wrap: wrap;
}

.banner-stat {
  background: rgba(255,255,255,.18);
  border-radius: var(--radius-md);
  padding: 10px 20px;
  font-size: var(--fs-sm);
  font-weight: 600;
  backdrop-filter: blur(4px);
}

/* ── 章节主页标题区 ───────────────────────────────── */
.chapter-hero {
  background: white;
  border-radius: var(--radius-xl);
  border: 1.5px solid var(--gray-200);
  padding: 36px 40px;
  margin-bottom: 28px;
  display: flex;
  gap: 28px;
  align-items: flex-start;
}

.chapter-hero-icon {
  width: 72px;
  height: 72px;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.2rem;
  flex-shrink: 0;
}

.chapter-hero-icon.py { background: var(--py-grad-subtle); }
.chapter-hero-icon.sql { background: var(--sql-grad-subtle); }

.chapter-hero-info h2 {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--gray-900);
  margin-bottom: 8px;
}

.chapter-hero-info p {
  font-size: var(--fs-body);
  color: var(--gray-500);
  line-height: 1.7;
}

.goals-list {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.goals-list li {
  font-size: var(--fs-sm);
  color: var(--gray-600);
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.goals-list li::before {
  content: '✓';
  color: var(--accent-green);
  font-weight: 800;
  flex-shrink: 0;
  margin-top: 1px;
}

/* ── 阅读进度条（讲义页） ────────────────────────── */
.reading-progress {
  position: fixed;
  top: var(--nav-h);
  left: 0;
  height: 4px;
  background: var(--py-grad);
  width: 0%;
  z-index: 200;
  transition: width .15s linear;
}

.reading-progress.sql { background: var(--sql-grad); }

/* ── 上/下章节导航 ───────────────────────────────── */
.chapter-nav {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  margin-top: 48px;
  padding-top: 32px;
  border-top: 1px solid var(--gray-200);
}

.chapter-nav-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 24px;
  background: white;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-md);
  font-size: var(--fs-sm);
  font-weight: 500;
  transition: all .25s var(--ease-out);
  max-width: 46%;
}

.chapter-nav-btn:hover {
  border-color: var(--py-primary);
  box-shadow: var(--shadow-sm);
  background: var(--py-light);
}

.chapter-nav-btn span {
  color: var(--gray-400);
  font-size: var(--fs-xs);
  display: block;
}

.chapter-nav-btn strong { color: var(--gray-800); font-size: var(--fs-sm); }

/* ── 页脚 ──────────────────────────────────────────*/
.footer {
  background: var(--gray-900);
  color: var(--gray-400);
  padding: 40px 28px;
  text-align: center;
  font-size: var(--fs-sm);
}

.footer a { color: var(--gray-400); text-decoration: underline; }
.footer strong { color: white; }

/* ── 辅助类 ───────────────────────────────────────── */
.flex { display: flex; }
.items-center { align-items: center; }
.gap-8 { gap: 8px; }
.gap-16 { gap: 16px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.text-sm { font-size: var(--fs-sm); }
.text-muted { color: var(--gray-500); }
.fw-600 { font-weight: 600; }

/* ================================================================
   响应式设计 — 平板 & 手机适配
================================================================ */

/* ━ 超宽屏 4K（≥2560px，原生 4K 输出） ━━━━━━━━━━━━━ */
@media (min-width: 2560px) {
  html { font-size: 28px; }
}

/* ━ 平板 (≤1024px) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
@media (max-width: 1024px) {
  html { font-size: 20px; }

  .lecture-layout {
    grid-template-columns: 240px 1fr;
    gap: 28px;
  }

  .lecture-content {
    padding: 40px 40px;
  }

  .card-grid-2 {
    grid-template-columns: 1fr;
  }

  .code-block-wrap pre {
    padding: 20px 20px;
  }
}

/* ━ 手机 (≤768px) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
@media (max-width: 768px) {
  html { font-size: 18px; }

  /* 导航 → 汉堡菜单 */
  .hamburger { display: flex; }

  .nav-links {
    position: fixed;
    top: 0;
    right: -100%;
    width: 75%;
    max-width: 320px;
    height: 100vh;
    background: white;
    flex-direction: column;
    padding: 100px 32px 40px;
    gap: 4px;
    transition: right .35s var(--ease-out);
    box-shadow: -8px 0 30px rgba(0,0,0,.1);
    z-index: 105;
    align-items: stretch;
  }

  .nav-links.open {
    right: 0;
  }

  .nav-links a {
    padding: 14px 20px;
    font-size: 1.05rem;
    border-radius: var(--radius-md);
  }

  /* 移动端遮罩 */
  .nav-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 104;
    opacity: 0;
    transition: opacity .3s;
  }

  .nav-overlay.open {
    display: block;
    opacity: 1;
  }

  /* Hero 区 */
  .hero {
    padding: 56px 24px 60px;
  }

  .hero h1 {
    font-size: 1.8rem;
  }

  .hero p {
    font-size: var(--fs-sm);
  }

  .hero-stats {
    gap: 16px;
  }

  .hero-stats .stat {
    padding: 12px 18px;
    border-radius: var(--radius-md);
  }

  .hero-stats .stat-num {
    font-size: 1.6rem;
  }

  /* 课程卡片 */
  .course-card-header {
    padding: 28px 24px 22px;
  }

  .course-card-body {
    padding: 20px 24px 24px;
  }

  /* 讲义页 → 单列 */
  .lecture-layout {
    grid-template-columns: 1fr;
  }

  .toc-sidebar {
    display: none;
  }

  .lecture-content {
    padding: 28px 24px;
    border-radius: var(--radius-md);
  }

  .lecture-content h2 {
    font-size: 1.4rem;
  }

  .lecture-content h3 {
    font-size: 1.15rem;
  }

  /* 代码块 */
  .code-block-wrap pre {
    padding: 16px 16px;
  }

  .code-block-wrap pre code {
    font-size: 0.95rem;
  }

  /* 入口卡片 */
  .entry-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

  .entry-card {
    padding: 20px 16px;
  }

  /* 章节 Hero */
  .chapter-hero {
    flex-direction: column;
    padding: 24px 28px;
  }

  /* 例题 */
  .example-card-header {
    padding: 16px 20px;
  }

  .exercise-answer-inner {
    padding: 16px 20px 20px 20px;
  }

  /* 面包屑 */
  .breadcrumb {
    padding: 12px 24px 0;
  }

  /* 页面主体 */
  .page-body {
    padding: 32px 20px 60px;
  }

  /* 章节导航 */
  .chapter-nav {
    flex-direction: column;
  }

  .chapter-nav-btn {
    max-width: 100%;
  }
}

/* ━ 小手机 (≤480px) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
@media (max-width: 480px) {
  html { font-size: 17px; }

  .nav-inner {
    padding: 0 16px;
  }

  .hero {
    padding: 44px 16px 48px;
  }

  .hero h1 {
    font-size: 1.5rem;
  }

  .hero-badge {
    font-size: .78rem;
    padding: 4px 14px;
  }

  .page-body {
    padding: 28px 16px 50px;
  }

  .entry-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .entry-card {
    padding: 16px 14px;
  }

  .entry-icon {
    width: 40px;
    height: 40px;
    font-size: 1.2rem;
  }

  .entry-title {
    font-size: .9rem;
  }

  .lecture-content {
    padding: 20px 16px;
  }

  .lecture-content h2 {
    font-size: 1.25rem;
  }

  .code-block-wrap pre {
    padding: 12px 12px;
  }

  .code-block-wrap pre code {
    font-size: .85rem;
  }

  .chapter-hero {
    padding: 20px 22px;
    border-radius: var(--radius-lg);
  }

  .chapter-card {
    padding: 18px 20px;
    gap: 10px;
  }

  .toggle-bar {
    flex-direction: column;
    gap: 12px;
    align-items: flex-start;
    padding: 14px 18px;
  }

  .breadcrumb {
    padding: 10px 16px 0;
  }

  .course-banner {
    padding: 36px 16px 32px;
  }

  .course-banner h1 {
    font-size: 1.4rem;
  }
}

/* ── 打印样式 ─────────────────────────────────────── */
@media print {
  .nav, .toc-sidebar, .chapter-nav, .footer, .reading-progress,
  .hamburger, .nav-overlay, .toggle-bar { display: none !important; }
  .lecture-layout { grid-template-columns: 1fr; }
  body { background: white; font-size: 12pt; }
  .lecture-content { border: none; box-shadow: none; padding: 0; }
  .exercise-answer { max-height: none !important; }
  .code-block-wrap { box-shadow: none; border: 1px solid #ccc; }
  .code-block-wrap pre { background: #f5f5f5; }
  .code-block-wrap pre code { color: #333; }
}
