/* teach.zahranm.cloud — shared lesson stylesheet
   Mobile-first, content-first, Tufte-inspired. */

:root {
  --bg: #fafafa;
  --fg: #1a1a1a;
  --muted: #555;
  --faint: #888;
  --accent: #2563eb;
  --accent-light: #dbeafe;
  --accent-dim: #93c5fd;
  --code-bg: #1e1e2e;
  --code-fg: #cdd6f4;
  --code-border: #313244;
  --highlight: #fef9c3;
  --border: #e2e8f0;
  --card-bg: white;
  --max-width: 760px;
  --serif: 'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --mono: 'SF Mono', 'Fira Code', 'JetBrains Mono', Consolas, monospace;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--serif);
  background: var(--bg);
  color: var(--fg);
  line-height: 1.7;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem;
}

/* Headers */
header.lesson-header {
  margin-bottom: 2rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 1.25rem;
}

.lesson-number {
  font-family: var(--sans);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--faint);
  margin-bottom: 0.4rem;
}

h1 {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.25;
  margin-bottom: 0.4rem;
}

.subtitle {
  color: var(--muted);
  font-size: 0.95rem;
  font-family: var(--sans);
}

/* Body content */
h2 {
  font-size: 1.2rem;
  margin-top: 2rem;
  margin-bottom: 0.6rem;
  font-weight: 700;
}

h3 {
  font-size: 1.05rem;
  margin-top: 1.5rem;
  margin-bottom: 0.4rem;
  font-weight: 600;
  color: #333;
}

p { margin-bottom: 0.85rem; }

a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid var(--accent-dim);
}

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

strong { font-weight: 700; }
em { font-style: italic; }

/* Lists */
ul, ol {
  margin-bottom: 0.85rem;
  padding-left: 1.25rem;
}
li { margin-bottom: 0.3rem; }

/* Code */
code {
  font-family: var(--mono);
  font-size: 0.82em;
  background: #f0f0f4;
  padding: 0.1em 0.3em;
  border-radius: 3px;
  border: 1px solid #e0e0e6;
}

pre {
  background: var(--code-bg);
  color: var(--code-fg);
  border-radius: 8px;
  padding: 1rem 0.85rem;
  overflow-x: auto;
  margin-bottom: 1.25rem;
  font-size: 0.78rem;
  line-height: 1.55;
  border: 1px solid var(--code-border);
  -webkit-overflow-scrolling: touch;
}

pre code {
  background: none;
  border: none;
  padding: 0;
  color: inherit;
  font-size: inherit;
}

/* Syntax highlighting */
.kw { color: #cba6f7; }
.fn { color: #89b4fa; }
.str { color: #a6e3a1; }
.cmt { color: #6c7086; font-style: italic; }
.num { color: #fab387; }
.cls { color: #f9e2af; }
.var { color: #f38ba8; }
.op { color: #94e2d5; }

/* Callout cards */
.callout {
  background: var(--card-bg);
  border-left: 3px solid var(--accent);
  padding: 0.85rem 1rem;
  margin: 1.25rem 0;
  border-radius: 0 6px 6px 0;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.callout .label {
  font-family: var(--sans);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.3rem;
}

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

.callout.danger { border-left-color: #ef4444; }
.callout.danger .label { color: #ef4444; }

.callout.tip { border-left-color: #10b981; }
.callout.tip .label { color: #10b981; }

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

/* Mermaid diagrams */
.diagram-container {
  margin: 1.5rem 0;
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.diagram-container .mermaid {
  display: flex;
  justify-content: center;
  min-width: 0;
  width: 100%;
}

.diagram-container .mermaid svg {
  max-width: 100% !important;
  height: auto !important;
}

.diagram-caption {
  text-align: center;
  font-family: var(--sans);
  font-size: 0.75rem;
  color: var(--faint);
  margin-top: 0.5rem;
  padding: 0 0.5rem;
}

/* Tables */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 1.25rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  font-family: var(--sans);
  min-width: 400px;
}
th, td {
  text-align: left;
  padding: 0.5rem 0.65rem;
  border-bottom: 1px solid var(--border);
}
th {
  font-weight: 600;
  color: var(--muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Footer */
footer.lesson-footer {
  margin-top: 2.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
  font-family: var(--sans);
  font-size: 0.8rem;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  align-items: center;
}

footer.lesson-footer a {
  color: var(--accent);
  border-bottom: none;
}

.nav-links {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  justify-content: center;
}

/* Quiz */
.quiz {
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  margin: 1.5rem 0;
}
.quiz .question {
  font-weight: 600;
  margin-bottom: 0.75rem;
  font-family: var(--sans);
  font-size: 0.9rem;
}
.quiz .options { display: flex; flex-direction: column; gap: 0.4rem; }
.quiz .option {
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  font-family: var(--sans);
  font-size: 0.85rem;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.quiz .option:active { transform: scale(0.98); }
.quiz .option:hover { border-color: var(--accent); background: var(--accent-light); }
.quiz .option.correct {
  border-color: #10b981;
  background: #ecfdf5;
}
.quiz .option.wrong {
  border-color: #ef4444;
  background: #fef2f2;
}
.quiz .feedback {
  margin-top: 0.6rem;
  font-family: var(--sans);
  font-size: 0.8rem;
  display: none;
  line-height: 1.5;
}
.quiz .feedback.visible { display: block; }

/* Sidenote */
.sidenote {
  font-family: var(--sans);
  font-size: 0.8rem;
  color: var(--muted);
  background: #f8f9fa;
  border-radius: 6px;
  padding: 0.65rem 0.85rem;
  margin: 0.85rem 0;
  border: 1px solid var(--border);
}

/* Highlight */
.highlight { background: var(--highlight); padding: 0.1em 0.2em; border-radius: 2px; }

/* Mobile: make pre scroll nicely, shrink mermaid */
@media (max-width: 480px) {
  body { font-size: 15px; }
  h1 { font-size: 1.3rem; }
  h2 { font-size: 1.1rem; }
  .container { padding: 1rem 0.75rem 2.5rem; }
  pre { font-size: 0.72rem; padding: 0.75rem 0.6rem; }
}