/* Moon Maths Book - Clean Reading Experience
   ========================================== */

@import url('https://fonts.googleapis.com/css2?family=Crimson+Pro:ital,wght@0,400;0,500;0,600;1,400;1,500&family=DM+Sans:wght@400;500;600;700&display=swap');

/* === Variables === */
:root {
  --color-bg: #FDFBF7;
  --color-bg-alt: #F5F1EA;
  --color-text: #2D2A26;
  --color-text-light: #5C5650;
  --color-accent: #1E3A5F;
  --color-accent-light: #3D6B99;
  --color-border: #E5E0D8;
  --color-highlight: #D4E4ED;
  
  --font-serif: 'Crimson Pro', Georgia, serif;
  --font-sans: 'DM Sans', -apple-system, sans-serif;
  
  --max-width: 680px;
  --spacing-unit: 1.5rem;
}

/* === Reset & Base === */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

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

body {
  font-family: var(--font-serif);
  background-color: var(--color-bg);
  color: var(--color-text);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* === Typography === */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-sans);
  font-weight: 600;
  line-height: 1.3;
  color: var(--color-text);
}

h1 {
  font-size: 2.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

h2 {
  font-size: 1.6rem;
  margin-top: 3rem;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--color-border);
}

h3 {
  font-size: 1.25rem;
  margin-top: 2.5rem;
  margin-bottom: 0.75rem;
  color: var(--color-accent);
}

p {
  margin-bottom: 1.5rem;
}

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

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

strong {
  font-weight: 600;
}

em {
  font-style: italic;
}

hr {
  border: none;
  height: 1px;
  background: var(--color-border);
  margin: 3rem 0;
}

/* === Layout === */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--spacing-unit);
}

.container-wide {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 var(--spacing-unit);
}

/* === Navigation === */
.site-nav {
  position: sticky;
  top: 0;
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
  padding: 1rem 0;
  z-index: 100;
}

.site-nav .container {
  max-width: 900px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.site-title {
  font-family: var(--font-sans);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--color-text);
  text-decoration: none;
}

.site-title:hover {
  color: var(--color-accent);
}

.nav-link {
  font-family: var(--font-sans);
  font-size: 0.875rem;
  color: var(--color-text-light);
  text-decoration: none;
}

.nav-link:hover {
  color: var(--color-accent);
}

/* === Home Page === */
.hero {
  padding: 5rem 0 3rem;
  text-align: center;
}

.hero h1 {
  margin-bottom: 1rem;
}

.hero-subtitle {
  font-size: 1.25rem;
  color: var(--color-text-light);
  font-style: italic;
  max-width: 500px;
  margin: 0 auto 1.5rem;
}

.hero-badge {
  display: inline-block;
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  background: var(--color-highlight);
  color: var(--color-accent);
  padding: 0.35rem 0.75rem;
  border-radius: 3px;
}

/* === Table of Contents === */
.toc-section {
  padding: 2rem 0 5rem;
}

.toc-header {
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-text-light);
  margin-bottom: 1.5rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--color-border);
}

.chapter-list {
  list-style: none;
}

.chapter-item {
  margin-bottom: 1rem;
}

.chapter-link {
  display: block;
  padding: 1.25rem 1.5rem;
  background: white;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  text-decoration: none;
  transition: all 0.2s ease;
}

.chapter-link:hover {
  border-color: var(--color-accent);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
  transform: translateY(-2px);
}

.chapter-number {
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-accent);
  display: block;
  margin-bottom: 0.25rem;
}

.chapter-title {
  font-family: var(--font-sans);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--color-text);
  display: block;
  margin-bottom: 0.35rem;
}

.chapter-desc {
  font-size: 0.95rem;
  color: var(--color-text-light);
  margin: 0;
}

.chapter-item.coming-soon .chapter-link {
  opacity: 0.5;
  pointer-events: none;
}

.chapter-item.coming-soon .chapter-link::after {
  content: 'Coming Soon';
  font-family: var(--font-sans);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-light);
  background: var(--color-bg-alt);
  padding: 0.2rem 0.5rem;
  border-radius: 3px;
  float: right;
  margin-top: 0.25rem;
}

/* === Chapter Page === */
.chapter-header {
  padding: 4rem 0 3rem;
  text-align: center;
  background: linear-gradient(180deg, var(--color-bg-alt) 0%, var(--color-bg) 100%);
}

.chapter-meta {
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--color-accent);
  margin-bottom: 0.75rem;
}

.chapter-header h1 {
  max-width: 600px;
  margin: 0 auto 1rem;
}

.chapter-intro {
  font-size: 1.15rem;
  color: var(--color-text-light);
  font-style: italic;
  max-width: 500px;
  margin: 0 auto;
}

/* === Chapter Content === */
.chapter-content {
  padding: 3rem 0 5rem;
}

.chapter-content ul,
.chapter-content ol {
  margin-bottom: 1.5rem;
  padding-left: 1.5rem;
}

.chapter-content li {
  margin-bottom: 0.5rem;
  padding-left: 0.5rem;
}

.chapter-content ul li {
  list-style-type: disc;
}

.chapter-content ol li {
  list-style-type: decimal;
}

/* === Images === */
.feature-image {
  margin: 2.5rem 0;
  text-align: center;
}

.feature-image img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.1);
}

/* === Maths (MathJax) === */
mjx-container {
  font-size: 1.05em !important;
}

/* === Chapter Navigation === */
.chapter-nav {
  margin-top: 4rem;
  padding: 2rem;
  background: var(--color-bg-alt);
  border-radius: 8px;
  text-align: center;
}

.chapter-nav-label {
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-text-light);
  margin-bottom: 0.5rem;
}

.chapter-nav-title {
  font-family: var(--font-sans);
  font-size: 1.1rem;
  font-weight: 600;
}

.chapter-nav a {
  text-decoration: none;
}

.btn {
  display: inline-block;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 500;
  padding: 0.75rem 1.5rem;
  border-radius: 5px;
  text-decoration: none;
  transition: all 0.2s ease;
}

.btn-primary {
  background: var(--color-accent);
  color: white;
}

.btn-primary:hover {
  background: var(--color-accent-light);
  color: white;
}

.btn-secondary {
  background: white;
  color: var(--color-accent);
  border: 1px solid var(--color-border);
}

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

/* === Footer === */
.site-footer {
  padding: 2rem 0;
  border-top: 1px solid var(--color-border);
  text-align: center;
}

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

.site-footer a {
  color: var(--color-text-light);
}

/* === Donation Box === */
.donation-box {
  margin-top: 3rem;
  padding: 1.5rem;
  background: var(--color-bg-alt);
  border-radius: 8px;
  font-size: 0.9rem;
}

.donation-box p {
  margin-bottom: 0.75rem;
}

.donation-box p:last-child {
  margin-bottom: 0;
}

.donation-box code {
  font-family: 'SF Mono', Monaco, monospace;
  font-size: 0.8rem;
  background: white;
  padding: 0.2rem 0.4rem;
  border-radius: 3px;
  word-break: break-all;
}

/* === Responsive === */
@media (max-width: 640px) {
  html {
    font-size: 16px;
  }
  
  h1 {
    font-size: 2rem;
  }
  
  h2 {
    font-size: 1.4rem;
  }
  
  .hero {
    padding: 3rem 0 2rem;
  }
  
  .chapter-header {
    padding: 3rem 0 2rem;
  }
  
  .chapter-link {
    padding: 1rem 1.25rem;
  }
}