/* 正则表达式完全指南 — common.css (finetune style) */
: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: #22c55e;
  --accent-2: #4ade80;
  --accent-glow: rgba(34,197,94,0.18);
  --yellow: #facc15;
  --blue: #60a5fa;
  --red: #f87171;
  --purple: #c084fc;
  --cyan: #22d3ee;
  --orange: #fb923c;
  --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.7;
  min-height: 100vh;
}

/* ── 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; }

/* ── HERO (index) ── */
.hero {
  position: relative; overflow: hidden;
  padding: 6rem 2rem 6rem; text-align: center;
  background: radial-gradient(ellipse 80% 60% at 50% 0%, rgba(34,197,94,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(34,197,94,0.06) 0%, transparent 50%),
    radial-gradient(circle at 85% 20%, rgba(74,222,128,0.04) 0%, transparent 40%),
    radial-gradient(circle at 55% 85%, rgba(34,197,94,0.04) 0%, transparent 40%);
}

/* Matrix particle animation */
.flame-bg {
  position: absolute; inset: 0; pointer-events: none; overflow: hidden;
}
.flame-bg .particle {
  position: absolute; width: 2px;
  border-radius: 1px;
  animation: matrixFall 4s linear infinite;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px; color: var(--accent); opacity: 0.5;
}
.flame-bg .particle:nth-child(1)  { left: 8%;   animation-delay: 0s;    animation-duration: 3.5s; }
.flame-bg .particle:nth-child(2)  { left: 18%;  animation-delay: 0.8s;  animation-duration: 4.2s; }
.flame-bg .particle:nth-child(3)  { left: 32%;  animation-delay: 1.5s;  animation-duration: 3.8s; }
.flame-bg .particle:nth-child(4)  { left: 48%;  animation-delay: 0.3s;  animation-duration: 4.5s; }
.flame-bg .particle:nth-child(5)  { left: 62%;  animation-delay: 1.2s;  animation-duration: 3.2s; }
.flame-bg .particle:nth-child(6)  { left: 75%;  animation-delay: 0.6s;  animation-duration: 4.8s; }
.flame-bg .particle:nth-child(7)  { left: 88%;  animation-delay: 2.0s;  animation-duration: 3.6s; }
.flame-bg .particle:nth-child(8)  { left: 25%;  animation-delay: 1.8s;  animation-duration: 4.1s; }
@keyframes matrixFall {
  0%   { top: -20px; opacity: 0; }
  10%  { opacity: 0.6; }
  90%  { opacity: 0.3; }
  100% { top: 110%; opacity: 0; }
}

.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(34,197,94,0.08);
}
.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%, #ccffd6 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text; position: relative;
}
.hero p {
  font-size: 1.1rem; 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;
  margin-top: 1.5rem;
}
.hero-meta span { display: flex; align-items: center; gap: 0.4rem; }
.hero-cta {
  display: inline-flex; align-items: center; gap: 0.5rem;
  padding: 0.75rem 2rem;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #051a0a; font-weight: 700; font-size: 0.95rem;
  border-radius: 40px; text-decoration: none; margin-top: 0.5rem;
  transition: opacity 0.2s, transform 0.2s, box-shadow 0.2s;
  box-shadow: 0 4px 24px rgba(34,197,94,0.35); position: relative;
}
.hero-cta:hover { opacity: 0.9; transform: translateY(-2px); box-shadow: 0 8px 32px rgba(34,197,94,0.45); }
.stack-badges { display: flex; justify-content: center; flex-wrap: wrap; gap: 0.6rem; margin: 2rem 0 1rem; position: relative; }
.stack-badge { padding: 0.3rem 0.8rem; background: rgba(34,197,94,0.1); border: 1px solid rgba(34,197,94,0.25); border-radius: 20px; font-size: 0.8rem; color: var(--accent-2); }

/* ── 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(34,197,94,0.15);
}
@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(34,197,94,0.1); color: var(--accent-2); border: 1px solid rgba(34,197,94,0.2); }

/* ── 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 { 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 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.1em; 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; }
.content ul, .content ol { color: var(--text-2); padding-left: 1.5rem; margin-bottom: 1.2rem; }
.content li { margin-bottom: 0.4rem; line-height: 1.7; }

/* ── 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; }
.def-item { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.25rem; border-left: 3px solid var(--accent); }
.def-term { font-size: 0.9rem; font-weight: 700; color: var(--accent-2); margin-bottom: 0.3rem; letter-spacing: 0.02em; font-family: 'JetBrains Mono', 'Fira Code', monospace; }
.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.7; }
.callout strong { display: block; font-size: 0.8rem; letter-spacing: 0.08em; text-transform: uppercase; margin-bottom: 0.4rem; }
.callout.info { background: rgba(34,197,94,0.07); border-color: var(--accent); color: var(--text-2); }
.callout.info strong { color: var(--accent); }
.callout.tip { background: rgba(96,165,250,0.07); border-color: var(--blue); color: var(--text-2); }
.callout.tip strong { color: var(--blue); }
.callout.warning { background: rgba(250,204,21,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-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.7rem; color: var(--text-3); font-family: inherit; letter-spacing: 0.05em; text-transform: uppercase; }
code { font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', 'SF Mono', Consolas, monospace; font-size: 0.875em; }
p code, li code, td code { background: rgba(34,197,94,0.1); color: var(--accent-2); padding: 0.1em 0.4em; border-radius: 4px; font-size: 0.85em; }

.kw  { color: #22c55e; font-weight: 600; }
.fn  { color: #4ade80; }
.st  { color: #86efac; }
.cm  { color: #4a6b5a; font-style: italic; }
.ty  { color: #22d3ee; }
.nu  { color: #c084fc; }
.at  { color: #f87171; }
.pr  { color: #60a5fa; }
.re  { color: #22c55e; }
.rg  { color: #f87171; }
.rq  { color: #facc15; }

/* ── REGEX BOX ── */
.regex-box {
  background: #090d12; border: 1px solid rgba(34,197,94,0.25);
  border-radius: var(--radius); padding: 1.25rem 1.5rem; margin: 1.5rem 0;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
}
.regex-box .label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-3); margin-bottom: 0.5rem; }
.regex-pattern { font-size: 1rem; color: var(--accent); margin-bottom: 0.75rem; word-break: break-all; }
.regex-subject { font-size: 0.9rem; line-height: 2; color: var(--text-2); }
.regex-note { font-size: 0.75rem; color: var(--text-3); margin-top: 0.5rem; font-family: inherit; }
.regex-match { background: rgba(34,197,94,0.18); border-bottom: 2px solid var(--accent); border-radius: 2px; color: var(--accent-2); padding: 0 2px; }
.regex-group1 { background: rgba(192,132,252,0.15); border-bottom: 2px solid var(--purple); border-radius: 2px; color: #e9d5ff; padding: 0 2px; }
.regex-group2 { background: rgba(251,146,60,0.15); border-bottom: 2px solid var(--orange); border-radius: 2px; color: #fed7aa; padding: 0 2px; }

/* ── 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; }
.two-col-item li { margin-bottom: 0.35rem; }

/* ── ASCII FLOW ── */
.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', 'Fira Code', monospace;
  font-size: 0.82rem; line-height: 1.9; color: var(--text-2);
  overflow-x: auto; white-space: pre;
}

/* ── COMPARE TABLE ── */
.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(34,197,94,0.03); }
.compare-table tr:hover td { background: rgba(34,197,94,0.06); }
.compare-table td:first-child { font-family: 'JetBrains Mono', monospace; color: var(--accent-2); font-size: 0.82rem; }

/* ── HIGHLIGHT BOX ── */
.highlight-box { background: linear-gradient(135deg, rgba(34,197,94,0.08), rgba(74,222,128,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; min-width: 0; max-width: 48%; }
.chapter-nav a:hover { background: var(--card); border-color: var(--border-bright); }
.chapter-nav .label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-3); }
.chapter-nav .title { 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; }

/* ── 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%; }
}
