/* =====================================================
   在线电子书馆 · 纯前端站点样式
   ===================================================== */

:root {
  --ink: #1f2933;
  --ink-soft: #52606d;
  --muted: #8a94a0;
  --accent: #b45309;
  --accent-deep: #92400e;
  --accent-soft: #fef3e2;
  --paper: #f7f4ef;
  --card: #ffffff;
  --line: #e7e1d6;
  --radius: 12px;
  --shadow: 0 6px 24px rgba(31, 41, 51, 0.08);
}

* { box-sizing: border-box; }

/* 防止类上的 display 声明覆盖 hidden 属性（.book-detail/.not-found 等均依赖 hidden 切换） */
[hidden] { display: none !important; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--paper);
  line-height: 1.7;
}

a { color: inherit; text-decoration: none; }

.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 24px;
}

.muted { color: var(--muted); font-size: 14px; }

/* ---------------- 顶部导航 ---------------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(247, 244, 239, 0.88);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 17px;
  letter-spacing: 1px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  color: #fff;
  font-family: "Noto Serif SC", "Source Han Serif SC", "SimSun", serif;
  background: linear-gradient(145deg, var(--accent), var(--accent-deep));
  box-shadow: 0 3px 10px rgba(146, 64, 14, 0.35);
}

.site-nav { display: flex; gap: 6px; }

.site-nav a {
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 14px;
  color: var(--ink-soft);
  transition: background 0.2s, color 0.2s;
}

.site-nav a:hover { background: rgba(180, 83, 9, 0.08); color: var(--accent-deep); }
.site-nav a.active { background: var(--accent-soft); color: var(--accent-deep); font-weight: 600; }

/* ---------------- 首页 Hero ---------------- */

.hero {
  padding: 72px 0 56px;
  background:
    radial-gradient(1200px 300px at 70% -40%, rgba(180, 83, 9, 0.10), transparent 70%),
    linear-gradient(180deg, #fbf9f5, var(--paper));
  border-bottom: 1px solid var(--line);
}

.hero h1 {
  margin: 0 0 10px;
  font-size: clamp(28px, 4vw, 40px);
  font-family: "Noto Serif SC", "Source Han Serif SC", "SimSun", serif;
  letter-spacing: 2px;
}

.hero-sub { margin: 0; color: var(--ink-soft); font-size: 16px; }

.hero-stats {
  margin: 18px 0 0;
  font-size: 13px;
  color: var(--accent-deep);
  background: var(--accent-soft);
  display: inline-block;
  padding: 4px 14px;
  border-radius: 999px;
}

/* ---------------- 图书卡片 ---------------- */

.main-section { padding: 40px 0 72px; }

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 20px;
}

.section-head h2 {
  margin: 0;
  font-size: 22px;
  font-family: "Noto Serif SC", "Source Han Serif SC", "SimSun", serif;
  letter-spacing: 1px;
}

.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 24px;
}

.book-card {
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(31, 41, 51, 0.04);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.book-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow);
}

.card-body { padding: 14px 16px 16px; }

.card-title {
  margin: 0 0 4px;
  font-size: 16px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-meta {
  margin: 0 0 10px;
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-views {
  display: flex;
  align-items: center;
  gap: 5px;
  margin: 0;
  font-size: 13px;
  color: var(--accent-deep);
}

.card-views svg { flex: none; opacity: 0.75; }

/* ---------------- 封面（纯 CSS 生成） ---------------- */

.cover {
  position: relative;
  aspect-ratio: 3 / 4;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  overflow: hidden;
}

.cover::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(120% 90% at 20% 0%, rgba(255, 255, 255, 0.22), transparent 55%),
    repeating-linear-gradient(115deg, rgba(255, 255, 255, 0.05) 0 2px, transparent 2px 8px);
}

.cover::after {
  content: "";
  position: absolute;
  inset: 10px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 4px;
}

.theme-0 { background: linear-gradient(150deg, #1e3a5f, #2d6a8f); }
.theme-1 { background: linear-gradient(150deg, #7c2d12, #b45309); }
.theme-2 { background: linear-gradient(150deg, #14532d, #4d7c0f); }
.theme-3 { background: linear-gradient(150deg, #3b0764, #7e22ce); }
.theme-4 { background: linear-gradient(150deg, #831843, #be185d); }
.theme-5 { background: linear-gradient(150deg, #0f172a, #3f4c63); }

.cover-title {
  position: relative;
  writing-mode: vertical-rl;
  font-family: "Noto Serif SC", "Source Han Serif SC", "SimSun", serif;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 6px;
  max-height: 78%;
}

.cover-author {
  position: absolute;
  right: 14px;
  bottom: 14px;
  font-size: 11px;
  letter-spacing: 1px;
  opacity: 0.85;
}

.cover-lg { aspect-ratio: auto; width: 100%; height: 380px; }
.cover-lg .cover-title { font-size: 34px; letter-spacing: 8px; }

.cover-sm { width: 84px; aspect-ratio: 3 / 4; flex: none; }
.cover-sm .cover-title { font-size: 15px; letter-spacing: 2px; }
.cover-sm .cover-author { display: none; }
.cover-sm::after { inset: 5px; }

/* ---------------- 详情页 ---------------- */

.main-section.detail { padding-top: 28px; }

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 24px;
}

.breadcrumb a:hover { color: var(--accent-deep); }
.breadcrumb .current { color: var(--ink-soft); }

.book-detail {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 36px;
  align-items: start;
}

.detail-cover-wrap {
  position: sticky;
  top: 88px;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.detail-meta-row { display: flex; gap: 8px; margin-bottom: 14px; }

.chip {
  display: inline-block;
  padding: 3px 12px;
  border-radius: 999px;
  font-size: 12px;
  background: #eef1f5;
  color: var(--ink-soft);
}

.chip-status.chip-ok { background: #e3f4e6; color: #1b6e2f; }
.chip-status.chip-pending { background: var(--accent-soft); color: var(--accent-deep); }

.detail-title {
  margin: 0 0 8px;
  font-size: clamp(26px, 3.4vw, 34px);
  font-family: "Noto Serif SC", "Source Han Serif SC", "SimSun", serif;
  letter-spacing: 1px;
}

.detail-author { margin: 0 0 22px; color: var(--ink-soft); }

/* 点击量面板（重点展示） */

.views-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 10px;
  background: var(--card);
  margin-bottom: 26px;
}

.views-main { display: flex; align-items: center; gap: 14px; }

.views-eye {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-deep);
}

.views-number {
  font-size: 28px;
  font-weight: 700;
  line-height: 1.2;
  color: var(--accent-deep);
  font-variant-numeric: tabular-nums;
}

.views-label { font-size: 12px; color: var(--muted); }

.detail-actions { display: flex; gap: 12px; flex-wrap: wrap; }

/* ---------------- 按钮 ---------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 22px;
  border-radius: 10px;
  border: 1px solid transparent;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
}

.btn-lg { padding: 12px 30px; font-size: 16px; }

.btn-primary {
  background: linear-gradient(145deg, var(--accent), var(--accent-deep));
  color: #fff;
  box-shadow: 0 4px 14px rgba(146, 64, 14, 0.35);
}

.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(146, 64, 14, 0.45); }

.btn-ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--ink-soft);
}

.btn-ghost:hover { border-color: var(--accent); color: var(--accent-deep); }

/* ---------------- 按钮禁用态（H5 未接入时） ---------------- */

.btn-primary:disabled {
  background: #d9d2c6;
  color: #fff;
  box-shadow: none;
  cursor: not-allowed;
}

.btn-primary:disabled:hover {
  transform: none;
  box-shadow: none;
}

/* ---------------- 详情小节 ---------------- */

.detail-section {
  margin-top: 44px;
  padding-top: 8px;
}

.detail-section h2 {
  margin: 0 0 16px;
  font-size: 20px;
  font-family: "Noto Serif SC", "Source Han Serif SC", "SimSun", serif;
  letter-spacing: 1px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.detail-section h2::before {
  content: "";
  width: 4px;
  height: 18px;
  border-radius: 2px;
  background: var(--accent);
}

.desc-text {
  margin: 0;
  color: var(--ink-soft);
  font-size: 15px;
  max-width: 76ch;
}

/* H5 阅读占位（阅读页未接入时显示） */

.reader-placeholder {
  display: grid;
  place-items: center;
  gap: 6px;
  padding: 56px 32px;
  text-align: center;
  width: 100%;
  max-width: 620px;
  border: 2px dashed #d8cfc0;
  border-radius: var(--radius);
  background: repeating-linear-gradient(45deg, #faf8f4, #faf8f4 12px, #f5f1e9 12px, #f5f1e9 24px);
}

.ph-icon { font-size: 40px; }
.ph-title { margin: 6px 0 2px; font-size: 17px; font-weight: 600; }
.ph-desc { margin: 0; font-size: 14px; color: var(--muted); max-width: 56ch; }
.reader-placeholder .btn { margin-top: 14px; }

/* ---------------- 阅读页（H5 整页加载） ---------------- */

body[data-page="reader"] {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.reader-bar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 16px;
  height: 52px;
  padding: 0 20px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.reader-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: none;
  font-size: 14px;
  color: var(--ink-soft);
  padding: 4px 10px;
  border-radius: 8px;
  transition: background 0.2s, color 0.2s;
}

.reader-back:hover { background: var(--accent-soft); color: var(--accent-deep); }

.reader-book-title {
  flex: 1;
  min-width: 0;
  text-align: center;
  font-weight: 600;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.reader-status { flex: none; font-size: 12px; color: var(--muted); }

.reader-main { flex: 1; min-height: 0; }

.reader-container {
  height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
}

.reader-container.has-frame { display: block; padding: 0; }

.reader-frame {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
}

/* 更多图书 */

.more-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

.more-card {
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  transition: transform 0.2s, box-shadow 0.2s;
}

.more-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }

.more-info { min-width: 0; }

.more-title {
  margin: 0 0 6px;
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 未找到 */

.not-found {
  display: grid;
  place-items: center;
  gap: 4px;
  padding: 80px 0;
  text-align: center;
}

.nf-emoji { font-size: 44px; margin: 0; }
.nf-title { margin: 6px 0 2px; font-size: 20px; font-weight: 700; }
.nf-desc { margin: 0 0 18px; color: var(--muted); }

/* ---------------- 页脚 ---------------- */

.site-footer {
  border-top: 1px solid var(--line);
  padding: 22px 0;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
  background: #fbf9f5;
}

/* ---------------- 响应式 ---------------- */

@media (max-width: 760px) {
  .book-detail {
    grid-template-columns: 1fr;
    gap: 24px;
  }

  .detail-cover-wrap {
    position: static;
    max-width: 240px;
    margin: 0 auto;
  }

  .cover-lg { height: 320px; }

  .views-panel { flex-direction: column; align-items: flex-start; }

  .hero { padding: 48px 0 40px; }
}
