/* course.css — shared stylesheet for all DSA lessons and reference sheets. */

:root {
  --bg: #fdfcf9;
  --fg: #1a1a1a;
  --muted: #595959;
  --accent: #8a3324;
  --code-bg: #f2f0ea;
  --border: #d9d5cc;
  --correct: #2e7d32;
  --correct-bg: #e6f2e6;
  --incorrect: #b3261e;
  --incorrect-bg: #f9e7e5;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1b1d;
    --fg: #e6e2da;
    --muted: #a6a099;
    --accent: #e0917f;
    --code-bg: #26262a;
    --border: #3d3d42;
    --correct: #7dc98a;
    --correct-bg: #22321f;
    --incorrect: #ee9088;
    --incorrect-bg: #3a2422;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0 auto;
  padding: 2.5rem 1.25rem 4rem;
  max-width: 65ch;
  background: var(--bg);
  color: var(--fg);
  font-family: Georgia, "Iowan Old Style", "Times New Roman", serif;
  font-size: 1.0625rem;
  line-height: 1.65;
}

h1, h2, h3 {
  font-weight: normal;
  line-height: 1.25;
  margin: 2.2em 0 0.6em;
}
h1 { font-size: 1.9rem; margin-top: 0.5em; }
h2 { font-size: 1.4rem; border-bottom: 1px solid var(--border); padding-bottom: 0.25em; }
h3 { font-size: 1.15rem; }

p, ul, ol { margin: 0 0 1.1em; }
a { color: var(--accent); }
strong { font-weight: bold; }
hr { border: none; border-top: 1px solid var(--border); margin: 2.5em 0; }

.subtitle { color: var(--muted); font-style: italic; margin-top: -0.6em; }

/* The one big idea of a lesson, stated large. */
.invariant {
  font-size: 1.35rem;
  line-height: 1.45;
  font-style: italic;
  border-left: 3px solid var(--accent);
  margin: 2em 0;
  padding: 0.4em 0 0.4em 1em;
}

/* Code */
code, pre, kbd {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.88em;
}
code {
  background: var(--code-bg);
  padding: 0.1em 0.35em;
  border-radius: 3px;
}
pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1em 1.2em;
  overflow-x: auto;
  line-height: 1.55;
  margin: 0 0 1.2em;
}
pre code { background: none; padding: 0; }
.code-comment { color: var(--muted); font-style: italic; }

/* Tables */
table {
  border-collapse: collapse;
  width: 100%;
  margin: 0 0 1.4em;
  font-size: 0.95rem;
}
th, td {
  text-align: left;
  padding: 0.45em 0.8em;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
th { border-bottom: 2px solid var(--fg); font-weight: bold; }
td code { white-space: nowrap; }

/* Callouts & blockquotes */
blockquote, .callout {
  margin: 1.5em 0;
  padding: 0.8em 1.2em;
  border-left: 3px solid var(--accent);
  background: var(--code-bg);
  border-radius: 0 6px 6px 0;
}
blockquote { font-style: italic; }
.callout > :last-child, blockquote > :last-child { margin-bottom: 0; }
.callout-title { font-weight: bold; display: block; margin-bottom: 0.3em; }

/* Quiz */
.quiz {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1.2em 1.4em;
  margin: 1.8em 0;
}
.quiz-q { font-weight: bold; margin-bottom: 0.9em; }
.quiz button {
  display: block;
  width: 100%;
  text-align: left;
  font: inherit;
  font-size: 0.97rem;
  color: var(--fg);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 0.55em 0.9em;
  margin: 0.45em 0;
  cursor: pointer;
}
.quiz button:hover:not(:disabled) { border-color: var(--accent); }
.quiz button:disabled { cursor: default; opacity: 0.85; }
.quiz button.correct {
  border-color: var(--correct);
  background: var(--correct-bg);
  color: var(--correct);
  opacity: 1;
}
.quiz button.incorrect {
  border-color: var(--incorrect);
  background: var(--incorrect-bg);
  color: var(--incorrect);
  opacity: 1;
}
.quiz-explain {
  margin-top: 0.9em;
  padding-top: 0.9em;
  border-top: 1px dashed var(--border);
  font-size: 0.95rem;
  color: var(--muted);
}
.quiz-explain strong.right { color: var(--correct); }
.quiz-explain strong.wrong { color: var(--incorrect); }

/* Lesson footer nav */
.lesson-nav {
  margin-top: 3.5em;
  padding-top: 1.2em;
  border-top: 1px solid var(--border);
  font-size: 0.95rem;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  gap: 1em;
  flex-wrap: wrap;
}

/* Print */
@media print {
  body { max-width: none; padding: 0; font-size: 10.5pt; background: #fff; color: #000; }
  a { color: #000; text-decoration: none; }
  .quiz button { border: 1px solid #999; }
  .quiz-explain { display: none; }
  .lesson-nav { display: none; }
  pre, table, .callout, .quiz { break-inside: avoid; }
  h1 { margin-top: 0; }
}

/* Book navigation bar (top & bottom of every lesson) */
.book-nav{display:flex;justify-content:space-between;align-items:baseline;gap:1rem;
  font-size:.85rem;margin:0 0 2rem;padding:.6rem 0;border-bottom:1px solid rgba(128,128,128,.35)}
.book-nav.bottom{margin:2.5rem 0 0;border-bottom:none;border-top:1px solid rgba(128,128,128,.35)}
.book-nav .spacer{flex:1}
.book-nav a{text-decoration:none}
.book-nav a:hover{text-decoration:underline}
@media print{.book-nav{display:none}}
