/* =========================================================
   Cursor AI 编程教程 — common.css
   风格：深灰暗色 IDE 感，紫蓝 accent #8b5cf6
   ========================================================= */

/* ── Reset & Base ─────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #1a1d23;
  --bg2:       #21252e;
  --bg3:       #272b35;
  --border:    #2e3340;
  --text:      #e8eaf0;
  --text2:     #a8adc0;
  --text3:     #6b7280;
  --accent:    #8b5cf6;
  --accent2:   #7c3aed;
  --accent3:   #a78bfa;
  --accent-bg: rgba(139,92,246,0.12);
  --green:     #4ade80;
  --yellow:    #fbbf24;
  --red:       #f87171;
  --cyan:      #22d3ee;
  --radius:    8px;
  --radius-lg: 14px;
  --shadow:    0 4px 24px rgba(0,0,0,0.4);
  --font:      'Inter', 'PingFang SC', 'Noto Sans SC', 'Microsoft YaHei', sans-serif;
  --mono:      'JetBrains Mono', 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
  --max-w:     760px;
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.75;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent3); text-decoration: none; transition: color .2s; }
a:hover { color: var(--accent); text-decoration: underline; }

h1,h2,h3,h4,h5 {
  font-weight: 700;
  line-height: 1.3;
  color: var(--text);
  margin-bottom: .5em;
}

p { margin-bottom: 1.1em; color: var(--text); }

ul, ol { padding-left: 1.6em; margin-bottom: 1.1em; }
li { margin-bottom: .35em; }

strong { color: var(--accent3); }
em { color: var(--yellow); font-style: normal; }

hr { border: none; border-top: 1px solid var(--border); margin: 2.5rem 0; }

/* ── Navigation ──────────────────────────────────────── */
.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(26,29,35,0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
}

.nav-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 58px;
  gap: 1rem;
}

.nav-logo {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text) !important;
  text-decoration: none !important;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: .5rem;
}

.nav-logo .logo-icon {
  width: 28px; height: 28px;
  background: var(--accent);
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  font-size: .8rem; color: #fff; font-weight: 800;
  flex-shrink: 0;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 1.2rem;
  list-style: none;
  padding: 0; margin: 0;
  flex-wrap: wrap;
}

.nav-links a {
  font-size: .9rem;
  color: var(--text2) !important;
  transition: color .2s;
  text-decoration: none !important;
}

.nav-links a:hover,
.nav-links a.active { color: var(--accent3) !important; }

.nav-cta {
  background: var(--accent);
  color: #fff !important;
  padding: .3rem .9rem;
  border-radius: 20px;
  font-size: .85rem;
  font-weight: 600;
  transition: background .2s;
}
.nav-cta:hover { background: var(--accent2) !important; text-decoration: none !important; }

/* ── Hero (index) ─────────────────────────────────────── */
.hero {
  background: linear-gradient(135deg, #1a1d23 0%, #1e1529 50%, #1a1d23 100%);
  padding: 5rem 1.5rem 4rem;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  top: -120px; left: 50%;
  transform: translateX(-50%);
  width: 600px; height: 600px;
  background: radial-gradient(circle, rgba(139,92,246,.18) 0%, transparent 70%);
  pointer-events: none;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  background: var(--accent-bg);
  border: 1px solid rgba(139,92,246,.3);
  border-radius: 20px;
  padding: .3rem .9rem;
  font-size: .82rem;
  color: var(--accent3);
  margin-bottom: 1.5rem;
}

.hero h1 {
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: .8rem;
  background: linear-gradient(135deg, var(--text) 0%, var(--accent3) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-sub {
  font-size: 1.1rem;
  color: var(--text2);
  max-width: 580px;
  margin: 0 auto 2.5rem;
  line-height: 1.7;
}

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

.hero-stats .stat-num {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--accent3);
  display: block;
}
.hero-stats .stat-label {
  font-size: .82rem;
  color: var(--text3);
}

.hero-actions {
  display: flex;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .7rem 1.6rem;
  border-radius: 8px;
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .2s;
  text-decoration: none !important;
  border: none;
}

.btn-primary {
  background: var(--accent);
  color: #fff !important;
}
.btn-primary:hover { background: var(--accent2); transform: translateY(-1px); box-shadow: 0 4px 16px rgba(139,92,246,.4); }

.btn-outline {
  background: transparent;
  color: var(--text) !important;
  border: 1px solid var(--border);
}
.btn-outline:hover { border-color: var(--accent3); color: var(--accent3) !important; transform: translateY(-1px); }

/* ── Container & Layout ────────────────────────────────── */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

.section {
  padding: 4rem 1.5rem;
}

.section-title {
  font-size: 1.6rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: 2.5rem;
  color: var(--text);
}

.section-title span {
  color: var(--accent3);
}

/* ── Cards (index chapter list) ───────────────────────── */
.card-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.2rem;
  max-width: 1100px;
  margin: 0 auto;
}

.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  transition: all .2s;
  position: relative;
  overflow: hidden;
  cursor: pointer;
}

.card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent3));
  opacity: 0;
  transition: opacity .2s;
}

.card:hover {
  border-color: rgba(139,92,246,.4);
  transform: translateY(-3px);
  box-shadow: 0 8px 30px rgba(0,0,0,.35);
}
.card:hover::before { opacity: 1; }

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

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

.card p {
  font-size: .88rem;
  color: var(--text2);
  line-height: 1.6;
  margin: 0;
}

.card-link {
  display: block;
  text-decoration: none !important;
  color: inherit;
}

/* ── Chapter Hero ─────────────────────────────────────── */
.chapter-hero {
  background: linear-gradient(135deg, #1a1d23, #1e1529);
  padding: 3.5rem 1.5rem 3rem;
  border-bottom: 1px solid var(--border);
}

.chapter-hero .breadcrumb {
  font-size: .83rem;
  color: var(--text3);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: .4rem;
  flex-wrap: wrap;
}
.chapter-hero .breadcrumb a { color: var(--text2); }
.chapter-hero .breadcrumb a:hover { color: var(--accent3); }
.chapter-hero .breadcrumb span { color: var(--text3); }

.chapter-hero .ch-label {
  display: inline-block;
  background: var(--accent-bg);
  border: 1px solid rgba(139,92,246,.3);
  color: var(--accent3);
  font-size: .8rem;
  font-weight: 700;
  padding: .2rem .7rem;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: .8rem;
}

.chapter-hero h1 {
  font-size: clamp(1.5rem, 4vw, 2.2rem);
  font-weight: 800;
  margin-bottom: .6rem;
  background: linear-gradient(135deg, var(--text), var(--accent3));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.chapter-hero .ch-desc {
  font-size: 1rem;
  color: var(--text2);
  max-width: 680px;
  line-height: 1.7;
}

/* ── Content area ─────────────────────────────────────── */
.content {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 3rem 1.5rem 4rem;
}

.content h2 {
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--text);
  margin: 2.5rem 0 1rem;
  padding-bottom: .5rem;
  border-bottom: 2px solid var(--border);
}

.content h2::before {
  content: '';
  display: inline-block;
  width: 4px; height: 1.1em;
  background: var(--accent);
  border-radius: 2px;
  vertical-align: middle;
  margin-right: .55rem;
}

.content h3 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--accent3);
  margin: 2rem 0 .7rem;
}

.content h4 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--yellow);
  margin: 1.5rem 0 .5rem;
}

/* ── Callouts ─────────────────────────────────────────── */
.callout {
  border-radius: var(--radius);
  padding: 1.1rem 1.3rem;
  margin: 1.5rem 0;
  border-left: 4px solid;
  display: flex;
  gap: .75rem;
  align-items: flex-start;
  line-height: 1.7;
}

.callout-icon { font-size: 1.1rem; flex-shrink: 0; margin-top: .05rem; }

.callout .callout-body { flex: 1; }
.callout .callout-body > *:last-child { margin-bottom: 0; }

.callout.info  { background: rgba(34,211,238,.08); border-color: #22d3ee; color: #a5f3fc; }
.callout.info .callout-icon::before { content: 'ℹ'; color: #22d3ee; }

.callout.tip   { background: rgba(74,222,128,.08); border-color: #4ade80; color: #bbf7d0; }
.callout.tip .callout-icon::before { content: '✦'; color: #4ade80; }

.callout.warning { background: rgba(251,191,36,.08); border-color: #fbbf24; color: #fde68a; }
.callout.warning .callout-icon::before { content: '⚠'; color: #fbbf24; }

.callout.danger { background: rgba(248,113,113,.08); border-color: #f87171; color: #fecaca; }
.callout.danger .callout-icon::before { content: '✖'; color: #f87171; }

/* ── Code ─────────────────────────────────────────────── */
code {
  font-family: var(--mono);
  font-size: .88em;
  background: var(--bg3);
  color: var(--accent3);
  padding: .15em .45em;
  border-radius: 4px;
  border: 1px solid var(--border);
}

pre {
  font-family: var(--mono);
  font-size: .88rem;
  line-height: 1.65;
  background: #111318;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.3rem 1.5rem;
  overflow-x: auto;
  margin: 1.3rem 0;
  position: relative;
}

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

/* Code highlight spans */
.kw { color: #c792ea; font-weight: 600; }   /* keyword */
.ty { color: #82aaff; }                      /* type */
.st { color: #c3e88d; }                      /* string */
.cm { color: #546e7a; font-style: italic; }  /* comment */
.fn { color: #82aaff; }                      /* function */
.nu { color: #f78c6c; }                      /* number */
.at { color: #ffcb6b; }                      /* attribute / key */
.pr { color: #89ddff; }                      /* property / punctuation */

.pre-label {
  position: absolute;
  top: .6rem; right: .8rem;
  font-size: .72rem;
  color: var(--text3);
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: .05em;
}

/* ── Definition list ──────────────────────────────────── */
.def-list {
  list-style: none;
  padding: 0;
  margin: 1.2rem 0;
  display: flex;
  flex-direction: column;
  gap: .8rem;
}

.def-list li {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .9rem 1.1rem;
  margin: 0;
}

.def-list li strong {
  display: block;
  font-size: .95rem;
  font-weight: 700;
  color: var(--accent3);
  margin-bottom: .3rem;
}

.def-list li span {
  font-size: .9rem;
  color: var(--text2);
  line-height: 1.65;
}

/* ── Two column ──────────────────────────────────────── */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.2rem;
  margin: 1.3rem 0;
}

@media (max-width: 640px) { .two-col { grid-template-columns: 1fr; } }

.two-col-item {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem;
}

.two-col-item h4 {
  font-size: .92rem;
  font-weight: 700;
  color: var(--accent3);
  margin: 0 0 .5rem;
}

.two-col-item ul {
  padding-left: 1.2em;
  margin: 0;
}

.two-col-item li {
  font-size: .88rem;
  color: var(--text2);
  margin-bottom: .2rem;
}

/* ── Progress ────────────────────────────────────────── */
.progress-wrap {
  margin: 2rem 0;
}

.progress-label {
  font-size: .83rem;
  color: var(--text3);
  margin-bottom: .4rem;
  display: flex;
  justify-content: space-between;
}

.progress {
  background: var(--bg3);
  border-radius: 99px;
  height: 6px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent3));
  border-radius: 99px;
  transition: width 1s ease;
}

/* ── Chapter navigation ──────────────────────────────── */
.chapter-nav {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 2rem 1.5rem 3rem;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  border-top: 1px solid var(--border);
}

.chapter-nav a {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .8rem 1.2rem;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text2) !important;
  font-size: .9rem;
  font-weight: 500;
  transition: all .2s;
  text-decoration: none !important;
  max-width: 48%;
}

.chapter-nav a:hover {
  border-color: var(--accent3);
  color: var(--accent3) !important;
  transform: translateX(0);
  background: var(--bg3);
}

.chapter-nav .prev { flex-direction: row; }
.chapter-nav .next { flex-direction: row-reverse; margin-left: auto; }

.chapter-nav .nav-arrow { font-size: 1.1rem; }

.chapter-nav .nav-label {
  display: flex;
  flex-direction: column;
  gap: .1rem;
}
.chapter-nav .nav-sub {
  font-size: .72rem;
  color: var(--text3);
  font-weight: 400;
}

/* ── Table ───────────────────────────────────────────── */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.3rem 0;
  font-size: .9rem;
}

th {
  background: var(--bg3);
  color: var(--accent3);
  font-weight: 700;
  padding: .7rem 1rem;
  text-align: left;
  border-bottom: 2px solid var(--border);
  font-size: .85rem;
  letter-spacing: .03em;
}

td {
  padding: .65rem 1rem;
  border-bottom: 1px solid var(--border);
  color: var(--text2);
  vertical-align: top;
  line-height: 1.6;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(139,92,246,.04); }

/* ── Tag / Badge ─────────────────────────────────────── */
.tag {
  display: inline-block;
  padding: .18rem .55rem;
  border-radius: 4px;
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .03em;
}

.tag-purple  { background: var(--accent-bg);           color: var(--accent3); border: 1px solid rgba(139,92,246,.3); }
.tag-green   { background: rgba(74,222,128,.1);        color: var(--green);   border: 1px solid rgba(74,222,128,.3); }
.tag-yellow  { background: rgba(251,191,36,.1);        color: var(--yellow);  border: 1px solid rgba(251,191,36,.3); }
.tag-red     { background: rgba(248,113,113,.1);       color: var(--red);     border: 1px solid rgba(248,113,113,.3); }
.tag-cyan    { background: rgba(34,211,238,.1);        color: var(--cyan);    border: 1px solid rgba(34,211,238,.3); }

/* ── Highlight box ─────────────────────────────────────── */
.highlight-box {
  background: var(--accent-bg);
  border: 1px solid rgba(139,92,246,.25);
  border-radius: var(--radius);
  padding: 1.2rem 1.4rem;
  margin: 1.3rem 0;
}

.highlight-box h4 {
  color: var(--accent3);
  margin: 0 0 .5rem;
  font-size: .95rem;
}

/* ── Feature grid ─────────────────────────────────────── */
.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  margin: 1.3rem 0;
}

.feature-item {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  text-align: center;
}

.feature-item .fi-icon {
  font-size: 1.8rem;
  margin-bottom: .5rem;
  display: block;
}

.feature-item h4 {
  font-size: .9rem;
  color: var(--text);
  margin: 0 0 .3rem;
}

.feature-item p {
  font-size: .8rem;
  color: var(--text3);
  margin: 0;
}

/* ── TOC (table of contents) ──────────────────────────── */
.toc {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem 1.4rem;
  margin-bottom: 2rem;
}

.toc h4 {
  font-size: .85rem;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-bottom: .8rem;
}

.toc ol {
  padding-left: 1.4em;
  margin: 0;
}

.toc li {
  font-size: .9rem;
  margin-bottom: .3rem;
}

.toc a { color: var(--text2) !important; }
.toc a:hover { color: var(--accent3) !important; }

/* ── Footer ───────────────────────────────────────────── */
.site-footer {
  background: var(--bg2);
  border-top: 1px solid var(--border);
  padding: 2.5rem 1.5rem;
  text-align: center;
  color: var(--text3);
  font-size: .88rem;
}

.site-footer a { color: var(--text2); }
.site-footer a:hover { color: var(--accent3); }

.footer-inner {
  max-width: 800px;
  margin: 0 auto;
}

.footer-links {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

/* ── Responsive ───────────────────────────────────────── */
@media (max-width: 768px) {
  .nav-links { display: none; }
  .hero { padding: 3.5rem 1.2rem 2.5rem; }
  .hero-stats { gap: 1.5rem; }
  .chapter-nav a { max-width: 100%; }
  .content { padding: 2rem 1.2rem 3rem; }
  .chapter-hero { padding: 2.5rem 1.2rem 2rem; }
}

@media (max-width: 480px) {
  .card-list { grid-template-columns: 1fr; }
  .chapter-nav { flex-direction: column; }
  .chapter-nav a { max-width: 100%; }
}
