:root {
  --bg: #d9d4cb;
  --ink: #1a1a1a;
  --btn: #fbfaf7;
  --btn-border: #8a8378;
  --btn-hover: #efeae1;
  --accent: #2f6b3a;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(ellipse at center, #e8e3da 0%, var(--bg) 70%);
  color: var(--ink);
  font-family: Georgia, 'Times New Roman', serif;
  overflow: hidden;
}

.stage {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 12px 20px;
}

/* --- книга ------------------------------------------------------------ */
.shift {
  transition: transform .7s cubic-bezier(.4, .1, .2, 1);
}
.stage.closed-front .shift { transform: translateX(-25%); }
.stage.closed-back  .shift { transform: translateX(25%); }

.shift { position: relative; }
.book { position: relative; z-index: 2; }
.book, .book * { cursor: pointer; }   /* листалка ловит все клики — текстовый курсор не нужен */

/* переплёт: тёмно-зелёный картон под блоком страниц, чуть шире его */
.board {
  position: absolute; z-index: 0;
  top: -4px; bottom: -6px;
  left: calc(-1px * var(--el, 6) - 5px);
  right: calc(-1px * var(--er, 6) - 5px);
  background: linear-gradient(90deg, #22463a, #2c5a49 8%, #2c5a49 92%, #22463a);
  border-radius: 3px;
  box-shadow: 0 16px 36px rgba(0, 0, 0, .35), 0 2px 5px rgba(0, 0, 0, .3);
  transition: left .5s, right .5s, opacity .4s;
}

/* срезы страниц по краям: стопка тонких листов; толщина — сколько страниц с этой стороны */
.edge {
  position: absolute; z-index: 1;
  top: 1px; bottom: -2px;
  background:
    linear-gradient(180deg, rgba(0,0,0,.06), transparent 6%, transparent 94%, rgba(0,0,0,.08)),
    repeating-linear-gradient(90deg, #fbfaf6 0 1px, #dcd6ca 1px 2px);
  transition: width .5s, opacity .4s;
}
.edge-l {
  right: 100%; width: calc(1px * var(--el, 6));
  border-radius: 2px 0 0 2px;
  box-shadow: inset 3px 0 3px -2px rgba(0, 0, 0, .25);
}
.edge-r {
  left: 100%; width: calc(1px * var(--er, 6));
  border-radius: 0 2px 2px 0;
  box-shadow: inset -3px 0 3px -2px rgba(0, 0, 0, .25);
}
/* закрытая книга: видна только обложка и срез с одной стороны */
.stage.closed-front .board, .stage.closed-back .board { opacity: 0; }
.stage.closed-front .edge-l, .stage.closed-back .edge-r { opacity: 0; }
.stage.closed-front .book, .stage.closed-back .book { filter: drop-shadow(0 14px 22px rgba(0,0,0,.3)); }

.bp { background: #fff; overflow: hidden; }

/* складка у корешка: тень внутрь страницы у переплёта, листается вместе со страницей */
.stf__item.--left:not(.--hard)::after,
.stf__item.--right:not(.--hard)::after {
  content: ''; position: absolute; top: 0; bottom: 0; width: 13%;
  pointer-events: none; z-index: 5;
}
.stf__item.--left:not(.--hard)::after {
  right: 0;
  background: linear-gradient(90deg, rgba(0,0,0,0) 0%, rgba(0,0,0,.035) 45%, rgba(0,0,0,.10) 82%, rgba(0,0,0,.22) 100%);
}
.stf__item.--right:not(.--hard)::after {
  left: 0;
  background: linear-gradient(270deg, rgba(0,0,0,0) 0%, rgba(0,0,0,.035) 45%, rgba(0,0,0,.10) 82%, rgba(0,0,0,.22) 100%);
}
/* лёгкое затенение к внешнему краю — страница «изгибается» */
.stf__item.--left:not(.--hard)::before,
.stf__item.--right:not(.--hard)::before {
  content: ''; position: absolute; top: 0; bottom: 0; width: 4%;
  pointer-events: none; z-index: 5;
}
.stf__item.--left:not(.--hard)::before { left: 0; background: linear-gradient(90deg, rgba(0,0,0,.06), rgba(0,0,0,0)); }
.stf__item.--right:not(.--hard)::before { right: 0; background: linear-gradient(270deg, rgba(0,0,0,.06), rgba(0,0,0,0)); }
.page-scale {
  position: absolute; left: 0; top: 0;
  width: 740px; height: 1000px;
  transform: scale(var(--k, 1));
  transform-origin: 0 0;
}
.page-scale > .page { margin: 0; }

/* задняя обложка: белая, картинка по центру */
.page.back-cover { display: flex; align-items: center; justify-content: center; padding: 0; }
.page.back-cover img { width: 58%; }

/* --- кнопки ------------------------------------------------------------- */
.topbar, .navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: var(--book-w, 800px);
  min-height: 44px;
  transition: opacity .4s;
}
.topbar { display: grid; grid-template-columns: 1fr auto 1fr; }
.topbar .slot-l { justify-self: start; }
.topbar .slot-c { justify-self: center; }
.topbar .slot-r { justify-self: end; }
.stage.closed-front .topbar,
.stage.closed-front .navbar { opacity: 0; pointer-events: none; }
.stage.closed-back .topbar { opacity: 0; pointer-events: none; }

.vbtn {
  font: italic 18px Georgia, serif;
  padding: 8px 18px;
  background: var(--btn);
  border: 1.5px solid var(--btn-border);
  border-radius: 6px;
  cursor: pointer;
  color: var(--ink);
}
.vbtn small { font-style: normal; font-size: 13px; color: #6d665c; margin-left: 6px; }
.vbtn:hover { background: var(--btn-hover); }
.vbtn.on { background: #e3ecdf; border-color: var(--accent); box-shadow: inset 0 1px 3px rgba(0,0,0,.18); }
.vbtn.on small { color: var(--accent); }

/* лист словаря поверх страницы (внутри .page-scale — масштабируется вместе со страницей) */
.vsheet {
  position: absolute; inset: 0; z-index: 3;
  opacity: 0; transition: opacity .25s ease;
}
.vsheet.show { opacity: 1; }
.vsheet > .page { background: #fff; position: relative; }
.vsheet-close {
  position: absolute; right: 34px; bottom: 26px;
  width: 44px; height: 44px; border-radius: 50%;
  font: 30px/1 Georgia, serif; color: #555;
  background: #fbfaf7; border: 1.5px solid var(--btn-border); cursor: pointer;
}
.vsheet-close:hover { background: var(--btn-hover); color: #000; }
.vsheet.on-left .vsheet-close { right: auto; left: 34px; }   /* крестик у внешнего края страницы */

.nbtn {
  width: 44px; height: 44px;
  padding: 0;
  display: grid; place-items: center;
  background: var(--btn);
  border: 1.5px solid var(--btn-border);
  border-radius: 4px;
  cursor: pointer;
}
.nbtn svg { width: 20px; height: 20px; fill: var(--ink); }
.nbtn:hover { background: var(--btn-hover); }
.nbtn:disabled { opacity: .35; cursor: default; }
.nbtn:disabled:hover { background: var(--btn); }

button:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* --- содержание: лист «Enhavo» поверх разворота, как страница книги ---------- */
.tocpage .toc-title { font-size: 34px; font-weight: bold; margin: 22px 0 26px; }
.tocpage.cont .toc-title { visibility: hidden; }          /* правая страница: строки на той же высоте */
.tocpage ol { list-style: none; margin: 0; padding: 0; }
.tocpage li button {
  display: grid; grid-template-columns: 6.4em 1fr auto;
  align-items: baseline; gap: 10px;
  width: 100%; padding: 9px 10px;
  background: none; border: none; border-radius: 4px;
  font: 21px/1.35 Georgia, 'Times New Roman', serif; color: inherit;
  text-align: left; cursor: pointer;
}
.tocpage li button > * { pointer-events: none; }         /* клик приходит в <button> — книга его не листает */
.tocpage li button:hover { background: #f1ede5; }
.tocpage .n { font-weight: bold; white-space: nowrap; }
.tocpage .t { overflow: hidden; white-space: nowrap; }
.tocpage .t::after {                                       /* отточие до номера страницы */
  content: ' . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .';
  color: #9a9285;
}
.tocpage .p { font-variant-numeric: tabular-nums; color: #555; }
.tocpage li.cur button { background: #eef3ea; }
.tocpage li.cur .n { color: var(--accent); }

/* копия страниц урока на время перелистывания из содержания — без плавного появления */
.vsheet.clone { opacity: 1; transition: none; }
