/* Reading-Optimized Typography and Layout */

/* Table of Contents Page */
.toc-page {
  max-width: var(--max-width-wide);
  margin: 0 auto;
}

.book-header {
  text-align: center;
  padding: var(--space-3xl) 0;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: var(--space-3xl);
}

.book-title {
  font-size: var(--font-size-4xl);
  font-weight: 800;
  line-height: var(--line-height-tight);
  color: var(--text-primary);
  margin-bottom: var(--space-md);
}

.book-subtitle {
  font-size: var(--font-size-xl);
  color: var(--text-secondary);
  line-height: var(--line-height-relaxed);
  margin-bottom: var(--space-lg);
}

.book-author {
  font-size: var(--font-size-lg);
  color: var(--text-secondary);
  font-weight: 500;
  margin-bottom: var(--space-sm);
}

.reading-estimate {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-md);
  font-size: var(--font-size-sm);
  color: var(--text-muted);
}

.book-description {
  max-width: 60ch;
  margin: var(--space-xl) auto 0;
  font-size: var(--font-size-lg);
  line-height: var(--line-height-relaxed);
  color: var(--text-secondary);
}

/* Table of Contents */
.toc-main {
  margin-bottom: var(--space-3xl);
}

.toc-heading {
  font-size: var(--font-size-2xl);
  font-weight: 700;
  margin-bottom: var(--space-xl);
  text-align: center;
}

.chapter-list {
  list-style: none;
  max-width: 50rem;
  margin: 0 auto;
  display: grid;
  gap: var(--space-lg);
}

.chapter-item {
  background: var(--bg-secondary);
  border-radius: var(--border-radius-lg);
  transition: all 0.2s ease;
  border: 1px solid var(--border-color);
}

.chapter-item:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  border-color: var(--accent-color);
}

.chapter-link {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: var(--space-xl);
  text-decoration: none;
  color: inherit;
  height: 100%;
}

.chapter-info {
  flex: 1;
}

.chapter-number {
  font-size: var(--font-size-sm);
  color: var(--accent-color);
  font-weight: 600;
  margin-bottom: var(--space-xs);
  display: block;
}

.chapter-title {
  font-size: var(--font-size-xl);
  font-weight: 600;
  line-height: var(--line-height-tight);
  color: var(--text-primary);
  margin-bottom: var(--space-sm);
}

.chapter-summary {
  font-size: var(--font-size-base);
  color: var(--text-secondary);
  line-height: var(--line-height-relaxed);
}

.chapter-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--space-xs);
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  margin-left: var(--space-lg);
  flex-shrink: 0;
}

/* Book Statistics */
.book-stats {
  background: var(--bg-secondary);
  border-radius: var(--border-radius-xl);
  padding: var(--space-xl);
  margin: var(--space-3xl) auto;
  max-width: 30rem;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(5rem, 1fr));
  gap: var(--space-lg);
  text-align: center;
}

.stat-item {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.stat-number {
  font-size: var(--font-size-2xl);
  font-weight: 700;
  color: var(--accent-color);
}

.stat-label {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Quick Actions */
.quick-actions {
  text-align: center;
  margin-bottom: var(--space-3xl);
}

.actions-grid {
  display: flex;
  gap: var(--space-lg);
  justify-content: center;
  flex-wrap: wrap;
}

/* Chapter Page */
.chapter {
  max-width: var(--max-width-prose);
  margin: 0 auto;
}

/* Reading Progress */
.reading-progress {
  position: sticky;
  top: var(--header-height);
  z-index: 50;
  margin: 0 -2rem var(--space-xl);
  background: var(--bg-primary);
  padding: var(--space-sm) 0;
  border-bottom: 1px solid var(--border-color);
}

.progress-bar {
  height: 3px;
  background: var(--bg-tertiary);
  border-radius: var(--border-radius-sm);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-color), var(--success-color));
  width: 0%;
  transition: width 0.2s ease;
  border-radius: var(--border-radius-sm);
}

/* Chapter Header */
.chapter-header {
  text-align: center;
  padding-bottom: var(--space-2xl);
  border-bottom: 1px solid var(--border-color);
  margin-bottom: var(--space-2xl);
}

.chapter-number {
  display: inline-block;
  font-size: var(--font-size-sm);
  color: var(--accent-color);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: var(--space-md);
}

.chapter-title {
  font-size: var(--font-size-3xl);
  font-weight: 800;
  line-height: var(--line-height-tight);
  color: var(--text-primary);
  margin-bottom: var(--space-lg);
}

.chapter-summary {
  font-size: var(--font-size-lg);
  color: var(--text-secondary);
  line-height: var(--line-height-relaxed);
  max-width: 50ch;
  margin: 0 auto var(--space-lg);
}

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

.reading-time::before {
  content: "📖 ";
  margin-right: var(--space-xs);
}

.chapter-date::before {
  content: "📅 ";
  margin-right: var(--space-xs);
}

/* Chapter Content - Prose Styles */
.chapter-content.prose {
  font-size: var(--font-size-lg);
  line-height: var(--line-height-relaxed);
  color: var(--text-primary);
}

.prose > * + * {
  margin-top: var(--space-lg);
}

.prose h1,
.prose h2,
.prose h3,
.prose h4,
.prose h5,
.prose h6 {
  font-weight: 700;
  line-height: var(--line-height-tight);
  color: var(--text-primary);
  scroll-margin-top: calc(var(--header-height) + 2rem);
}

.prose h1 {
  font-size: var(--font-size-3xl);
  margin-top: var(--space-3xl);
  margin-bottom: var(--space-xl);
}

.prose h2 {
  font-size: var(--font-size-2xl);
  margin-top: var(--space-2xl);
  margin-bottom: var(--space-lg);
  padding-bottom: var(--space-sm);
  border-bottom: 2px solid var(--border-color);
}

.prose h3 {
  font-size: var(--font-size-xl);
  margin-top: var(--space-xl);
  margin-bottom: var(--space-md);
}

.prose h4 {
  font-size: var(--font-size-lg);
  margin-top: var(--space-lg);
  margin-bottom: var(--space-md);
}

.prose h5,
.prose h6 {
  font-size: var(--font-size-base);
  margin-top: var(--space-md);
  margin-bottom: var(--space-sm);
}

.prose p {
  margin-bottom: var(--space-lg);
}

.prose a {
  color: var(--accent-color);
  text-decoration: none;
  text-decoration-thickness: 2px;
  text-underline-offset: 2px;
  transition: all 0.2s ease;
}

.prose a:hover {
  color: var(--accent-hover);
  /* text-decoration-thickness: 3px; */
}

.prose strong {
  font-weight: 700;
  color: var(--text-primary);
}

.prose em {
  font-style: italic;
  color: var(--text-secondary);
}

.prose code {
  background: var(--bg-secondary);
  color: var(--error-color);
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--border-radius-sm);
  font-size: 0.9em;
  font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
}

.prose pre {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  padding: var(--space-lg);
  border-radius: var(--border-radius-lg);
  overflow-x: auto;
  font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
  font-size: var(--font-size-sm);
  line-height: var(--line-height-normal);
}

.prose pre code {
  background: none;
  color: inherit;
  padding: 0;
  border-radius: 0;
  font-size: inherit;
}

.prose blockquote {
  border-left: 4px solid var(--accent-color);
  padding: var(--space-md) var(--space-lg);
  background: var(--bg-secondary);
  border-radius: 0 var(--border-radius-md) var(--border-radius-md) 0;
  font-style: italic;
  color: var(--text-secondary);
  margin: var(--space-xl) 0;
}

.prose ul,
.prose ol {
  margin: var(--space-lg) 0;
  padding-left: var(--space-xl);
}

.prose li {
  margin: var(--space-sm) 0;
  line-height: var(--line-height-relaxed);
}

.prose table {
  width: 100%;
  border-collapse: collapse;
  margin: var(--space-xl) 0;
}

.prose th,
.prose td {
  padding: var(--space-md);
  border: 1px solid var(--border-color);
  text-align: left;
}

.prose th {
  background: var(--bg-secondary);
  font-weight: 600;
}

.prose img {
  max-width: 100%;
  height: auto;
  border-radius: var(--border-radius-lg);
  margin: var(--space-xl) 0;
  box-shadow: var(--shadow-md);
}

.prose hr {
  border: none;
  height: 2px;
  background: var(--border-color);
  margin: var(--space-3xl) 0;
  border-radius: var(--border-radius-sm);
}

/* Chapter Navigation */
.chapter-nav {
  border-top: 1px solid var(--border-color);
  margin-top: var(--space-3xl);
  padding-top: var(--space-2xl);
}

.nav-container {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: var(--space-lg);
  align-items: center;
}

.nav-link {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: inherit;
  padding: var(--space-lg);
  border-radius: var(--border-radius-lg);
  background: var(--bg-secondary);
  transition: all 0.2s ease;
  border: 1px solid var(--border-color);
}

.nav-link:hover {
  background: var(--bg-tertiary);
  border-color: var(--accent-color);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.nav-prev {
  align-items: flex-start;
  text-align: left;
}

.nav-next {
  align-items: flex-end;
  text-align: right;
}

.nav-toc {
  text-align: center;
  background: var(--accent-color);
  color: white;
  border-color: var(--accent-color);
}

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

.nav-direction {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-xs);
}

.nav-toc .nav-direction {
  color: rgba(255, 255, 255, 0.8);
}

.nav-title {
  font-weight: 600;
  color: var(--text-primary);
  line-height: var(--line-height-tight);
}

.nav-toc .nav-title {
  color: white;
}

.nav-random {
  text-align: center;
  background: var(--success-color);
  color: white;
  border: none;
  border-color: var(--success-color);
  cursor: pointer;
  font-family: inherit;
  font-size: inherit;
}

.nav-random:hover {
  background: #059669;
  border-color: #059669;
}

.nav-random .nav-direction {
  color: rgba(255, 255, 255, 0.9);
}

.nav-random-container {
  display: flex;
  justify-content: center;
  margin-bottom: 16px;
}

.nav-random-container .nav-link {
  min-width: auto;
  width: auto;
  max-width: 200px;
  padding: var(--space-md) var(--space-lg);
}

/* Responsive Design */
@media (max-width: 768px) {
  .book-title {
    font-size: var(--font-size-3xl);
  }
  
  .chapter-title {
    font-size: var(--font-size-2xl);
  }
  
  .chapter-content.prose {
    font-size: var(--font-size-base);
  }
  
  .chapter-link {
    flex-direction: column;
    gap: var(--space-md);
  }
  
  .chapter-meta {
    align-self: stretch;
    align-items: flex-start;
    flex-direction: row;
    justify-content: space-between;
    margin-left: 0;
  }
  
  .nav-container {
    grid-template-columns: 1fr;
    gap: var(--space-md);
  }
  
  .nav-prev,
  .nav-next,
  .nav-toc,
  .nav-random {
    text-align: center;
    align-items: center;
  }
  
  .actions-grid {
    flex-direction: column;
    align-items: center;
  }
  
  .nav-random-container {
    margin: 0;
    margin-bottom: 16px;
  }
  
  .nav-random-container .nav-link {
    max-width: none;
    width: 100%;
    margin: 0;
    text-align: center;
  }
  
  .action-button {
    width: 100%;
    max-width: 20rem;
  }
}

@media (max-width: 480px) {
  .book-header {
    padding: var(--space-2xl) 0;
  }
  
  .chapter-header {
    padding-bottom: var(--space-xl);
  }
  
  .reading-progress {
    margin-left: -1rem;
    margin-right: -1rem;
  }
  
  .chapter-meta {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-xs);
  }
}