/* 2014books magazine-style web styles */
:root {
  --paper: #faf8f3;
  --ink: #1a1a1a;
  --ink-light: #4a4a4a;
  --muted: #7a7a7a;
  --accent: #8b3a3a;
  --accent-hover: #6e2e2e;
  --border: #d8d4cc;
  --border-light: #e8e4dc;
  --shadow: rgba(0,0,0,0.04);
  --warn-bg: #fff8f0;
  --warn-border: #e8d5c0;
  --warn-text: #8b5a2b;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  --serif: "Noto Serif CJK SC", "Source Han Serif SC", "STSong", "SimSun", "Songti SC", serif;
}

/* Night mode variables */
html.night {
  --paper: #1e1e1e;
  --ink: #e0dcd0;
  --ink-light: #b8b4a8;
  --muted: #888480;
  --accent: #c07070;
  --accent-hover: #d08080;
  --border: #3a3a3a;
  --border-light: #2e2e2e;
  --shadow: rgba(0,0,0,0.2);
  --warn-bg: #2a2520;
  --warn-border: #4a4035;
  --warn-text: #c8a070;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--serif);
  background: var(--paper);
  color: var(--ink);
  line-height: 1.85;
  font-size: 17px;
}

/* Typography */
h1, h2, h3, h4 {
  font-family: var(--serif);
  font-weight: 600;
  line-height: 1.3;
  color: var(--ink);
}

a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s;
}

a:hover { border-bottom-color: var(--accent); }

/* Reading progress bar */
.reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  background: var(--accent);
  z-index: 200;
  width: 0%;
  transition: width 0.1s linear;
}

/* Hero / Masthead */
.hero {
  background: linear-gradient(180deg, #f5f2ec 0%, var(--paper) 100%);
  border-bottom: 1px solid var(--border);
  padding: 4rem 1.5rem 3rem;
  text-align: center;
  position: relative;
}

.hero::before {
  content: "";
  display: block;
  width: 48px;
  height: 3px;
  background: var(--accent);
  margin: 0 auto 1.5rem;
}

.hero .issue-label {
  font-family: var(--sans);
  font-size: 0.8rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 1rem;
}

.hero h1 {
  font-size: 2.6rem;
  margin: 0 0 1rem;
  letter-spacing: 0.02em;
  font-weight: 700;
}

.hero .subtitle {
  font-size: 1.15rem;
  color: var(--ink-light);
  margin: 0 0 1.5rem;
  font-style: italic;
}

.hero .lead {
  max-width: 600px;
  margin: 0 auto 2rem;
  font-size: 1rem;
  color: var(--muted);
  line-height: 1.8;
}

.hero-badges {
  display: flex;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 2rem;
}

.badge {
  font-family: var(--sans);
  font-size: 0.75rem;
  padding: 0.35rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 2px;
  color: var(--muted);
  background: rgba(255,255,255,0.6);
  letter-spacing: 0.05em;
}

.hero-cta {
  display: flex;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.btn {
  font-family: var(--sans);
  font-size: 0.9rem;
  padding: 0.7rem 1.6rem;
  border: 1px solid var(--accent);
  border-radius: 2px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  letter-spacing: 0.05em;
  transition: all 0.2s;
}

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

.btn-ghost {
  background: transparent;
  color: var(--accent);
}

.btn-ghost:hover {
  background: var(--accent);
  color: #fff;
}

.btn-small {
  font-size: 0.75rem;
  padding: 0.4rem 0.8rem;
}

/* Container */
.container {
  max-width: 860px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* Section divider */
.section-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 3rem 0;
}

.section-label {
  font-family: var(--sans);
  font-size: 0.7rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

/* Editor's Note */
.editors-note { padding: 2.5rem 0; }

.editors-note h2 {
  font-size: 1.4rem;
  margin: 0 0 1.2rem;
  font-weight: 600;
}

.editors-note p {
  margin: 0 0 1rem;
  color: var(--ink-light);
  text-align: justify;
}

.editors-note .note-meta {
  font-family: var(--sans);
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-light);
}

/* Featured Chapters */
.featured-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.5rem;
  margin-top: 1.5rem;
}

@media (max-width: 700px) {
  .featured-grid { grid-template-columns: 1fr; }
}

.featured-card {
  background: #fff;
  border: 1px solid var(--border-light);
  padding: 1.5rem;
  transition: box-shadow 0.2s, border-color 0.2s;
  cursor: pointer;
}

.featured-card:hover {
  box-shadow: 0 4px 16px var(--shadow);
  border-color: var(--border);
}

.featured-card .chapter-num {
  font-family: var(--sans);
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--border);
  line-height: 1;
  margin-bottom: 0.5rem;
}

.featured-card h3 {
  font-size: 1.15rem;
  margin: 0 0 0.6rem;
  font-weight: 600;
}

.featured-card p {
  font-size: 0.95rem;
  color: var(--ink-light);
  margin: 0 0 1rem;
  line-height: 1.7;
}

.featured-card .read-link {
  font-family: var(--sans);
  font-size: 0.8rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* Chapter Archive */
.archive-list { margin-top: 1.5rem; }

.archive-item {
  display: flex;
  gap: 1.2rem;
  padding: 1.2rem 0;
  border-bottom: 1px solid var(--border-light);
  align-items: flex-start;
}

.archive-item:last-child { border-bottom: none; }

.archive-num {
  font-family: var(--sans);
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--border);
  line-height: 1;
  min-width: 2.5rem;
  text-align: right;
  flex-shrink: 0;
}

.archive-content { flex: 1; }

.archive-content h3 {
  font-size: 1.05rem;
  margin: 0 0 0.3rem;
  font-weight: 600;
}

.archive-content h3 a {
  color: var(--ink);
  border-bottom: none;
}

.archive-content h3 a:hover { color: var(--accent); }

.archive-content p {
  font-size: 0.9rem;
  color: var(--muted);
  margin: 0;
  line-height: 1.6;
}

/* Reading Paths */
.reading-paths-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.5rem;
  margin-top: 1.5rem;
}

@media (max-width: 700px) {
  .reading-paths-grid { grid-template-columns: 1fr; }
}

.path-card {
  background: #fff;
  border: 1px solid var(--border-light);
  padding: 1.5rem;
  transition: box-shadow 0.2s;
}

.path-card:hover {
  box-shadow: 0 4px 16px var(--shadow);
}

.path-card h3 {
  font-size: 1.1rem;
  margin: 0 0 0.5rem;
  font-weight: 600;
}

.path-card p {
  font-size: 0.9rem;
  color: var(--ink-light);
  margin: 0 0 1rem;
  line-height: 1.7;
}

.path-card .path-chapters {
  font-family: var(--sans);
  font-size: 0.8rem;
  color: var(--muted);
}

.path-card .path-chapters a {
  margin-right: 0.6rem;
  border-bottom: none;
}

/* Book Archive */
.book-search {
  margin: 1.5rem 0 2rem;
}

.book-search input {
  width: 100%;
  padding: 0.8rem 1rem;
  border: 1px solid var(--border);
  border-radius: 2px;
  font-size: 1rem;
  font-family: var(--sans);
  background: #fff;
  color: var(--ink);
}

.book-search input:focus {
  outline: none;
  border-color: var(--accent);
}

.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.book-card {
  background: #fff;
  border: 1px solid var(--border-light);
  padding: 1.2rem;
  transition: box-shadow 0.2s;
}

.book-card:hover {
  box-shadow: 0 3px 12px var(--shadow);
}

.book-card .book-title {
  font-family: var(--serif);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 0.4rem;
}

.book-card .book-author {
  font-size: 0.9rem;
  color: var(--ink-light);
  margin-bottom: 0.6rem;
}

.book-card .book-meta {
  font-family: var(--sans);
  font-size: 0.75rem;
  color: var(--muted);
  line-height: 1.5;
}

.book-tag {
  display: inline-block;
  font-family: var(--sans);
  font-size: 0.7rem;
  padding: 0.15rem 0.5rem;
  border: 1px solid var(--border-light);
  border-radius: 2px;
  color: var(--muted);
  margin-right: 0.4rem;
  margin-top: 0.4rem;
}

.book-confidence {
  display: inline-block;
  font-family: var(--sans);
  font-size: 0.7rem;
  padding: 0.15rem 0.4rem;
  border-radius: 2px;
  margin-left: 0.4rem;
}

.confidence-high {
  background: #e8f5e9;
  color: #2e7d32;
  border: 1px solid #c8e6c9;
}

.confidence-medium {
  background: #fff8e1;
  color: #f57f17;
  border: 1px solid #ffecb3;
}

.confidence-low {
  background: #ffebee;
  color: #c62828;
  border: 1px solid #ffcdd2;
}

/* Research Appendix */
.research-appendix {
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  padding: 2rem;
  margin: 2rem 0;
}

.research-appendix h2 {
  font-size: 1.2rem;
  margin: 0 0 0.8rem;
  color: var(--warn-text);
}

.research-appendix > p {
  font-size: 0.95rem;
  color: var(--warn-text);
  margin: 0 0 1rem;
  opacity: 0.85;
}

.research-appendix ul {
  margin: 0;
  padding-left: 1.2rem;
}

.research-appendix li {
  font-size: 0.95rem;
  color: var(--ink-light);
  margin-bottom: 0.4rem;
}

/* Chapter reading view (home page inline) */
.chapter-reading {
  background: #fff;
  border: 1px solid var(--border-light);
  padding: 2.5rem 2rem;
  margin: 2rem 0;
}

.chapter-reading h2 {
  font-size: 1.6rem;
  margin: 0 0 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 2px solid var(--border-light);
}

.chapter-reading .chapter-body {
  font-size: 1.05rem;
  line-height: 1.9;
  color: var(--ink-light);
}

.chapter-reading .chapter-body p {
  margin: 0 0 1.2rem;
  text-align: justify;
}

.chapter-reading .chapter-body a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

.chapter-reading .book-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.8rem;
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-light);
}

/* Chapter page styles */
.chapter-page .top-nav {
  position: sticky;
  top: 0;
  background: rgba(250,248,243,0.95);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  padding: 0.6rem 1.5rem;
  z-index: 100;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.chapter-page .nav-title {
  font-family: var(--serif);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ink);
}

.chapter-page .nav-links {
  display: flex;
  gap: 1.2rem;
  font-family: var(--sans);
  font-size: 0.8rem;
}

.chapter-page .nav-links a {
  color: var(--muted);
  border-bottom: none;
}

.chapter-page .nav-links a:hover { color: var(--accent); }

.chapter-page .reading-settings {
  display: flex;
  gap: 0.4rem;
  align-items: center;
}

.chapter-page .chapter-container {
  max-width: 760px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

.chapter-page .chapter-header {
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-light);
}

.chapter-page .chapter-header .back-link {
  font-family: var(--sans);
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 1rem;
  display: inline-block;
}

.chapter-page .chapter-header .chapter-num-display {
  font-family: var(--sans);
  font-size: 0.75rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

.chapter-page .chapter-header h1 {
  font-size: 1.8rem;
  margin: 0;
  font-weight: 700;
  line-height: 1.3;
}

.chapter-page .chapter-body-text {
  font-size: 1.05rem;
  line-height: 1.9;
  color: var(--ink-light);
}

.chapter-page .chapter-body-text p {
  margin: 0 0 1.4rem;
  text-align: justify;
}

.chapter-page .chapter-body-text a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

.chapter-page .chapter-books {
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
}

.chapter-page .chapter-books h3 {
  font-size: 1.1rem;
  margin: 0 0 1rem;
  font-weight: 600;
}

.chapter-page .chapter-nav {
  display: flex;
  justify-content: space-between;
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
}

.chapter-page .chapter-nav a {
  font-family: var(--sans);
  font-size: 0.85rem;
  color: var(--muted);
  border-bottom: none;
}

.chapter-page .chapter-nav a:hover { color: var(--accent); }

/* Mobile drawer */
.drawer-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.4);
  z-index: 150;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s;
}

.drawer-overlay.open {
  opacity: 1;
  visibility: visible;
}

.chapter-drawer {
  position: fixed;
  top: 0;
  left: 0;
  width: 280px;
  height: 100%;
  background: var(--paper);
  border-right: 1px solid var(--border);
  z-index: 160;
  transform: translateX(-100%);
  transition: transform 0.3s ease;
  overflow-y: auto;
  padding: 1.5rem;
}

.chapter-drawer.open {
  transform: translateX(0);
}

.chapter-drawer .drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-light);
}

.chapter-drawer .drawer-title {
  font-family: var(--sans);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.chapter-drawer .drawer-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--muted);
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.chapter-drawer .drawer-item {
  display: block;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border-light);
  font-size: 0.9rem;
  color: var(--ink-light);
  border-bottom: none;
}

.chapter-drawer .drawer-item:hover { color: var(--accent); }

.chapter-drawer .drawer-item .drawer-num {
  font-family: var(--sans);
  font-size: 0.75rem;
  color: var(--muted);
  margin-right: 0.5rem;
  min-width: 1.5rem;
  display: inline-block;
}

/* Navigation */
.top-nav {
  position: sticky;
  top: 0;
  background: rgba(250,248,243,0.95);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  padding: 0.6rem 1.5rem;
  z-index: 100;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.top-nav .nav-title {
  font-family: var(--serif);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ink);
}

.top-nav .nav-links {
  display: flex;
  gap: 1.2rem;
  font-family: var(--sans);
  font-size: 0.8rem;
}

.top-nav .nav-links a {
  color: var(--muted);
  border-bottom: none;
}

.top-nav .nav-links a:hover { color: var(--accent); }

.back-to-top {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  width: 40px;
  height: 40px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.2rem;
  color: var(--muted);
  box-shadow: 0 2px 8px var(--shadow);
  opacity: 0;
  transition: opacity 0.3s;
  z-index: 99;
}

.back-to-top.visible { opacity: 1; }

.back-to-top:hover {
  color: var(--accent);
  border-color: var(--accent);
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 3rem 1.5rem;
  margin-top: 4rem;
  text-align: center;
}

.site-footer p {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0 0 0.5rem;
  font-family: var(--sans);
}

.site-footer .footer-links {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  margin-top: 1rem;
  font-family: var(--sans);
  font-size: 0.8rem;
}

/* Hidden utility */
.hidden { display: none !important; }

/* Responsive */
@media (max-width: 700px) {
  html { font-size: 16px; }
  .hero { padding: 2.5rem 1rem 2rem; }
  .hero h1 { font-size: 1.8rem; }
  .hero .subtitle { font-size: 1rem; }
  .container { padding: 0 1rem; }
  .chapter-reading { padding: 1.5rem 1rem; }
  .top-nav { padding: 0.5rem 1rem; }
  .top-nav .nav-links { display: none; }
  .back-to-top { right: 1rem; bottom: 1rem; }
  .featured-grid { grid-template-columns: 1fr; }
  .reading-paths-grid { grid-template-columns: 1fr; }
  .archive-item { gap: 0.8rem; }
  .archive-num { font-size: 1.4rem; min-width: 2rem; }
  .chapter-page .chapter-container { padding: 1.5rem 1rem 3rem; }
  .chapter-page .chapter-header h1 { font-size: 1.5rem; }
}
