/* =========================================================
   ГАРАЖ — сайт-книга. Настоящий раскрытый разворот.
   Левая страница — текст, правая — иллюстрация.
   Переворот листа (3D), номера страниц, открытие книги.
   Палитра: бетон, ржавый, тёплый жёлтый, чёрная тушь.
   ========================================================= */

:root {
  --concrete:  #16181c;
  --concrete-2:#1d2026;
  --concrete-3:#252932;
  --ink:       #14120e;
  --amber:     #f0a52e;
  --rust:      #a8481c;
  --steel:     #838d9a;
  --steel-dim: #59616c;

  /* бумага книги — тёплая, тонированная */
  --paper:     #e7e0d1;
  --paper-2:   #ded5c3;
  --paper-3:   #d3c9b3;
  --paper-line:#c4b99f;

  --font-book: Georgia, 'Iowan Old Style', 'Times New Roman', serif;
  --font-disp: 'Oswald', 'Arial Narrow', system-ui, sans-serif;

  --page-h: 76vh;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
html { height: 100%; }
body {
  min-height: 100%;
  background:
    radial-gradient(1200px 700px at 50% -10%, #23262d 0%, transparent 60%),
    var(--concrete);
  color: #e7e0d1;
  font-family: var(--font-book);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

/* ── верхняя панель ── */
.bar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 16px;
  padding: 10px 18px;
  background: linear-gradient(var(--concrete-2), var(--concrete));
  border-bottom: 1px solid #000;
}
.brand {
  font-family: var(--font-disp); font-size: 20px; letter-spacing: .16em;
  color: var(--amber); text-decoration: none; font-weight: 600;
}
.bar-mid {
  flex: 1; text-align: center;
  font-family: var(--font-disp); font-size: 11px; letter-spacing: .18em;
  text-transform: uppercase; color: var(--steel);
}
.bar-tools { display: flex; gap: 8px; }
.tool {
  font-family: var(--font-disp); font-size: 11px; letter-spacing: .14em;
  text-transform: uppercase;
  background: transparent; color: var(--steel);
  border: 1px solid var(--steel-dim); border-radius: 3px;
  padding: 7px 12px; cursor: pointer;
}
.tool:hover { color: #fff; border-color: var(--amber); }
.tool[aria-pressed="true"] { color: #14120e; background: var(--amber); border-color: var(--amber); }

/* ── оглавление ── */
.toc {
  position: fixed; top: 44px; right: 0; z-index: 25;
  width: 320px; max-width: 88vw; max-height: calc(100vh - 44px); overflow: auto;
  background: var(--concrete-3);
  border-left: 1px solid #000; border-bottom: 1px solid #000;
  padding: 16px 18px 22px;
}
.toc-head {
  font-family: var(--font-disp); font-size: 12px; letter-spacing: .2em;
  text-transform: uppercase; color: var(--amber); margin-bottom: 12px;
  display: flex; align-items: baseline; gap: 8px;
}
.toc-sub {
  font-family: var(--font-book); font-size: 11px; letter-spacing: 0;
  text-transform: none; font-style: italic; color: var(--steel-dim);
}
.toc-prog {
  height: 3px; background: #00000050; border-radius: 3px; overflow: hidden;
  margin-bottom: 8px;
}
.toc-prog span { display: block; height: 100%; width: 0; background: var(--amber); transition: width .3s; }
.toc-stat { font-size: 11.5px; color: var(--steel-dim); margin-bottom: 14px; }
.toc-list { list-style: none; margin: 0; padding: 0; }
.toc-part {
  font-family: var(--font-disp); font-size: 10px; letter-spacing: .2em;
  text-transform: uppercase; color: var(--steel-dim); margin: 16px 0 6px;
}
.toc-link {
  display: flex; gap: 10px; align-items: baseline;
  width: 100%; text-align: left;
  background: none; border: 0; border-radius: 3px;
  padding: 7px 8px; cursor: pointer;
  color: #d9d2c4; font-family: var(--font-book); font-size: 15px;
}
.toc-link:hover { background: #00000030; }
.toc-link .n { color: var(--steel-dim); font-family: var(--font-disp); font-size: 12px; min-width: 22px; }
.toc-link .t { flex: 1; }
.toc-link .s {
  font-family: var(--font-disp); font-size: 10px; letter-spacing: .12em;
  text-transform: uppercase; color: var(--steel-dim); white-space: nowrap;
}
.toc-link.read .s { color: #6fa86f; }
.toc-link.now { color: var(--amber); }
.toc-link.now .n, .toc-link.now .s { color: var(--amber); }
.toc-link.locked { color: var(--steel-dim); cursor: default; }
.toc-link.locked:hover { background: none; }
.toc-link.locked .t { font-style: italic; }
.toc-note { color: var(--steel-dim); font-size: 12.5px; margin: 16px 0 0; }

/* ── сцена книги ── */
.stage {
  display: flex; flex-direction: column; align-items: center;
  padding: 24px 16px 40px;
}

.book {
  position: relative;
  perspective: 2600px;
  animation: openBook 1s cubic-bezier(.22,.68,.24,1) both;
  transform-origin: bottom center;
}
@keyframes openBook {
  0%   { opacity: 0; transform: rotateX(-88deg) scale(.94); }
  60%  { opacity: 1; }
  100% { opacity: 1; transform: rotateX(0) scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  .book { animation: none; }
}

.book-inner {
  position: relative;
  display: flex;
  width: min(1120px, 94vw);
  height: var(--page-h);
  transform-style: preserve-3d;
  /* тень книги на «столе» */
  filter: drop-shadow(0 40px 60px rgba(0,0,0,.55));
}

.page {
  position: relative;
  flex: 1 1 50%;
  width: 50%;
  background:
    linear-gradient(90deg, rgba(0,0,0,.05), transparent 30%),
    var(--paper);
  overflow: hidden;
}
.page-left {
  border-radius: 6px 2px 2px 6px;
  box-shadow: inset -18px 0 26px -18px rgba(0,0,0,.45);
}
.page-right {
  border-radius: 2px 6px 6px 2px;
  box-shadow: inset 18px 0 26px -18px rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center;
}

/* корешок */
.spine {
  position: absolute; top: 0; bottom: 0; left: 50%;
  width: 26px; transform: translateX(-50%);
  background: linear-gradient(90deg,
    rgba(0,0,0,.28), rgba(0,0,0,.06) 45%,
    rgba(255,255,255,.10) 52%, rgba(0,0,0,.06) 60%, rgba(0,0,0,.28));
  pointer-events: none; z-index: 6;
}

/* ── левая страница: текст ── */
.page-left { display: flex; flex-direction: column; padding: 34px 40px 30px; }

.head {
  font-family: var(--font-disp); font-weight: 600;
  font-size: 15px; letter-spacing: .22em; text-transform: uppercase;
  color: var(--rust);
}
.head small { display:block; font-size: 10px; letter-spacing:.2em; color:#8a7f63; margin-top:3px; font-weight:400; }

.scene {
  font-family: var(--font-disp); font-size: 10.5px; letter-spacing: .2em;
  text-transform: uppercase; color: #8a7f63;
  border-bottom: 1px solid var(--paper-line);
  padding-bottom: 10px; margin: 10px 0 16px;
}

.text-scroll {
  flex: 1 1 auto; overflow: hidden; overflow-x: hidden;
  padding-right: 8px;
}

.prose p { margin: 0 0 14px; font-size: 17.5px; line-height: 1.72; color: var(--ink); }
.prose .line { margin: 0 0 14px; padding-left: 16px; border-left: 2px solid var(--paper-line); font-size: 17.5px; }
.prose .think { margin: 0 0 14px; font-style: italic; color: #55503f; }
.prose .end {
  margin: 22px 0 4px; text-align: center;
  font-family: var(--font-disp); font-size: 11.5px; letter-spacing: .3em;
  text-transform: uppercase; color: #8a7f63;
}
.prose .end::before, .prose .end::after { content: " · "; color: var(--rust); }

.hooks { margin: 6px 0 4px; display: flex; flex-direction: column; gap: 5px; }
.hook {
  font-size: 13.5px; font-style: italic; color: #8a7f63;
  display: flex; gap: 8px; align-items: baseline;
  margin: 5px 0;
}
.hook::before { content: "⌖"; color: var(--rust); font-style: normal; }

/* номер страницы (колофон) */
.folio {
  position: absolute; bottom: 12px;
  font-family: var(--font-disp); font-size: 11px; letter-spacing: .1em;
  color: #9a8f72;
}
.folio-l { left: 26px; }
.folio-r { right: 26px; }
.page-left .text-scroll { padding-bottom: 4px; }

/* ── правая страница: иллюстрация ── */
.plate {
  margin: 0; width: 100%; height: 100%;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 30px 30px 44px;
}
.plate-art {
  flex: 1 1 auto; width: 100%;
  display: flex; align-items: center; justify-content: center;
  min-height: 0;
}
.plate-art img {
  max-width: 100%; max-height: 100%;
  width: auto; height: auto; object-fit: contain;
  border: 1px solid var(--paper-line);
  filter: grayscale(.3) contrast(1.03) sepia(.14);
}
/* заглушка иллюстрации — «книжная плашка» до отрисовки */
.plate-art .stub {
  width: 100%; height: 100%;
  border: 1px solid var(--paper-line);
  background:
    repeating-linear-gradient(45deg, rgba(0,0,0,.02) 0 12px, transparent 12px 24px),
    var(--paper-2);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; text-align: center; padding: 24px;
}
.plate-art .stub .no {
  font-family: var(--font-disp); font-size: 42px; font-weight: 600;
  letter-spacing: .1em; color: #c2b596;
}
.plate-art .stub .lbl {
  font-family: var(--font-disp); font-size: 11px; letter-spacing: .24em;
  text-transform: uppercase; color: #9a8f72;
}
.plate-art .stub .sub { font-size: 13px; font-style: italic; color: #8a7f63; }

.plate-cap {
  margin-top: 16px; text-align: center;
  font-family: var(--font-disp); font-size: 11px; letter-spacing: .18em;
  text-transform: uppercase; color: #8a7f63;
}

/* ── переворачиваемый лист ── */
.leaf {
  position: absolute; top: 0; left: 50%;
  width: 50%; height: 100%;
  transform-style: preserve-3d;
  transform-origin: left center;
  transform: rotateY(0deg);
  z-index: 8;
  visibility: hidden;
  pointer-events: none;
  will-change: transform;
}
.face {
  position: absolute; inset: 0;
  backface-visibility: hidden;
  overflow: hidden;
  background: var(--paper);
}
.face.front {
  display: flex; align-items: center; justify-content: center;
  background:
    linear-gradient(90deg, rgba(0,0,0,.05), transparent 30%),
    var(--paper);
  border-radius: 2px 6px 6px 2px;
  box-shadow: inset 18px 0 26px -18px rgba(0,0,0,.45);
}
.face.back {
  transform: rotateY(180deg);
  display: flex; flex-direction: column;
  padding: 34px 40px 30px;
  background:
    linear-gradient(270deg, rgba(0,0,0,.05), transparent 30%),
    var(--paper);
  border-radius: 6px 2px 2px 6px;
  box-shadow: inset -18px 0 26px -18px rgba(0,0,0,.45);
}
/* содержимое лицевой стороны = страница-иллюстрация */
.face.front .plate { padding: 30px 30px 44px; }
.face.back .text-scroll { padding-bottom: 4px; }
/* сгиб листа слева (на обороте) */
.face.back::after {
  content:""; position:absolute; top:0; right:0; bottom:0; width:20px;
  background: linear-gradient(270deg, rgba(0,0,0,.16), transparent);
}

/* ── управление ── */
/* ── стрелки на краях страниц — часть книги ── */
.turn-arrow {
  position: absolute; top: 50%; transform: translateY(-50%);
  z-index: 12;
  width: 40px; height: 64px;
  display: flex; align-items: center; justify-content: center;
  color: rgba(20, 18, 14, .38);
  background: transparent; border: 0; padding: 0;
  cursor: pointer;
  transition: color .18s, transform .18s;
}
.turn-arrow.left  { left: 0; }
.turn-arrow.right { right: 0; }
.turn-arrow svg { display: block; }
.turn-arrow:hover:not(:disabled) { color: var(--rust); }
.turn-arrow.left:hover:not(:disabled)  { transform: translateY(-50%) translateX(-3px); }
.turn-arrow.right:hover:not(:disabled) { transform: translateY(-50%) translateX(3px); }
.turn-arrow:disabled { opacity: 0; pointer-events: none; }

/* ── плеер: под книгой, в ширину разворота ── */
.player {
  width: min(1120px, 94vw);
  margin-top: 12px;
  display: flex; align-items: center; gap: 16px;
  padding: 13px 22px;
  background: linear-gradient(var(--concrete-3), var(--concrete-2));
  border: 1px solid #000; border-top: 0;
  border-radius: 0 0 6px 6px;
  box-shadow: 0 26px 50px -30px #000;
}
.play {
  width: 42px; height: 42px; border-radius: 50%;
  background: var(--amber); color: #14120e; border: 0; cursor: pointer;
  font-size: 15px; flex: 0 0 auto;
}
/* Приход с «магнитолы» гаража (kniga.html?focus=player):
   плеер коротко подсвечивается — видно, куда вас привели. */
.player.flash-in { animation: playerflash 2.4s ease-out; }
@keyframes playerflash {
  0%   { box-shadow: 0 0 0 3px rgba(232,179,74,.95), 0 0 46px rgba(232,179,74,.6), 0 26px 50px -30px #000; }
  70%  { box-shadow: 0 0 0 2px rgba(232,179,74,.55), 0 0 26px rgba(232,179,74,.3), 0 26px 50px -30px #000; }
  100% { box-shadow: 0 0 0 0 rgba(232,179,74,0), 0 0 0 rgba(232,179,74,0), 0 26px 50px -30px #000; }
}
@media (prefers-reduced-motion: reduce) { .player.flash-in { animation: none; } }
.play:disabled { opacity: .4; cursor: not-allowed; }
.player-body { flex: 0 1 auto; min-width: 0; }
.player-title { font-family: var(--font-disp); font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--paper); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-sub { font-size: 13px; color: var(--steel); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── шкала перемотки ── */
.timeline { flex: 1 1 320px; min-width: 140px; display: flex; align-items: center; gap: 10px; }
.time {
  font-family: var(--font-disp); font-size: 11px; letter-spacing: .04em;
  color: var(--steel); min-width: 32px; text-align: center; flex: 0 0 auto;
  font-variant-numeric: tabular-nums;
}
.time.end { color: var(--steel-dim); }
.seek {
  -webkit-appearance: none; appearance: none;
  flex: 1 1 auto; min-width: 80px; height: 5px; border-radius: 5px;
  background: linear-gradient(to right,
    var(--amber) 0, var(--amber) var(--p, 0%),
    #00000059 var(--p, 0%), #00000059 100%);
  outline: none; cursor: pointer;
}
.seek::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 15px; height: 15px; border-radius: 50%;
  background: var(--paper); border: 2px solid var(--rust);
  box-shadow: 0 1px 3px #000a; cursor: grab;
}
.seek::-moz-range-thumb {
  width: 15px; height: 15px; border: 2px solid var(--rust);
  border-radius: 50%; background: var(--paper);
  box-shadow: 0 1px 3px #000a; cursor: grab;
}
.seek:disabled { opacity: .5; cursor: not-allowed; }

/* ── значок звука (вкл/выкл) ── */
.vol {
  width: 34px; height: 34px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: transparent; border: 1px solid transparent;
  color: var(--paper); cursor: pointer; flex: 0 0 auto;
  transition: color .15s, border-color .15s;
}
.vol:hover { color: var(--amber); border-color: var(--steel-dim); }
.vol .slash { display: none; }
.vol.muted { color: var(--steel-dim); }
.vol.muted .wave { display: none; }
.vol.muted .slash { display: block; }
.vol.muted:hover { color: var(--rust); }

/* ── регулятор громкости ── */
.vol-group { display: flex; align-items: center; gap: 9px; flex: 0 0 auto; }
.vol-range {
  -webkit-appearance: none; appearance: none;
  width: 88px; height: 5px; border-radius: 5px;
  background: linear-gradient(to right,
    var(--amber) 0, var(--amber) var(--vp, 100%),
    #00000059 var(--vp, 100%), #00000059 100%);
  outline: none; cursor: pointer;
}
.vol-range::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 13px; height: 13px; border-radius: 50%;
  background: var(--paper); border: 2px solid var(--rust);
  box-shadow: 0 1px 3px #000a; cursor: grab;
}
.vol-range::-moz-range-thumb {
  width: 13px; height: 13px; border: 2px solid var(--rust);
  border-radius: 50%; background: var(--paper);
  box-shadow: 0 1px 3px #000a; cursor: grab;
}

/* ── мобильник ── */
@media (max-width: 820px) {
  :root { --page-h: auto; }
  .book { perspective: none; animation: none; }
  .book-inner {
    flex-direction: column; height: auto; width: 96vw;
    filter: drop-shadow(0 20px 34px rgba(0,0,0,.5));
  }
  .page { width: 100%; }
  .page-left { border-radius: 6px 6px 0 0; min-height: 64vh; }
  .page-right { border-radius: 0 0 6px 6px; min-height: 54vh; }
  .spine { display: none; }
  .leaf { display: none; }
  .text-scroll { overflow: visible; }
  .turn-arrow { width: 48px; height: 88px; color: rgba(20, 18, 14, .4); }
  .turn-arrow svg { width: 34px; height: 34px; }
  .prose p, .prose .line { font-size: 16.5px; }
  .player { flex-wrap: wrap; gap: 12px; padding: 12px 14px; }
  .player-body { flex: 1 1 auto; }
  .vol { order: 2; }
  .timeline { flex: 1 1 100%; order: 3; }
}
