/* book.css — оформление сайта book-1.
 *
 * Две поверхности. Обложка — полированный гранит (granite.svg) с золотыми буквами в
 * римском начертании: Cinzel для латинского названия, Forum для оглавления (у Cinzel нет
 * кириллицы, Forum нарисован по мотивам римского капитального письма и кириллицу имеет).
 * Страницы чтения — бумага и PT Serif, тот же ParaType, что в печатной книге; служебное —
 * PT Sans, как рубрики на полосе.
 *
 * Разметку книжного аппарата (утверждения, поговорки, заглушки, рисунки) задаёт
 * book1.cfg; имена классов — оттуда.
 */

:root {
  --paper: #f8f4eb;
  --paper-2: #f0e9da;
  --ink: #1f1d1a;
  --muted: #6d665b;
  --rule: #dcd2bf;
  --gold: #9a7419;
  --gold-soft: rgba(154, 116, 25, .16);
  --ph: #9c3b1b;
  --ph-bg: #f3e9df;
  --link-line: rgba(154, 116, 25, .45);
  --stone: #141316;
  --stone-text: #cfc8bb;
  --measure: 36rem;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #18171a;
    --paper-2: #211f22;
    --ink: #e8e2d5;
    --muted: #a39b8c;
    --rule: #3a3631;
    --gold: #d6b35c;
    --gold-soft: rgba(214, 179, 92, .12);
    --ph: #e59a76;
    --ph-bg: #2b211c;
    --link-line: rgba(214, 179, 92, .45);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 1.1875rem/1.62 "PT Serif", Georgia, "Times New Roman", serif;
  font-kerning: normal;
  text-rendering: optimizeLegibility;
}

a { color: inherit; text-decoration-color: var(--link-line); text-underline-offset: .18em; text-decoration-thickness: 1px; }
a:hover { text-decoration-color: var(--gold); }

/* --- золото на камне ------------------------------------------------------------ */

.gold, .cover .contents a .t, .cover .contents .num, .topbar .brand {
  background: linear-gradient(176deg, #fbeeb8 0%, #e2c065 28%, #b88a2a 52%, #f0d68a 70%, #9a7019 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  /* врезанная буква: тень сверху, блик снизу */
  filter: drop-shadow(0 -1px 0 rgba(0, 0, 0, .75)) drop-shadow(0 1px 0 rgba(255, 236, 180, .14));
}
/* мелкое золото оглавления — ещё и тёмный ореол, чтобы буква отделялась от зерна */
.cover .contents a .t, .cover .contents .num {
  filter: drop-shadow(0 -1px 0 rgba(0, 0, 0, .75)) drop-shadow(0 1px 0 rgba(255, 236, 180, .14))
          drop-shadow(0 0 3px rgba(0, 0, 0, .85));
}

.stone, .topbar {
  background-color: var(--stone);
  background-image:
    radial-gradient(120% 70% at 25% 0%, rgba(255, 255, 255, .075), rgba(255, 255, 255, 0) 60%),
    url(granite.svg);
  background-size: auto, 520px 520px;
  color: var(--stone-text);
}

/* --- верхняя полоса страниц чтения ---------------------------------------------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .7rem max(1rem, calc((100% - 52rem) / 2));
  border-bottom: 1px solid rgba(0, 0, 0, .5);
  box-shadow: inset 0 -1px 0 rgba(226, 192, 101, .25);
}
.topbar .brand {
  font: 600 1.15rem/1 Cinzel, "Trajan Pro", serif;
  letter-spacing: .28em;
  text-decoration: none;
  padding: .2rem 0;
}
.topnav {
  display: flex;
  align-items: center;
  gap: 1.1rem;
  font: 400 .8rem/1 "PT Sans", sans-serif;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.topnav a { color: var(--stone-text); text-decoration: none; }
.topnav a:hover { color: #f0d68a; }

.langs { display: inline-flex; gap: .35rem; align-items: center; }
.langs .sep { opacity: .5; }
.langs [aria-current] { color: #e2c065; }

/* --- лист ---------------------------------------------------------------------- */

.sheet {
  max-width: calc(var(--measure) + 4rem);
  margin: 0 auto;
  padding: 3.5rem 2rem 2rem;
}

.chapter-head { margin-bottom: 2.4rem; text-align: center; }
.chapter-head .eyebrow {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: .2rem 1.2rem;
  font: 400 .78rem/1.4 "PT Sans", sans-serif;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: .9rem;
}
.chapter-head h1 {
  font: 400 clamp(2rem, 5vw, 2.75rem)/1.15 Forum, "PT Serif", serif;
  letter-spacing: .02em;
  margin: 0;
  text-wrap: balance;
}
.chapter-head h1::after {
  content: "";
  display: block;
  width: 4.5rem;
  height: 1px;
  margin: 1.4rem auto 0;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
}
.chapter-head h1 .footnote-mark { font-size: .45em; vertical-align: super; }

/* --- текст --------------------------------------------------------------------- */

.text { hyphens: auto; -webkit-hyphens: auto; overflow-wrap: break-word; }
.text p { margin: 0; }
.text p.indent { text-indent: 1.5em; }
.text p.noindent { text-indent: 0; }
.text h2 + p, .text h3 + p { text-indent: 0; }

@media (min-width: 40rem) {
  .text { text-align: justify; }
  .text h2, .text h3, .text figcaption, .text .st-title,
  .text .bk-index-list, .text .bk-index-sayings, .text .bk-index-tldr { text-align: left; }
}

.text h2 {
  font: 700 1.2rem/1.3 "PT Sans", sans-serif;
  margin: 2.8rem 0 1rem;
  text-wrap: balance;
}
.text h3 {
  font: 700 1.05rem/1.3 "PT Sans", sans-serif;
  margin: 2rem 0 .8rem;
}
.text .secnum { color: var(--gold); font-weight: 400; margin-right: .35em; }

.text ul, .text ol { padding-left: 1.4em; margin: .8rem 0; }
.text li { margin: .2rem 0; }

.text .quote, .text blockquote:not(.saying) {
  margin: 1.2rem 0 1.2rem 1.5em;
  font-size: .95em;
}

.text code { font: .88em/1 "PT Mono", Menlo, monospace; }

/* формулы: MathML браузер набирает сам */
.text table.equation, .text table.equation-star { width: 100%; margin: 1.1rem 0; border-collapse: collapse; text-indent: 0; }
.text table.equation td, .text table.equation-star td { padding: 0; text-align: center; }
.text table.equation td.eq-no { width: 3em; text-align: right; color: var(--muted); }
math { font-family: "STIX Two Math", "Cambria Math", "Latin Modern Math", math; }

/* --- утверждения: определение, постулат, основание, принцип, следствие ----------- */

.st {
  margin: 1.8rem 0;
  padding: .95rem 1.2rem 1.05rem;
  background: var(--paper-2);
  border-left: 3px solid var(--rule);
  border-radius: 0 6px 6px 0;
}
.st p.indent, .st p.noindent { text-indent: 0; }
.st p + p { margin-top: .5rem; }
.st-label {
  font: 400 .72rem/1.3 "PT Sans", sans-serif;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: .3rem;
}
.st-title {
  font: 700 1.04rem/1.35 "PT Sans", sans-serif;
  margin-bottom: .45rem;
  hyphens: manual;
}
.st-fals {
  margin-top: .65rem;
  font-size: .86rem;
  font-style: italic;
  color: var(--muted);
}
.st-fals-label { font-style: normal; font-family: "PT Sans", sans-serif; letter-spacing: .04em; }

.st-principle { border-left-color: var(--gold); background: linear-gradient(90deg, var(--gold-soft), var(--paper-2) 40%); }
.st-principle .st-label { color: var(--gold); }
.st-axiom { border-left: 3px double var(--gold); }
.st-definition .st-label { color: var(--ink); }

/* --- поговорки ----------------------------------------------------------------- */

.saying {
  margin: 0 0 2.2rem auto;
  max-width: 72%;
  text-align: right;
  font-style: italic;
  font-size: .97em;
  line-height: 1.5;
}
.saying p { margin: 0; text-indent: 0 !important; }
.saying footer {
  margin-top: .35rem;
  font: 400 .78rem/1.4 "PT Sans", sans-serif;
  font-style: normal;
  color: var(--muted);
}
.saying footer em { font-style: italic; }

/* --- заглушки: видны, как в черновой сборке ------------------------------------ */

.ph {
  font: 400 .84em/1.4 "PT Sans", sans-serif;
  color: var(--ph);
  text-indent: 0;
}
.ph-block {
  margin: 1.5rem 0;
  padding: .8rem 1rem;
  background: var(--ph-bg);
  border: 1px dashed var(--ph);
  border-radius: 6px;
  font: 400 .92rem/1.5 "PT Sans", sans-serif;
  text-align: left;
}
.ph-label { font-size: .72rem; letter-spacing: .16em; color: var(--ph); }
.ph-title { font-weight: 700; margin: .15rem 0 .3rem; }

/* --- рисунки ------------------------------------------------------------------- */

.bk-figure, .bk-glyph { margin: 2rem 0; text-align: center; }
.bk-figure img, .bk-glyph img {
  width: calc(var(--w, 1) * 100%);
  max-width: 100%;
  height: auto;
  border-radius: 4px;
}
.bk-figure-drawn img { width: 100%; }
@media (prefers-color-scheme: dark) {
  /* рисунки чёрные на белом, как на полосе: в тёмной теме — на белой карточке */
  .bk-figure img, .bk-glyph img { background: #fbf9f4; padding: .6rem; }
}
.bk-figure figcaption, .bk-glyph figcaption {
  margin: .7rem auto 0;
  max-width: 34rem;
  font: 400 .86rem/1.45 "PT Sans", sans-serif;
  color: var(--muted);
  text-align: left;
}
.bk-glyph figcaption { text-align: center; font-size: .8rem; }
.bk-figure figcaption strong { color: var(--ink); }

/* --- сноски -------------------------------------------------------------------- */

.footnote-mark a, a .footnote-mark { text-decoration: none; }
.footnote-mark sup, sup.textsuperscript { font: 700 .62em/0 "PT Sans", sans-serif; color: var(--gold); padding-left: .08em; }

.footnotes {
  margin-top: 3.5rem;
  padding-top: 1.3rem;
  border-top: 1px solid var(--rule);
  font-size: .86rem;
  line-height: 1.5;
  text-align: left;
  hyphens: manual;
}
.footnotetext { display: block; margin: 0 0 .6rem; }
.footnotetext p { text-indent: 0 !important; }
.footnotetext .footnote-mark { margin-right: .3em; }
.footnotetext:target { background: var(--gold-soft); border-radius: 4px; }
.footnotes a.url { word-break: break-all; }

/* --- своды --------------------------------------------------------------------- */

.bk-index-list, .bk-index-sayings, .bk-index-tldr { list-style: none; padding: 0; margin: 1.5rem 0; }
.bk-index-list li { display: block; padding: .45rem 0; border-bottom: 1px solid var(--rule); }
.bk-index-list a { display: flex; gap: .9rem; text-decoration: none; }
.bk-index-list .ix-num { flex: 0 0 2.4rem; color: var(--gold); font: 400 .95rem/1.5 "PT Sans", sans-serif; text-align: right; }
.bk-index-list .ix-title { font-weight: 700; font-family: "PT Sans", sans-serif; font-size: 1rem; }
.bk-index-list a:hover .ix-title { text-decoration: underline; text-decoration-color: var(--gold); }
.ix-where { display: block; margin-left: 3.3rem; font: 400 .78rem/1.4 "PT Sans", sans-serif; color: var(--muted); }
.bk-index-sayings li { padding: .6rem 0; border-bottom: 1px solid var(--rule); font-style: italic; }
.bk-index-sayings a { text-decoration: none; }
.bk-index-sayings .ix-where { margin: .2rem 0 0; font-style: normal; }
.bk-index-tldr li { padding: .7rem 0; border-bottom: 1px solid var(--rule); }
.bk-index-tldr .ix-chapter {
  display: block;
  font: 400 .76rem/1.4 "PT Sans", sans-serif;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--gold);
  text-decoration: none;
  margin-bottom: .2rem;
}

/* описания: «Кто есть кто», «Состояние рукописи», источники */
dl.description { margin: 1.5rem 0; }
dl.description dt { font-family: "PT Sans", sans-serif; margin-top: .9rem; }
dl.description dd { margin: .15rem 0 0; }
dl.description dd p { text-indent: 0 !important; }
.thebibliography p, .bibliography p { text-indent: 0 !important; margin: 0 0 .7rem; }

/* --- листание ------------------------------------------------------------------ */

.pager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin: 4rem 0 1rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--rule);
}
.pager a {
  display: flex;
  flex-direction: column;
  gap: .25rem;
  text-decoration: none;
  padding: .8rem 1rem;
  border-radius: 6px;
}
.pager a:hover { background: var(--paper-2); }
.pager .next { grid-column: 2; text-align: right; }
.pager .dir { font: 400 .74rem/1 "PT Sans", sans-serif; letter-spacing: .14em; text-transform: uppercase; color: var(--gold); }
.pager .t { font: 400 1.2rem/1.25 Forum, "PT Serif", serif; }

.footer {
  padding: 2rem 1rem 3rem;
  text-align: center;
  font: 400 .78rem/1.4 "PT Sans", sans-serif;
  color: var(--muted);
}

/* --- обложка ------------------------------------------------------------------- */

body.cover { background: var(--stone); }
.cover .stone { min-height: 100vh; padding: 0 1.25rem 4rem; }

.cover-top {
  display: flex;
  justify-content: flex-end;
  max-width: 52rem;
  margin: 0 auto;
  padding: 1.1rem 0;
  font: 400 .8rem/1 "PT Sans", sans-serif;
  letter-spacing: .14em;
}
.cover-top a { color: var(--stone-text); text-decoration: none; }

.cover-title {
  min-height: calc(100vh - 3.5rem);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding-bottom: 8vh;
}
.cover-title .author {
  font: 400 clamp(1rem, 2.6vw, 1.35rem)/1.2 Forum, serif;
  letter-spacing: .42em;
  text-transform: uppercase;
  margin-right: -.42em;
}
.cover-title .title {
  font: 600 clamp(2.6rem, 11.5vw, 7.6rem)/1 Cinzel, "Trajan Pro", serif;
  letter-spacing: .14em;
  margin: 2.2rem -.14em 0 0;
}
.cover-title .rule {
  position: relative;
  width: min(22rem, 70vw);
  height: 1px;
  margin: 2.4rem 0;
  background: linear-gradient(90deg, transparent, #c9a23f 20%, #f0d68a 50%, #c9a23f 80%, transparent);
}
.cover-title .rule::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 7px;
  height: 7px;
  transform: translate(-50%, -50%) rotate(45deg);
  background: linear-gradient(135deg, #fbeeb8, #b88a2a);
}
.cover-title .motto {
  max-width: 30rem;
  margin: 0;
  font: italic 400 1.02rem/1.6 "PT Serif", serif;
  color: #c4bdb0;
  text-shadow: 0 1px 1px #000, 0 0 10px rgba(0, 0, 0, .9), 0 0 22px rgba(0, 0, 0, .7);
}
.cover-title .begin {
  margin-top: 3.2rem;
  font: 400 .95rem/1 Forum, serif;
  letter-spacing: .3em;
  text-transform: uppercase;
  text-decoration: none;
  padding: .7rem 1.4rem;
  border: 1px solid rgba(226, 192, 101, .35);
}

.contents {
  max-width: 40rem;
  margin: 0 auto;
  padding: 3rem 0 2rem;
}
.contents h2 {
  margin: 0 0 2.5rem;
  text-align: center;
  font: 400 1.6rem/1 Forum, serif;
  letter-spacing: .4em;
  text-transform: uppercase;
  margin-right: -.4em;
}
.contents ol { list-style: none; margin: 0; padding: 0; }
.contents li a {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  padding: .42rem 0;
  text-decoration: none;
  border-bottom: 1px solid rgba(226, 192, 101, .09);
}
.contents li a .t {
  font: 400 1.08rem/1.3 Forum, serif;
  letter-spacing: .11em;
  text-transform: uppercase;
}
.contents li a .num {
  flex: 0 0 2.2rem;
  text-align: right;
  font: 400 .95rem/1.3 Forum, serif;
  letter-spacing: .05em;
}
.contents li a:hover { border-bottom-color: rgba(226, 192, 101, .5); }
.cover .contents li a:hover .t { filter: drop-shadow(0 -1px 0 rgba(0, 0, 0, .75)) drop-shadow(0 0 6px rgba(240, 214, 138, .35)); }
.contents .toc-plain { margin: 1.8rem 0; }
.contents .toc-chapters { max-width: 31rem; margin: 0 auto; }
.contents .toc-plain li a { justify-content: center; }
.contents section { margin: 2.6rem 0; }
.contents .toc-part {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 0 0 .8rem;
  font: 400 1.25rem/1 Forum, serif;
  letter-spacing: .32em;
  text-transform: uppercase;
  color: #e2c065;
}
.contents .toc-part::before, .contents .toc-part::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(226, 192, 101, .5), transparent);
}
.contents .toc-part .num { font-family: Cinzel, serif; font-weight: 600; letter-spacing: .1em; }
.contents .toc-part .num::after { content: " · "; letter-spacing: 0; padding: 0 .3em; }

.cover .colophon {
  text-shadow: 0 1px 1px #000, 0 0 10px rgba(0, 0, 0, .9);
  max-width: 32rem;
  margin: 3rem auto 0;
  padding-top: 2rem;
  border-top: 1px solid rgba(226, 192, 101, .18);
  font: 400 .84rem/1.6 "PT Serif", serif;
  color: #a59e91;
  text-align: center;
}
.cover .colophon p { margin: 0 0 .8rem; }
.cover .colophon strong { font: 400 .95rem/1.4 Forum, serif; letter-spacing: .3em; text-transform: uppercase; color: #d9cfb8; }
.cover .colophon .ph { color: #e59a76; }

/* --- узкий экран --------------------------------------------------------------- */

@media (max-width: 40rem) {
  body { font-size: 1.0625rem; }
  .sheet { padding: 2.2rem 1rem 1.5rem; }
  .topbar { padding: .6rem 1rem; }
  .topbar .brand { font-size: 1rem; letter-spacing: .2em; }
  .topnav { gap: .7rem; font-size: .72rem; }
  .saying { max-width: 88%; }
  .st { padding: .8rem .9rem; }
  .pager { grid-template-columns: 1fr; }
  .pager .next { grid-column: 1; }
  .contents li a .t { font-size: .98rem; letter-spacing: .07em; }
  .contents .toc-part { font-size: 1.05rem; letter-spacing: .22em; }
}

@media print {
  .topbar, .pager, .footer { display: none; }
  body { background: #fff; }
}
