/* CSS Variables */
:root {
  --primary: #2563eb;
  --primary-dark: #1e40af;
  --secondary: #7c3aed;
  --text: #1e293b;
  --text-light: #64748b;
  --bg: #ffffff;
  --bg-alt: #f8fafc;
  --border: #e2e8f0;
  --code-bg: #f1f5f9;
  --success: #059669;
  --warning: #d97706;
  --danger: #dc2626;

  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Courier New', monospace;

  --container-width: 800px;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.1);
}

/* Dark mode */
@media (prefers-color-scheme: dark) {
  :root {
    --text: #f1f5f9;
    --text-light: #94a3b8;
    --bg: #0f172a;
    --bg-alt: #1e293b;
    --border: #334155;
    --code-bg: #1e293b;
  }
}

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

html {
  font-size: 16px;
}

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

/* Navigation */
.main-nav {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(10px);
  background: rgba(255, 255, 255, 0.8);
}

@media (prefers-color-scheme: dark) {
  .main-nav {
    background: rgba(15, 23, 42, 0.8);
  }
}

.nav-container {
  max-width: var(--container-width);
  margin: 0 auto;
  padding: 1rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 2rem;
}

.nav-brand a {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  display: inline-block;
}

.nav-subtitle {
  display: block;
  font-size: 0.75rem;
  color: var(--text-light);
  font-weight: 400;
  margin-top: 0.125rem;
}

.nav-links {
  display: flex;
  gap: 1.5rem;
}

.nav-links a {
  color: var(--text-light);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s;
}

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

/* Container */
.container {
  max-width: var(--container-width);
  margin: 0 auto;
  padding: 0 1.5rem;
}

.content {
  min-height: calc(100vh - 200px);
  padding: 3rem 0;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  line-height: 1.2;
  margin: 2rem 0 1rem;
  color: var(--text);
}

h1 {
  font-size: 2.5rem;
  margin-top: 0;
}

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

h3 {
  font-size: 1.5rem;
}

h4 {
  font-size: 1.25rem;
}

p {
  margin: 1rem 0;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

strong {
  font-weight: 600;
}

em {
  font-style: italic;
  color: var(--text-light);
}

blockquote {
  border-left: 4px solid var(--primary);
  padding: 1rem 1.5rem;
  margin: 1.5rem 0;
  background: var(--bg-alt);
  border-radius: var(--radius);
  font-style: italic;
  color: var(--text-light);
}

hr {
  border: none;
  border-top: 2px solid var(--border);
  margin: 2rem 0;
}

/* Code */
code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: var(--code-bg);
  padding: 0.2em 0.4em;
  border-radius: 4px;
  color: var(--secondary);
}

pre {
  background: var(--code-bg);
  padding: 1.5rem;
  border-radius: var(--radius);
  overflow-x: auto;
  margin: 1.5rem 0;
  border: 1px solid var(--border);
}

pre code {
  background: none;
  padding: 0;
  color: var(--text);
  font-size: 0.875rem;
}

/* Lists */
ul, ol {
  margin: 1rem 0;
  padding-left: 2rem;
}

li {
  margin: 0.5rem 0;
}

/* Home Page Specific */
.home-hero h1 {
  font-size: 3rem;
  margin-bottom: 0.25rem;
}

.home-hero h2 {
  font-size: 1.5rem;
  font-weight: 400;
  color: var(--text-light);
  border: none;
  margin-top: 0;
  padding-bottom: 0;
}

.subtitle {
  font-size: 1.125rem;
  color: var(--text-light);
  margin: 1rem 0 2rem;
}

.chapter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 1.5rem;
  margin: 2rem 0;
}

.chapter-card {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  transition: all 0.2s;
}

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

.chapter-card h3 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
}

.chapter-card h3 a {
  color: var(--primary);
  text-decoration: none;
}

.chapter-card p {
  margin: 0;
  font-size: 0.875rem;
  color: var(--text-light);
}

.cta {
  text-align: center;
  margin: 3rem 0;
}

.button {
  display: inline-block;
  background: var(--primary);
  color: white;
  padding: 0.75rem 2rem;
  border-radius: var(--radius);
  font-weight: 600;
  text-decoration: none;
  transition: all 0.2s;
  box-shadow: var(--shadow);
}

.button:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg);
  text-decoration: none;
}

/* Chapter Navigation */
.chapter-nav {
  border-top: 2px solid var(--border);
  padding: 2rem 0;
  margin-top: 3rem;
}

.chapter-nav .container {
  display: flex;
  justify-content: space-between;
  gap: 2rem;
}

.nav-prev, .nav-next {
  flex: 1;
  padding: 1rem 1.5rem;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
  transition: all 0.2s;
  display: block;
}

.nav-prev:hover, .nav-next:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  transform: translateY(-1px);
  text-decoration: none;
}

.nav-next {
  text-align: right;
}

/* Footer */
.main-footer {
  background: var(--bg-alt);
  border-top: 1px solid var(--border);
  padding: 3rem 0;
  margin-top: 4rem;
  text-align: center;
  color: var(--text-light);
  font-size: 0.875rem;
}

.footer-links {
  margin-top: 1rem;
}

.footer-links a {
  color: var(--text-light);
  text-decoration: none;
}

.footer-links a:hover {
  color: var(--primary);
}

/* Table of Contents */
.content ul li a {
  font-weight: 500;
}

/* Responsive */
@media (max-width: 768px) {
  html {
    font-size: 14px;
  }

  .nav-container {
    flex-direction: column;
    gap: 1rem;
  }

  .nav-brand {
    text-align: center;
  }

  .home-hero h1 {
    font-size: 2rem;
  }

  .home-hero h2 {
    font-size: 1.25rem;
  }

  .chapter-grid {
    grid-template-columns: 1fr;
  }

  .chapter-nav .container {
    flex-direction: column;
  }

  .nav-next {
    text-align: left;
  }
}

/* Utilities */
.text-center {
  text-align: center;
}

.mt-4 {
  margin-top: 2rem;
}

.mb-4 {
  margin-bottom: 2rem;
}
