/* ------------------------------------------------------------------
   Сигма · Tufte-inspired styles (поверх Quarto Cosmo theme)
   ------------------------------------------------------------------ */

/* ET Book font ---------------------------------------------------- */
@font-face {
  font-family: "et-book";
  src: url("et-book/et-book-roman-line-figures/et-book-roman-line-figures.woff") format("woff"),
       url("et-book/et-book-roman-line-figures/et-book-roman-line-figures.ttf") format("truetype");
  font-weight: normal; font-style: normal;
}
@font-face {
  font-family: "et-book";
  src: url("et-book/et-book-display-italic-old-style-figures/et-book-display-italic-old-style-figures.woff") format("woff"),
       url("et-book/et-book-display-italic-old-style-figures/et-book-display-italic-old-style-figures.ttf") format("truetype");
  font-weight: normal; font-style: italic;
}
@font-face {
  font-family: "et-book";
  src: url("et-book/et-book-bold-line-figures/et-book-bold-line-figures.woff") format("woff"),
       url("et-book/et-book-bold-line-figures/et-book-bold-line-figures.ttf") format("truetype");
  font-weight: bold; font-style: normal;
}

/* Global typography ---------------------------------------------- */
:root {
  --sigma-bg: #fffff8;
  --sigma-ink: #111;
  --sigma-muted: #6b6555;
  --sigma-link: #a00000;
}

html, body {
  background: var(--sigma-bg) !important;
  color: var(--sigma-ink);
  font-family: "et-book", Palatino, "Palatino Linotype", "Palatino LT STD",
               "Book Antiqua", Georgia, serif;
  font-size: 17px;
  line-height: 1.55;
}

/* Sans для UI элементов навбара и тонких надписей */
.navbar, .sidebar, .toc-active, .quarto-title-banner,
.quarto-secondary-nav, .nav-footer, .page-navigation {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif !important;
}

/* Контент */
main.content {
  background: var(--sigma-bg) !important;
}

/* Заголовки тонкие, серифные */
h1, h2, h3, h4, h5, h6 {
  font-family: "et-book", Palatino, Georgia, serif;
  font-weight: 400;
  letter-spacing: 0;
  color: var(--sigma-ink);
}
h1 { font-size: 2.4rem; line-height: 1.1; margin-top: 1.6em; }
h2 { font-size: 1.65rem; font-style: italic; margin-top: 2em; }
h3 { font-size: 1.25rem; font-style: italic; margin-top: 1.6em; }

/* Ссылки — тонкие, не подчёркнуты, только цвет (Tufte) */
a, a:visited {
  color: var(--sigma-link);
  text-decoration: none;
}
a:hover { text-decoration: underline; }

/* Параграфы — Tufte's ragged-right (опционально). Оставим justify. */
p { margin: 0 0 1em 0; }

/* Drop cap для первого параграфа главы (опционально) */
.chapter > p:first-of-type::first-letter {
  font-size: 3.4em;
  float: left;
  line-height: 0.9;
  padding: 0.05em 0.08em 0 0;
  font-weight: 400;
}

/* Цитаты — italic, узкие */
blockquote {
  font-style: italic;
  border-left: 2px solid var(--sigma-muted);
  margin-left: 0;
  padding-left: 1em;
  color: #444;
}

/* Код — monospace, чуть тёмнее, не отвлекает */
code, pre {
  font-family: "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.9em;
}
pre, div.sourceCode {
  background: #f5f3e8 !important;
  border: none !important;
  border-radius: 2px;
  position: relative;
}
/* Иконка copy внутри code block — внутри границ блока, не уезжает в margin */
div.sourceCode .code-copy-button,
div.sourceCode button.code-copy-button {
  right: 0.4em !important;
  top: 0.4em !important;
  left: auto !important;
}

/* Margin callouts (Tufte sidenotes) — компактно */
.column-margin .callout, aside.column-margin .callout {
  margin: 0.5em 0 1em 0;
  font-size: 0.85em;
  border-left-width: 2px !important;
}
.column-margin .callout .callout-header { padding: 0.2em 0.4em; font-size: 0.95em; }
.column-margin .callout .callout-body-container { padding: 0.3em 0.5em; }
.column-margin figcaption, .column-margin p.caption { font-size: 0.8em; }

/* Margin notes / sidenotes — стиль Tufte */
.column-margin, .margin-caption, aside.aside {
  font-size: 0.85em;
  line-height: 1.4;
  color: var(--sigma-muted);
  font-family: "et-book", Palatino, Georgia, serif;
}
.column-margin p { margin-bottom: 0.5em; }

/* Caption под figures — italic, мельче */
figcaption, .figure-caption, p.caption {
  font-size: 0.88em;
  font-style: italic;
  color: #444;
  line-height: 1.4;
  margin-top: 0.4em;
}

/* Сайдбар (TOC слева) — тонкий, без bg */
.sidebar.sidebar-navigation {
  background: var(--sigma-bg) !important;
  border-right: 1px solid #e8e2d0;
}
.sidebar-item-text, .sidebar-link {
  font-size: 0.92em;
  color: #444 !important;
}
.sidebar-item-text.active, .sidebar-link.active {
  color: var(--sigma-ink) !important;
  font-weight: 600;
}

/* Навбар — лёгкий */
.navbar {
  background: var(--sigma-bg) !important;
  border-bottom: 1px solid #e8e2d0;
  box-shadow: none;
}
.navbar-brand { color: var(--sigma-ink) !important; font-weight: 700; font-size: 1.3rem; }
.navbar-nav .nav-link { color: var(--sigma-ink) !important; }

/* TOC справа (на странице главы) */
nav#TOC, .toc-active {
  font-size: 0.85em;
}

/* Theorem/algorithm/notebox callouts — тонкая рамка слева */
.callout {
  background: var(--sigma-bg) !important;
  border-left-width: 3px !important;
  border-radius: 0 !important;
  margin: 1.2em 0;
}
.callout-body { background: transparent !important; }

/* Tables — академический стиль */
table {
  border-collapse: collapse;
  margin: 1em auto;
}
table thead { border-bottom: 1.2px solid var(--sigma-ink); border-top: 1.2px solid var(--sigma-ink); }
table tbody { border-bottom: 1.2px solid var(--sigma-ink); }
table th, table td { padding: 0.3em 0.8em; border: none; }

/* "Other Formats" / "Other Links" блоки в правом TOC */
.quarto-alternate-formats h2,
.quarto-other-links h2 {
  font-size: 0.95em;
  font-weight: 600;
  margin-top: 1.2em;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
.quarto-alternate-formats a,
.quarto-other-links a {
  font-size: 0.9em;
}
/* Спрятать слово "Typst" — заменим через ::after */
.quarto-alternate-formats a span,
.quarto-alternate-formats a {
  /* визуальный hack пока без js не починить — оставляем как есть */
}

/* Селект-бокс для inline кода в Tufte книгах часто скрыт */
.quarto-section-identifier { display: none; }

/* Скрываем шапки code chunks, оставляем самих код */
.cell-output-display { margin-top: 0.4em; }
