/* ============================================================
   Шрифты
   ============================================================ */

@font-face {
  font-family: 'BrokgauzEfron';
  src: url('../fonts/brokgauzefron.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

/* ============================================================
   Дореволюционная российская типографика
   ============================================================ */

:root {
  --bg: #fdfcf8;
  --text: #1a1a1a;
  --muted: #666;
  --link: #2a2a2a;
  --border: #d8d2c4;

  --font-body:    'PT Sans', 'Inter', system-ui, sans-serif;
  --font-heading: 'BrokgauzEfron', 'Old Standard TT', 'PT Serif', Georgia, serif;
  --font-size-base: 17px;
  --line-height:    1.75;
  --max-width:      720px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a1a1a;
    --text: #e8e4dc;
    --muted: #a8a29a;
    --link: #c8c4bc;
    --border: #3a3630;
  }
}

/* ============================================================
   База
   ============================================================ */

html {
  font-size: var(--font-size-base);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  line-height: var(--line-height);
  font-feature-settings: "liga", "kern";
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

main, .wrap {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 2rem 1.25rem 2rem;
}

/* ============================================================
   Заголовки
   ============================================================ */

h1, h2, h3, h4 {
  font-family: var(--font-heading);
  font-weight: 400;
  line-height: 1.25;
  margin: 1.8em 0 1.6em;
  letter-spacing: 0.02em;
}

h1 {
  font-size: 2rem;
  text-align: center;
  letter-spacing: 0.03em;
  margin-top: 0.5em;
}
h2 { font-size: 1.55rem; }
h3 { font-size: 1.3rem; }
h4 { font-size: 1.1rem; }

/* ============================================================
   Текст
   ============================================================ */

p {
  margin: 0 0 1.1em;
  text-align: left;
  hyphens: none;
}



/* ============================================================
   Ссылки
   ============================================================ */

a {
  color: var(--link);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}
a:hover {
  color: var(--text);
}

/* ============================================================
   Разделители
   ============================================================ */

hr {
  border: none;
  text-align: center;
  margin: 2.5rem auto;
  color: var(--border);
}
hr::before {
  content: "❦";
  font-size: 1.2rem;
  letter-spacing: 0.6em;
}

/* ============================================================
   Цитаты и код
   ============================================================ */

blockquote {
  margin: 1.5em 0;
  padding: 0 1.5em;
  border-left: 2px solid var(--border);
  font-style: italic;
  color: var(--muted);
}

code, pre {
  font-family: 'Courier New', monospace;
  font-size: 0.95em;
}
code {
  background: color-mix(in srgb, var(--border) 50%, transparent);
  padding: 0.1em 0.35em;
  border-radius: 2px;
}
pre {
  background: color-mix(in srgb, var(--border) 50%, transparent);
  padding: 1em;
  overflow-x: auto;
  border: 1px solid var(--border);
}

/* ============================================================
   Мелочи
   ============================================================ */

small, .muted { color: var(--muted); }

::selection {
  background: var(--text);
  color: var(--bg);
}

/* ============================================================
   Шапка сайта
   ============================================================ */

header {
  padding: 1.2rem 1.25rem;
}

.header-content {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.header-content a {
  display: contents;
  text-decoration: none;
  color: inherit;
}

.header-avatar {
  width: 56px;
  height: auto;
  display: block;
}

.header-text p {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
  letter-spacing: 0.05em;
}

.header-text h1 {
  margin: 0.15em 0 0;
  font-size: 1.5rem;
  text-align: left;
  letter-spacing: 0.02em;
}

/* ============================================================
   Страница книги
   ============================================================ */

.book-intro {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
  margin-bottom: 2.5rem;
}

.book-cover {
  flex: 0 0 150px;
}

.book-cover img {
  display: block;
  width: 100%;
  height: auto;
}

.book-info {
  flex: 1;
  min-width: 0;
}

.book-info p {
  margin: 0 0 0.5em;
}

.book-note {
  margin-top: 0.8em;
}

.book-note small {
  line-height: 1.55;
  color: var(--muted);
}

/* Кнопка «Читать» */
.read-button {
  text-align: center;
  margin: 2rem 0 0.5rem;
}

.btn {
  display: inline-block;
  padding: 0.7em 2.2em;
  background: var(--text);
  color: var(--bg);
  text-decoration: none;
  border-radius: 2px;
  font-family: var(--font-heading);
  font-size: 1.05rem;
  letter-spacing: 0.06em;
  transition: opacity 0.2s;
}
.btn:hover {
  opacity: 0.85;
  color: var(--bg);
}

/* Оглавление */
.toc h3 {
  text-align: center;
  margin-bottom: 1.2rem;
}

.part-title {
  margin-top: 2rem;
  margin-bottom: 0.6rem;
  color: var(--muted);
  letter-spacing: 0.03em;
}

.toc ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.toc ul li {
  margin: 0.35em 0;
}

.toc ul li a {
  text-decoration: none;
  color: var(--text);
}
.toc ul li a:hover {
  text-decoration: underline;
  color: var(--link);
}

/* ============================================================
   Подвал
   ============================================================ */

footer {
  padding: 1.25rem 1.25rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
}

footer p {
  margin: 0.3em 0;
  text-align: center;
}

footer .tg-link {
  color: var(--text);
  text-decoration: none;
}
footer .tg-link:hover {
  text-decoration: underline;
}

/* ============================================================
   Кнопка «наверх»
   ============================================================ */

#myScrollBtn {
  position: fixed;
  bottom: 30px;
  right: 30px;
  width: 50px;
  height: 50px;
  background: var(--text);
  color: var(--bg);
  border-radius: 50%;
  font-size: 26px;
  font-weight: bold;
  cursor: pointer;
  z-index: 9999;
  display: none;
  transition: transform 0.2s, opacity 0.2s;
  user-select: none;
  align-items: center;
  justify-content: center;
}

#myScrollBtn:hover {
  transform: scale(1.08);
  opacity: 0.9;
}

/* ============================================================
   Мобильные
   ============================================================ */

@media (max-width: 600px) {
  :root { --font-size-base: 17px; }

  .book-cover { flex: 0 0 110px; }

  .header-avatar { width: 44px; height: 44px; }
  .header-text h1 { font-size: 1.25rem; }

  #myScrollBtn {
    width: 44px;
    height: 44px;
    font-size: 22px;
    bottom: 20px;
    right: 20px;
  }

  .book-intro {
    flex-direction: column;
    align-items: center;
  }

  .book-cover {
    flex: 0 0 auto;
    width: 180px;
    margin-bottom: 1rem;
  }

  .book-info {
    text-align: left;
    width: 100%;
  }

  main {
    padding: 1.5rem 0.75rem 2.5rem;
  }
	
}




/* ============================================================
   Главная страница
   ============================================================ */

.header-text .header-subtitle {
  margin: 0.35em 0 0;
  font-size: 0.95rem;
  letter-spacing: 0;
  line-height: 1.45;
  color: var(--muted);
}

.home-quote {
  text-align: center;
  font-family: var(--font-heading);
  font-size: 1.35rem;
  line-height: 1.5;
  letter-spacing: 0.02em;
  color: var(--text);
  max-width: 32rem;
  margin: 1.5rem auto 4.5rem;
  padding: 0 1rem;
}

.book-list {
  list-style: none;
  padding: 0;
  margin: 0 auto 5rem;

  text-align: left;
}

.book-list li {
  margin: 0.85em 0;
  font-size: 1.15rem;
  line-height: 1;
}

.book-list li a {
  color: var(--text);
  text-decoration: none;
}

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

.book-list li.unavailable {
  color: var(--muted);
  cursor: default;
}



h4[id] {
  scroll-margin-top: 1.5rem;
}

.book-text h4 {
  margin-top: 3.5em;
}
.book-text h4:first-child {
  margin-top: 2em;
}

.book-text h4 {
  color: var(--muted);
}

/* ============================================================
   Сноски
   ============================================================ */

/* Цифра в тексте */
sup a {
  color: var(--text);
  text-decoration: none;
  font-size: 0.7em;
  font-weight: bold;
  padding: 0 0.1em;
  letter-spacing: 0.03em;
}
sup a:hover {
  color: var(--muted);
  text-decoration: underline;
}

/* Блок сносок внизу */
.footnotes {
  margin-top: 2rem;
  padding-top: 1.5rem;
  font-size: 0.9rem;
  line-height: 1.55;
  color: var(--muted);

}

/* Список сносок */
.footnotes ol {
  padding-left: 1.5em;
  margin: 0;
}

.footnotes li {
  margin-bottom: 0.6em;
  /* чтобы возврат ↑ стоял рядом с текстом сноски */
  padding-right: 1.5em;
  position: relative;
}

/* Обратная ссылка ↑ */
.footnote-back {
  color: var(--muted);
  text-decoration: none;
  margin-left: 0.3em;
  font-size: 0.9em;
  opacity: 0.6;
}
.footnote-back:hover {
  opacity: 1;
  color: var(--text);
}

/* Подсветить сноску, когда перешли по ссылке — приятная мелочь */
.footnotes li:target {
  background: color-mix(in srgb, var(--border) 30%, transparent);
  border-radius: 2px;
  transition: background 0.6s;
}

/* ============================================================
   Навигация между главами
   ============================================================ */

.chapter-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 4rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border);
    font-family: var(--font-heading);
}

.chapter-nav a {
    text-decoration: none;
    color: var(--text);
    font-size: 1.1rem;
    letter-spacing: 0.03em;
    transition: color 0.2s;
}

.chapter-nav a:hover {
    color: var(--muted);
}

/* Если ссылки нет (например, для первой главы нет "назад"), прячем её */
.chapter-nav a.nav-prev:only-child,
.chapter-nav a.nav-next:only-child {
    visibility: hidden;
}