/* The Codex Book: EPUB stylesheet (Apple Books, phone and tablet readers). */
@charset "UTF-8";

body {
  font-family: "Iowan Old Style", "Charter", "Palatino", Georgia, serif;
  line-height: 1.55;
  color: #1b1b1b;
  margin: 0 0.4em;
  text-rendering: optimizeLegibility;
  -webkit-hyphens: auto;
  hyphens: auto;
}
p { margin: 0 0 0.85em 0; text-align: left; }

h1, h2, h3, h4 {
  font-family: "Avenir Next", "Helvetica Neue", Helvetica, Arial, sans-serif;
  color: #111;
  line-height: 1.25;
  -webkit-hyphens: none;
  hyphens: none;
  page-break-after: avoid;
}
h1 {
  font-size: 1.75em;
  font-weight: 600;
  margin: 0.4em 0 1em 0;
  padding-bottom: 0.35em;
  border-bottom: 3px solid #d3002d;
}
h2 {
  font-size: 1.3em;
  font-weight: 600;
  margin: 1.8em 0 0.6em 0;
  color: #b3002a;
}
h3 { font-size: 1.08em; font-weight: 600; margin: 1.4em 0 0.4em 0; color: #222; }

/* Part pages */
h1.part {
  text-align: center;
  border-bottom: none;
  margin-top: 28%;
  font-size: 2em;
  color: #d3002d;
}
h1.part + p, h1.part ~ p { text-align: center; color: #555; font-style: italic; }

a { color: #1c5cab; text-decoration: none; }
strong { font-weight: 700; }
em { font-style: italic; }

/* Callout boxes from Pandoc fenced divs */
div.bigidea, div.status, div.note, div.pitfall, div.tryit {
  margin: 1.1em 0;
  padding: 0.75em 0.95em 0.15em 0.95em;
  border-radius: 6px;
  page-break-inside: avoid;
}
div.bigidea {
  background: #fdf1f3;
  border-left: 5px solid #d3002d;
  font-family: "Avenir Next", "Helvetica Neue", sans-serif;
  font-size: 1.04em;
  font-weight: 500;
}
div.status { background: #eef4fc; border-left: 5px solid #2a78d6; }
div.note { background: #eefaf4; border-left: 5px solid #1baf7a; }
div.pitfall { background: #fdf0ea; border-left: 5px solid #eb6834; }
div.tryit { background: #f3f1fd; border-left: 5px solid #6250d6; }
div.status strong:first-child, div.note strong:first-child, div.pitfall strong:first-child,
div.tryit strong:first-child {
  font-family: "Avenir Next", "Helvetica Neue", sans-serif;
  font-style: normal;
}
div.status ul, div.note ul, div.pitfall ul, div.tryit ul { margin-bottom: 0.7em; }

blockquote {
  margin: 1em 0;
  padding: 0.5em 1em;
  border-left: 4px solid #c9c9c4;
  color: #333;
  background: #f7f7f5;
}

/* Code */
code, pre, kbd {
  font-family: "SF Mono", Menlo, Monaco, "Courier New", monospace;
  -webkit-hyphens: none;
  hyphens: none;
}
code { font-size: 0.86em; background: #f3f2ef; padding: 0.05em 0.25em; border-radius: 3px; }
pre {
  font-size: 0.76em;
  line-height: 1.45;
  background: #f7f6f3;
  border: 1px solid #e3e1db;
  border-left: 4px solid #6250d6;
  border-radius: 5px;
  padding: 0.7em 0.8em;
  margin: 1em 0;
  white-space: pre-wrap;
  word-wrap: break-word;
  page-break-inside: avoid;
}
pre code { background: none; padding: 0; font-size: 1em; }
div.sourceCode { margin: 1em 0; }
/* Syntax colors (light theme, readable in Apple Books) */
pre.sourceCode code span.kw, pre.sourceCode code span.cf { color: #7a1fa2; font-weight: 600; } /* keyword, control flow */
pre.sourceCode code span.dt { color: #1c5cab; }                                   /* data type */
pre.sourceCode code span.dv, pre.sourceCode code span.bn, pre.sourceCode code span.fl { color: #b35900; }       /* numbers */
pre.sourceCode code span.st, pre.sourceCode code span.ss, pre.sourceCode code span.ch, pre.sourceCode code span.vs { color: #1a7f37; } /* strings */
pre.sourceCode code span.co { color: #6a737d; font-style: italic; }               /* comments */
pre.sourceCode code span.fu { color: #005cc5; }                                   /* functions */
pre.sourceCode code span.bu { color: #005cc5; }                                   /* builtins */
pre.sourceCode code span.op { color: #444; }
pre.sourceCode code span.im { color: #7a1fa2; }                                   /* import */
pre.sourceCode code span.at { color: #b35900; }                                   /* attribute / JSON keys */
pre.sourceCode code span.va { color: #24292e; }
pre.sourceCode code span.cn { color: #b35900; }
pre.sourceCode code span.ex { color: #005cc5; }
pre.sourceCode code span.ot { color: #24292e; }
pre.sourceCode code span.al, pre.sourceCode code span.er { color: #d3002d; font-weight: 600; }

/* Tables */
table {
  border-collapse: collapse;
  width: 100%;
  margin: 1.1em 0;
  font-family: "Avenir Next", "Helvetica Neue", sans-serif;
  font-size: 0.8em;
  line-height: 1.35;
  page-break-inside: avoid;
}
th {
  background: #f1efe9;
  color: #111;
  font-weight: 600;
  text-align: left;
  border-bottom: 2px solid #d3002d;
  padding: 0.45em 0.5em;
}
td { border-bottom: 1px solid #e3e1db; padding: 0.4em 0.5em; vertical-align: top; }
tr:nth-child(even) td { background: #fafaf8; }

/* Figures */
figure { margin: 1.3em 0; text-align: center; page-break-inside: avoid; }
figure img, img { max-width: 100%; height: auto; }
figcaption {
  font-family: "Avenir Next", "Helvetica Neue", sans-serif;
  font-size: 0.82em;
  color: #555;
  margin-top: 0.45em;
  text-align: center;
  line-height: 1.35;
}

/* Math (inline SVG from the typeset-math filter) */
svg { max-width: 100%; }
p > span.math.display, span.math.display { display: block; text-align: center; margin: 0.8em 0; overflow-x: auto; }

ul, ol { margin: 0.4em 0 1em 0; padding-left: 1.4em; }
li { margin-bottom: 0.35em; }
hr { border: none; border-top: 1px solid #ddd; margin: 2em 0; }

/* Title page */
section.titlepage { text-align: center; padding-top: 18%; }
section.titlepage h1.title {
  font-size: 2.3em; border-bottom: none; margin-bottom: 0.3em; color: #111;
}
section.titlepage p { text-align: center; }
section.titlepage p.subtitle {
  font-family: "Avenir Next Condensed", "Avenir Next", sans-serif;
  font-size: 1.35em; color: #cc6228; margin-bottom: 2.2em;
}
section.titlepage p.author {
  font-family: "Avenir Next", sans-serif; font-size: 1.2em; font-weight: 600; margin-bottom: 0.3em;
}
section.titlepage p.author::before { content: "by "; font-weight: 400; }
section.titlepage p.date { display: none; }
section.titlepage div.rights {
  margin-top: 3em; font-family: "Avenir Next", sans-serif; font-size: 0.85em; color: #999;
}
section.titlepage::before {
  content: "CODING AGENT INTERNALS"; display: block; color: #d3002d; font-family: "Avenir Next", sans-serif;
  font-weight: 700; letter-spacing: 0.12em; margin-bottom: 2em;
}

/* Let the reader size table columns to their content (Pandoc writes equal inline widths). */
table col { width: auto !important; }
table { table-layout: auto; }

/* ---- Web edition additions ---- */
html { background: #faf8f5; }
body { max-width: 46em; margin: 0 auto; padding: 0 1.2em 2em; background: #fff; box-shadow: 0 0 24px rgba(0,0,0,.06); font-size: 18px; }
main img { max-width: 100%; height: auto; }
main pre { overflow-x: auto; }
main table { display: block; overflow-x: auto; }
nav.chapnav { display: flex; justify-content: space-between; align-items: center; gap: 1em; font-family: "Avenir Next", "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: .82em; padding: .8em 0; }
nav.chapnav.top { border-bottom: 1px solid #eee; margin-bottom: 1em; }
nav.chapnav.bottom { border-top: 1px solid #eee; margin-top: 2em; }
nav.chapnav .prev, nav.chapnav .next { flex: 1; }
nav.chapnav .next { text-align: right; }
nav.chapnav .toc { font-weight: 600; white-space: nowrap; }
.partbanner { margin: .5em 0 1.5em; padding: .6em 1em; border-left: 4px solid #d3002d; background: #fdf1f3; font-family: "Avenir Next", "Helvetica Neue", Helvetica, Arial, sans-serif; }
.partbanner p { margin: .2em 0; color: #555; font-size: .9em; }
.partbanner .partname { color: #d3002d; font-weight: 600; font-size: 1em; }
footer { border-top: 1px solid #eee; margin-top: 1em; padding-top: .8em; font-size: .78em; color: #666; font-family: "Avenir Next", "Helvetica Neue", Helvetica, Arial, sans-serif; }
.hero { text-align: center; padding-top: 1.5em; }
.hero img { max-width: 320px; width: 70%; box-shadow: 0 4px 18px rgba(0,0,0,.18); }
.downloads { text-align: center; font-family: "Avenir Next", "Helvetica Neue", Helvetica, Arial, sans-serif; }
.downloads a { display: inline-block; margin: .3em; padding: .45em 1em; border: 1px solid #d3002d; border-radius: 4px; color: #d3002d; }
ol.toc, ol.toc ol { list-style: none; padding-left: 0; }
ol.toc li.part { margin-top: 1.3em; }
ol.toc .partname { display: block; font-family: "Avenir Next", "Helvetica Neue", Helvetica, Arial, sans-serif; font-weight: 600; color: #d3002d; }
ol.toc .blurb { display: block; color: #666; font-style: italic; font-size: .9em; margin-bottom: .3em; }
ol.toc ol li { padding: .15em 0 .15em 1em; }
.notice { font-size: .88em; background: #f6f6f6; padding: .8em 1em; border-radius: 6px; }
@media (max-width: 600px) { body { font-size: 16px; } nav.chapnav { font-size: .75em; } }
.hero p { text-align: center; }
