/* Base styles for the interactive book */
:root {
  --primary-color: #2c3e50;
  --secondary-color: #1a6ba8; /* Changed from #3498db for WCAG AA contrast (4.5:1) on light backgrounds */
  --success-color: #27ae60;
  --warning-color: #f39c12;
  --error-color: #e74c3c;
  --bg-color: #fff;
  --text-color: #333;
  --code-bg: #f8f8f8;
  --border-color: #e0e0e0;
  --header-height: 60px;
  --footer-height: 80px;
  --max-width: 1200px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  font-family:
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Roboto,
    "Helvetica Neue",
    sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: var(--text-color);
  background-color: var(--bg-color);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 20px;
}

/* Header */
.site-header {
  background-color: var(--primary-color);
  color: white;
  height: var(--header-height);
  display: flex;
  align-items: center;
  box-shadow: 0 2px 4px rgb(0 0 0 / 0.1);
  position: sticky;
  top: 0;
  z-index: 100;
}

.site-header .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}

.site-title {
  margin: 0;
  font-size: 24px;
  font-weight: 600;
}

.site-version {
  font-size: 14px;
  opacity: 0.8;
}

/* Main content */
.site-content {
  flex: 1;
  padding: 40px 0;
}

/* Footer */
.site-footer {
  background-color: #f8f9fa;
  border-top: 1px solid var(--border-color);
  padding: 20px 0;
  text-align: center;
  font-size: 14px;
  color: #666;
}

.site-footer p {
  margin: 5px 0;
}

/* Typography */
h1 {
  font-size: 36px;
  margin: 1.5rem 0 1rem;
  color: var(--primary-color);
  line-height: 1.2;
}

/* Ensure consistent h1 sizing in sections */
section h1,
article h1,
aside h1,
nav h1 {
  font-size: 36px;
  margin: 1.5rem 0 1rem;
}

/* Chapter styles */
.chapter-header {
  margin-bottom: 40px;
  padding-bottom: 20px;
  border-bottom: 2px solid var(--border-color);
}

.chapter-header h1 {
  margin: 0 0 10px;
  font-size: 36px;
  color: var(--primary-color);
}

.chapter-header .author {
  font-size: 18px;
  color: #666;
  font-style: italic;
}

/* Navigation */
.chapter-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 30px 0;
  padding: 20px;
  background-color: #f8f9fa;
  border-radius: 8px;
}

.chapter-nav a {
  color: var(--secondary-color);
  text-decoration: none;
  font-weight: 500;
  padding: 8px 16px;
  border-radius: 4px;
  transition: background-color 0.2s;
}

.chapter-nav a:hover {
  background-color: rgb(52 152 219 / 0.1);
}

.nav-home {
  color: var(--primary-color) !important;
}

/* Interactive code blocks */
.code-block {
  margin: 20px 0;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 4px rgb(0 0 0 / 0.05);
}

.code-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 15px;
  background-color: #f8f9fa;
  border-bottom: 1px solid var(--border-color);
}

.language-label {
  font-size: 14px;
  font-weight: 600;
  color: #666;
}

.run-button {
  background-color: var(--success-color);
  color: white;
  border: none;
  padding: 6px 16px;
  border-radius: 4px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: background-color 0.2s;
}

.run-button:hover {
  background-color: #229954;
}

.run-button:disabled {
  background-color: #95a5a6;
  cursor: not-allowed;
}

.run-button .icon {
  font-size: 12px;
}

.code-block pre {
  margin: 0;
  padding: 15px;
  overflow-x: auto;
  background-color: var(--code-bg);
}

.code-block code {
  font-family: Consolas, Monaco, Menlo, "Ubuntu Mono", "Courier New", monospace;
  font-size: 14px;
  line-height: 1.5;
}

/* Output container */
.output-container {
  border-top: 1px solid var(--border-color);
  background-color: #f0f0f0;
}

.output-header {
  padding: 10px 15px;
  font-size: 14px;
  font-weight: 600;
  color: #666;
  background-color: #e8e8e8;
}

.output {
  margin: 0;
  padding: 15px;
  font-family: Consolas, Monaco, Menlo, "Ubuntu Mono", "Courier New", monospace;
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  max-height: 400px;
  overflow-y: auto;
}

.output.error {
  color: var(--error-color);
}

/* Pyodide status */
.pyodide-status {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background-color: white;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 15px 20px;
  box-shadow: 0 4px 8px rgb(0 0 0 / 0.1);
  display: none;
  max-width: 300px;
}

.pyodide-status.loading {
  display: block;
}

.status-text {
  font-size: 14px;
  color: #666;
  display: block;
  margin-bottom: 10px;
}

.progress-bar {
  width: 100%;
  height: 4px;
  background-color: #e0e0e0;
  border-radius: 2px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background-color: var(--secondary-color);
  width: 0;
  transition: width 0.3s ease;
}

/* Index page */
.index-page {
  text-align: center;
  padding: 60px 0;
}

.index-page h1 {
  font-size: 48px;
  margin-bottom: 10px;
  color: var(--primary-color);
}

.index-page h2 {
  font-size: 24px;
  color: #666;
  margin-bottom: 20px;
  font-weight: 400;
}

.index-page .authors {
  font-size: 18px;
  color: #666;
  margin-bottom: 60px;
}

.toc {
  text-align: left;
  max-width: 600px;
  margin: 0 auto;
}

.toc h3 {
  font-size: 24px;
  margin-bottom: 20px;
  color: var(--primary-color);
}

.toc-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.toc-list li {
  margin-bottom: 15px;
  padding: 15px;
  background-color: #f8f9fa;
  border-radius: 8px;
  transition: background-color 0.2s;
}

.toc-list li:hover {
  background-color: #e9ecef;
}

.toc-list a {
  text-decoration: none;
  color: var(--text-color);
  display: flex;
  align-items: baseline;
  gap: 15px;
}

.chapter-number {
  font-size: 20px;
  font-weight: 600;
  color: var(--secondary-color);
  min-width: 30px;
}

.chapter-title {
  font-size: 18px;
  flex: 1;
}

.toc-list .author {
  font-size: 14px;
  color: #666;
  font-style: italic;
}

/* Responsive */
@media (width <= 768px) {
  .index-page h1 {
    font-size: 36px;
  }

  .pyodide-status {
    right: 10px;
    bottom: 10px;
    max-width: calc(100% - 20px);
  }
}
