/* Сайт книги — доска Figma «08 · Сайт». Бумага, чернила и рубрика — «Книга · цвета» (Design/Colors.xcassets),
   шрифт — EB Garamond, как в приложении. Только светлая тема (решение владельца 28.11.2026).
   Движение — как в приложении (Design/Motion.swift): бумага, а не резина — без отскока; проявление 0,6 с,
   появление 0,3 с; при «Уменьшить движение» сдвиги заменяются прозрачностью. */

@font-face {
  font-family: "EB Garamond";
  src: url("fonts/EBGaramond.woff2") format("woff2");
  font-weight: 400 800;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "EB Garamond";
  src: url("fonts/EBGaramond-Italic.woff2") format("woff2");
  font-weight: 400 800;
  font-style: italic;
  font-display: swap;
}

:root {
  color-scheme: light;
  --paper: #F4EFE7;
  --ink: #2A2520;
  --ink-2: rgba(42, 37, 32, 0.80);
  --ink-3: rgba(42, 37, 32, 0.55);
  --hairline: rgba(42, 37, 32, 0.20);
  --rubric: #65433B;
  --accent: #B5553A;

  --column: 680px;
  --gutter: 20px;

  /* Motion.swift: regular — smooth 0,3 с; reveal — easeInOut 0,6 с; quick — 0,2 с. */
  --smooth: cubic-bezier(0.25, 0.1, 0.25, 1);
  --ease-in-out: cubic-bezier(0.42, 0, 0.58, 1);
  --regular: 0.3s;
  --reveal: 0.6s;
  --quick: 0.2s;
}

* { box-sizing: border-box; }

html {
  background: var(--paper);
  color: var(--ink);
  font: 400 20px/1.5 "EB Garamond", Georgia, "Times New Roman", serif;
  -webkit-text-size-adjust: 100%;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}
body { margin: 0; min-height: 100vh; position: relative; overflow-x: hidden; }

a {
  color: var(--rubric);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.16em;
  text-decoration-color: color-mix(in srgb, var(--rubric) 45%, transparent);
  transition: color var(--quick) var(--smooth), text-decoration-color var(--quick) var(--smooth);
}
a:hover { color: var(--accent); text-decoration-color: currentColor; }
a:focus-visible { outline: 2px solid var(--rubric); outline-offset: 3px; border-radius: 2px; }

.page {
  position: relative;
  z-index: 1;
  max-width: calc(var(--column) + 2 * var(--gutter));
  margin: 0 auto;
  padding: 56px var(--gutter) 72px;
}

/* Колонтитул: книга слева, разделы справа. */
.running {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  padding-bottom: 8px;
  margin-bottom: 56px;
  border-bottom: 1px solid var(--hairline);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.running a { color: var(--ink-3); text-decoration: none; }
.running a:hover, .running [aria-current] { color: var(--rubric); }
.running nav { display: flex; gap: 18px; }

.kicker {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--rubric);
}
h1 {
  margin: 0 0 14px;
  font-size: 48px;
  line-height: 1.08;
  font-weight: 400;
  text-wrap: balance;
}
.lede {
  margin: 0 0 40px;
  font-size: 23px;
  line-height: 1.4;
  font-style: italic;
  color: var(--ink-2);
  text-wrap: pretty;
}

.part { margin-top: 30px; }
h2 {
  margin: 0 0 10px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--rubric);
}
h2::before { content: "§ "; }
p { margin: 0 0 14px; text-wrap: pretty; }
ul { margin: 0 0 16px; padding: 0; list-style: none; }
li { position: relative; padding-left: 22px; margin-bottom: 8px; }
li::before { content: "•"; position: absolute; left: 0; color: var(--rubric); }

/* Таблица «что — зачем — сколько хранится». */
.ledger { width: 100%; border-collapse: collapse; margin: 14px 0 18px; font-size: 17px; line-height: 1.4; }
.ledger th {
  padding: 0 20px 8px 0;
  text-align: left;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
  border-bottom: 1px solid var(--hairline);
}
.ledger td { width: 33.3%; padding: 12px 20px 12px 0; vertical-align: top; border-bottom: 1px solid var(--hairline); color: var(--ink-2); }
.ledger td:first-child { font-weight: 500; color: var(--ink); }
.ledger td:last-child { font-style: italic; }
.ledger th:last-child, .ledger td:last-child { padding-right: 0; }

/* Почта — строкой между линейками, как оглавление. */
.mail {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  margin: 0 0 28px;
  padding: 16px 0;
  border-top: 1px solid var(--hairline);
  border-bottom: 1px solid var(--hairline);
  font-size: 22px;
}
.mail a { font-size: 26px; font-style: italic; overflow-wrap: anywhere; }

/* Частые вопросы: «+» превращается в «–», ответ раскрывается по высоте. */
.faq { border-top: 1px solid var(--hairline); }
details { border-bottom: 1px solid var(--hairline); }
summary {
  display: flex;
  gap: 10px;
  padding: 14px 0;
  cursor: pointer;
  list-style: none;
  font-weight: 500;
  line-height: 1.4;
  transition: color var(--quick) var(--smooth);
}
summary::-webkit-details-marker { display: none; }
summary:hover { color: var(--rubric); }
summary:focus-visible { outline: 2px solid var(--rubric); outline-offset: 2px; border-radius: 2px; }
.sign { position: relative; flex: none; width: 12px; height: 1.4em; }
.sign::before, .sign::after {
  content: "";
  position: absolute;
  left: 0;
  top: calc(0.7em - 0.5px);
  width: 12px;
  height: 1px;
  background: var(--rubric);
  transition: transform var(--regular) var(--smooth);
}
.sign::after { transform: rotate(90deg); }
details[open] .sign::after { transform: rotate(0deg); }
.answer { overflow: hidden; }
.answer p { margin: 0 0 14px 22px; font-size: 19px; color: var(--ink-2); }

.footnote { margin-top: 20px; color: var(--ink-2); }

.colophon {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 64px;
  padding-top: 12px;
  border-top: 1px solid var(--hairline);
  font-size: 14px;
  font-style: italic;
  color: var(--ink-3);
}
.colophon nav { display: flex; gap: 14px; }
.colophon a { color: inherit; text-decoration: none; }
.colophon a:hover { color: var(--rubric); }

/* Обложка — титульный лист: без колонтитула, всё по центру. */
.title-page { padding-top: 120px; text-align: center; }
.exlibris { display: block; width: 216px; height: auto; margin: 0 auto 32px; }
.title-page .lede { margin-bottom: 32px; }
.store-line { margin: 0 0 48px; }
.store {
  display: inline-block;
  padding: 12px 22px;
  border-radius: 10px;
  background: var(--ink);
  color: var(--paper);
  font-size: 18px;
  font-weight: 500;
  text-decoration: none;
  transition: background var(--quick) var(--smooth);
}
a.store:hover { background: var(--rubric); color: var(--paper); }
.store.soon { background: none; color: var(--ink-3); font-style: italic; padding: 0; }
.contents { margin: 0; padding: 0; list-style: none; text-align: left; border-top: 1px solid var(--hairline); }
.contents li { padding: 0; margin: 0; border-bottom: 1px solid var(--hairline); }
.contents li::before { content: none; }
.contents a { display: flex; align-items: baseline; gap: 16px; padding: 14px 0; color: var(--ink); text-decoration: none; }
.contents .no { width: 24px; flex: none; font-size: 13px; font-weight: 500; letter-spacing: 0.1em; color: var(--rubric); }
.contents .title { flex: 1; font-size: 22px; transition: color var(--quick) var(--smooth); }
.contents .note { font-size: 16px; font-style: italic; color: var(--ink-3); }
.contents a:hover .title { color: var(--rubric); }
.title-page .colophon { text-align: left; }

/* Фоны: стол цветным карандашом (Pipeline/site/scenes.sh, backdrops.py), бумага подогнана к --paper. */
.backdrop { pointer-events: none; }
/* Стол шире окна (поля по 60 px за краями, как в макете), но без прокрутки вбок: широк сам рисунок, а не слой. */
.backdrop.table {
  --table: max(1400px, 110vw);
  position: absolute;
  inset: 0 0 auto 0;
  height: calc(var(--table) * 1429 / 2560);
  background: url("img/table-wide.webp") center top / var(--table) auto no-repeat;
}
/* Неподвижный фон — слоем position: fixed: background-attachment: fixed в Safari на iPhone и iPad не работает.
   100lvh — чтобы фон не прыгал, когда Safari прячет адресную строку. */
.backdrop.sparse {
  position: fixed;
  inset: 0 0 auto 0;
  height: 100lvh;
  background: center / cover no-repeat;
}
.backdrop.privacy { background-image: url("img/policy-wide.webp"); }
.backdrop.support { background-image: url("img/help-wide.webp"); }
.backdrop i { display: none; }

/* Телефон и узкое окно: стол сверху на обложке; на политике и поддержке — заставка и концовка,
   прокручиваются со страницей (неподвижный фон лёг бы под текст). */
@media (max-width: 899px) {
  .backdrop.sparse { position: absolute; inset: 0; height: auto; background: none; }
  .backdrop i { display: block; position: absolute; background: center / contain no-repeat; }
  .backdrop .head { top: 0; width: 200px; aspect-ratio: 400 / 380; }
  .backdrop .foot { bottom: 0; width: 150px; aspect-ratio: 300 / 321; }
  .privacy .head { left: 0; background-image: url("img/policy-head.webp"); }
  .privacy .foot { right: 0; background-image: url("img/policy-foot.webp"); }
  .support .head { right: 0; background-image: url("img/help-head.webp"); }
  .support .foot { left: 0; background-image: url("img/help-foot.webp"); }
  body.privacy .page, body.support .page { padding-top: 180px; padding-bottom: 150px; }
}
@media (max-width: 699px) {
  .backdrop.table { height: auto; aspect-ratio: 780 / 758; background: url("img/table-tall.webp") center top / 100% auto no-repeat; }
  .page.title-page { padding-top: 170px; }
}
@media (max-width: 599px) {
  html { font-size: 18px; }
  .page { padding: 28px var(--gutter) 40px; }
  .running { margin-bottom: 32px; font-size: 12px; }
  .running nav { display: none; }
  h1 { font-size: 36px; }
  .lede { font-size: 20px; margin-bottom: 28px; }
  .exlibris { width: 164px; }
  .contents .title { font-size: 20px; }
  .contents .note { display: none; }
  .mail { font-size: 20px; }
  .mail a { font-size: 22px; }
  .answer p { font-size: 17px; }
  .ledger, .ledger tbody, .ledger tr, .ledger td { display: block; width: auto; }
  .ledger thead { display: none; }
  .ledger tr { padding: 12px 0; border-bottom: 1px solid var(--hairline); }
  .ledger td { padding: 0 0 3px; border: 0; }
  .colophon { margin-top: 40px; }
  .page.title-page { padding-top: 170px; }
}

/* Движение. Без скрипта (нет класса .js) всё видно сразу. */
@media (prefers-reduced-motion: no-preference) {
  .js [data-rise], .js [data-reveal] {
    opacity: 0;
    transform: translateY(8px);
    transition: opacity var(--regular) var(--smooth), transform var(--regular) var(--smooth);
    transition-delay: calc(var(--i, 0) * 70ms);
  }
  .js .exlibris { opacity: 0; transform: scale(0.985); transition: opacity var(--reveal) var(--ease-in-out), transform var(--reveal) var(--ease-in-out); }
  .js .backdrop { opacity: 0; transition: opacity var(--reveal) var(--ease-in-out); }
  .js .backdrop i { transform: translateY(-6px); transition: transform 1.2s var(--smooth); }
  .js .backdrop .foot { transform: translateY(6px); }
  .js .backdrop.shown i { transform: none; }

  .js .shown[data-rise], .js .shown[data-reveal], .js .shown.exlibris { opacity: 1; transform: none; }
  .js .backdrop.shown { opacity: 1; }
}
/* book.js не загрузился — всё видно (класс ставит скрипт в <head> через 2,5 с). */
.settled [data-rise], .settled [data-reveal], .settled .exlibris, .settled .backdrop { opacity: 1 !important; transform: none !important; }
/* Неподвижный фон на широком экране оседает: чуть крупнее → в размер (слой fixed, прокрутку вбок не даёт). */
@media (prefers-reduced-motion: no-preference) and (min-width: 900px) {
  .js .backdrop.sparse { transition: opacity var(--reveal) var(--ease-in-out), transform 1.2s var(--smooth); }
  .js .backdrop.sparse:not(.shown) { transform: scale(1.015); }
}
/* «Уменьшить движение»: те же появления — одной прозрачностью. */
@media (prefers-reduced-motion: reduce) {
  .js [data-rise], .js [data-reveal], .js .exlibris, .js .backdrop { opacity: 0; transition: opacity 0.2s var(--ease-in-out); }
  .js .shown[data-rise], .js .shown[data-reveal], .js .shown.exlibris, .js .backdrop.shown { opacity: 1; }
}
