/* ACEpresso — Editorial Newspaper Theme
 * 基于编辑报风（Editorial Print）设计语言
 */

@import url('https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;700;900&family=Noto+Sans+SC:wght@300;400;500;700&family=Space+Mono:wght@400;700&display=swap');

:root {
  /* 纸质底纹色板 */
  --bg: #F3F1EC;
  --surface: #FAF9F6;
  --text: #1A1A1A;
  --text-secondary: #555;
  --text-muted: #888;

  /* 分隔线与边框 */
  --border: #D8D4CC;
  --border-dark: #C0B8A8;

  /* 强调色：深墨色，不用绿色/金色 */
  --accent: #1A1A1A;
  --accent-subtle: #E8E4DF;

  /* 卡片类型标识色（细线而非色块） */
  --card-tip: #4CAF50;
  --card-wrong: #D32F2F;
  --card-right: #1565C0;
  --card-warn: #E65100;
  --card-scene: #7B1FA2;

  /* 布局 */
  --sidebar-width: 260px;
  --header-height: 52px;
  --content-max: 720px;

  /* 字体 */
  --font-serif: 'Noto Serif SC', 'Source Han Serif SC', 'Songti SC', Georgia, serif;
  --font-sans: 'Noto Sans SC', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'Space Mono', 'SF Mono', 'Fira Code', monospace;
}

[data-theme="dark"] {
  --bg: #111111;
  --surface: #1A1A1A;
  --text: #E8E4DF;
  --text-secondary: #999;
  --text-muted: #666;
  --border: #2A2A2A;
  --border-dark: #3A3A3A;
  --accent: #E8E4DF;
  --accent-subtle: #222;
  --card-tip: #81C784;
  --card-wrong: #EF9A9A;
  --card-right: #90CAF9;
  --card-warn: #FFB74D;
  --card-scene: #CE93D8;
}

/* ============ 全局 ============ */

* { margin: 0; padding: 0; box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  font-size: 16px;
}

body {
  font-family: var(--font-serif);
  background: var(--bg);
  color: var(--text);
  line-height: 1.85;
  -webkit-font-smoothing: antialiased;
  transition: background 0.3s, color 0.3s;
}

/* 纸质纹理叠加 */
body::before {
  content: '';
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.025'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 0;
}

/* ============ 进度条 ============ */

.progress-bar {
  position: fixed;
  top: 0; left: 0;
  height: 2px;
  background: var(--text);
  z-index: 1000;
  width: 0%;
  transition: width 0.1s linear;
}

/* ============ 顶部元数据栏 ============ */

.meta-bar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-height);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  z-index: 100;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.meta-bar .meta-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.meta-bar .brand {
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 13px;
  color: var(--text);
  letter-spacing: 0.15em;
}

.meta-bar .brand-sub {
  font-size: 10px;
  color: var(--text-muted);
}

.meta-bar .chapter-label {
  font-weight: 700;
  color: var(--text);
}

.meta-bar .meta-right {
  display: flex;
  align-items: center;
  gap: 20px;
}

.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 4px 12px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.2s;
}

.theme-toggle:hover {
  border-color: var(--text);
  color: var(--text);
}

/* ============ 布局 ============ */

.layout {
  display: flex;
  margin-top: var(--header-height);
  min-height: calc(100vh - var(--header-height));
  position: relative;
  z-index: 1;
}

/* ============ 侧边栏 ============ */

.sidebar {
  position: fixed;
  top: var(--header-height);
  left: 0;
  width: var(--sidebar-width);
  height: calc(100vh - var(--header-height));
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 24px 0;
  z-index: 50;
  font-family: var(--font-sans);
}

.sidebar::-webkit-scrollbar { width: 3px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.toc-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 0 20px 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}

.toc-link {
  display: block;
  padding: 6px 20px;
  font-size: 13px;
  color: var(--text-secondary);
  text-decoration: none;
  border-left: 2px solid transparent;
  transition: all 0.15s;
  line-height: 1.5;
}

.toc-link:hover {
  color: var(--text);
  border-left-color: var(--border-dark);
}

.toc-link.active {
  color: var(--text);
  font-weight: 600;
  border-left-color: var(--text);
}

.toc-h2 { padding-left: 20px; font-weight: 600; font-size: 13px; color: var(--text); margin-top: 12px; }
.toc-h3 { padding-left: 28px; font-size: 12.5px; }
.toc-h4 { padding-left: 36px; font-size: 11.5px; color: var(--text-muted); }

/* 章间导航 */
.chapter-nav {
  padding: 20px;
  border-top: 1px solid var(--border);
  margin-top: 16px;
}

.chapter-nav-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.chapter-nav a {
  display: block;
  padding: 6px 0;
  font-size: 12px;
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 0.15s;
}

.chapter-nav a:hover { color: var(--text); }
.chapter-nav a.current { color: var(--text); font-weight: 600; }

/* ============ 主内容区 ============ */

.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  max-width: var(--content-max);
  padding: 0 48px 120px;
}

/* ============ Hero 章头 ============ */

.hero {
  padding: 56px 0 40px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 48px;
}

.hero-meta {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 20px;
}

.hero h1 {
  font-family: var(--font-serif);
  font-size: 42px;
  font-weight: 900;
  line-height: 1.15;
  color: var(--text);
  margin-bottom: 12px;
  letter-spacing: -0.02em;
}

.hero .subtitle-en {
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 400;
  font-style: italic;
  color: var(--text-muted);
  margin-bottom: 24px;
}

.hero .intro {
  font-size: 16px;
  color: var(--text-secondary);
  line-height: 1.8;
  max-width: 560px;
  border-left: 2px solid var(--text);
  padding-left: 20px;
}

/* ============ Tabs ============ */

.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 40px;
  font-family: var(--font-sans);
}

.tab-btn {
  background: none;
  border: none;
  border-bottom: 1px solid transparent;
  padding: 12px 24px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: -1px;
}

.tab-btn:hover { color: var(--text); }

.tab-btn.active {
  color: var(--text);
  font-weight: 700;
  border-bottom-color: var(--text);
}

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ============ 标题层级 ============ */

.section-heading {
  font-family: var(--font-serif);
  font-size: 28px;
  font-weight: 900;
  color: var(--text);
  margin: 56px 0 24px;
  padding-bottom: 16px;
  border-bottom: 2px solid var(--text);
  line-height: 1.3;
  letter-spacing: -0.01em;
}

.subsection-heading {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  margin: 40px 0 18px;
  line-height: 1.35;
}

.sub-subsection-heading {
  font-family: var(--font-sans);
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin: 28px 0 12px;
  line-height: 1.4;
}

.sub-sub-subsection-heading {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  margin: 24px 0 10px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

/* ============ 正文 ============ */

.main-content p {
  margin-bottom: 18px;
  text-align: justify;
  font-size: 15.5px;
  line-height: 1.9;
}

.main-content strong {
  font-weight: 700;
}

.main-content em {
  font-style: italic;
}

/* 列表 */
.main-content ul, .main-content ol {
  margin: 12px 0 18px 24px;
  font-size: 15px;
}

.main-content li {
  margin-bottom: 6px;
  line-height: 1.8;
}

/* ============ 表格 ============ */

.table-wrapper {
  overflow-x: auto;
  margin: 24px 0;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  font-family: var(--font-sans);
}

th {
  background: var(--text);
  color: var(--bg);
  padding: 10px 14px;
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

tr:nth-child(even) td {
  background: var(--accent-subtle);
}

/* ============ 图片 ============ */

.main-content img {
  max-width: 100%;
  height: auto;
  margin: 24px 0;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: transform 0.2s;
}

.main-content img:hover {
  transform: scale(1.01);
}

/* ============ 知识卡片（编辑报风） ============ */

.card {
  margin: 28px 0;
  padding: 20px 24px;
  border-left: 3px solid;
  position: relative;
  background: var(--surface);
}

.card-label {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  padding: 3px 10px;
  display: inline-block;
  margin-bottom: 10px;
  border: 1px solid;
}

.card p {
  font-size: 14.5px !important;
  line-height: 1.8;
  margin-bottom: 8px !important;
}

.card p:last-child { margin-bottom: 0 !important; }

/* 卡片类型 — 用细线+标签色区分，不用色块背景 */
.card-tip { border-left-color: var(--card-tip); }
.card-tip .card-label { color: var(--card-tip); border-color: var(--card-tip); }

.card-wrong { border-left-color: var(--card-wrong); }
.card-wrong .card-label { color: var(--card-wrong); border-color: var(--card-wrong); }

.card-right { border-left-color: var(--card-right); }
.card-right .card-label { color: var(--card-right); border-color: var(--card-right); }

.card-warn { border-left-color: var(--card-warn); }
.card-warn .card-label { color: var(--card-warn); border-color: var(--card-warn); }

.card-scene { border-left-color: var(--card-scene); }
.card-scene .card-label { color: var(--card-scene); border-color: var(--card-scene); }

.card-memory {
  border-left-color: var(--text-muted);
  background: none;
}

.card-memory .card-label { color: var(--text-muted); border-color: var(--border); }
.card-memory p { font-style: italic; font-size: 14px !important; color: var(--text-secondary); }

/* ============ 自测题 ============ */

.quiz-section {
  padding: 0;
}

.quiz-item {
  margin: 28px 0;
  padding: 20px 24px;
  border: 1px solid var(--border);
  background: var(--surface);
}

.quiz-tag {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  padding: 3px 10px;
  display: inline-block;
  margin-bottom: 12px;
  border: 1px solid var(--border-dark);
  color: var(--text-muted);
}

.quiz-item p {
  font-size: 15px;
  margin-bottom: 12px;
}

.quiz-answer {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-secondary);
}

.quiz-answer summary {
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* ============ 章间导航（底部） ============ */

.chapter-footer {
  margin-top: 80px;
  padding-top: 32px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  font-family: var(--font-sans);
}

.chapter-footer a {
  text-decoration: none;
  color: var(--text-secondary);
  font-size: 13px;
  transition: color 0.15s;
}

.chapter-footer a:hover { color: var(--text); }

.chapter-footer .nav-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.chapter-footer .nav-title {
  font-weight: 600;
}

/* ============ 灯箱 ============ */

.lightbox {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.9);
  z-index: 2000;
  justify-content: center;
  align-items: center;
  cursor: pointer;
}

.lightbox.active { display: flex; }
.lightbox img { max-width: 90vw; max-height: 90vh; object-fit: contain; }

/* ============ 响应式 ============ */

@media (max-width: 1024px) {
  .sidebar { display: none; }
  .main-content {
    margin-left: 0;
    padding: 0 28px 100px;
  }
}

@media (max-width: 640px) {
  .hero h1 { font-size: 30px; }
  .section-heading { font-size: 22px; }
  .main-content { padding: 0 20px 80px; }
  .meta-bar { padding: 0 16px; }
  .meta-bar .brand-sub,
  .meta-bar .chapter-label { display: none; }
}

/* ============ 打印 ============ */

@media print {
  .site-header, .sidebar, .tabs, .chapter-footer, .progress-bar, .theme-toggle, .lightbox {
    display: none !important;
  }
  .main-content {
    margin-left: 0;
    max-width: 100%;
  }
  body { background: white; color: black; }
  .card { break-inside: avoid; }
}
