/* Java 并发编程教程 — 古法编程
   风格：暖白背景 + 深蓝黑文字 + 橙红 accent
   以可阅读性为首要原则
*/
:root {
  --bg: #fafaf8;
  --surface: #f4f3ef;
  --surface-2: #ece9e2;
  --card: #ffffff;
  --card-hover: #fff8f4;
  --border: rgba(30,41,59,0.1);
  --border-bright: rgba(234,88,12,0.35);
  --text: #1e293b;
  --text-2: #334155;
  --text-3: #64748b;
  --accent: #ea580c;
  --accent-2: #c2410c;
  --accent-light: #fff7ed;
  --accent-glow: rgba(234,88,12,0.10);
  --green: #16a34a;
  --blue: #2563eb;
  --red: #dc2626;
  --yellow: #ca8a04;
  --purple: #7c3aed;
  --radius: 8px;
  --radius-lg: 12px;
}

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

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', system-ui, sans-serif;
  font-size: 17px;
  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: 56px;
  background: rgba(250,250,248,0.96);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
  box-shadow: 0 1px 4px rgba(30,41,59,0.06);
}

.nav-back {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  white-space: nowrap;
  transition: color 0.2s, background 0.2s;
  padding: 4px 12px;
  border: 1px solid var(--border-bright);
  border-radius: 6px;
  background: var(--accent-light);
}
.nav-back:hover { background: #ffedd5; color: var(--accent-2); }

.nav-title {
  color: var(--text-3);
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── HERO (index) ── */
.hero {
  position: relative;
  padding: 5rem 2rem 4.5rem;
  text-align: center;
  overflow: hidden;
  background: linear-gradient(160deg, #fff7ed 0%, #fafaf8 40%, #fdf4ff 100%);
  border-bottom: 1px solid var(--border);
}
.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle 500px at 15% 50%, rgba(234,88,12,0.07) 0%, transparent 70%),
    radial-gradient(circle 500px at 85% 50%, rgba(124,58,237,0.05) 0%, transparent 70%);
  pointer-events: none;
}

.hero-badge {
  display: inline-block;
  padding: 4px 16px;
  background: var(--accent-light);
  border: 1px solid rgba(234,88,12,0.3);
  border-radius: 99px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 1.5rem;
}

.hero h1 {
  font-size: clamp(2rem, 5vw, 3.4rem);
  font-weight: 800;
  line-height: 1.15;
  margin-bottom: 1rem;
  color: var(--text);
  letter-spacing: -0.02em;
}
.hero h1 span {
  color: var(--accent);
}

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

.hero-tags {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.6rem;
  margin-bottom: 3rem;
}
.hero-tag {
  padding: 5px 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 99px;
  color: var(--text-3);
  font-size: 0.82rem;
  font-weight: 500;
  box-shadow: 0 1px 3px rgba(30,41,59,0.06);
}

.hero-stats {
  display: flex;
  justify-content: center;
  gap: 3rem;
  flex-wrap: wrap;
}
.stat-item { text-align: center; }
.stat-num {
  display: block;
  font-size: 2rem;
  font-weight: 800;
  color: var(--accent);
  line-height: 1.1;
}
.stat-label { font-size: 0.8rem; color: var(--text-3); }

/* ── CHAPTER HERO ── */
.chapter-hero {
  padding: 4rem 2rem 3rem;
  text-align: center;
  background: linear-gradient(160deg, #fff7ed 0%, #fafaf8 60%);
  border-bottom: 2px solid rgba(234,88,12,0.15);
  position: relative;
  overflow: hidden;
}
.chapter-hero::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle 350px at 50% 110%, rgba(234,88,12,0.08) 0%, transparent 70%);
  pointer-events: none;
}

.ch-num {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  color: var(--accent);
  text-transform: uppercase;
  margin-bottom: 0.75rem;
}

.chapter-hero h1 {
  font-size: clamp(1.7rem, 4vw, 2.6rem);
  font-weight: 800;
  margin-bottom: 0.75rem;
  color: var(--text);
  letter-spacing: -0.01em;
}

.chapter-hero p {
  color: var(--text-2);
  font-size: 1.05rem;
  max-width: 640px;
  margin: 0 auto;
  line-height: 1.8;
}

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

/* ── SECTION HEADINGS ── */
.section-title {
  text-align: center;
  margin-bottom: 2.5rem;
}
.section-title h2 {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--text);
}
.section-title p { color: var(--text-2); margin-top: 0.4rem; }

/* ── CARD LIST (index chapter list) ── */
.card-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.2rem;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem 1.6rem;
  text-decoration: none;
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  transition: border-color 0.2s, transform 0.2s, box-shadow 0.2s;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(30,41,59,0.05);
}
.card:hover {
  border-color: var(--border-bright);
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(234,88,12,0.10);
  background: var(--card-hover);
}

.card-num {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  color: var(--accent);
  text-transform: uppercase;
}
.card h3 {
  font-size: 1.02rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.4;
}
.card p {
  font-size: 0.85rem;
  color: var(--text-2);
  line-height: 1.6;
  flex: 1;
}
.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.3rem;
}
.card-tag {
  padding: 2px 8px;
  background: var(--accent-light);
  border: 1px solid rgba(234,88,12,0.15);
  border-radius: 4px;
  font-size: 0.72rem;
  color: var(--accent-2);
}

/* ── INTRO BLOCK (index) ── */
.intro-block {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  margin: 2rem 0;
  box-shadow: 0 1px 4px rgba(30,41,59,0.06);
}
.intro-block h2 {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.75rem;
}
.intro-block p {
  color: var(--text-2);
  line-height: 1.8;
  margin-bottom: 0.6rem;
}
.intro-block p:last-child { margin-bottom: 0; }

/* ── FEATURES (index) ── */
.features {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
  margin: 2rem 0;
}
.feature-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: 0 1px 3px rgba(30,41,59,0.05);
}
.feature-icon {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
}
.feature-item h3 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 0.25rem;
}
.feature-item p { font-size: 0.83rem; color: var(--text-2); line-height: 1.6; }

/* ── CONTENT (chapter pages) ── */
.content {
  max-width: 760px;
  margin: 0 auto;
  padding: 2.5rem 2rem 5rem;
}

.content h2 {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text);
  margin: 2.8rem 0 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--border);
  position: relative;
  letter-spacing: -0.01em;
}
.content h2::before {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 56px;
  height: 2px;
  background: var(--accent);
}

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

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

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

.content ul, .content ol {
  color: var(--text-2);
  padding-left: 1.6rem;
  margin-bottom: 1.1rem;
}
.content li { margin-bottom: 0.45rem; line-height: 1.8; font-size: 1rem; }
.content strong { color: var(--text); font-weight: 700; }
.content em { color: var(--accent-2); font-style: normal; font-weight: 600; }

/* ── PROGRESS ── */
.progress {
  height: 5px;
  background: var(--surface-2);
  border-radius: 99px;
  margin-bottom: 2.5rem;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #f97316);
  border-radius: 99px;
  transition: width 0.6s ease;
}

/* ── CALLOUT ── */
.callout {
  border-radius: var(--radius);
  padding: 1rem 1.3rem;
  margin: 1.5rem 0;
  border-left: 4px solid;
  font-size: 0.93rem;
  line-height: 1.75;
}
.callout .callout-title {
  font-weight: 700;
  font-size: 0.8rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 0.4rem;
}
.callout p { margin-bottom: 0; }
.callout ul { margin-bottom: 0; }

.callout.info {
  background: #fff7ed;
  border-color: var(--accent);
  color: #7c2d12;
}
.callout.info .callout-title { color: var(--accent); }

.callout.tip {
  background: #f0fdf4;
  border-color: var(--green);
  color: #14532d;
}
.callout.tip .callout-title { color: var(--green); }

.callout.warning {
  background: #fffbeb;
  border-color: var(--yellow);
  color: #713f12;
}
.callout.warning .callout-title { color: var(--yellow); }

.callout.danger {
  background: #fef2f2;
  border-color: var(--red);
  color: #7f1d1d;
}
.callout.danger .callout-title { color: var(--red); }

/* ── CODE ── */
pre {
  background: #1e2a3a;
  color: #e2e8f0;
  border: 1px solid rgba(30,41,59,0.15);
  border-radius: var(--radius);
  padding: 1.3rem 1.5rem;
  overflow-x: auto;
  margin: 1.3rem 0;
  font-size: 0.875rem;
  line-height: 1.75;
  position: relative;
  box-shadow: 0 2px 8px rgba(30,41,59,0.08);
}
pre::before {
  content: attr(data-lang);
  position: absolute;
  top: 0.5rem;
  right: 0.75rem;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: #94a3b8;
  text-transform: uppercase;
}
code {
  font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', Consolas, monospace;
  font-size: 0.875rem;
}
p code, li code {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  color: var(--accent-2);
  font-size: 0.875em;
  font-family: 'JetBrains Mono', 'Fira Code', Consolas, monospace;
}

/* Code highlight spans */
.kw { color: #f97316; font-weight: 700; }   /* keyword — 橙 */
.fn { color: #fbbf24; }                       /* function — 黄 */
.st { color: #34d399; }                       /* string — 绿 */
.cm { color: #64748b; font-style: italic; }   /* comment */
.ty { color: #93c5fd; }                       /* type — 蓝 */
.nu { color: #c084fc; }                       /* number — 紫 */
.at { color: #fb923c; }                       /* annotation — 橙 */
.pr { color: #94a3b8; }                       /* punctuation */

/* ── ASCII DIAGRAM ── */
.ascii-diagram {
  background: #1e2a3a;
  border: 1px solid rgba(30,41,59,0.15);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  font-family: 'JetBrains Mono', Consolas, monospace;
  font-size: 0.82rem;
  line-height: 1.65;
  color: #cbd5e1;
  margin: 1.25rem 0;
  overflow-x: auto;
  white-space: pre;
}

/* ── DEF LIST ── */
.def-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin: 1.25rem 0;
}
.def-item {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 1rem;
  align-items: start;
  padding: 0.9rem 1.1rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 1px 3px rgba(30,41,59,0.04);
}
.def-term {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--accent);
  font-family: 'JetBrains Mono', Consolas, monospace;
  padding-top: 0.05rem;
}
.def-desc {
  font-size: 0.9rem;
  color: var(--text-2);
  line-height: 1.7;
}

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

.two-col-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
}
.two-col-item h4 {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.two-col-item ul {
  padding-left: 1.2rem;
  margin: 0;
}
.two-col-item li {
  font-size: 0.88rem;
  color: var(--text-2);
  margin-bottom: 0.3rem;
}

/* ── CHAPTER NAV ── */
.chapter-nav {
  display: flex;
  justify-content: space-between;
  align-items: stretch;
  gap: 1rem;
  margin-top: 3.5rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
}
.chapter-nav a {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 1rem 1.4rem;
  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;
  min-width: 0;
  flex: 1;
  box-shadow: 0 1px 3px rgba(30,41,59,0.05);
}
.chapter-nav a:hover {
  border-color: var(--border-bright);
  box-shadow: 0 4px 16px rgba(234,88,12,0.10);
}
.chapter-nav .nav-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
}
.chapter-nav .nav-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chapter-nav .prev { text-align: left; }
.chapter-nav .next { text-align: right; }
.chapter-nav .spacer { flex: 1; }

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

/* ── TABLE ── */
.content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.3rem 0;
  font-size: 0.9rem;
}
.content th {
  background: var(--surface-2);
  color: var(--text);
  font-weight: 700;
  padding: 0.6rem 0.9rem;
  border: 1px solid var(--border);
  text-align: left;
}
.content td {
  padding: 0.6rem 0.9rem;
  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); }

/* ── RESPONSIVE ── */
@media (max-width: 768px) {
  .nav { padding: 0 1rem; }
  .hero { padding: 3.5rem 1.25rem 3rem; }
  .container { padding: 2rem 1.25rem; }
  .content { padding: 2rem 1.25rem 4rem; }
  .chapter-hero { padding: 2.5rem 1.25rem 2rem; }
  .def-item { grid-template-columns: 1fr; gap: 0.25rem; }
  .chapter-nav { flex-direction: column; }
}
