/* ============================================================
   纯净小说阅读网站全局样式表
   ============================================================ */

:root {
  --font-size: 18px;
  --line-height: 1.85;
  --max-width: 800px;
  --transition-fast: 0.2s ease;
  --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 主题色彩变量体系 */
html[data-theme="white"] {
  --bg-color: #ffffff;
  --text-color: #23272e;
  --text-muted: #6b7280;
  --surface-bg: #f9fafb;
  --surface-hover: #f3f4f6;
  --border-color: #e5e7eb;
  --primary-color: #3b82f6;
  --primary-hover: #2563eb;
  --primary-text: #ffffff;
  --card-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
  --nav-bg: rgba(255, 255, 255, 0.92);
}

html[data-theme="parchment"] {
  --bg-color: #f7f1e5;
  --text-color: #30261f;
  --text-muted: #796c5f;
  --surface-bg: #ede4d2;
  --surface-hover: #e5dac4;
  --border-color: #dfd2b9;
  --primary-color: #8c5b36;
  --primary-hover: #724727;
  --primary-text: #ffffff;
  --card-shadow: 0 4px 20px rgba(74, 52, 33, 0.08);
  --nav-bg: rgba(247, 241, 229, 0.92);
}

html[data-theme="green"] {
  --bg-color: #e5ede3;
  --text-color: #213326;
  --text-muted: #5e7765;
  --surface-bg: #d7e4d4;
  --surface-hover: #cbdbcb;
  --border-color: #c0d3c0;
  --primary-color: #2e7d4d;
  --primary-hover: #23653d;
  --primary-text: #ffffff;
  --card-shadow: 0 4px 20px rgba(28, 59, 36, 0.08);
  --nav-bg: rgba(229, 237, 227, 0.92);
}

html[data-theme="night"] {
  --bg-color: #1a1b26;
  --text-color: #c0caf5;
  --text-muted: #7aa2f7;
  --surface-bg: #24283b;
  --surface-hover: #2f354d;
  --border-color: #414868;
  --primary-color: #7aa2f7;
  --primary-hover: #bb9af7;
  --primary-text: #1a1b26;
  --card-shadow: 0 4px 25px rgba(0, 0, 0, 0.45);
  --nav-bg: rgba(26, 27, 38, 0.92);
}

html[data-theme="black"] {
  --bg-color: #000000;
  --text-color: #9499a6;
  --text-muted: #5b6270;
  --surface-bg: #121316;
  --surface-hover: #1e2025;
  --border-color: #2a2d34;
  --primary-color: #4f87e8;
  --primary-hover: #6ea1f7;
  --primary-text: #000000;
  --card-shadow: 0 4px 25px rgba(0, 0, 0, 0.8);
  --nav-bg: rgba(0, 0, 0, 0.95);
}

/* 字体族系变量 */
html[data-font="sans"] {
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif;
}

html[data-font="serif"] {
  --font-family: "Noto Serif SC", "Source Han Serif SC", "Songti SC", "SimSun", "STSong", serif;
}

html[data-font="kaiti"] {
  --font-family: "STKaiti", "KaiTi", "BiauKai", "楷体", serif;
}

/* 页面宽度控制 */
html[data-width="narrow"] { --max-width: 680px; }
html[data-width="medium"] { --max-width: 800px; }
html[data-width="wide"] { --max-width: 960px; }

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  background-color: var(--bg-color);
  color: var(--text-color);
  font-family: var(--font-family);
  min-height: 100vh;
  line-height: var(--line-height);
  transition: background-color var(--transition-normal), color var(--transition-normal);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* 顶部阅读进度条 */
.progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 0%;
  background: var(--primary-color);
  z-index: 1100;
  transition: width 0.15s ease-out;
}

/* 顶部常驻导航栏 */
.top-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 56px;
  background: var(--nav-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.25rem;
  z-index: 1000;
  transition: transform var(--transition-normal), background var(--transition-normal), border-color var(--transition-normal);
}

.nav-left, .nav-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.book-title-nav {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-color);
  max-width: 160px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.current-chapter-indicator {
  font-size: 0.85rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 280px;
}

.icon-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-color);
  padding: 0.45rem 0.65rem;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
  font-family: inherit;
  transition: background var(--transition-fast), border-color var(--transition-fast);
}

.icon-btn:hover {
  background: var(--surface-hover);
  border-color: var(--border-color);
}

/* 主阅读区域容器 */
.reader-container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 80px 1.5rem 60px;
  transition: max-width var(--transition-normal);
}

.article-content {
  margin: 0 auto;
}

/* 章节头部信息 */
.chapter-header {
  padding: 2rem 0 2rem;
  border-bottom: 1px dashed var(--border-color);
  margin-bottom: 2.5rem;
  text-align: center;
}

.chapter-title {
  font-size: 1.85rem;
  font-weight: 700;
  line-height: 1.35;
  color: var(--text-color);
  margin-bottom: 0.75rem;
  letter-spacing: 0.02em;
}

.chapter-meta {
  font-size: 0.85rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.meta-dot {
  opacity: 0.6;
}

/* 小说正文段落排版 */
.chapter-body {
  font-size: var(--font-size);
  line-height: var(--line-height);
  letter-spacing: 0.015em;
  color: var(--text-color);
}

.chapter-body p {
  text-indent: 2em;
  margin-bottom: 1.25em;
  text-align: justify;
  text-justify: inter-ideograph;
  word-break: break-word;
}

/* 章节底部操作栏 */
.chapter-footer {
  margin-top: 4rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.nav-page-btn {
  flex: 1;
  padding: 0.75rem 1rem;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  background: var(--surface-bg);
  color: var(--text-color);
  font-size: 0.95rem;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  transition: all var(--transition-fast);
}

.nav-page-btn:hover:not(:disabled) {
  background: var(--surface-hover);
  border-color: var(--primary-color);
  color: var(--primary-color);
}

.nav-page-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.nav-page-btn.primary {
  background: var(--primary-color);
  color: var(--primary-text);
  border-color: var(--primary-color);
}

.nav-page-btn.primary:hover:not(:disabled) {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  color: var(--primary-text);
}

/* 抽屉式目录 */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(2px);
  z-index: 1200;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal);
}

.drawer-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.catalog-drawer {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  width: 380px;
  max-width: 86vw;
  background: var(--bg-color);
  border-right: 1px solid var(--border-color);
  box-shadow: var(--card-shadow);
  z-index: 1250;
  transform: translateX(-100%);
  transition: transform var(--transition-normal);
  display: flex;
  flex-direction: column;
}

.catalog-drawer.active {
  transform: translateX(0);
}

.drawer-header {
  padding: 1.25rem 1.25rem 1rem;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
}

.drawer-title-group h2 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-color);
  margin-bottom: 0.25rem;
}

.drawer-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.25rem;
  padding: 0.25rem 0.5rem;
  cursor: pointer;
  border-radius: 6px;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.close-btn:hover {
  background: var(--surface-hover);
  color: var(--text-color);
}

.drawer-search {
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
}

.drawer-search input {
  width: 100%;
  padding: 0.6rem 0.85rem;
  background: var(--surface-bg);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-color);
  font-size: 0.88rem;
  font-family: inherit;
  outline: none;
  transition: border-color var(--transition-fast);
}

.drawer-search input:focus {
  border-color: var(--primary-color);
}

.catalog-list {
  flex: 1;
  overflow-y: auto;
  list-style: none;
  padding: 0.5rem 0;
}

.catalog-item {
  padding: 0.8rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.92rem;
  color: var(--text-color);
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: all var(--transition-fast);
}

.catalog-item:hover {
  background: var(--surface-hover);
}

.catalog-item.active {
  background: var(--surface-bg);
  color: var(--primary-color);
  font-weight: 600;
  border-left-color: var(--primary-color);
}

.catalog-item-words {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* 阅读设置浮层弹窗 */
.settings-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  z-index: 1200;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal);
}

.settings-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.settings-panel {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.95);
  width: 440px;
  max-width: 92vw;
  background: var(--bg-color);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  box-shadow: var(--card-shadow);
  padding: 1.5rem;
  z-index: 1250;
  opacity: 0;
  pointer-events: none;
  transition: all var(--transition-normal);
}

.settings-panel.active {
  transform: translate(-50%, -50%) scale(1);
  opacity: 1;
  pointer-events: auto;
}

.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-color);
}

.settings-header h3 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-color);
}

.settings-group {
  margin-bottom: 1.25rem;
}

.settings-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.settings-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  display: block;
  margin-bottom: 0.5rem;
}

.settings-val {
  font-size: 0.82rem;
  color: var(--primary-color);
  font-weight: 600;
}

.theme-options {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.theme-chip {
  flex: 1;
  min-width: 65px;
  padding: 0.55rem 0.25rem;
  border-radius: 8px;
  border: 2px solid var(--border-color);
  font-size: 0.82rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  text-align: center;
  transition: all var(--transition-fast);
}

.theme-chip.theme-white { background: #ffffff; color: #111827; }
.theme-chip.theme-parchment { background: #f7f1e5; color: #30261f; }
.theme-chip.theme-green { background: #e5ede3; color: #213326; }
.theme-chip.theme-night { background: #1a1b26; color: #c0caf5; }
.theme-chip.theme-black { background: #000000; color: #9499a6; }

.theme-chip.active {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px var(--primary-color);
}

.font-options {
  display: flex;
  gap: 0.5rem;
}

.choice-btn {
  flex: 1;
  padding: 0.55rem 0.4rem;
  border: 1px solid var(--border-color);
  background: var(--surface-bg);
  color: var(--text-color);
  border-radius: 8px;
  font-size: 0.82rem;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-align: center;
}

.choice-btn:hover {
  background: var(--surface-hover);
}

.choice-btn.active {
  border-color: var(--primary-color);
  background: var(--surface-hover);
  color: var(--primary-color);
  font-weight: 600;
}

.range-control {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.step-btn {
  background: var(--surface-bg);
  border: 1px solid var(--border-color);
  color: var(--text-color);
  padding: 0.35rem 0.65rem;
  border-radius: 6px;
  font-size: 0.85rem;
  cursor: pointer;
  font-family: inherit;
  transition: background var(--transition-fast);
}

.step-btn:hover {
  background: var(--surface-hover);
}

.range-control input[type="range"] {
  flex: 1;
  accent-color: var(--primary-color);
  height: 6px;
  background: var(--border-color);
  border-radius: 3px;
  outline: none;
}

.settings-footer {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
  text-align: right;
}

.reset-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.82rem;
  cursor: pointer;
  font-family: inherit;
  transition: color var(--transition-fast);
}

.reset-btn:hover {
  color: var(--text-color);
  text-decoration: underline;
}

/* 底部固定阅读提示 */
.bottom-tips {
  margin: 2.5rem auto 0;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.82rem;
  padding: 0.6rem 1.25rem;
  background: var(--surface-bg);
  border: 1px dashed var(--border-color);
  border-radius: 20px;
  width: fit-content;
  max-width: 90%;
  letter-spacing: 0.02em;
}

/* 移动端与小屏媒体查询适配 */
@media (max-width: 640px) {
  .top-nav {
    padding: 0 0.75rem;
    height: 50px;
  }

  .btn-label {
    display: none;
  }

  .current-chapter-indicator {
    max-width: 150px;
    font-size: 0.8rem;
  }

  .reader-container {
    padding: 65px 1rem 40px;
  }

  .chapter-header {
    padding: 1rem 0 1.5rem;
    margin-bottom: 1.75rem;
  }

  .chapter-title {
    font-size: 1.4rem;
  }

  .chapter-footer {
    margin-top: 2.5rem;
    gap: 0.5rem;
  }

  .nav-page-btn {
    padding: 0.65rem 0.5rem;
    font-size: 0.88rem;
  }

  .floating-tips {
    display: none;
  }
}
