/* --- Mobile Experience Revolution & Refinements --- */

/* 1. 全局阅读体验优化 */
.book-main-content {
  padding: 1rem 1rem; /* 移动端更紧凑的内边距 */
  max-width: 100%;
}

@media (min-width: 768px) {
  .book-main-content {
    padding: 2rem 1.5rem;
  }
}

@media (min-width: 1024px) {
  .book-main-content {
    padding: 3rem 4rem;
  }
}

.chapter-body {
  line-height: 1.8;
  font-size: 17px; /* 移动端稍大一点的字体 */
  color: var(--color-text-primary);
}

@media (min-width: 768px) {
  .chapter-body {
    font-size: 18px;
  }
}

.chapter-body h2 {
  border-top: 2px solid var(--color-brand-cyan);
  padding-top: 1.5em;
  margin-top: 2.5em;
  margin-bottom: 1em;
}

.chapter-body h3 {
  margin-top: 2em;
  margin-bottom: 0.8em;
  color: var(--color-text-primary);
}

.chapter-body p {
  margin-bottom: 1.5em;
  text-align: justify; /* 移动端两端对齐 */
}

@media (min-width: 768px) {
  .chapter-body p {
    text-align: left; /* 桌面端左对齐 */
  }
}

/* 2. 桌面/移动端元素显隐控制 */
.desktop-only {
  display: none;
}

@media (min-width: 1024px) {
  .desktop-only {
    display: block;
  }
}

.mobile-only {
  display: block;
}

@media (min-width: 1024px) {
  .mobile-only {
    display: none;
  }
}

/* 3. 章节内子目录样式 (TOC) */
.chapter-toc {
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 1.5rem;
  margin: 2rem 0 3rem 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.chapter-toc h4 {
  margin: 0 0 1rem 0;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--color-brand-blue);
  font-family: var(--font-sans);
  text-align: center;
}

.chapter-toc ul, 
.chapter-toc li {
  list-style: none;
  padding: 0;
  margin: 0;
}

.chapter-toc ul {
  counter-reset: toc-counter;
}

.chapter-toc li {
  counter-increment: toc-counter;
  margin-bottom: 0.5rem;
}

.chapter-toc a {
  display: flex;
  align-items: center;
  text-decoration: none;
  color: var(--color-text-secondary);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  line-height: 1.6;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  transition: all 0.3s ease;
  position: relative;
}

.chapter-toc a:before {
  content: counter(toc-counter, decimal-leading-zero);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background-color: var(--color-brand-cyan);
  color: white;
  border-radius: 50%;
  font-size: 0.8rem;
  font-weight: 600;
  margin-right: 0.75rem;
  flex-shrink: 0;
}

.chapter-toc a:hover {
      background-color: rgba(139, 69, 19, 0.1);
  color: var(--color-brand-blue);
  transform: translateX(4px);
}

/* 4. 全新的移动端汉堡导航系统 */
.mobile-nav-toggle {
  display: block;
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 60px;
  height: 60px;
  background: linear-gradient(135deg, var(--color-brand-blue) 0%, #1a365d 100%);
  color: white;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  z-index: 1001;
  box-shadow: 0 6px 20px rgba(10, 37, 64, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.mobile-nav-toggle:hover {
  transform: scale(1.1);
  box-shadow: 0 8px 25px rgba(10, 37, 64, 0.4);
}

@media (min-width: 1024px) {
  .mobile-nav-toggle {
    display: none;
  }
}

.mobile-nav-panel {
  display: block;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  background: linear-gradient(135deg, rgba(10, 37, 64, 0.98) 0%, rgba(26, 54, 93, 0.98) 100%);
  backdrop-filter: blur(10px);
  z-index: 1000;
  padding: 2rem;
  transform: translateY(-100%);
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  overflow-y: auto;
  text-align: center;
}

body.mobile-nav-is-active {
  overflow: hidden;
}

body.mobile-nav-is-active .mobile-nav-panel {
  transform: translateY(0);
}

.mobile-nav-panel .book-info {
  margin-top: 3rem;
  margin-bottom: 2rem;
}

.mobile-nav-panel .book-info h3 a {
  color: white;
  font-size: 1.8rem;
  text-decoration: none;
  font-weight: 700;
}

.mobile-nav-panel .book-subtitle {
  color: rgba(255, 255, 255, 0.8);
  font-size: 1rem;
  margin-top: 0.5rem;
}

.mobile-nav-panel .book-nav h3 {
  color: var(--color-brand-cyan);
  font-size: 1.4rem;
  margin-bottom: 1.5rem;
  font-weight: 700;
}

.mobile-nav-panel .chapter-list {
  max-height: 60vh;
  overflow-y: auto;
}

.mobile-nav-panel .chapter-item {
  margin-bottom: 0.75rem;
}

.mobile-nav-panel .chapter-item a {
  display: flex;
  align-items: center;
  color: rgba(255, 255, 255, 0.9);
  font-family: var(--font-sans);
  font-size: 1rem;
  font-weight: 500;
  text-decoration: none;
  padding: 1rem 1.5rem;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(5px);
  transition: all 0.3s ease;
  text-align: left;
}

.mobile-nav-panel .chapter-item a:hover,
.mobile-nav-panel .chapter-item.current a {
  background: var(--color-brand-cyan);
  color: var(--color-brand-blue);
  transform: scale(1.02);
}

.mobile-nav-panel .chapter-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  font-size: 0.9rem;
  font-weight: 600;
  margin-right: 1rem;
}

.mobile-nav-panel .chapter-item.current .chapter-number {
  background: var(--color-brand-blue);
  color: white;
}

.mobile-nav-close {
  position: absolute;
  top: 20px;
  right: 20px;
  color: white;
  background: none;
  border: none;
  font-size: 2.5rem;
  cursor: pointer;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

.mobile-nav-close:hover {
  background: rgba(255, 255, 255, 0.1);
  transform: rotate(90deg);
}

/* 5. 修正原始的桌面布局 */
.book-container {
  display: block;
  max-width: 100%;
  margin: 0;
  padding: 0;
}

@media (min-width: 1024px) {
  .book-container {
    display: flex;
    max-width: 1400px;
    margin: 0 auto;
    gap: 2rem;
    padding: 0 2rem;
  }
}

.book-sidebar {
  display: none;
}

@media (min-width: 1024px) {
  .book-sidebar {
    display: block;
    width: 320px;
    flex-shrink: 0;
    padding: 2rem;
    position: sticky;
    top: 2rem;
    align-self: flex-start;
    height: calc(100vh - 4rem);
    overflow-y: auto;
    background-color: #f8f9fa;
    border-radius: 10px;
    border: 1px solid var(--color-border);
  }
}

/* 6. 章节标题移动端优化 */
.chapter-header {
  text-align: center;
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 2px solid var(--color-brand-cyan);
}

.chapter-title {
  font-size: 1.8rem !important;
  line-height: 1.3;
  margin-bottom: 1rem;
  color: var(--color-brand-blue);
}

@media (min-width: 768px) {
  .chapter-title {
    font-size: 2.2rem !important;
  }
}

@media (min-width: 1024px) {
  .chapter-title {
    font-size: 2.5rem !important;
  }
}

.chapter-subtitle {
  font-size: 1.1rem;
  color: var(--color-text-secondary);
  font-weight: 400;
  margin: 0;
}

.chapter-meta {
  margin-top: 1rem;
}

.chapter-order {
  display: inline-block;
  background: var(--color-brand-cyan);
  color: var(--color-brand-blue);
  padding: 0.5rem 1rem;
  border-radius: 20px;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 600;
}

/* 7. 章节导航优化 */
.chapter-pagination {
  margin-top: 4rem;
  padding-top: 2rem;
  border-top: 1px solid var(--color-border);
}

.pagination-links {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

@media (min-width: 768px) {
  .pagination-links {
    flex-direction: row;
    justify-content: space-between;
  }
}

.pagination-link {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  padding: 1.5rem;
  border: 1px solid var(--color-border);
  border-radius: 12px;
  background: var(--color-bg-light);
  transition: all 0.3s ease;
  min-width: 0;
}

@media (min-width: 768px) {
  .pagination-link {
    flex: 0 1 48%;
  }
}

.pagination-link:hover {
  border-color: var(--color-brand-cyan);
  background: white;
  transform: translateY(-2px);
      box-shadow: 0 4px 12px rgba(139, 69, 19, 0.1);
}

.pagination-link .link-label {
  font-size: 0.9rem;
  color: var(--color-text-secondary);
  font-family: var(--font-sans);
  font-weight: 500;
  margin-bottom: 0.5rem;
}

.pagination-link .link-title {
  font-size: 1rem;
  color: var(--color-brand-blue);
  font-weight: 600;
  line-height: 1.4;
}

/* 8. 移动端专用优化 */
@media (max-width: 480px) {
  .book-main-content {
    padding: 0.75rem;
  }
  
  .chapter-header {
    margin-bottom: 1.5rem;
  }
  
  .chapter-title {
    font-size: 1.6rem !important;
  }
  
  .chapter-toc {
    padding: 1.25rem;
    margin: 1.5rem 0 2rem 0;
  }
  
  .chapter-body {
    font-size: 16px;
  }
  
  .mobile-nav-toggle {
    width: 55px;
    height: 55px;
    bottom: 15px;
    right: 15px;
  }
} 