/* ============================================================
   逍遥忆情。·逍遥小说阁 — 都市仙侠 · 墨纸主题样式
   Author: 逍遥忆情。 | fankeyi.com
   © 2026 保留所有权利
   ============================================================ */

/* ---------- 字体加载（思源宋体 + 霞鹜文楷） ---------- */
@font-face {
  font-family: 'LXGW WenKai';
  src: url('https://cdn.jsdelivr.net/npm/cn-fontsource-lxgw-wen-kai-gb-screen@1.0.4/font.woff2') format('woff2');
  font-display: swap;
}

:root {
  /* 墨纸配色：宣纸 + 墨绿 + 朱红 + 淡金（都市仙侠基调） */
  --paper: #f5f1e8;
  --paper-dark: #ede6d3;
  --ink: #2a2420;
  --ink-soft: #4a4038;
  --ink-light: #7a6f63;
  --green: #3a5a4a;
  --green-deep: #2d4a3a;
  --red: #8b2e2e;
  --red-soft: #b04848;
  --gold: #b8935a;
  --line: #d6ccb5;
  --shadow: rgba(42, 36, 32, 0.12);

  --font-serif: 'LXGW WenKai', 'Source Han Serif SC', 'Noto Serif SC', 'Songti SC', 'STSong', serif;
  --font-display: 'LXGW WenKai', 'ZCOOL XiaoWei', 'Source Han Serif SC', serif;
}

/* 夜间模式 */
[data-theme='dark'] {
  --paper: #1a1612;
  --paper-dark: #0f0d0a;
  --ink: #d8cfc0;
  --ink-soft: #b8ae9e;
  --ink-light: #8a8070;
  --green: #6a9a7a;
  --green-deep: #88b09a;
  --red: #c46a6a;
  --gold: #d4b080;
  --line: #3a3228;
  --shadow: rgba(0, 0, 0, 0.4);
}

/* ---------- 基础重置 ---------- */
* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font-serif);
  background: var(--paper);
  color: var(--ink);
  line-height: 1.8;
  font-size: 16px;
  min-height: 100vh;
  background-image:
    radial-gradient(circle at 20% 30%, rgba(184, 147, 90, 0.05), transparent 40%),
    radial-gradient(circle at 80% 70%, rgba(58, 90, 74, 0.04), transparent 40%);
  background-attachment: fixed;
  transition: background-color 0.3s, color 0.3s;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--green-deep); text-decoration: none; transition: color 0.2s; }
a:hover { color: var(--red); }

img { max-width: 100%; height: auto; display: block; }

/* ---------- 顶部导航 ---------- */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(245, 241, 232, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
[data-theme='dark'] .navbar { background: rgba(26, 22, 18, 0.92); }

.nav-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: 2px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.logo .seal {
  display: inline-block;
  width: 28px;
  height: 28px;
  background: var(--red);
  color: var(--paper);
  border-radius: 4px;
  text-align: center;
  line-height: 28px;
  font-size: 14px;
  font-weight: 700;
  transform: rotate(-3deg);
  box-shadow: 0 2px 4px var(--shadow);
}

.nav-links {
  display: flex;
  gap: 28px;
  list-style: none;
  align-items: center;
}
.nav-links a {
  color: var(--ink-soft);
  font-size: 15px;
  position: relative;
}
.nav-links a:hover { color: var(--red); }
.nav-links a.active { color: var(--red); font-weight: 700; }
.nav-links a.active::after {
  content: '';
  position: absolute;
  bottom: -6px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--red);
}

.theme-toggle {
  background: none;
  border: 1px solid var(--line);
  border-radius: 50%;
  width: 36px;
  height: 36px;
  cursor: pointer;
  color: var(--ink-soft);
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}
.theme-toggle:hover { color: var(--red); border-color: var(--red); }

.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  font-size: 24px;
  color: var(--ink);
  cursor: pointer;
}

/* ---------- 首页 Hero ---------- */
.hero {
  max-width: 1200px;
  margin: 0 auto;
  padding: 60px 24px 40px;
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 48px;
  align-items: center;
}

.hero-cover {
  aspect-ratio: 3 / 4;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--green-deep), var(--green));
  box-shadow: 0 20px 40px var(--shadow), 0 0 0 1px var(--line);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 32px 24px;
  color: var(--paper);
  position: relative;
  overflow: hidden;
}
.hero-cover::before {
  content: '';
  position: absolute;
  inset: 8px;
  border: 1px solid rgba(245, 241, 232, 0.25);
  border-radius: 4px;
  pointer-events: none;
}
.hero-cover::after {
  content: '';
  position: absolute;
  right: -40px;
  bottom: -40px;
  width: 160px;
  height: 160px;
  background: radial-gradient(circle, rgba(184, 147, 90, 0.25), transparent 70%);
  pointer-events: none;
}
.cover-title {
  font-family: var(--font-display);
  font-size: 36px;
  font-weight: 700;
  letter-spacing: 8px;
  writing-mode: vertical-rl;
  line-height: 1.2;
  align-self: flex-end;
  margin-right: 4px;
  text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}
.cover-author {
  font-size: 14px;
  letter-spacing: 3px;
  opacity: 0.85;
}
.cover-seal {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 44px;
  height: 44px;
  background: var(--red);
  color: #fff;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  transform: rotate(-5deg);
  letter-spacing: 1px;
  text-align: center;
  line-height: 1.2;
  box-shadow: 0 3px 8px rgba(0,0,0,0.3);
}

.hero-info .eyebrow {
  display: inline-block;
  font-size: 13px;
  color: var(--red);
  letter-spacing: 4px;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}
.hero-info h1 {
  font-family: var(--font-display);
  font-size: 48px;
  letter-spacing: 4px;
  color: var(--ink);
  margin-bottom: 16px;
  line-height: 1.2;
}
.hero-info .meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 20px;
}
.tag {
  display: inline-block;
  padding: 4px 12px;
  background: var(--paper-dark);
  color: var(--ink-soft);
  border-radius: 20px;
  font-size: 13px;
  border: 1px solid var(--line);
}
.tag.primary { background: var(--green-deep); color: var(--paper); border-color: var(--green-deep); }
.hero-info .intro {
  color: var(--ink-soft);
  font-size: 16px;
  line-height: 1.9;
  margin-bottom: 28px;
  max-width: 560px;
}
.hero-btns { display: flex; gap: 12px; flex-wrap: wrap; }
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 28px;
  border-radius: 4px;
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 2px;
  cursor: pointer;
  transition: all 0.2s;
  border: 1px solid transparent;
  font-family: inherit;
}
.btn-primary { background: var(--red); color: #fff; }
.btn-primary:hover { background: var(--red-soft); color: #fff; transform: translateY(-1px); }
.btn-secondary {
  background: transparent;
  color: var(--ink);
  border-color: var(--line);
}
.btn-secondary:hover { border-color: var(--red); color: var(--red); }

/* ---------- 区块标题 ---------- */
.section {
  max-width: 1200px;
  margin: 0 auto;
  padding: 48px 24px;
}
.section-title {
  font-family: var(--font-display);
  font-size: 28px;
  color: var(--ink);
  margin-bottom: 28px;
  letter-spacing: 3px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.section-title::before,
.section-title::after {
  content: '';
  flex: 0 0 40px;
  height: 1px;
  background: linear-gradient(to right, transparent, var(--gold), transparent);
}
.section-title::before { background: linear-gradient(to left, var(--gold), transparent); }

/* ---------- 章节列表 / 卡片 ---------- */
.chapter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.chapter-card {
  background: var(--paper-dark);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  transition: all 0.2s;
}
.chapter-card:hover {
  border-color: var(--red);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px var(--shadow);
}
.chapter-card .num {
  font-family: var(--font-display);
  color: var(--gold);
  font-size: 18px;
  letter-spacing: 2px;
  flex: 0 0 auto;
}
.chapter-card .title {
  flex: 1;
  color: var(--ink);
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chapter-card .date {
  flex: 0 0 auto;
  color: var(--ink-light);
  font-size: 12px;
}

/* 最新动态 */
.timeline {
  border-left: 2px solid var(--line);
  padding-left: 24px;
  margin-left: 8px;
}
.timeline-item {
  position: relative;
  padding-bottom: 20px;
}
.timeline-item::before {
  content: '';
  position: absolute;
  left: -30px;
  top: 8px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 0 3px var(--paper);
}
.timeline-item .t-date { color: var(--ink-light); font-size: 13px; }
.timeline-item .t-title { color: var(--ink); font-size: 15px; margin-top: 2px; }

/* ---------- 作者卡 ---------- */
.author-card {
  background: var(--paper-dark);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 32px;
  display: flex;
  gap: 24px;
  align-items: center;
}
.author-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--green-deep), var(--red));
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--paper);
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 700;
  flex: 0 0 auto;
  box-shadow: 0 4px 12px var(--shadow);
}
.author-info h3 {
  font-family: var(--font-display);
  font-size: 22px;
  color: var(--ink);
  margin-bottom: 6px;
  letter-spacing: 2px;
}
.author-info .bio {
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.7;
}

/* ---------- 页脚 ---------- */
.footer {
  margin-top: 80px;
  padding: 40px 24px 24px;
  background: var(--paper-dark);
  border-top: 1px solid var(--line);
  text-align: center;
  color: var(--ink-light);
  font-size: 13px;
  line-height: 1.9;
}
.footer a { color: var(--ink-soft); }
.footer .copyright {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
  display: inline-block;
}

/* ===== 书籍详情页 ===== */
.book-header {
  max-width: 1200px;
  margin: 0 auto;
  padding: 48px 24px;
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 40px;
}
.book-cover {
  aspect-ratio: 3 / 4;
  border-radius: 6px;
  background: linear-gradient(135deg, var(--green-deep), var(--green));
  position: relative;
  overflow: hidden;
  box-shadow: 0 12px 30px var(--shadow);
  padding: 24px 20px;
  color: var(--paper);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.book-cover::before {
  content: '';
  position: absolute;
  inset: 6px;
  border: 1px solid rgba(245, 241, 232, 0.25);
  border-radius: 3px;
  pointer-events: none;
}
.book-cover .bc-title {
  font-family: var(--font-display);
  font-size: 28px;
  letter-spacing: 6px;
  writing-mode: vertical-rl;
  align-self: flex-end;
}
.book-cover .bc-author { font-size: 12px; letter-spacing: 3px; opacity: 0.85; }
.book-detail h1 {
  font-family: var(--font-display);
  font-size: 36px;
  letter-spacing: 4px;
  margin-bottom: 12px;
}
.book-detail .meta-row {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  color: var(--ink-light);
  font-size: 14px;
  margin-bottom: 16px;
}
.book-detail .meta-row span strong { color: var(--ink); margin-right: 4px; }
.book-detail .synopsis {
  color: var(--ink-soft);
  line-height: 1.9;
  margin: 20px 0 28px;
  padding: 20px;
  background: var(--paper-dark);
  border-left: 3px solid var(--gold);
  border-radius: 0 4px 4px 0;
}

/* 目录 */
.toc-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}
.toc-controls .search-box {
  flex: 1;
  max-width: 280px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--paper-dark);
  color: var(--ink);
  font-family: inherit;
  font-size: 14px;
}
.toc-controls .search-box:focus { outline: none; border-color: var(--red); }
.sort-btn {
  background: none;
  border: 1px solid var(--line);
  padding: 6px 14px;
  border-radius: 20px;
  cursor: pointer;
  color: var(--ink-soft);
  font-family: inherit;
  font-size: 13px;
  transition: all 0.2s;
}
.sort-btn:hover { border-color: var(--red); color: var(--red); }

/* ===== 阅读页 ===== */
.reader-body {
  background: var(--paper);
}
.reader-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(245, 241, 232, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
[data-theme='dark'] .reader-header { background: rgba(26, 22, 18, 0.92); }

.reader-nav {
  max-width: 900px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.reader-nav .back { color: var(--ink-soft); font-size: 14px; flex: 0 0 auto; }
.reader-nav .book-name {
  flex: 1;
  text-align: center;
  font-family: var(--font-display);
  font-size: 16px;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.reader-nav .tools { display: flex; gap: 8px; flex: 0 0 auto; }
.reader-nav .tool-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: transparent;
  cursor: pointer;
  color: var(--ink-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: all 0.2s;
}
.reader-nav .tool-btn:hover { color: var(--red); border-color: var(--red); }

/* 进度条 */
.progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  background: var(--red);
  z-index: 200;
  transition: width 0.1s;
}

.reader-main {
  max-width: 720px;
  margin: 0 auto;
  padding: 48px 24px 80px;
  position: relative;
}
.chapter-title {
  font-family: var(--font-display);
  font-size: 32px;
  text-align: center;
  letter-spacing: 4px;
  margin-bottom: 8px;
  color: var(--ink);
}
.chapter-sub {
  text-align: center;
  color: var(--ink-light);
  font-size: 13px;
  letter-spacing: 3px;
  margin-bottom: 12px;
}
.chapter-divider {
  text-align: center;
  color: var(--gold);
  font-size: 20px;
  margin-bottom: 32px;
  letter-spacing: 8px;
}
.chapter-content {
  font-size: 18px;
  line-height: 2;
  color: var(--ink);
  position: relative;
  /* 阻止复制的视觉提示（不影响 SEO） */
  user-select: none;
  -webkit-user-select: none;
}
.chapter-content p {
  margin-bottom: 1.3em;
  text-indent: 2em;
}

/* 隐形水印（人眼几乎看不见，但会被一起复制） */
.invisible-watermark {
  position: absolute;
  color: rgba(0,0,0,0);
  user-select: text;
  -webkit-user-select: text;
  font-size: 1px;
  pointer-events: none;
}

/* 章节底部版权栏 */
.chapter-footer {
  margin-top: 48px;
  padding: 24px;
  border-top: 2px solid var(--line);
  text-align: center;
  color: var(--ink-light);
  font-size: 13px;
  line-height: 1.8;
}
.chapter-footer .cf-title { color: var(--red); font-weight: 700; margin-bottom: 6px; }

/* 上下章按钮 */
.chapter-actions {
  margin-top: 40px;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
}
.chapter-actions .btn {
  padding: 14px;
  justify-content: center;
  text-align: center;
  font-size: 14px;
}
.chapter-actions .btn.disabled {
  opacity: 0.4;
  pointer-events: none;
}

/* 阅读页侧边目录（抽屉） */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
  z-index: 150;
}
.drawer-backdrop.open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed;
  top: 0;
  right: -360px;
  width: 320px;
  max-width: 85vw;
  height: 100vh;
  background: var(--paper);
  border-left: 1px solid var(--line);
  transition: right 0.25s;
  z-index: 160;
  display: flex;
  flex-direction: column;
}
.drawer.open { right: 0; }
.drawer-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.drawer-header h3 {
  font-family: var(--font-display);
  font-size: 18px;
  letter-spacing: 2px;
}
.drawer-close {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--ink-soft);
}
.drawer-list {
  list-style: none;
  padding: 8px 0;
  overflow-y: auto;
  flex: 1;
}
.drawer-list li a {
  display: block;
  padding: 12px 20px;
  color: var(--ink-soft);
  font-size: 14px;
  border-bottom: 1px dashed var(--line);
}
.drawer-list li a:hover { background: var(--paper-dark); color: var(--red); }
.drawer-list li a.current { color: var(--red); background: var(--paper-dark); font-weight: 700; }

/* 字号调节面板 */
.settings-panel {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
  box-shadow: 0 8px 24px var(--shadow);
  z-index: 100;
  display: none;
  min-width: 220px;
}
.settings-panel.open { display: block; }
.settings-panel .sp-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  font-size: 14px;
}
.settings-panel .sp-row:last-child { margin-bottom: 0; }
.font-size-btns button {
  width: 28px;
  height: 28px;
  border: 1px solid var(--line);
  background: transparent;
  border-radius: 4px;
  cursor: pointer;
  margin-left: 4px;
}
.font-size-btns button:hover { border-color: var(--red); color: var(--red); }

/* 背景色选择 */
.bg-options { display: flex; gap: 6px; }
.bg-options button {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid var(--line);
  cursor: pointer;
}
.bg-options button.active { border-color: var(--red); }

/* ============== 响应式 ============== */
@media (max-width: 820px) {
  .nav-links { display: none; }
  .mobile-menu-btn { display: block; }
  .nav-links.mobile-open {
    display: flex;
    flex-direction: column;
    position: absolute;
    top: 64px;
    left: 0;
    right: 0;
    background: var(--paper);
    padding: 20px;
    border-bottom: 1px solid var(--line);
    gap: 16px;
  }
  .hero {
    grid-template-columns: 1fr;
    gap: 24px;
    padding: 32px 20px;
  }
  .hero-cover { max-width: 220px; margin: 0 auto; }
  .hero-info { text-align: center; }
  .hero-info h1 { font-size: 32px; }
  .hero-info .intro { font-size: 15px; }
  .hero-btns { justify-content: center; }

  .book-header { grid-template-columns: 1fr; padding: 32px 20px; gap: 24px; }
  .book-cover { max-width: 200px; margin: 0 auto; }
  .book-detail { text-align: center; }
  .book-detail .meta-row { justify-content: center; }

  .chapter-title { font-size: 26px; }
  .chapter-content { font-size: 17px; line-height: 1.95; }
  .reader-main { padding: 32px 20px 60px; }
  .chapter-actions { grid-template-columns: 1fr; }

  .section-title { font-size: 22px; letter-spacing: 2px; }
  .author-card { flex-direction: column; text-align: center; padding: 24px; }
}

@media (max-width: 480px) {
  body { font-size: 15px; }
  .logo { font-size: 18px; }
  .hero-info h1 { font-size: 26px; letter-spacing: 2px; }
  .chapter-title { font-size: 22px; }
}

/* 打印版权保护：隐藏内容 */
@media print {
  body::before {
    content: '本作品版权所有 © 逍遥忆情。 · fankeyi.com · 禁止打印与传播';
    display: block;
    text-align: center;
    font-size: 24px;
    padding: 100px;
  }
  .chapter-content,
  .reader-main,
  .hero,
  .section { display: none !important; }
}
