/* Apache Spark — common.css */
/* 设计参考：LLM微调实战风格 — GitHub Deep Dark + 精调对比度 */
:root {
  --bg:           #0d1117;
  --surface:      #161b22;
  --surface-2:    #21262d;
  --card:         #1c2128;
  --card-hover:   #262c36;
  --border:       rgba(180,185,210,0.12);
  --border-bright:rgba(180,185,210,0.26);
  --text:         #e6edf3;
  --text-2:       #adbac7;
  --text-3:       #768390;
  --accent:       #E25A1C;
  --accent-2:     #fb923c;
  --accent-glow:  rgba(226,90,28,0.18);
  --green:        #4ade80;
  --blue:         #60a5fa;
  --red:          #f87171;
  --yellow:       #fbbf24;
  --purple:       #c084fc;
  --cyan:         #22d3ee;
  --radius:       10px;
  --radius-lg:    14px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'SF Pro Text', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 16px;
  line-height: 1.75;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── NAV ── */
.nav {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; gap: 1rem;
  padding: 0 2rem; height: 56px;
  background: rgba(13,17,23,0.94);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.nav-back {
  color: var(--accent); text-decoration: none;
  font-size: 0.85rem; font-weight: 600; letter-spacing: 0.03em;
  opacity: 0.85; transition: opacity 0.2s;
  display: flex; align-items: center; gap: 0.4rem;
}
.nav-back::before { content: '←'; font-size: 1rem; }
.nav-back:hover { opacity: 1; }
.nav-title {
  flex: 1; text-align: center;
  font-size: 0.9rem; color: var(--text-2); font-weight: 500;
}
.nav-badge {
  background: var(--accent); color: #000;
  font-size: 0.65rem; font-weight: 700;
  padding: 3px 10px; border-radius: 20px;
}

/* ── HERO (index page) ── */
.hero {
  position: relative; overflow: hidden;
  padding: 6rem 2rem 5rem; text-align: center;
  background: radial-gradient(ellipse 80% 60% at 50% 0%, rgba(226,90,28,0.07) 0%, #161b22 40%, #0d1117 100%);
}
.hero::before {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(circle at 15% 50%, rgba(226,90,28,0.07) 0%, transparent 50%),
    radial-gradient(circle at 85% 20%, rgba(226,90,28,0.05) 0%, transparent 40%);
}
.hero-badge {
  display: inline-block; padding: 0.3rem 1rem;
  border: 1px solid var(--border-bright); border-radius: 20px;
  font-size: 0.8rem; color: var(--accent-2);
  letter-spacing: 0.1em; text-transform: uppercase;
  margin-bottom: 1.5rem; background: rgba(226,90,28,0.1);
}
.hero h1 {
  font-size: clamp(2rem, 5vw, 3.2rem);
  font-weight: 700; letter-spacing: -0.02em; line-height: 1.2;
  margin-bottom: 1.2rem;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 50%, #e6edf3 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
  position: relative;
}
.hero p {
  font-size: 1.05rem; color: var(--text-2);
  max-width: 600px; margin: 0 auto 2.5rem; line-height: 1.8; position: relative;
}
.hero-meta {
  display: flex; justify-content: center; gap: 2rem;
  font-size: 0.85rem; color: var(--text-3); position: relative;
}
.hero-meta span { display: flex; align-items: center; gap: 0.4rem; }

/* ── CONTAINER ── */
.container { max-width: 1100px; margin: 0 auto; padding: 4rem 2rem; }
.section-header { text-align: center; margin-bottom: 3rem; }
.section-header h2 { font-size: 1.8rem; font-weight: 700; color: var(--text); margin-bottom: 0.5rem; }
.section-header p { color: var(--text-3); font-size: 0.95rem; }

/* ── CARDS (index) ── */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1.25rem; }
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 1.5rem;
  text-decoration: none; color: var(--text);
  transition: background 0.2s, border-color 0.2s, transform 0.2s, box-shadow 0.2s;
  display: flex; flex-direction: column; gap: 0.75rem;
  opacity: 0; transform: translateY(20px);
  animation: cardIn 0.5s ease forwards;
}
.card:hover {
  background: var(--card-hover); border-color: var(--border-bright);
  transform: translateY(-3px); box-shadow: 0 8px 32px rgba(226,90,28,0.18);
}
@keyframes cardIn { to { opacity: 1; transform: translateY(0); } }
.card-num { font-size: 0.75rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--accent); opacity: 0.7; }
.card-title { font-size: 1rem; font-weight: 600; color: var(--text); line-height: 1.4; }
.card-desc { font-size: 0.85rem; color: var(--text-3); line-height: 1.6; flex: 1; }
.card-tags { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.25rem; }
.tag { font-size: 0.72rem; padding: 0.2rem 0.55rem; border-radius: 6px; background: rgba(226,90,28,0.1); color: var(--accent-2); border: 1px solid rgba(226,90,28,0.22); }

/* ── CHAPTER HERO ── */
.chapter-hero {
  padding: 4.5rem 2rem 3.5rem; text-align: center;
  background: radial-gradient(ellipse at top, #161b22 0%, #0d1117 70%);
  border-bottom: 1px solid var(--border);
  position: relative; overflow: hidden;
}
.chapter-hero::after {
  content: ''; position: absolute; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 200px; height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent-glow), transparent);
}
.ch-num, .chapter-hero .ch-num {
  font-size: 0.75rem; font-weight: 700; letter-spacing: 0.15em;
  text-transform: uppercase; color: var(--accent); opacity: 0.6; margin-bottom: 1rem;
}
.chapter-hero h1 {
  font-size: clamp(1.6rem, 4vw, 2.4rem); font-weight: 700;
  letter-spacing: -0.02em; margin-bottom: 1rem;
  background: linear-gradient(135deg, var(--accent-2), var(--text));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.chapter-hero p { font-size: 1rem; color: var(--text-2); max-width: 560px; margin: 0 auto; line-height: 1.8; }

/* ── CONTENT ── */
.content { max-width: 860px; margin: 0 auto; padding: 3rem 2rem 5rem; }

.content h2 {
  font-size: 1.45rem; font-weight: 700; color: var(--text);
  margin: 3rem 0 1rem; padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border); position: relative;
}
.content h2::before {
  content: ''; position: absolute; bottom: -1px; left: 0;
  width: 40px; height: 1px; background: var(--accent);
}
.content h2:first-child { margin-top: 0; }
.content h3 { font-size: 1.1rem; font-weight: 600; color: var(--accent-2); margin: 2rem 0 0.75rem; }
.content h4 { font-size: 0.8rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-3); margin: 1.5rem 0 0.5rem; }
.content p { color: var(--text-2); margin-bottom: 1.2rem; line-height: 1.85; font-size: 0.97rem; }
.content ul, .content ol { color: var(--text-2); padding-left: 1.5rem; margin-bottom: 1.2rem; }
.content li { margin-bottom: 0.45rem; line-height: 1.75; color: var(--text-2); }
.content strong { color: var(--text); }
.content a { color: var(--accent-2); text-decoration: none; }
.content a:hover { text-decoration: underline; }

/* ── PROGRESS ── */
.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), var(--accent-2)); border-radius: 2px; box-shadow: 0 0 8px var(--accent-glow); transition: width 0.6s ease; }

/* ── DEF LIST ── */
.def-list { display: flex; flex-direction: column; gap: 0.75rem; margin: 1.5rem 0; list-style: none; padding: 0; }
.def-item, .def-list li {
  background: var(--surface); border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius); padding: 1rem 1.25rem;
}
.def-term { font-size: 0.9rem; font-weight: 700; color: var(--accent-2); margin-bottom: 0.3rem; letter-spacing: 0.02em; }
.def-desc { font-size: 0.9rem; color: var(--text-3); line-height: 1.7; }

/* ── CALLOUT ── */
.callout { border-radius: var(--radius); padding: 1rem 1.25rem; margin: 1.5rem 0; border-left: 3px solid; font-size: 0.92rem; line-height: 1.75; }
.callout strong { display: block; font-size: 0.78rem; letter-spacing: 0.08em; text-transform: uppercase; margin-bottom: 0.4rem; }
.callout p { margin: 0; color: inherit; font-size: inherit; }
.callout.info { background: rgba(96,165,250,0.07); border-color: #60a5fa; color: var(--text-2); }
.callout.info strong { color: #60a5fa; }
.callout.tip { background: rgba(74,222,128,0.07); border-color: var(--green); color: var(--text-2); }
.callout.tip strong { color: var(--green); }
.callout.warning { background: rgba(251,191,36,0.07); border-color: var(--yellow); color: var(--text-2); }
.callout.warning strong { color: var(--yellow); }
.callout.danger { background: rgba(248,113,113,0.08); border-color: var(--red); color: var(--text-2); }
.callout.danger strong { color: var(--red); }

/* ── CODE ── */
pre {
  background: #090d12; border: 1px solid var(--border);
  border-top: 2px solid var(--accent);
  border-radius: var(--radius); padding: 1.25rem 1.5rem;
  overflow-x: auto; margin: 1.5rem 0;
  font-size: 0.875rem; line-height: 1.75; position: relative;
}
pre::before { content: attr(data-lang); position: absolute; top: 0.5rem; right: 0.75rem; font-size: 0.68rem; color: var(--text-3); letter-spacing: 0.06em; text-transform: uppercase; }
code { font-family: 'JetBrains Mono', 'Fira Code', 'SF Mono', Consolas, monospace; font-size: 0.875em; }
p code, li code, td code, h3 code {
  background: rgba(226,90,28,0.1); color: var(--accent-2);
  padding: 0.1em 0.45em; border-radius: 4px; font-size: 0.85em;
}

/* ── SYNTAX HIGHLIGHT ── */
.kw { color: var(--accent);    font-weight: 600; }
.fn { color: var(--accent-2); }
.st { color: var(--green); }
.cm { color: var(--text-3);    font-style: italic; }
.ty { color: var(--cyan); }
.nu { color: var(--purple); }
.at { color: var(--red); }
.pr { color: var(--blue); }

/* ── TABLES ── */
table { width: 100%; border-collapse: collapse; margin: 1.5rem 0; font-size: 0.875rem; }
th { background: var(--surface-2); color: var(--accent-2); font-weight: 600; padding: 0.75rem 1rem; text-align: left; border: 1px solid var(--border); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em; }
td { padding: 0.7rem 1rem; border: 1px solid var(--border); color: var(--text-2); vertical-align: top; line-height: 1.65; }
tr:nth-child(even) td { background: rgba(226,90,28,0.03); }
tr:hover td { background: rgba(226,90,28,0.06); }

/* ── TWO COL ── */
.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; } }
.two-col-item { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; }
.two-col-item h4 { font-size: 0.9rem; font-weight: 700; color: var(--accent); margin-bottom: 0.75rem; }
.two-col-item ul { font-size: 0.875rem; color: var(--text-3); padding-left: 1.2rem; }

/* ── ASCII / COMPARE ── */
.ascii-flow {
  background: #090d12; border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.5rem 2rem; margin: 1.5rem 0;
  font-family: 'JetBrains Mono', monospace; font-size: 0.82rem;
  line-height: 1.9; color: var(--text-2); overflow-x: auto; white-space: pre;
}
.compare-table { width: 100%; border-collapse: collapse; margin: 1.5rem 0; font-size: 0.875rem; }
.compare-table th { background: var(--surface-2); color: var(--accent-2); font-weight: 600; padding: 0.75rem 1rem; text-align: left; border: 1px solid var(--border); }
.compare-table td { padding: 0.65rem 1rem; border: 1px solid var(--border); color: var(--text-2); vertical-align: top; }
.compare-table tr:nth-child(even) td { background: rgba(226,90,28,0.03); }
.compare-table tr:hover td { background: rgba(226,90,28,0.06); }

/* ── STEP LIST ── */
.step-list { counter-reset: step; list-style: none; padding: 0; margin: 1.5rem 0; }
.step-list li {
  counter-increment: step; padding: 0.75rem 0.75rem 0.75rem 3.5rem;
  position: relative; border-left: 1px solid var(--border);
  margin-left: 1.5rem; margin-bottom: 0.5rem;
  color: var(--text-2); font-size: 0.92rem; line-height: 1.7;
}
.step-list li::before {
  content: counter(step); position: absolute; left: -1.5rem; top: 0.65rem;
  width: 2rem; height: 2rem; background: var(--card);
  border: 1px solid var(--border-bright); border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem; font-weight: 700; color: var(--accent);
}

/* ── HIGHLIGHT BOX ── */
.highlight-box {
  background: linear-gradient(135deg, rgba(226,90,28,0.08), rgba(251,146,60,0.04));
  border: 1px solid var(--border-bright);
  border-radius: var(--radius-lg); padding: 1.5rem; margin: 1.5rem 0;
}

/* ── CHAPTER NAV ── */
.chapter-nav { display: flex; justify-content: space-between; gap: 1rem; margin-top: 4rem; padding-top: 2rem; border-top: 1px solid var(--border); }
.chapter-nav a {
  display: flex; flex-direction: column; gap: 0.25rem;
  padding: 0.875rem 1.25rem;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); text-decoration: none; color: var(--text);
  transition: background 0.2s, border-color 0.2s, box-shadow 0.2s;
  min-width: 0; max-width: 48%;
}
.chapter-nav a:hover { background: var(--card); border-color: var(--border-bright); box-shadow: 0 4px 16px rgba(0,0,0,0.2); }
.chapter-nav .label, .chapter-nav .nav-dir, .chapter-nav .nav-label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-3); }
.chapter-nav .title, .chapter-nav .nav-title, .chapter-nav .nav-title-text { font-size: 0.9rem; font-weight: 600; color: var(--accent-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chapter-nav .prev { align-items: flex-start; }
.chapter-nav .next { align-items: flex-end; margin-left: auto; }

/* ── SITE FOOTER ── */
.site-footer { text-align: center; padding: 1.5rem; font-size: 0.82rem; color: var(--text-3); border-top: 1px solid var(--border); }
.site-footer a { color: var(--accent); text-decoration: none; opacity: 0.8; }
.site-footer a:hover { opacity: 1; }

/* ── CARD LIST (chapter list on index) ── */
.card-list { list-style: none; }
.card-list li { border-bottom: 1px solid var(--border); }
.card-list li:last-child { border-bottom: none; }
.card-list a { display: flex; align-items: flex-start; gap: 14px; padding: 14px 12px; text-decoration: none; color: inherit; border-radius: var(--radius); transition: background 0.15s; }
.card-list a:hover { background: var(--card-hover); }
.list-num { width: 28px; height: 28px; background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #000; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 0.72rem; font-weight: 800; flex-shrink: 0; }
.list-content { flex: 1; }
.list-title { font-size: 0.95rem; font-weight: 600; color: var(--text); margin-bottom: 3px; }
.list-desc { font-size: 0.8rem; color: var(--text-3); }
.list-chevron { color: var(--text-3); font-size: 1rem; align-self: center; }
.section-label { font-size: 0.7rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-3); margin: 28px 0 10px 2px; }

/* ── MISC ── */
.badge { display: inline-flex; align-items: center; gap: 4px; background: rgba(226,90,28,0.1); border: 1px solid rgba(226,90,28,0.22); color: var(--accent-2); font-size: 0.7rem; font-weight: 700; padding: 2px 8px; border-radius: 4px; font-family: monospace; }
.chip { display: inline-block; background: rgba(226,90,28,0.1); border: 1px solid rgba(226,90,28,0.22); color: var(--text-2); font-size: 0.75rem; padding: 3px 10px; border-radius: 20px; }

/* ── OVERVIEW / FEATURE GRID ── */
.overview-grid, .feature-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1rem; margin: 1.5rem 0; }
.overview-card, .feature-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; transition: border-color 0.2s, transform 0.2s; }
.overview-card:hover, .feature-card:hover { border-color: var(--border-bright); transform: translateY(-2px); }
.overview-card h3, .feature-card h3 { font-size: 0.9rem; font-weight: 700; color: var(--accent-2); margin: 0.5rem 0 0.4rem; }
.overview-card p, .feature-card p { font-size: 0.8rem; color: var(--text-3); line-height: 1.55; margin: 0; }
.fc-icon, .ov-icon { font-size: 1.5rem; margin-bottom: 0.5rem; display: block; }

/* ── RESPONSIVE ── */
@media (max-width: 768px) {
  .nav { padding: 0 1rem; }
  .content { padding: 2rem 1.25rem 4rem; }
  .chapter-hero { padding: 3rem 1.25rem 2.5rem; }
  .container { padding: 3rem 1.25rem; }
  .ascii-flow { font-size: 0.72rem; padding: 1rem; }
  .compare-table { font-size: 0.8rem; }
  .chapter-nav { flex-direction: column; }
  .chapter-nav a { max-width: 100%; }
  .two-col { grid-template-columns: 1fr; }
}


/* ── INDEX PAGE EXTRAS (Remix / tRPC pattern) ── */

.hero-grid-bg {
  position: absolute; inset: 0; pointer-events: none;
  background-image:
    linear-gradient(var(--accent-glow) 1px, transparent 1px),
    linear-gradient(90deg, var(--accent-glow) 1px, transparent 1px);
  background-size: 40px 40px; opacity: 0.35;
}
.hero-glow {
  position: absolute; width: 640px; height: 420px;
  background: radial-gradient(ellipse, var(--accent-glow) 0%, transparent 70%);
  top: -120px; left: 50%; transform: translateX(-50%);
  pointer-events: none;
}
.hero-eyebrow {
  display: inline-block; font-size: 0.78rem; font-weight: 600;
  letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--accent); margin-bottom: 1rem;
  padding: 0.3rem 1rem; border: 1px solid var(--border-bright);
  border-radius: 20px; background: var(--accent-glow); position: relative;
}
.hero-sub-title {
  font-size: 1.1rem; color: var(--text-2); max-width: 580px;
  margin: 0 auto 0.75rem; line-height: 1.75; position: relative; font-weight: 500;
}
.hero-desc {
  font-size: 0.95rem; color: var(--text-3); max-width: 640px;
  margin: 0 auto 2rem; line-height: 1.85; position: relative;
}
.hero-chips {
  display: flex; flex-wrap: wrap; justify-content: center;
  gap: 0.5rem; margin-bottom: 2rem; position: relative;
}

/* ── FEATURE ITEMS ── */
.feature-item {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.25rem;
  transition: border-color 0.2s, transform 0.2s;
}
.feature-item:hover { border-color: var(--border-bright); transform: translateY(-2px); }
.feature-item h3 { font-size: 0.9rem; font-weight: 700; color: var(--accent-2); margin: 0.5rem 0 0.4rem; }
.feature-item p { font-size: 0.8rem; color: var(--text-3); line-height: 1.55; margin: 0; }
.fi-icon { font-size: 1.5rem; margin-bottom: 0.5rem; display: block; }

/* ── LEARN PATH ── */
.learn-path {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); overflow: hidden;
}
.learn-item {
  display: flex; align-items: center; gap: 1rem;
  padding: 1rem 1.25rem; text-decoration: none; color: inherit;
  border-bottom: 1px solid var(--border); transition: background 0.15s;
}
.learn-item:last-child { border-bottom: none; }
.learn-item:hover { background: var(--card-hover); }
.learn-num {
  width: 34px; height: 34px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #000; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.8rem; font-weight: 800;
}
.learn-info { flex: 1; min-width: 0; }
.learn-title { font-size: 0.95rem; font-weight: 600; color: var(--text); margin-bottom: 0.2rem; }
.learn-desc { font-size: 0.8rem; color: var(--text-3); line-height: 1.5; }
.learn-arrow { color: var(--text-3); font-size: 1.3rem; flex-shrink: 0; }

/* ── TYPEWRITER ── */
.typewriter::after { content: '|'; animation: blink 1s step-end infinite; color: var(--accent); }
@keyframes blink { 0%,100% { opacity: 1; } 50% { opacity: 0; } }
