/* ── 微信小程序开发教程 — 温暖米白·清爽可读 ── */
:root {
  --accent:       #07c160;
  --accent-dark:  #059a4c;
  --accent-light: #e8f9ef;
  --accent-mid:   #b7efd1;
  --bg:           #f8f6f2;
  --bg-card:      #ffffff;
  --bg-code:      #1e1e2e;
  --ink:          #1a1a2e;
  --ink-2:        #3d3d56;
  --ink-3:        #6b6b88;
  --ink-4:        #9898b0;
  --border:       #e2dfd8;
  --border-light: #eeebe5;
  --warn-bg:      #fff8e6;
  --warn-border:  #f5c842;
  --info-bg:      #e8f4ff;
  --info-border:  #4dabf7;
  --tip-bg:       #e8f9ef;
  --tip-border:   #07c160;
  --danger-bg:    #fff0f0;
  --danger-border:#f03e3e;
  --radius:       10px;
  --radius-sm:    6px;
  --radius-lg:    16px;
  --shadow:       0 2px 12px rgba(26,26,46,.07);
  --shadow-md:    0 4px 24px rgba(26,26,46,.10);
  --max-w:        760px;
  --font-body:    'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', system-ui, -apple-system, sans-serif;
  --font-mono:    'JetBrains Mono', 'Fira Code', 'Cascadia Code', 'Source Code Pro', Consolas, monospace;
}

/* ── RESET ── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; font-size: 16px; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
a { color: var(--accent-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── TOP NAV ── */
.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(248,246,242,.92);
  backdrop-filter: blur(18px) saturate(160%);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 54px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.nav-back {
  color: var(--accent-dark);
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}
.nav-back::before { content: '‹'; font-size: 1.4rem; line-height: 1; }
.nav-back:hover { color: var(--accent); text-decoration: none; }
.nav-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--ink);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.nav-badge {
  background: var(--accent);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 20px;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

/* ── HERO (首页) ── */
.hero {
  background: linear-gradient(135deg, #0f3d24 0%, #07c160 60%, #0ea843 100%);
  color: #fff;
  padding: 64px 24px 56px;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 70% 40%, rgba(255,255,255,.08) 0%, transparent 65%);
}
.hero-icon {
  font-size: 3.6rem;
  margin-bottom: 20px;
  line-height: 1;
}
.hero h1 {
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 14px;
  line-height: 1.2;
}
.hero p {
  font-size: 1.1rem;
  opacity: 0.88;
  max-width: 560px;
  margin: 0 auto 32px;
  line-height: 1.7;
}
.hero-meta {
  display: flex;
  justify-content: center;
  gap: 28px;
  flex-wrap: wrap;
}
.hero-meta span {
  font-size: 0.88rem;
  opacity: 0.8;
  display: flex;
  align-items: center;
  gap: 5px;
}

/* ── CONTAINER ── */
.container {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 40px 24px;
}

/* ── SECTION TITLE ── */
.section-title {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--ink);
  margin: 48px 0 20px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--accent);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── CARD & CARD-LIST ── */
.card-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px;
  margin: 16px 0;
}
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  overflow: hidden;
}
.card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}
.card a {
  display: block;
  padding: 20px 22px;
  text-decoration: none;
  color: inherit;
  height: 100%;
}
.card-num {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 6px;
}
.card h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 6px;
  line-height: 1.4;
}
.card p {
  font-size: 0.875rem;
  color: var(--ink-3);
  line-height: 1.6;
}
.card-tag {
  display: inline-block;
  margin-top: 10px;
  background: var(--accent-light);
  color: var(--accent-dark);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
}

/* ── CHAPTER HERO ── */
.chapter-hero {
  background: linear-gradient(135deg, #0f3d24 0%, #07c160 60%, #0ea843 100%);
  color: #fff;
  padding: 52px 24px 44px;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.chapter-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 30% 60%, rgba(255,255,255,.08) 0%, transparent 60%);
}
.ch-num {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  opacity: 0.7;
  margin-bottom: 12px;
  text-transform: uppercase;
}
.chapter-hero h1 {
  font-size: clamp(1.5rem, 3.5vw, 2.2rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 12px;
  line-height: 1.25;
}
.chapter-hero p {
  font-size: 1.05rem;
  opacity: 0.85;
  max-width: 520px;
  margin: 0 auto;
  line-height: 1.7;
}

/* ── CONTENT ── */
.content {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 40px 24px 60px;
}
.content h2 {
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--ink);
  margin: 48px 0 16px;
  padding-left: 12px;
  border-left: 4px solid var(--accent);
  line-height: 1.35;
}
.content h2:first-of-type { margin-top: 8px; }
.content h3 {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--ink);
  margin: 28px 0 12px;
}
.content h4 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--ink-2);
  margin: 20px 0 8px;
}
.content p {
  font-size: 1rem;
  line-height: 1.8;
  color: var(--ink-2);
  margin-bottom: 16px;
}
.content ul, .content ol {
  padding-left: 22px;
  margin-bottom: 16px;
}
.content li {
  font-size: 1rem;
  line-height: 1.8;
  color: var(--ink-2);
  margin-bottom: 6px;
}
.content strong { color: var(--ink); font-weight: 600; }
.content em { color: var(--ink-2); font-style: italic; }

/* ── INLINE CODE ── */
code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: rgba(7,193,96,.10);
  color: #0a7a40;
  padding: 1px 5px;
  border-radius: 4px;
  word-break: break-word;
}

/* ── CODE BLOCK ── */
pre {
  background: var(--bg-code);
  border-radius: var(--radius);
  padding: 20px 22px;
  overflow-x: auto;
  margin: 20px 0;
  font-family: var(--font-mono);
  font-size: 0.875rem;
  line-height: 1.65;
  border: 1px solid rgba(255,255,255,.04);
  box-shadow: 0 4px 20px rgba(0,0,0,.18);
}
pre code {
  background: none;
  color: #cdd6f4;
  padding: 0;
  font-size: inherit;
  border-radius: 0;
  word-break: normal;
}
/* syntax highlight spans */
pre .kw { color: #cba6f7; }   /* keyword   */
pre .ty { color: #89b4fa; }   /* type      */
pre .st { color: #a6e3a1; }   /* string    */
pre .cm { color: #6c7086; font-style: italic; } /* comment */
pre .fn { color: #89dceb; }   /* function  */
pre .nu { color: #fab387; }   /* number    */
pre .at { color: #f38ba8; }   /* attribute / decorator */
pre .pr { color: #f5c2e7; }   /* property  */
pre .op { color: #89b4fa; }   /* operator  */

/* ── TABLE ── */
.content table {
  width: 100%;
  border-collapse: collapse;
  margin: 20px 0;
  font-size: 0.92rem;
  background: var(--bg-card);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.content thead { background: var(--accent); color: #fff; }
.content th {
  padding: 12px 14px;
  font-weight: 600;
  text-align: left;
  font-size: 0.88rem;
}
.content td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-light);
  color: var(--ink-2);
  vertical-align: top;
}
.content tr:last-child td { border-bottom: none; }
.content tr:nth-child(even) td { background: rgba(7,193,96,.03); }

/* ── CALLOUT ── */
.callout {
  display: flex;
  gap: 12px;
  padding: 14px 18px;
  border-radius: var(--radius);
  margin: 22px 0;
  border-left: 4px solid;
  font-size: 0.95rem;
  line-height: 1.7;
}
.callout-icon { font-size: 1.2rem; flex-shrink: 0; margin-top: 1px; }
.callout > div p { margin: 4px 0 0; color: var(--ink-2); }
.callout > div strong { display: block; margin-bottom: 4px; }
.callout.info  { background: var(--info-bg);   border-color: var(--info-border);   }
.callout.tip   { background: var(--tip-bg);    border-color: var(--tip-border);    }
.callout.warning { background: var(--warn-bg); border-color: var(--warn-border);   }
.callout.danger  { background: var(--danger-bg); border-color: var(--danger-border); }
.callout.info strong  { color: #1971c2; }
.callout.tip strong   { color: var(--accent-dark); }
.callout.warning strong { color: #915300; }
.callout.danger strong  { color: #c92a2a; }

/* ── DEF-LIST ── */
.def-list {
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border-light);
  overflow: hidden;
  margin: 20px 0;
}
.def-item {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 0;
  border-bottom: 1px solid var(--border-light);
}
.def-item:last-child { border-bottom: none; }
.def-term {
  padding: 12px 16px;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--accent-dark);
  background: var(--accent-light);
  font-family: var(--font-mono);
  word-break: break-all;
}
.def-desc {
  padding: 12px 16px;
  font-size: 0.9rem;
  color: var(--ink-2);
  line-height: 1.7;
}

/* ── TWO-COL ── */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin: 20px 0;
}
.two-col .col-box {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 18px;
}
.two-col .col-box h4 {
  font-size: 0.88rem;
  font-weight: 700;
  margin: 0 0 12px;
  color: var(--accent-dark);
}

/* ── PROGRESS BAR ── */
.progress {
  height: 5px;
  background: var(--border-light);
  border-radius: 99px;
  margin-bottom: 40px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-dark));
  border-radius: 99px;
  transition: width 0.6s cubic-bezier(.4,0,.2,1);
}

/* ── CHAPTER NAV ── */
.chapter-nav {
  display: flex;
  gap: 14px;
  margin: 56px 0 20px;
  border-top: 1px solid var(--border);
  padding-top: 28px;
}
.chapter-nav a {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  text-decoration: none;
  transition: border-color .18s, box-shadow .18s, transform .18s;
  color: inherit;
}
.chapter-nav a:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 12px rgba(7,193,96,.14);
  transform: translateY(-2px);
  text-decoration: none;
}
.chapter-nav .nav-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--accent);
  text-transform: uppercase;
}
.chapter-nav .nav-title-text {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.4;
}
.chapter-nav .prev { text-align: left; }
.chapter-nav .next { text-align: right; }
.chapter-nav .prev .nav-label::before { content: '← '; }
.chapter-nav .next .nav-label::after  { content: ' →'; }

/* ── SITE FOOTER ── */
.site-footer {
  background: var(--ink);
  color: rgba(255,255,255,.55);
  text-align: center;
  padding: 32px 24px;
  font-size: 0.82rem;
  line-height: 1.8;
}
.site-footer a { color: var(--accent); }
.site-footer a:hover { color: #fff; text-decoration: none; }

/* ── STEP LIST ── */
.step-list { list-style: none; padding: 0; margin: 20px 0; counter-reset: step; }
.step-list li {
  counter-increment: step;
  display: flex;
  gap: 14px;
  margin-bottom: 18px;
  align-items: flex-start;
}
.step-list li::before {
  content: counter(step);
  flex-shrink: 0;
  width: 28px; height: 28px;
  background: var(--accent);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  margin-top: 3px;
}

/* ── TAG PILLS ── */
.tag { display: inline-block; background: var(--accent-light); color: var(--accent-dark); font-size: 0.72rem; font-weight: 600; padding: 2px 9px; border-radius: 99px; margin: 2px 3px 2px 0; }
.tag.new { background: #fde8f5; color: #b5179e; }
.tag.important { background: #fff3cd; color: #856404; }

/* ── RESPONSIVE ── */
@media (max-width: 640px) {
  .nav { padding: 0 14px; }
  .hero, .chapter-hero { padding: 44px 16px 36px; }
  .container, .content { padding-left: 16px; padding-right: 16px; }
  .card-list { grid-template-columns: 1fr; }
  .two-col { grid-template-columns: 1fr; }
  .def-item { grid-template-columns: 1fr; }
  .def-term { border-bottom: 1px solid var(--border-light); }
  .chapter-nav { flex-direction: column; }
  .content h2 { font-size: 1.25rem; }
  pre { font-size: 0.82rem; padding: 14px 14px; }
}
