/* GitHub Branches for Agentic Coding — shared course stylesheet.
   Every lesson, reference page, and the index link this file. */

@import url("https://fonts.googleapis.com/css2?family=Source+Serif+4:ital,opsz,wght@0,8..60,400;0,8..60,600;1,8..60,400&family=JetBrains+Mono:wght@400;600&display=swap");

:root {
  --bg: #fffff8;
  --surface: #f6f4ea;
  --ink: #1d1d1b;
  --muted: #5f5d55;
  --rule: #d9d5c3;
  --accent: #a3361f;        /* brick: links, highlights */
  --main: #2f5d8a;          /* the main branch colour */
  --feature: #b5651d;       /* feature branch colour */
  --feature2: #4f7a3a;      /* second feature branch colour */
  --ok: #2e7d32;
  --bad: #b3261e;
  --code-bg: #f1eee2;
  --serif: "Source Serif 4", "Iowan Old Style", Georgia, serif;
  --mono: "JetBrains Mono", ui-monospace, Consolas, monospace;
  --measure: 40rem;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #161614;
    --surface: #201f1c;
    --ink: #e9e6da;
    --muted: #a7a395;
    --rule: #3a3833;
    --accent: #e48a6f;
    --main: #7fb0e0;
    --feature: #e3a35f;
    --feature2: #9cc786;
    --ok: #7bc47f;
    --bad: #f08a80;
    --code-bg: #24231f;
  }
}
:root[data-theme="dark"] {
  --bg: #161614; --surface: #201f1c; --ink: #e9e6da; --muted: #a7a395;
  --rule: #3a3833; --accent: #e48a6f; --main: #7fb0e0; --feature: #e3a35f;
  --feature2: #9cc786; --ok: #7bc47f; --bad: #f08a80; --code-bg: #24231f;
}

* { box-sizing: border-box; }

html { font-size: 18px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--serif);
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}

main, .site-header, .site-footer {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 0 16px;
}

/* ---------- header / nav ---------- */
.site-header {
  display: flex; justify-content: space-between; align-items: baseline;
  flex-wrap: wrap; gap: .5rem;
  padding-top: 1.25rem; padding-bottom: .5rem;
  border-bottom: 1px solid var(--rule);
  font-size: .85rem;
}
.site-header a { color: var(--muted); text-decoration: none; }
.site-header a:hover { color: var(--accent); }
.site-header .course { font-variant: small-caps; letter-spacing: .04em; }

h1, h2, h3 { font-weight: 600; line-height: 1.25; }
h1 { font-size: 2.1rem; margin: 2rem 0 .25rem; }
h2 { font-size: 1.35rem; margin: 2.5rem 0 .5rem; }
h3 { font-size: 1.05rem; margin: 1.75rem 0 .25rem; }
.subtitle { color: var(--muted); font-style: italic; font-size: 1.1rem; margin: 0 0 1.5rem; }
.kicker { font-variant: small-caps; letter-spacing: .06em; color: var(--accent); margin: 2rem 0 0; font-size: .9rem; }

a { color: var(--accent); text-underline-offset: 2px; }
p, li { hyphens: auto; }
strong { font-weight: 600; }

/* ---------- lesson furniture ---------- */
.win {
  border-left: 3px solid var(--accent);
  padding: .5rem 1rem; margin: 1.5rem 0;
  background: var(--surface);
}
.win::before { content: "Today's win"; display: block; font-variant: small-caps; color: var(--accent); letter-spacing: .05em; font-size: .85rem; }

.note, .warn {
  font-size: .9rem; color: var(--muted);
  border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule);
  padding: .5rem 0; margin: 1.5rem 0;
}
.warn { color: var(--ink); border-color: var(--bad); }
.warn::before { content: "Watch out — "; font-weight: 600; color: var(--bad); }

.cite { font-size: .8rem; vertical-align: super; line-height: 0; text-decoration: none; }
.cite::before { content: "["; } .cite::after { content: "]"; }

.primary-source, .ask-agent {
  margin: 2rem 0; padding: 1rem 1.25rem; border: 1px solid var(--rule); border-radius: 4px;
}
.primary-source::before { content: "Primary source"; display: block; font-variant: small-caps; letter-spacing: .05em; color: var(--muted); font-size: .85rem; }
.ask-agent::before { content: "Stuck? Ask your teacher"; display: block; font-variant: small-caps; letter-spacing: .05em; color: var(--muted); font-size: .85rem; }

.sources { font-size: .85rem; color: var(--muted); }
.sources ol { padding-left: 1.25rem; }

.lesson-nav {
  display: flex; justify-content: space-between; gap: 1rem;
  margin: 3rem 0 1rem; padding-top: 1rem; border-top: 1px solid var(--rule); font-size: .9rem;
}
.lesson-nav a { text-decoration: none; }

/* ---------- code ---------- */
code, pre, kbd { font-family: var(--mono); font-size: .82em; }
code { background: var(--code-bg); padding: .08em .3em; border-radius: 3px; }
pre {
  background: var(--code-bg); padding: .85rem 1rem; border-radius: 4px;
  overflow-x: auto; line-height: 1.45; margin: 1rem 0;
}
pre code { background: none; padding: 0; font-size: 1em; }
pre .c { color: var(--muted); }           /* comment */
pre .p { color: var(--accent); user-select: none; } /* prompt */
kbd { border: 1px solid var(--rule); border-bottom-width: 2px; border-radius: 3px; padding: 0 .3em; }

/* ---------- tables ---------- */
table { border-collapse: collapse; width: 100%; font-size: .9rem; margin: 1rem 0; }
th, td { text-align: left; padding: .4rem .5rem; border-bottom: 1px solid var(--rule); vertical-align: top; }
th { font-weight: 600; border-bottom: 2px solid var(--ink); }
.table-wrap { overflow-x: auto; }

/* ---------- figures / diagrams ---------- */
figure { margin: 1.5rem 0; }
figure svg { width: 100%; height: auto; display: block; }
figcaption { font-size: .85rem; color: var(--muted); font-style: italic; margin-top: .25rem; }
svg .main-line { stroke: var(--main); } svg .main-fill { fill: var(--main); }
svg .feat-line { stroke: var(--feature); } svg .feat-fill { fill: var(--feature); }
svg .feat2-line { stroke: var(--feature2); } svg .feat2-fill { fill: var(--feature2); }
svg .ink-fill { fill: var(--ink); } svg .muted-fill { fill: var(--muted); }
svg .ink-line { stroke: var(--ink); } svg .rule-line { stroke: var(--rule); }
svg .bg-fill { fill: var(--bg); } svg .surface-fill { fill: var(--surface); }
svg text { font-family: var(--mono); font-size: 12px; fill: var(--ink); }
svg text.label { font-family: var(--serif); font-size: 13px; }

/* ---------- step lists (real-world tasks) ---------- */
ol.steps { counter-reset: step; list-style: none; padding-left: 0; }
ol.steps > li { counter-increment: step; position: relative; padding-left: 2.25rem; margin: 1rem 0; }
ol.steps > li::before {
  content: counter(step); position: absolute; left: 0; top: .1rem;
  width: 1.6rem; height: 1.6rem; border-radius: 50%;
  background: var(--ink); color: var(--bg); font-size: .8rem; text-align: center; line-height: 1.6rem;
}
ol.steps input[type="checkbox"] { margin-right: .4rem; }

/* ---------- quiz component (assets/quiz.js) ---------- */
.quiz { border: 1px solid var(--rule); border-radius: 4px; padding: 1rem 1.25rem; margin: 1.25rem 0; }
.quiz .q { margin-top: 0; font-weight: 600; }
.quiz .opts { list-style: none; padding: 0; margin: 0; display: grid; gap: .5rem; }
.quiz button.opt {
  width: 100%; text-align: left; font: inherit; font-size: .95rem;
  background: var(--bg); color: var(--ink);
  border: 1px solid var(--rule); border-radius: 4px; padding: .5rem .75rem; cursor: pointer;
}
.quiz button.opt:hover:not([disabled]) { border-color: var(--ink); }
.quiz button.opt[disabled] { cursor: default; }
.quiz button.opt.correct { border-color: var(--ok); box-shadow: inset 4px 0 0 var(--ok); }
.quiz button.opt.wrong { border-color: var(--bad); box-shadow: inset 4px 0 0 var(--bad); opacity: .8; }
.quiz .why { display: none; font-size: .9rem; margin: .75rem 0 0; color: var(--muted); }
.quiz.answered .why { display: block; }
.quiz .verdict { font-weight: 600; }
.quiz .verdict.ok { color: var(--ok); } .quiz .verdict.bad { color: var(--bad); }
.score { font-variant: small-caps; letter-spacing: .04em; color: var(--muted); text-align: right; }

/* ---------- command drill (assets/drill.js) ---------- */
.drill { border: 1px solid var(--rule); border-radius: 4px; padding: 1rem 1.25rem; margin: 1.25rem 0; }
.drill .prompt { margin: 0 0 .5rem; }
.drill form { display: flex; gap: .5rem; flex-wrap: wrap; }
.drill input {
  flex: 1 1 14rem; min-width: 0; font-family: var(--mono); font-size: .9rem;
  padding: .45rem .6rem; border: 1px solid var(--rule); border-radius: 4px; background: var(--code-bg); color: var(--ink);
}
.drill button, .sim button {
  font: inherit; font-size: .85rem; padding: .4rem .8rem; border-radius: 4px; cursor: pointer;
  border: 1px solid var(--ink); background: var(--ink); color: var(--bg);
}
.drill button.secondary, .sim button.secondary { background: transparent; color: var(--ink); }
.drill .feedback { margin: .5rem 0 0; font-size: .9rem; min-height: 1.4em; }
.drill .feedback.ok { color: var(--ok); } .drill .feedback.bad { color: var(--bad); }

/* ---------- branch simulator (assets/branch-sim.js) ---------- */
.sim { border: 1px solid var(--rule); border-radius: 4px; margin: 1.5rem 0; overflow: hidden; }
.sim .sim-graph { background: var(--surface); padding: .5rem; overflow-x: auto; }
.sim .sim-graph svg { display: block; min-width: 100%; height: auto; }
.sim .sim-graph svg text { paint-order: stroke; stroke: var(--surface); stroke-width: 4px; stroke-linejoin: round; }
/* marks left by `git merge-base` and `git diff` in the simulator */
svg .mark-base { fill: none; stroke: var(--ink); stroke-width: 2; }
svg .mark-added { fill: var(--ok); fill-opacity: .4; }
svg .mark-reversed { fill: none; stroke: var(--bad); stroke-width: 2.5; stroke-dasharray: 4 3; }
.sim .sim-legend { margin: .25rem 0 0; font-size: .8rem; color: var(--muted); display: flex; flex-wrap: wrap; gap: .25rem 1rem; }
.sim .sim-legend i { display: inline-block; width: .8em; height: .8em; vertical-align: -.05em; }
.sim .sim-legend .key-base { border: 2px solid var(--ink); }
.sim .sim-legend .key-added { border-radius: 50%; background: var(--ok); opacity: .55; }
.sim .sim-legend .key-reversed { border-radius: 50%; border: 2px dashed var(--bad); }
.sim .sim-term { background: var(--code-bg); font-family: var(--mono); font-size: .8rem; padding: .5rem .75rem; }
.sim .sim-log { max-height: 9rem; overflow-y: auto; white-space: pre-wrap; margin: 0; padding: 0; background: none; color: var(--muted); }
.sim .sim-log .cmd { color: var(--ink); }
.sim .sim-log .err { color: var(--bad); }
.sim form { display: flex; gap: .5rem; align-items: center; margin-top: .25rem; }
.sim form span { color: var(--accent); }
.sim input { flex: 1; min-width: 0; font: inherit; background: transparent; border: none; border-bottom: 1px solid var(--rule); color: var(--ink); padding: .25rem 0; }
.sim input:focus { outline: none; border-bottom-color: var(--accent); }
.sim .sim-tasks { padding: .5rem 1rem 1rem; font-size: .9rem; }
.sim .sim-tasks ol { margin: .25rem 0; padding-left: 1.25rem; }
.sim .sim-tasks li.done { color: var(--ok); }
.sim .sim-tasks li.done::marker { content: "✓  "; }
.sim .sim-bar { display: flex; justify-content: space-between; align-items: center; gap: .5rem; flex-wrap: wrap; }
.sim .sim-bar h4 { margin: .25rem 0; font-size: .9rem; font-variant: small-caps; letter-spacing: .05em; color: var(--muted); font-weight: 600; }

/* ---------- index / reference ---------- */
.toc { list-style: none; padding: 0; }
.toc li { display: grid; grid-template-columns: 2.5rem 1fr; gap: .25rem .75rem; padding: .75rem 0; border-bottom: 1px solid var(--rule); }
.toc .num { font-family: var(--mono); color: var(--muted); font-size: .85rem; padding-top: .2rem; }
.toc a { font-weight: 600; text-decoration: none; }
.toc p { grid-column: 2; margin: 0; font-size: .9rem; color: var(--muted); }

dl.glossary dt { font-weight: 600; margin-top: 1rem; }
dl.glossary dd { margin: .15rem 0 0 0; }
dl.glossary .avoid { font-size: .85rem; color: var(--muted); font-style: italic; }

.site-footer { font-size: .8rem; color: var(--muted); padding-top: 1rem; padding-bottom: 2rem; border-top: 1px solid var(--rule); margin-top: 3rem; }
.theme-toggle { font: inherit; font-size: .8rem; background: none; border: 1px solid var(--rule); color: var(--muted); border-radius: 4px; padding: .1rem .5rem; cursor: pointer; }

/* ---------- print ---------- */
@media print {
  html { font-size: 11pt; }
  :root { --bg: #fff; --surface: #fff; --code-bg: #f4f4f4; --ink: #000; --muted: #444; }
  .site-header, .lesson-nav, .theme-toggle, .sim form, .drill form, .ask-agent { display: none; }
  a { color: inherit; }
  main a[href^="http"]::after { content: " (" attr(href) ")"; font-size: .75em; color: #555; word-break: break-all; }
  pre, table, figure, .quiz, dl.glossary dt { break-inside: avoid; }
  .quiz .why { display: block; }
  h2 { break-after: avoid; }
}

/* ---------- copyable prompt (reference/practice-tutor.html) ---------- */
.prompt-box { border: 1px solid var(--rule); border-radius: 4px; margin: 1.25rem 0; }
.prompt-box .bar { display: flex; justify-content: space-between; align-items: center; gap: .5rem; padding: .5rem .75rem; border-bottom: 1px solid var(--rule); font-size: .85rem; color: var(--muted); }
.prompt-box pre { margin: 0; border-radius: 0 0 4px 4px; max-height: 28rem; overflow-y: auto; white-space: pre-wrap; overflow-wrap: anywhere; }
.prompt-box pre.code { white-space: pre; overflow-wrap: normal; overflow-x: auto; }  /* source code: scroll, never wrap */
button.copy {
  font: inherit; font-size: .85rem; padding: .35rem .8rem; border-radius: 4px; cursor: pointer;
  border: 1px solid var(--ink); background: var(--ink); color: var(--bg);
}
