/* ============================================================
   WorkBuddy AI 编程课程 — 共享样式
   Style: 技术文档风，干净、留白、层次清晰
   ============================================================ */

:root {
  --c-bg: #f8fafc;
  --c-surface: #ffffff;
  --c-text: #1a1a2e;
  --c-text-secondary: #64748b;
  --c-border: #e2e8f0;
  --c-accent: #2563eb;
  --c-accent-light: #eff6ff;
  --c-accent-hover: #1d4ed8;

  --c-tip-bg: #ecfdf5;
  --c-tip-border: #10b981;
  --c-warn-bg: #fffbeb;
  --c-warn-border: #f59e0b;
  --c-info-bg: #eff6ff;
  --c-info-border: #3b82f6;
  --c-danger-bg: #fef2f2;
  --c-danger-border: #ef4444;
  --c-summary-bg: #f0f9ff;
  --c-summary-border: #0ea5e9;

  --sidebar-w: 250px;
  --content-max: 740px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  --font-mono: "SF Mono", "Fira Code", "Cascadia Code", "Consolas", monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
img { max-width: 100%; height: auto; display: block; }
html { scroll-behavior: smooth; font-size: 16px; }

body {
  font-family: var(--font);
  color: var(--c-text);
  background: var(--c-bg);
  line-height: 1.8;
  display: flex;
  min-height: 100vh;
}

/* ---- Sidebar ---- */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--c-surface);
  border-right: 1px solid var(--c-border);
  overflow-y: auto;
  padding: 28px 16px 40px;
  z-index: 100;
  display: flex;
  flex-direction: column;
}
.sidebar-logo {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.4;
  padding: 0 8px 20px;
  border-bottom: 1px solid var(--c-border);
  margin-bottom: 12px;
  color: var(--c-text);
  text-decoration: none;
  display: block;
}
.sidebar-logo .brand { color: var(--c-accent); }
.sidebar-section {
  padding: 8px 8px 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--c-text-secondary);
  margin-top: 12px;
}
.sidebar nav { flex: 1; }
.sidebar nav a {
  display: block;
  padding: 7px 8px 7px 12px;
  border-radius: 5px;
  text-decoration: none;
  color: var(--c-text-secondary);
  font-size: 13px;
  transition: all 0.12s;
  border-left: 2px solid transparent;
  line-height: 1.5;
}
.sidebar nav a:hover {
  background: var(--c-accent-light);
  color: var(--c-accent);
}
.sidebar nav a.active {
  background: var(--c-accent-light);
  color: var(--c-accent);
  font-weight: 600;
  border-left-color: var(--c-accent);
}
.sidebar-footer {
  margin-top: auto;
  padding: 16px 8px 0;
  font-size: 11px;
  color: var(--c-text-secondary);
  border-top: 1px solid var(--c-border);
}

/* ---- Main Content ---- */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  justify-content: center;
  padding: 40px 24px 80px;
  min-height: 100vh;
}
.content {
  width: 100%;
  max-width: var(--content-max);
}

/* ---- Home page hero ---- */
.home-hero {
  padding: 60px 0 40px;
  text-align: center;
}
.home-hero .badge {
  display: inline-block;
  padding: 4px 14px;
  background: var(--c-accent-light);
  color: var(--c-accent);
  font-size: 12px;
  font-weight: 600;
  border-radius: 20px;
  margin-bottom: 20px;
}
.home-hero h1 {
  font-size: 38px;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.5px;
  margin-bottom: 16px;
}
.home-hero .tagline {
  font-size: 17px;
  color: var(--c-text-secondary);
  max-width: 500px;
  margin: 0 auto 28px;
}
.home-meta {
  display: flex;
  gap: 28px;
  justify-content: center;
  font-size: 13px;
  color: var(--c-text-secondary);
  margin-bottom: 40px;
}
.home-cta {
  display: inline-block;
  padding: 12px 28px;
  background: var(--c-accent);
  color: white;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 600;
  font-size: 15px;
  transition: background 0.15s;
}
.home-cta:hover { background: var(--c-accent-hover); }

/* Chapter cards for home page */
.chapter-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 48px;
}
.chapter-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: 8px;
  padding: 20px;
  text-decoration: none;
  color: var(--c-text);
  transition: all 0.15s;
}
.chapter-card:hover {
  border-color: var(--c-accent);
  box-shadow: 0 2px 12px rgba(37,99,235,0.08);
}
.chapter-card .num {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--c-accent);
  font-weight: 700;
}
.chapter-card .title {
  font-size: 15px;
  font-weight: 700;
  margin: 6px 0 4px;
}
.chapter-card .desc {
  font-size: 13px;
  color: var(--c-text-secondary);
  line-height: 1.5;
}

/* ---- Chapter content ---- */
.chapter-header {
  margin-bottom: 36px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--c-border);
}
.chapter-num {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--c-accent);
  letter-spacing: 0.8px;
  text-transform: uppercase;
}
.chapter-header h1 {
  font-size: 28px;
  font-weight: 800;
  margin: 8px 0 12px;
  line-height: 1.3;
}
.chapter-header .lead {
  font-size: 15px;
  color: var(--c-text-secondary);
  max-width: 600px;
}

h2 {
  font-size: 21px;
  font-weight: 700;
  margin: 40px 0 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--c-border);
}
h3 {
  font-size: 17px;
  font-weight: 600;
  margin: 32px 0 10px;
}
h4 {
  font-size: 15px;
  font-weight: 600;
  margin: 24px 0 8px;
}
p {
  margin-bottom: 16px;
  font-size: 15px;
  color: var(--c-text);
}
strong { font-weight: 600; color: #0f172a; }
code {
  font-family: var(--font-mono);
  font-size: 13px;
  background: #f1f5f9;
  padding: 2px 6px;
  border-radius: 3px;
  color: #1e293b;
}
pre {
  background: #1e293b;
  color: #e2e8f0;
  padding: 18px 22px;
  border-radius: 8px;
  overflow-x: auto;
  margin: 20px 0;
  font-size: 13px;
  line-height: 1.7;
}
pre code {
  background: none;
  padding: 0;
  color: inherit;
}

/* ---- Callout boxes ---- */
.callout {
  padding: 16px 20px;
  border-radius: 8px;
  margin: 20px 0;
  font-size: 14px;
  border-left: 3px solid;
  line-height: 1.7;
}
.callout-title {
  font-weight: 700;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-bottom: 4px;
}
.callout-tip { background: var(--c-tip-bg); border-color: var(--c-tip-border); }
.callout-tip .callout-title { color: #059669; }
.callout-warning { background: var(--c-warn-bg); border-color: var(--c-warn-border); }
.callout-warning .callout-title { color: #d97706; }
.callout-info { background: var(--c-info-bg); border-color: var(--c-info-border); }
.callout-info .callout-title { color: #2563eb; }
.callout-danger { background: var(--c-danger-bg); border-color: var(--c-danger-border); }
.callout-danger .callout-title { color: #dc2626; }
.callout-summary {
  background: var(--c-summary-bg);
  border-color: var(--c-summary-border);
  border-radius: 10px;
  padding: 20px 24px;
}

/* ---- Tables ---- */
.table-wrap {
  overflow-x: auto;
  margin: 20px 0;
  border: 1px solid var(--c-border);
  border-radius: 8px;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
thead th {
  background: #f8fafc;
  text-align: left;
  padding: 10px 14px;
  font-weight: 600;
  font-size: 12px;
  color: var(--c-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  border-bottom: 1px solid var(--c-border);
  white-space: nowrap;
}
tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--c-border);
  vertical-align: top;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fafbfc; }

/* ---- Lists ---- */
ul, ol {
  margin: 14px 0;
  padding-left: 22px;
}
li { margin-bottom: 5px; font-size: 15px; }
li strong { color: var(--c-text); }

/* ---- hr ---- */
hr {
  border: none;
  border-top: 1px solid var(--c-border);
  margin: 36px 0;
}

/* ---- Blockquote ---- */
blockquote {
  background: var(--c-accent-light);
  border-left: 3px solid var(--c-accent);
  padding: 14px 18px;
  margin: 20px 0;
  border-radius: 0 6px 6px 0;
}
blockquote p { margin: 0; font-size: 14px; color: #1e40af; }

/* ---- Chapter nav (prev/next) ---- */
.chapter-nav {
  margin-top: 48px;
  padding-top: 20px;
  border-top: 1px solid var(--c-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.nav-prev, .nav-next {
  font-size: 13px;
  color: var(--c-accent);
  text-decoration: none;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 4px;
}
.nav-prev:hover, .nav-next:hover { text-decoration: underline; }
.nav-spacer { flex: 1; }

/* ---- Visual: Flow chart ---- */
.flow-chart {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 16px 0;
  margin: 20px 0;
}
.flow-step {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: 8px;
  padding: 12px 16px;
  text-align: center;
  font-size: 13px;
  min-width: 70px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.flow-step .icon { font-size: 22px; margin-bottom: 4px; }
.flow-step .label { font-size: 11px; font-weight: 600; color: var(--c-text-secondary); }
.flow-step .text { font-size: 13px; font-weight: 600; margin-top: 2px; }
.flow-arrow {
  font-size: 18px;
  color: var(--c-text-secondary);
  flex-shrink: 0;
}

/* ---- Visual: Radar chart (CSS-only) ---- */
.radar-chart {
  width: 280px;
  height: 280px;
  margin: 24px auto;
  position: relative;
}
.radar-chart canvas {
  width: 100%;
  height: 100%;
}

/* ---- Visual: Interface mockup ---- */
.iface-mockup {
  border: 1px solid var(--c-border);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 2px 16px rgba(0,0,0,0.05);
  margin: 20px auto;
  max-width: 520px;
  background: var(--c-surface);
}
.iface-titlebar {
  background: #f1f5f9;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--c-border);
}
.iface-dot { width: 10px; height: 10px; border-radius: 50%; }
.iface-dot.r { background: #ef4444; }
.iface-dot.y { background: #f59e0b; }
.iface-dot.g { background: #10b981; }
.iface-title {
  font-size: 12px;
  color: var(--c-text-secondary);
  margin-left: 8px;
  font-weight: 500;
}
.iface-body { padding: 16px 20px; }
.iface-body p { margin: 0 0 8px; font-size: 13px; }

/* ---- Visual: Annotated screenshot ---- */
.annotated-box {
  border: 1px solid var(--c-border);
  border-radius: 10px;
  padding: 24px;
  margin: 20px 0;
  background: #fafbfc;
  position: relative;
}
.annotated-box .zone {
  border: 2px dashed #94a3b8;
  border-radius: 6px;
  padding: 6px 12px;
  display: inline-block;
  margin: 4px;
  position: relative;
  font-size: 12px;
  color: var(--c-text-secondary);
  background: rgba(255,255,255,0.6);
}
.annotated-box .zone-label {
  position: absolute;
  top: -22px;
  left: 8px;
  font-size: 10px;
  font-weight: 700;
  color: var(--c-accent);
  white-space: nowrap;
  background: var(--c-accent-light);
  padding: 1px 8px;
  border-radius: 4px;
}

/* ---- Visual: feature card ---- */
.feature-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 16px 0;
}
.feature-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: 8px;
  padding: 16px;
  font-size: 13px;
}
.feature-card .fc-icon { font-size: 24px; margin-bottom: 8px; }
.feature-card .fc-title { font-weight: 700; font-size: 14px; margin-bottom: 4px; }
.feature-card .fc-desc { color: var(--c-text-secondary); font-size: 12px; }

/* ---- Stars ---- */
.stars { color: #f59e0b; letter-spacing: 1px; white-space: nowrap; }

/* ---- Trust matrix ---- */
.trust-matrix td:first-child { font-weight: 600; white-space: nowrap; }
.trust-matrix td:nth-child(2) { text-align: center; }

/* ---- Responsive ---- */
/* ---- Mobile top bar (仅 ≤820px 显示) ---- */
.m-topbar { display: none; }
.sidebar-backdrop { display: none; }

@media (max-width: 820px) {
  /* 顶栏 */
  .m-topbar {
    display: flex;
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 52px;
    align-items: center;
    gap: 10px;
    padding: 0 12px;
    background: var(--c-surface);
    border-bottom: 1px solid var(--c-border);
    z-index: 101;
  }
  .m-menu-btn {
    width: 40px; height: 40px;
    display: flex; flex-direction: column;
    justify-content: center; align-items: center;
    gap: 5px;
    background: none; border: none; cursor: pointer; padding: 8px; flex-shrink: 0;
  }
  .m-menu-btn span { display: block; width: 22px; height: 2px; background: var(--c-text); border-radius: 2px; }
  .m-topbar-brand {
    font-size: 15px; font-weight: 700; color: var(--c-text); text-decoration: none;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .m-topbar-brand .brand { color: var(--c-accent); }

  /* 侧边栏 → 离屏抽屉 */
  .sidebar {
    top: 52px;
    height: calc(100vh - 52px);
    transform: translateX(-100%);
    transition: transform .25s ease;
    z-index: 100;
    box-shadow: 2px 0 16px rgba(15, 23, 42, .12);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop {
    display: block; position: fixed; inset: 0;
    background: rgba(15, 23, 42, .45); opacity: 0; visibility: hidden;
    transition: opacity .25s ease; z-index: 90;
  }
  .sidebar-backdrop.show { opacity: 1; visibility: visible; }

  /* 主内容让出顶栏空间 */
  .main { margin-left: 0; padding: 68px 16px 48px; }
  .content h2 { scroll-margin-top: 64px; }

  .chapter-grid { grid-template-columns: 1fr; }
  .feature-cards { grid-template-columns: 1fr; }
  .home-hero { padding: 32px 0 20px; }
  .home-hero h1 { font-size: 26px; }
  .home-meta { flex-wrap: wrap; gap: 16px; }
}
@media print {
  .sidebar { display: none; }
  .main { margin-left: 0; }
}
