/* Lesson Shared Stylesheet
   Inspired by Tufte: clean typography, marginal notes, readable measure */

:root {
  --text: #1a1a2e;
  --text-light: #555;
  --bg: #fefefa;
  --accent: #2563eb;
  --accent-light: #dbeafe;
  --border: #e2e8f0;
  --success: #16a34a;
  --error: #dc2626;
  --code-bg: #f8f9fa;
  --font-serif: 'Georgia', 'Noto Serif SC', serif;
  --font-sans: 'Inter', 'Noto Sans SC', -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

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

body {
  font-family: var(--font-serif);
  color: var(--text);
  background: var(--bg);
  line-height: 1.7;
  max-width: 680px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

/* Typography */

h1, h2, h3, h4 {
  font-family: var(--font-sans);
  font-weight: 700;
  line-height: 1.3;
  margin-top: 2rem;
  margin-bottom: 0.75rem;
}

h1 {
  font-size: 1.8rem;
  border-bottom: 2px solid var(--accent);
  padding-bottom: 0.5rem;
}

h2 {
  font-size: 1.35rem;
  color: var(--accent);
}

h3 {
  font-size: 1.1rem;
}

p {
  margin-bottom: 1rem;
}

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

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

strong {
  font-weight: 700;
}

em {
  font-style: italic;
}

/* Code */

code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--code-bg);
  padding: 0.15em 0.4em;
  border-radius: 3px;
  border: 1px solid var(--border);
}

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

pre code {
  border: none;
  padding: 0;
  background: none;
  font-size: 0.82em;
}

/* Lesson metadata */

.lesson-meta {
  font-family: var(--font-sans);
  font-size: 0.78rem;
  color: var(--text-light);
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.lesson-meta .series {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  color: var(--accent);
}

/* Key insight callouts */

.insight {
  background: var(--accent-light);
  border-left: 4px solid var(--accent);
  padding: 1rem 1.25rem;
  margin: 1.5rem 0;
  border-radius: 0 6px 6px 0;
  font-family: var(--font-sans);
  font-size: 0.92rem;
}

.insight::before {
  content: "💡 Key Insight";
  display: block;
  font-weight: 700;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.4rem;
  color: var(--accent);
}

/* Practical callouts */

.practical {
  background: #f0fdf4;
  border-left: 4px solid var(--success);
  padding: 1rem 1.25rem;
  margin: 1.5rem 0;
  border-radius: 0 6px 6px 0;
  font-family: var(--font-sans);
  font-size: 0.92rem;
}

.practical::before {
  content: "🔧 For Developers";
  display: block;
  font-weight: 700;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.4rem;
  color: var(--success);
}

/* Quiz sections */

.quiz {
  background: #fff;
  border: 2px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem 1.5rem;
  margin: 1.5rem 0;
}

.quiz h3 {
  font-family: var(--font-sans);
  color: var(--accent);
  margin-top: 0;
  font-size: 1rem;
}

.quiz-question {
  margin: 1rem 0;
  font-weight: 600;
}

.quiz-options {
  list-style: none;
  padding: 0;
}

.quiz-options li {
  margin: 0.4rem 0;
}

.quiz-options button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.6rem 1rem;
  font-family: var(--font-sans);
  font-size: 0.88rem;
  background: #f8fafc;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  color: var(--text);
}

.quiz-options button:hover {
  background: var(--accent-light);
  border-color: var(--accent);
}

.quiz-options button.correct {
  background: #dcfce7;
  border-color: var(--success);
  color: var(--success);
  font-weight: 600;
}

.quiz-options button.wrong {
  background: #fef2f2;
  border-color: var(--error);
  color: var(--error);
}

.quiz-feedback {
  margin-top: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: 6px;
  font-family: var(--font-sans);
  font-size: 0.88rem;
  display: none;
}

.quiz-feedback.show {
  display: block;
}

.quiz-feedback.correct {
  background: #dcfce7;
  color: #166534;
}

.quiz-feedback.wrong {
  background: #fef2f2;
  color: #991b1b;
}

/* Diagrams */

.diagram {
  text-align: center;
  margin: 1.5rem 0;
  padding: 1rem;
}

.diagram svg {
  max-width: 100%;
  height: auto;
}

.diagram-caption {
  font-family: var(--font-sans);
  font-size: 0.78rem;
  color: var(--text-light);
  margin-top: 0.5rem;
}

/* Tables */

table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.25rem 0;
  font-size: 0.9rem;
}

th, td {
  padding: 0.5rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

th {
  font-family: var(--font-sans);
  font-weight: 600;
  color: var(--accent);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Navigation */

.lesson-nav {
  display: flex;
  justify-content: space-between;
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 2px solid var(--border);
  font-family: var(--font-sans);
  font-size: 0.85rem;
}

.lesson-nav a {
  text-decoration: none;
  padding: 0.5rem 1rem;
  border: 1.5px solid var(--accent);
  border-radius: 6px;
  transition: all 0.15s;
}

.lesson-nav a:hover {
  background: var(--accent);
  color: white;
}

/* Footer */

.lesson-footer {
  margin-top: 2rem;
  padding: 1rem;
  background: #f8fafc;
  border-radius: 6px;
  font-family: var(--font-sans);
  font-size: 0.82rem;
  color: var(--text-light);
  text-align: center;
}

/* Lists */

ul, ol {
  margin: 0.75rem 0 1rem 1.5rem;
}

li {
  margin-bottom: 0.35rem;
}

/* Blockquotes */

blockquote {
  border-left: 3px solid var(--border);
  padding-left: 1.25rem;
  margin: 1.25rem 0;
  color: var(--text-light);
  font-style: italic;
}

/* Responsive */

@media (max-width: 600px) {
  html { font-size: 16px; }
  body { padding: 1.25rem 1rem 3rem; }
  h1 { font-size: 1.5rem; }
}

/* Print */

@media print {
  body { max-width: none; font-size: 11pt; }
  .quiz { break-inside: avoid; }
  .lesson-nav { display: none; }
}
