/* UniApp 跨端开发教程 — common.css
   设计理念：可阅读性优先，暖灰背景 + 深棕文字 + 天蓝 accent
   ============================================================ */
:root {
  --bg:           #f5f5f0;
  --surface:      #eeede8;
  --surface-2:    #e8e7e1;
  --card:         #ffffff;
  --card-hover:   #f8f8f4;
  --border:       rgba(41,37,36,0.12);
  --border-mid:   rgba(41,37,36,0.20);
  --text:         #292524;
  --text-2:       #57534e;
  --text-3:       #78716c;
  --accent:       #0ea5e9;
  --accent-dark:  #0284c7;
  --accent-light: #38bdf8;
  --accent-bg:    rgba(14,165,233,0.08);
  --accent-glow:  rgba(14,165,233,0.18);
  --yellow:       #d97706;
  --orange:       #ea580c;
  --green:        #16a34a;
  --red:          #dc2626;
  --purple:       #7c3aed;
  --radius:       8px;
  --radius-lg:    12px;
  --max-w:        760px;
  --nav-h:        56px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', system-ui, -apple-system, sans-serif;
  line-height: 1.75;
  min-height: 100vh;
}

/* ── NAV ── */
.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 2rem;
  height: var(--nav-h);
  background: rgba(245,245,240,0.94);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.nav-back {
  color: var(--accent-dark);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  transition: color 0.2s;
  white-space: nowrap;
}
.nav-back:hover { color: var(--accent); }
.nav-back::before { content: '← '; }

.nav-title {
  color: var(--text-2);
  font-size: 0.88rem;
  margin-left: auto;
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── INDEX HERO ── */
.hero {
  padding: 5rem 2rem 4rem;
  text-align: center;
  background: linear-gradient(160deg, #e0f2fe 0%, #f0f9ff 40%, #f5f5f0 100%);
  border-bottom: 1px solid var(--border);
}

.hero-badge {
  display: inline-block;
  padding: 0.3rem 1rem;
  border: 1px solid rgba(14,165,233,0.3);
  border-radius: 999px;
  font-size: 0.78rem;
  color: var(--accent-dark);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 1.5rem;
  background: rgba(14,165,233,0.08);
  font-weight: 600;
}

.hero h1 {
  font-size: clamp(2rem, 5vw, 3.2rem);
  font-weight: 800;
  color: var(--text);
  line-height: 1.2;
  margin-bottom: 1.25rem;
  letter-spacing: -0.02em;
}

.hero h1 span { color: var(--accent); }

.hero p {
  font-size: 1.1rem;
  color: var(--text-2);
  max-width: 600px;
  margin: 0 auto 2.5rem;
  line-height: 1.7;
}

.hero-stats {
  display: flex;
  justify-content: center;
  gap: 3rem;
  flex-wrap: wrap;
  margin-bottom: 2rem;
}

.stat { text-align: center; }
.stat-num {
  display: block;
  font-size: 2rem;
  font-weight: 800;
  color: var(--accent);
  line-height: 1;
}
.stat-label {
  font-size: 0.8rem;
  color: var(--text-3);
  letter-spacing: 0.06em;
  margin-top: 0.3rem;
}

/* ── CONTAINER ── */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 4rem 2rem;
}

/* ── CARD & CARD-LIST ── */
.card-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.25rem;
  margin-top: 2rem;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  text-decoration: none;
  color: var(--text);
  display: block;
  transition: box-shadow 0.2s, transform 0.2s, border-color 0.2s;
}
.card:hover {
  box-shadow: 0 4px 20px rgba(14,165,233,0.12);
  transform: translateY(-2px);
  border-color: rgba(14,165,233,0.3);
}

.card-num {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 0.6rem;
}

.card h3 {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: var(--text);
  line-height: 1.35;
}

.card p {
  font-size: 0.88rem;
  color: var(--text-2);
  line-height: 1.6;
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 1rem;
}
.tag {
  font-size: 0.72rem;
  padding: 0.15rem 0.6rem;
  border-radius: 4px;
  background: var(--accent-bg);
  color: var(--accent-dark);
  font-weight: 600;
}

/* ── SECTION HEADINGS (INDEX) ── */
.section-title {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 0.5rem;
  margin-top: 3.5rem;
}
.section-desc {
  color: var(--text-2);
  font-size: 0.95rem;
  margin-bottom: 1.5rem;
}

/* ── CHAPTER HERO ── */
.chapter-hero {
  background: linear-gradient(135deg, #0ea5e9 0%, #0284c7 60%, #0369a1 100%);
  color: #fff;
  padding: 4rem 2rem 3rem;
  text-align: center;
}

.ch-num {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  opacity: 0.75;
  margin-bottom: 1rem;
}

.chapter-hero h1 {
  font-size: clamp(1.7rem, 4vw, 2.6rem);
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 1rem;
  letter-spacing: -0.01em;
}

.chapter-hero p {
  font-size: 1rem;
  opacity: 0.88;
  max-width: 580px;
  margin: 0 auto;
  line-height: 1.7;
}

/* ── CONTENT AREA ── */
.content {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 3rem 2rem 4rem;
}

.content h2 {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text);
  margin-top: 3rem;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--accent);
  line-height: 1.3;
}

.content h3 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  margin-top: 2rem;
  margin-bottom: 0.75rem;
}

.content h4 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-2);
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
}

.content p {
  font-size: 1rem;
  line-height: 1.8;
  color: var(--text);
  margin-bottom: 1rem;
}

.content ul, .content ol {
  padding-left: 1.6rem;
  margin-bottom: 1rem;
}

.content li {
  font-size: 1rem;
  line-height: 1.8;
  color: var(--text);
  margin-bottom: 0.3rem;
}

.content strong { color: var(--text); font-weight: 700; }
.content em { color: var(--text-2); font-style: italic; }

.content code {
  font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
  font-size: 0.875em;
  background: var(--surface-2);
  color: var(--accent-dark);
  padding: 0.15em 0.45em;
  border-radius: 4px;
  border: 1px solid var(--border);
}

/* ── CODE BLOCKS ── */
pre {
  background: #1e2328;
  color: #abb2bf;
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  overflow-x: auto;
  margin: 1.5rem 0;
  font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
  font-size: 0.875rem;
  line-height: 1.65;
  border: 1px solid rgba(255,255,255,0.06);
  box-shadow: 0 2px 12px rgba(0,0,0,0.12);
}

pre code {
  background: none;
  color: inherit;
  padding: 0;
  border: none;
  font-size: inherit;
}

/* code highlight spans */
.kw { color: #c678dd; font-weight: 600; }   /* keyword */
.ty { color: #e5c07b; }                      /* type */
.st { color: #98c379; }                      /* string */
.cm { color: #5c6370; font-style: italic; }  /* comment */
.fn { color: #61afef; }                      /* function */
.nu { color: #d19a66; }                      /* number */
.at { color: #e06c75; }                      /* attribute/tag */
.pr { color: #56b6c2; }                      /* property/builtin */

/* ── CALLOUTS ── */
.callout {
  border-radius: var(--radius-lg);
  padding: 1.1rem 1.4rem;
  margin: 1.5rem 0;
  border-left: 4px solid;
  font-size: 0.95rem;
  line-height: 1.7;
}

.callout-title {
  font-weight: 700;
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 0.45rem;
}

.callout.info {
  background: rgba(14,165,233,0.07);
  border-color: var(--accent);
  color: var(--text);
}
.callout.info .callout-title { color: var(--accent-dark); }

.callout.tip {
  background: rgba(22,163,74,0.07);
  border-color: var(--green);
  color: var(--text);
}
.callout.tip .callout-title { color: var(--green); }

.callout.warning {
  background: rgba(217,119,6,0.07);
  border-color: var(--yellow);
  color: var(--text);
}
.callout.warning .callout-title { color: var(--yellow); }

.callout.danger {
  background: rgba(220,38,38,0.07);
  border-color: var(--red);
  color: var(--text);
}
.callout.danger .callout-title { color: var(--red); }

/* ── DEF-LIST ── */
.def-list {
  margin: 1.25rem 0;
}
.def-list dt {
  font-weight: 700;
  color: var(--accent-dark);
  font-size: 0.95rem;
  margin-top: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.def-list dt::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}
.def-list dd {
  color: var(--text-2);
  font-size: 0.95rem;
  line-height: 1.7;
  margin-left: 1.2rem;
  margin-top: 0.2rem;
}

/* ── TWO COLUMN ── */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  margin: 1.5rem 0;
}
@media (max-width: 640px) {
  .two-col { grid-template-columns: 1fr; }
}

.col-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}
.col-box h4 {
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent-dark);
  margin-bottom: 0.8rem;
  margin-top: 0;
}
.col-box ul { padding-left: 1.2rem; }
.col-box li { font-size: 0.9rem; color: var(--text-2); margin-bottom: 0.35rem; }

/* ── PROGRESS BAR ── */
.progress {
  width: 100%;
  height: 4px;
  background: var(--surface-2);
  border-radius: 2px;
  margin-bottom: 3rem;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent-light) 100%);
  border-radius: 2px;
  transition: width 0.4s ease;
}

/* ── CHAPTER NAV ── */
.chapter-nav {
  display: flex;
  gap: 1rem;
  margin-top: 4rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
}

.chapter-nav a {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 1rem 1.25rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.chapter-nav a:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 12px var(--accent-glow);
}

.chapter-nav .nav-dir {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 0.35rem;
}

.chapter-nav .nav-label {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--accent-dark);
  line-height: 1.35;
}

.chapter-nav .prev { text-align: left; }
.chapter-nav .next { text-align: right; }
.chapter-nav .prev .nav-dir::before { content: '← '; }
.chapter-nav .next .nav-dir::after  { content: ' →'; }

/* ── SITE FOOTER ── */
.site-footer {
  text-align: center;
  padding: 2.5rem 2rem;
  background: var(--surface);
  border-top: 1px solid var(--border);
  color: var(--text-3);
  font-size: 0.85rem;
  line-height: 1.8;
}
.site-footer a {
  color: var(--text-2);
  text-decoration: none;
}
.site-footer a:hover { color: var(--accent); }

/* ── TABLE ── */
.content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.9rem;
}
.content th {
  background: var(--surface-2);
  color: var(--text);
  font-weight: 700;
  padding: 0.7rem 1rem;
  text-align: left;
  border: 1px solid var(--border);
  font-size: 0.85rem;
}
.content td {
  padding: 0.65rem 1rem;
  border: 1px solid var(--border);
  color: var(--text-2);
  vertical-align: top;
  line-height: 1.6;
}
.content tr:nth-child(even) td { background: var(--surface); }

/* ── HIGHLIGHT BOX ── */
.highlight-box {
  background: var(--accent-bg);
  border: 1px solid rgba(14,165,233,0.2);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin: 1.5rem 0;
}
.highlight-box h4 {
  color: var(--accent-dark);
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
}

/* ── RESPONSIVE ── */
@media (max-width: 768px) {
  .content { padding: 2rem 1.25rem 3rem; }
  .hero { padding: 3.5rem 1.25rem 3rem; }
  .chapter-hero { padding: 3rem 1.25rem 2.5rem; }
  .container { padding: 2.5rem 1.25rem; }
  .nav { padding: 0 1.25rem; }
  .chapter-nav { flex-direction: column; }
}
