@import url("github.min.css");

/* 
  System Design & Distributed Systems - Shared Lesson Stylesheet
  Designed for clarity, readability, and quick reference.
  Modern design system with clean typography and accessible colors.
*/

:root {
  --background: hsl(0 0% 98.4%);
  --foreground: hsl(240 6% 10%);

  --card: hsl(0 0% 100%);
  --card-foreground: hsl(240 6% 10%);

  --popover: hsl(0 0% 97.4%);
  --popover-foreground: hsl(240 6% 10%);

  --primary: hsl(215 100% 51%);
  --primary-foreground: hsl(0 0% 100%);

  --secondary: hsl(0 0% 100%);
  --secondary-foreground: hsl(240 6% 10%);

  --muted: hsl(0 0% 94.8%);
  --muted-foreground: hsl(0 0% 45.2%);

  --accent: hsl(0 0% 96.1%);
  --accent-foreground: hsl(0 0% 3.9%);

  --destructive: hsl(357 96% 57.7%);
  --destructive-foreground: hsl(0 0% 100%);

  --border: hsl(0 0% 91.5%);
  --input: hsl(0 0% 91.5%);
  --ring: hsl(215 100% 51%);

  --chart-1: hsl(215 100% 51%);
  --chart-2: hsl(199 100% 47.9%);
  --chart-3: hsl(160 100% 30%);
  --chart-4: hsl(44 100% 47.1%);
  --chart-5: hsl(357 96% 57.7%);

  --sidebar: hsl(0 0% 100%);
  --sidebar-foreground: hsl(240 6% 10%);
  --sidebar-primary: hsl(215 100% 51%);
  --sidebar-primary-foreground: hsl(0 0% 100%);
  --sidebar-accent: hsl(0 0% 96.1%);
  --sidebar-accent-foreground: hsl(0 0% 3.9%);
  --sidebar-border: hsl(0 0% 91.5%);
  --sidebar-ring: hsl(215 100% 51%);

  --font-sans:
    ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji",
    "Segoe UI Symbol", "Noto Color Emoji";
  --font-serif: ui-serif, Georgia, Cambria, "Times New Roman", Times, serif;
  --font-mono:
    ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New",
    monospace;

  --radius: 0.625rem;

  --shadow-2xs: 0 1px 3px 0px hsl(0 0% 0% / 0.05);
  --shadow-xs: 0 1px 3px 0px hsl(0 0% 0% / 0.05);
  --shadow-sm: 0 1px 3px 0px hsl(0 0% 0% / 0.1), 0 1px 2px -1px hsl(0 0% 0% / 0.1);
  --shadow: 0 1px 3px 0px hsl(0 0% 0% / 0.1), 0 1px 2px -1px hsl(0 0% 0% / 0.1);
  --shadow-md: 0 1px 3px 0px hsl(0 0% 0% / 0.1), 0 2px 4px -1px hsl(0 0% 0% / 0.1);
  --shadow-lg: 0 1px 3px 0px hsl(0 0% 0% / 0.1), 0 4px 6px -1px hsl(0 0% 0% / 0.1);
  --shadow-xl: 0 1px 3px 0px hsl(0 0% 0% / 0.1), 0 8px 10px -1px hsl(0 0% 0% / 0.1);
  --shadow-2xl: 0 1px 3px 0px hsl(0 0% 0% / 0.25);

  --font-size-body: 18px;
  --line-height: 1.65;
  --max-width: 680px;
  --gutter: 160px;
}

/* Base */
html {
  font-size: var(--font-size-body);
  line-height: var(--line-height);
  color: var(--foreground);
  background: var(--background);
}

body {
  font-family: var(--font-serif);
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 3rem 2rem 4rem;
  position: relative;
}

/* Typography */
h1 {
  font-size: 2.2rem;
  font-weight: 400;
  margin-bottom: 1rem;
  line-height: 1.3;
  letter-spacing: -0.01em;
  color: var(--foreground);
}

h2 {
  font-size: 1.4rem;
  font-weight: 600;
  margin-top: 2.5rem;
  margin-bottom: 0.8rem;
  color: var(--foreground);
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.3rem;
}

h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-top: 1.8rem;
  margin-bottom: 0.5rem;
  color: var(--muted-foreground);
}

p {
  margin-bottom: 1.2rem;
  text-align: justify;
}

/* Links */
a {
  color: var(--primary);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s;
}

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

/* Code */
code,
pre {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  background: var(--muted);
  border-radius: 3px;
}

code {
  padding: 0.1rem 0.3rem;
}

pre {
  padding: 1rem;
  overflow-x: auto;
  border-left: 3px solid var(--primary);
  margin: 1.5rem 0;
}

/* Syntax Highlighting Tokens (Highlight.js GitHub Theme) */
.hljs-keyword,
.hljs-selector-tag,
.hljs-subst,
.token-kw {
  color: #cf222e;
  font-weight: 600;
}
.hljs-string,
.hljs-title,
.hljs-section,
.hljs-attribute,
.hljs-literal,
.hljs-template-tag,
.hljs-template-variable,
.hljs-type,
.hljs-addition,
.token-str {
  color: #0a3069;
}
.hljs-comment,
.hljs-quote,
.hljs-deletion,
.hljs-meta,
.token-cmt {
  color: #6e7781;
  font-style: italic;
}
.hljs-number,
.token-num {
  color: #0550ae;
}
.hljs-title.function_,
.hljs-title.class_,
.token-fn {
  color: #8250df;
  font-weight: 600;
}
.hljs-symbol,
.hljs-bullet,
.hljs-link,
.token-type {
  color: #953800;
  font-weight: 500;
}

/* Lists */
ul,
ol {
  margin: 1rem 0;
  padding-left: 1.5rem;
}

li {
  margin-bottom: 0.5rem;
}

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.9rem;
}

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

th {
  font-weight: 600;
  background: var(--muted);
  border-bottom: 2px solid var(--border);
}

/* Blockquotes / Key Concepts */
.key-concept {
  background: hsl(215 100% 51% / 0.06);
  border-left: 4px solid var(--primary);
  padding: 1rem 1.2rem;
  margin: 1.5rem 0;
  border-radius: 0 var(--radius) var(--radius) 0;
}

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

/* Marginalia (Tufte-style side notes) */
.sidenote {
  position: absolute;
  right: -var(--gutter);
  width: calc(var(--gutter) - 2rem);
  font-size: 0.75rem;
  line-height: 1.5;
  color: var(--muted-foreground);
}

@media (max-width: 1100px) {
  .sidenote {
    position: static;
    width: auto;
    margin: 1rem 0;
    padding: 0.5rem 1rem;
    background: var(--muted);
    border-radius: var(--radius);
    font-size: 0.85rem;
  }
}

/* Quiz/Interactive styling */
.quiz-container {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin: 2rem 0;
  background: var(--card);
  box-shadow: var(--shadow);
}

.quiz-question {
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--primary);
}

.quiz-option {
  display: block;
  padding: 0.6rem 1rem;
  margin-bottom: 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s;
}

.quiz-option:hover {
  background: hsl(215 100% 51% / 0.06);
  border-color: var(--primary);
}

.quiz-option.correct {
  background: hsl(160 100% 30% / 0.08);
  border-color: var(--chart-3);
}

.quiz-option.incorrect {
  background: hsl(357 96% 57.7% / 0.08);
  border-color: var(--destructive);
}

.quiz-container .quiz-q {
  margin-bottom: 1.5rem;
}

.quiz-container .quiz-q p {
  font-weight: 600;
  margin-bottom: 0.5rem;
}

/* Diagram containers */
.diagram {
  text-align: center;
  margin: 2rem 0;
  padding: 1rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.diagram-caption {
  font-size: 0.85rem;
  color: var(--muted-foreground);
  margin-top: 0.5rem;
  font-style: italic;
}

/* Quiz feedback text */
.quiz-feedback {
  margin-top: 0.5rem;
  font-size: 0.85rem;
}

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

.lesson-nav a {
  padding: 0.5rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: background 0.2s;
  color: var(--primary);
}

.lesson-nav a:hover {
  background: hsl(215 100% 51% / 0.06);
}

/* Chapter linked list (course map) */
.chapter-list {
  list-style: none;
  margin: 2rem 0;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.chapter-list li {
  border-bottom: 1px solid var(--border);
  padding: 0.65rem 1rem;
  font-size: 0.92rem;
}

.chapter-list li:last-child {
  border-bottom: none;
}

.chapter-list a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
}

.chapter-list a:hover {
  text-decoration: underline;
}

.chapter-list li.current {
  background: hsl(215 100% 51% / 0.06);
  font-weight: 600;
  color: var(--foreground);
}

/* Print styles */
@media print {
  body {
    background: white;
    color: black;
    max-width: none;
    padding: 0;
  }

  .sidenote {
    position: static;
    width: auto;
    border: 1px solid var(--border);
    padding: 0.5rem;
    margin: 0.5rem 0;
  }

  .quiz-container {
    box-shadow: none;
    border: 1px solid var(--border);
  }
}

/* ----- Code Tabs (from components.css) ----- */
.code-tabs {
  position: relative;
  margin: 1rem 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--card);
}

.code-tab-bar {
  display: flex;
  background: var(--muted);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}

.code-tab-btn {
  background: none;
  border: none;
  color: var(--muted-foreground);
  padding: 0.45rem 1rem;
  font-size: 0.8rem;
  font-family: var(--font-mono);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition:
    color 0.15s,
    border-bottom-color 0.15s;
}

.code-tab-btn:hover {
  color: var(--foreground);
}

.code-tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.code-tabs pre[data-lang] {
  display: none;
  margin: 0;
  padding: 1rem;
  overflow-x: auto;
  font-size: 0.85rem;
  line-height: 1.55;
  background: var(--card);
  color: var(--foreground);
  border: none;
  border-radius: 0;
}

.code-tabs pre[data-lang].active {
  display: block;
}

.code-tabs pre[data-lang] code {
  background: none;
  padding: 0;
  font-size: inherit;
}

.code-copy-btn {
  position: absolute;
  top: 0.35rem;
  right: 0.5rem;
  background: var(--muted);
  border: 1px solid var(--border);
  color: var(--muted-foreground);
  padding: 0.2rem 0.6rem;
  font-size: 0.7rem;
  border-radius: 4px;
  cursor: pointer;
  font-family: inherit;
  opacity: 0;
  transition:
    opacity 0.2s,
    background 0.2s;
  z-index: 2;
}

.code-tabs:hover .code-copy-btn {
  opacity: 1;
}

.code-copy-btn:hover {
  background: var(--accent);
  color: var(--foreground);
}

.code-copy-btn.copied {
  background: hsl(160 100% 30% / 0.08);
  border-color: var(--chart-3);
  color: var(--chart-3);
}

/* ----- Notes Block (from components.css) ----- */
.notes-block {
  border: 2px solid var(--border);
  background: var(--card);
  padding: 1.5rem 2rem;
  margin: 2rem 0;
  font-size: 0.82rem;
  line-height: 1.7;
  border-radius: 6px;
  color: var(--foreground);
}

.notes-block h3 {
  margin-top: 0;
  font-size: 0.92rem;
  border: none;
  padding: 0;
}

.notes-block h4 {
  font-size: 0.85rem;
  margin-bottom: 0.3rem;
}

.notes-block p {
  margin-bottom: 0.2rem;
  text-align: left;
}

.notes-block p.notes-indent {
  margin-left: 1.5rem;
}

.notes-sep {
  border-top: 1px dashed var(--border);
  margin: 1rem 0;
}

/* ----- Quiz (from components.css) ----- */
.quiz {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem 1.5rem;
  margin: 1.5rem 0;
}

.quiz p {
  margin: 0 0 0.8rem;
}

.quiz pre {
  margin: 0.5rem 0 0.8rem;
}

.quiz button {
  background: var(--muted);
  color: var(--foreground);
  border: 1px solid var(--border);
  padding: 0.4rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  margin: 0.25rem;
  transition:
    background 0.15s,
    border-color 0.15s;
  font-family: inherit;
}

.quiz button:hover:not(:disabled) {
  background: var(--accent);
  border-color: var(--ring);
}

.quiz button:disabled {
  opacity: 0.6;
  cursor: default;
}

.quiz button.correct {
  background: hsl(160 100% 30% / 0.08);
  border-color: var(--chart-3);
  color: var(--chart-3);
}

.quiz button.incorrect {
  background: hsl(357 96% 57.7% / 0.08);
  border-color: var(--destructive);
  color: var(--destructive);
}

.quiz-feedback {
  display: none;
  margin-top: 0.8rem;
  padding: 0.5rem 0.8rem;
  border-radius: 6px;
  font-size: 0.9rem;
}

.quiz-feedback.correct {
  display: block;
  background: hsl(160 100% 30% / 0.08);
  border: 1px solid var(--chart-3);
  color: var(--chart-3);
}

.quiz-feedback.incorrect {
  display: block;
  background: hsl(357 96% 57.7% / 0.08);
  border: 1px solid var(--destructive);
  color: var(--destructive);
}

/* ----- blockquote (from style.css convention) ----- */
blockquote {
  background: hsl(215 100% 51% / 0.06);
  border-left: 4px solid var(--primary);
  padding: 1rem 1.2rem;
  margin: 1.5rem 0;
  border-radius: 0 var(--radius) var(--radius) 0;
  font-style: normal;
}

blockquote p:last-child {
  margin-bottom: 0;
}

/* ----- meta line ----- */
p.meta {
  color: var(--muted-foreground);
  font-size: 0.85rem;
  margin-bottom: 1.5rem;
}

/* ----- Topic index pages (search + lesson list) ----- */
.search-input {
  width: 100%;
  padding: 0.6rem 0.8rem;
  font-size: 0.95rem;
  font-family: var(--font-sans);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--foreground);
  margin-bottom: 1.5rem;
  box-sizing: border-box;
}

.search-input:focus {
  outline: 2px solid var(--primary);
}

.lesson-item {
  margin-bottom: 0.75rem;
}

.lesson-item small {
  color: var(--muted-foreground);
  font-family: var(--font-sans);
  font-size: 0.85rem;
}

.topic-section {
  margin-bottom: 2rem;
}
