/* Shared stylesheet for backend-depth lessons and reference docs. Tufte-inspired: readable, print-friendly, quiet. */

:root {
  --bg: #fdfcfa;
  --fg: #1a1a1a;
  --muted: #5c5c5c;
  --rule: #d8d4cc;
  --accent: #8a3324;
  --code-bg: #f2efe9;
  --callout-bg: #f6f1e7;
  --correct: #2f6f3e;
  --incorrect: #a3312a;
  --link: #8a3324;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17181a;
    --fg: #e8e6e1;
    --muted: #a3a099;
    --rule: #3a3a38;
    --accent: #e0a37a;
    --code-bg: #232326;
    --callout-bg: #232120;
    --correct: #6fbf7f;
    --incorrect: #e58a83;
    --link: #e0a37a;
  }
}

:root[data-theme="dark"] {
  --bg: #17181a; --fg: #e8e6e1; --muted: #a3a099; --rule: #3a3a38;
  --accent: #e0a37a; --code-bg: #232326; --callout-bg: #232120;
  --correct: #6fbf7f; --incorrect: #e58a83; --link: #e0a37a;
}
:root[data-theme="light"] {
  --bg: #fdfcfa; --fg: #1a1a1a; --muted: #5c5c5c; --rule: #d8d4cc;
  --accent: #8a3324; --code-bg: #f2efe9; --callout-bg: #f6f1e7;
  --correct: #2f6f3e; --incorrect: #a3312a; --link: #8a3324;
}

* { box-sizing: border-box; }

body {
  background: var(--bg);
  color: var(--fg);
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  font-size: 19px;
  line-height: 1.6;
  max-width: 720px;
  margin: 0 auto;
  padding: 3rem 1.5rem 6rem;
}

h1, h2, h3 {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  font-weight: 600;
  line-height: 1.25;
}
h1 { font-size: 1.9rem; margin-bottom: 0.2rem; }
h2 { font-size: 1.3rem; margin-top: 2.5rem; border-top: 1px solid var(--rule); padding-top: 1.5rem; }
h3 { font-size: 1.05rem; margin-top: 1.5rem; }

.kicker {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.72rem;
  color: var(--muted);
  margin-bottom: 0.8rem;
}

p { margin: 1rem 0; }
a { color: var(--link); }
.muted { color: var(--muted); }

code, pre {
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.85em;
}
code { background: var(--code-bg); padding: 0.1em 0.35em; border-radius: 3px; }
pre {
  background: var(--code-bg);
  padding: 1rem 1.2rem;
  border-radius: 6px;
  overflow-x: auto;
  line-height: 1.5;
}
pre code { background: none; padding: 0; }

.callout {
  background: var(--callout-bg);
  border-left: 3px solid var(--accent);
  padding: 0.9rem 1.2rem;
  border-radius: 0 4px 4px 0;
  margin: 1.5rem 0;
}
.callout p:first-child { margin-top: 0; }
.callout p:last-child { margin-bottom: 0; }

.callout-title {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
  margin-bottom: 0.4rem;
}

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

.nav-links {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 0.9rem;
  display: flex;
  justify-content: space-between;
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--rule);
  color: var(--muted);
}

table { border-collapse: collapse; width: 100%; margin: 1.2rem 0; font-size: 0.92rem; }
th, td { text-align: left; padding: 0.5rem 0.8rem; border-bottom: 1px solid var(--rule); }
th { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; font-weight: 600; }

/* Quiz widget */
.quiz {
  background: var(--callout-bg);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 1.3rem 1.4rem;
  margin: 1.8rem 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
.quiz-q { font-weight: 600; margin-bottom: 0.9rem; font-size: 0.98rem; }
.quiz-options { display: flex; flex-direction: column; gap: 0.5rem; }
.quiz-option {
  text-align: left;
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 0.6rem 0.9rem;
  cursor: pointer;
  font-size: 0.92rem;
  color: var(--fg);
  font-family: inherit;
}
.quiz-option:hover { border-color: var(--accent); }
.quiz-option.correct { border-color: var(--correct); background: color-mix(in srgb, var(--correct) 15%, var(--bg)); }
.quiz-option.incorrect { border-color: var(--incorrect); background: color-mix(in srgb, var(--incorrect) 15%, var(--bg)); }
.quiz-option:disabled { cursor: default; opacity: 0.85; }
.quiz-feedback { margin-top: 0.9rem; font-size: 0.9rem; padding-top: 0.9rem; border-top: 1px dashed var(--rule); display: none; }
.quiz-feedback.show { display: block; }
.quiz-feedback.correct-text { color: var(--correct); }
.quiz-feedback.incorrect-text { color: var(--incorrect); }

@media print {
  body { max-width: 100%; padding: 0.5in; font-size: 12pt; color: #000; background: #fff; }
  .nav-links, .quiz { display: none; }
  a { color: #000; text-decoration: underline; }
}
