/* ═══════════════════════════════════════════════════════════════
   Book content: prose, code, figures, tables, callouts
   ═══════════════════════════════════════════════════════════════ */

.prose {
  max-width: 72ch;
  font-size: 17px;
  line-height: 1.7;
}

.prose > h2 {
  font-size: clamp(1.6rem, 3vw, 2.25rem);
  line-height: 1.1;
  letter-spacing: -0.03em;
  text-transform: uppercase;
  margin: 4rem 0 1.5rem;
  padding-top: 1.5rem;
  border-top: var(--border-thick) solid var(--border);
}
.prose > h2:first-child { margin-top: 0; }

.prose > h3 {
  font-size: clamp(1.15rem, 2vw, 1.5rem);
  line-height: 1.2;
  letter-spacing: -0.02em;
  margin: 3rem 0 1rem;
  padding-left: 16px;
  border-left: var(--border-thick) solid var(--accent);
}

.prose > h4 {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: .02em;
  text-transform: uppercase;
  margin: 2.25rem 0 .85rem;
}

/* anchor links on hover */
.prose h2, .prose h3 { position: relative; }
.prose h2::before, .prose h3::before {
  content: "#";
  position: absolute;
  left: -1.1em;
  color: var(--accent);
  opacity: 0;
  font-weight: 700;
  transition: opacity .15s linear;
}
.prose h2:hover::before, .prose h3:hover::before { opacity: 1; }

.prose strong { font-weight: 700; }
.prose em { font-style: italic; }

.prose a {
  border-bottom: var(--border-w) solid var(--fg);
  transition: color .15s linear, border-color .15s linear;
}
.prose a:hover { color: var(--accent); border-color: var(--accent); }

.prose ul, .prose ol { padding-left: 1.5em; }
.prose li::marker { color: var(--accent); font-weight: 700; }

.prose code {
  font-family: var(--mono);
  font-size: .875em;
  background: var(--muted);
  padding: .12em .35em;
  border: 1px solid rgba(0,0,0,.12);
  white-space: nowrap;
}

/* ── Code blocks ─────────────────────────────────────────────── */
.prose pre,
.codehilite pre,
div.hl pre {
  margin: 1.5rem 0;
  padding: 20px 24px;
  background: var(--muted);
  border-left: var(--border-thick) solid var(--accent);
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 13.5px;
  line-height: 1.6;
  tab-size: 2;
}
.prose pre code {
  background: none;
  border: 0;
  padding: 0;
  font-size: inherit;
  white-space: pre;
}
.hl { margin: 1.5rem 0; }
.hl pre { margin: 0; }

/* Pygments - restrained palette, Swiss discipline */
.hl .k, .hl .kd, .hl .kn, .hl .kt, .hl .kr { color: #000; font-weight: 700; }
.hl .s, .hl .s1, .hl .s2, .hl .sb, .hl .sd { color: #A02000; }
.hl .c, .hl .c1, .hl .cm, .hl .ch { color: #6A6A6A; font-style: italic; }
.hl .n, .hl .nn, .hl .nx { color: #000; }
.hl .nf, .hl .nb { color: #000; font-weight: 700; }
.hl .mi, .hl .mf, .hl .m { color: #0B5FA5; }
.hl .o, .hl .p { color: #444; }
.hl .nt { color: #000; font-weight: 700; }
.hl .err { color: inherit; background: none; }

/* ── Code annotations ────────────────────────────────────────── */
.code-notes {
  list-style: none;
  margin: -.5rem 0 2rem;
  padding: 16px 20px;
  background: #fff;
  border: var(--border-w) solid var(--border);
  border-top: 0;
  font-size: 14px;
  line-height: 1.5;
}
.code-notes li {
  display: flex;
  gap: 12px;
  margin: 0 0 .5em;
}
.code-notes li:last-child { margin-bottom: 0; }
.note-num {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  background: var(--accent);
  color: #fff;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
}
.note-body code {
  white-space: normal;
}

/* ── Figures ─────────────────────────────────────────────────── */
.fig {
  margin: 2.5rem 0;
  padding: 0;
  border: var(--border-w) solid var(--border);
  background: #fff;
}
.fig img { width: 100%; }
.fig figcaption {
  padding: 14px 18px;
  border-top: var(--border-w) solid var(--border);
  background: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}
.fig-num {
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--accent);
  margin-right: 8px;
}
.orphan-caption { font-size: 13px; color: rgba(0,0,0,.7); }

/* ── Tables ──────────────────────────────────────────────────── */
.table-caption {
  margin: 2.5rem 0 .75rem;
  font-size: 13px;
  font-weight: 700;
}
.table-wrap {
  margin: 0 0 2rem;
  overflow-x: auto;
  border: var(--border-w) solid var(--border);
}
.prose table {
  border-collapse: collapse;
  width: 100%;
  min-width: 560px;
  font-size: 14px;
}
.prose th, .prose td {
  padding: 10px 14px;
  border: 1px solid rgba(0,0,0,.18);
  text-align: left;
  vertical-align: top;
  line-height: 1.45;
}
.prose th {
  background: var(--fg);
  color: #fff;
  font-weight: 700;
  font-size: 11px;
  letter-spacing: .12em;
  text-transform: uppercase;
  border-color: var(--fg);
}
.prose tbody tr:nth-child(even) { background: rgba(0,0,0,.025); }

/* ── Callouts / sidebars ─────────────────────────────────────── */
.callout {
  margin: 2.5rem 0;
  padding: 28px 32px;
  border: var(--border-w) solid var(--border);
  background: var(--muted);
  background-image: radial-gradient(rgba(0,0,0,.04) 1px, transparent 1px);
  background-size: 16px 16px;
}
.callout > h4 {
  margin: 0 0 1rem;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: .16em;
  text-transform: uppercase;
  padding-bottom: 10px;
  border-bottom: var(--border-w) solid var(--border);
}
.callout > *:last-child { margin-bottom: 0; }
.callout pre { background: #fff; }

/* ── "В этой главе рассматриваются" ─────────────────────────── */
/* No box: the chapter intro reads as ordinary prose, like the front matter. */
.chapter-covers {
  margin: 0 0 2.5rem;
  padding: 0;
  border: 0;
  background: none;
}
.chapter-covers > h4 {
  margin: 0 0 .85rem;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--accent);
}
.chapter-covers ul { margin: 0; padding-left: 1.4em; }
.chapter-covers li { font-weight: 500; }

/* ── Notes ───────────────────────────────────────────────────── */
.note {
  margin: 2rem 0;
  padding: 18px 22px;
  border-left: var(--border-thick) solid var(--fg);
  background: var(--muted);
  font-size: 15.5px;
}
.note > *:last-child { margin-bottom: 0; }
.note strong:first-child { text-transform: uppercase; letter-spacing: .1em; font-size: 12px; }

/* ── Blockquote ──────────────────────────────────────────────── */
.prose blockquote {
  margin: 2rem 0;
  padding-left: 24px;
  border-left: var(--border-thick) solid var(--accent);
  font-size: 18px;
}

@media (max-width: 767px) {
  .prose { font-size: 16px; }
  .prose pre { padding: 16px; font-size: 12.5px; }
  .callout, .chapter-covers { padding: 20px; }
  .prose h2::before, .prose h3::before { display: none; }
}

/* ── Copy button ─────────────────────────────────────────────── */
.pre-wrap { position: relative; }
.copy-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  padding: 6px 12px;
  background: var(--bg);
  border: var(--border-w) solid var(--border);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  opacity: 0;
  transition: opacity .15s linear, background .15s linear, color .15s linear;
}
.pre-wrap:hover .copy-btn, .copy-btn:focus-visible { opacity: 1; }
.copy-btn:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
