/* Shared base stylesheet for AI Compiler course */
/* Tufte-inspired: clean, readable, print-friendly */

@import url('https://fonts.googleapis.com/css2?family=Inter:opsz,wght@14..32,400;14..32,600;14..32,700&family=JetBrains+Mono:wght@400;600&display=swap');

:root {
  --text: #1a1a1a;
  --muted: #555;
  --accent: #2563eb;
  --accent-dim: #3b82f6;
  --bg: #fffff8;
  --bg-sidenote: #f8f8f0;
  --border: #d4d4d4;
  --code-bg: #f4f4f0;
  --correct: #16a34a;
  --incorrect: #dc2626;
  --radius: 6px;
}

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

html {
  font-size: 18px;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--text);
  background: var(--bg);
  max-width: 760px;
  margin: 60px auto 120px;
  padding: 0 24px;
  line-height: 1.65;
}

h1 {
  font-size: 2rem;
  font-weight: 700;
  margin: 0 0 0.15em 0;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

h2 {
  font-size: 1.35rem;
  font-weight: 700;
  margin: 2em 0 0.5em 0;
  letter-spacing: -0.01em;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.25em;
}

h3 {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 1.5em 0 0.35em 0;
  color: var(--muted);
}

p { margin: 0.8em 0; }

strong { font-weight: 600; }

a, a:visited {
  color: var(--accent);
  text-decoration: none;
}

a:hover { text-decoration: underline; }

/* Flow diagram */
.diagram {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 20px;
  margin: 1.2em 0;
  font-family: 'JetBrains Mono', 'SF Mono', 'Cascadia Code', 'Consolas', monospace;
  font-size: 0.78rem;
  line-height: 1.7;
  overflow-x: auto;
  white-space: pre;
  color: #333;
}

.diagram .highlight { color: var(--accent); font-weight: 600; }
.diagram .dim { color: #999; }

/* Code */
code {
  font-family: 'JetBrains Mono', 'SF Mono', 'Cascadia Code', 'Consolas', monospace;
  font-size: 0.85em;
  background: var(--code-bg);
  padding: 0.1em 0.35em;
  border-radius: 3px;
  border: 1px solid var(--border);
}

pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin: 1em 0;
  font-size: 0.78rem;
  line-height: 1.55;
  overflow-x: auto;
}

pre code {
  background: none;
  border: none;
  padding: 0;
}

/* Callout */
.callout {
  border-left: 4px solid var(--accent);
  background: #eef2ff;
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 14px 18px;
  margin: 1.2em 0;
  font-size: 0.92rem;
}

.callout.warn {
  border-left-color: #f59e0b;
  background: #fffbeb;
}

.callout.good {
  border-left-color: var(--correct);
  background: #f0fdf4;
}

/* Table */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.2em 0;
  font-size: 0.9rem;
}

thead { background: var(--code-bg); }

th {
  text-align: left;
  padding: 10px 14px;
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  border-bottom: 2px solid var(--border);
}

td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

tr:last-child td { border-bottom: none; }

/* Quiz */
.quiz {
  margin: 2em 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fafaf5;
  padding: 20px 22px;
}

.quiz h3 {
  margin-top: 0;
  color: var(--text);
}

.quiz .q {
  margin: 1.4em 0;
}

.quiz .q .stem {
  font-weight: 600;
  margin-bottom: 0.5em;
}

.quiz .q .options { display: flex; flex-direction: column; gap: 6px; }

.quiz .q .opt {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: white;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  font-size: 0.9rem;
  user-select: none;
  line-height: 1.4;
}

.quiz .q .opt:hover { border-color: var(--accent-dim); background: #f8faff; }

.quiz .q .opt.selected { border-color: var(--accent); background: #eef2ff; }

.quiz .q .opt.correct { border-color: var(--correct); background: #f0fdf4; }

.quiz .q .opt.incorrect { border-color: var(--incorrect); background: #fef2f2; }

.quiz .q .feedback {
  margin-top: 10px;
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 0.88rem;
  display: none;
  line-height: 1.55;
}

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

.quiz .q .feedback.ok { background: #f0fdf4; border: 1px solid var(--correct); }
.quiz .q .feedback.nok { background: #fef2f2; border: 1px solid var(--incorrect); }

.quiz button.check {
  margin-top: 1.2em;
  padding: 10px 28px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s;
}

.quiz button.check:hover { background: #1d4ed8; }
.quiz button.check:disabled { opacity: 0.5; cursor: default; }

.quiz button.reset {
  margin-left: 8px;
  padding: 10px 20px;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9rem;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s;
}

.quiz button.reset:hover { background: #f5f5f0; }

/* Sidenote-style citations */
cite {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
  padding-left: 12px;
  border-left: 2px solid var(--border);
  margin: 0.6em 0;
  font-style: normal;
}

cite a { color: var(--muted); text-decoration: underline; }

/* Navigation */
nav.lesson-nav {
  margin-top: 3em;
  padding-top: 1em;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  font-size: 0.88rem;
}

.todo-note {
  background: #fefce8;
  border: 1px solid #fde047;
  border-radius: var(--radius);
  padding: 10px 16px;
  margin: 1.4em 0;
  font-size: 0.88rem;
  color: #a16207;
}

.todo-note strong { color: #854d0e; }

@media print {
  body { font-size: 12px; line-height: 1.5; max-width: 100%; margin: 0; }
  .quiz { border: 1px solid #ccc; page-break-inside: avoid; }
  .quiz button, nav { display: none; }
}

@media (max-width: 640px) {
  body { font-size: 16px; margin: 24px auto 60px; padding: 0 16px; }
  .diagram { font-size: 0.7rem; }
  pre { font-size: 0.72rem; }
}