/* Книги Виталия Слесарева. Colours are taken from the author's illustrations. */
:root {
  --ink-fixed: #1f1b2e;
  --ink: #1f1b2e;
  --paper: #fbfbf7;
  --muted: #5b5668;
  --rule: #e2dfd6;
  --lime: #8fd400;
  --cyan: #19c6d6;
  --magenta: #c81d7d;
  --sun: #ffcc1a;
  --tone: var(--ink);
  --on-tone: var(--paper);
  --fs: 20px;
  --measure: 34em;
  --display: "Unbounded", "Arial Black", sans-serif;
  --text: "Literata", Georgia, "Times New Roman", serif;
  color-scheme: light;
}
html[data-tone="lime"] { --tone: var(--lime); --on-tone: var(--ink-fixed); }
html[data-tone="cyan"] { --tone: var(--cyan); --on-tone: var(--ink-fixed); }
html[data-tone="magenta"] { --tone: var(--magenta); --on-tone: #fff; }
html[data-tone="sun"] { --tone: var(--sun); --on-tone: var(--ink-fixed); }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #ece9f2;
    --paper: #17141f;
    --muted: #aaa4b9;
    --rule: #2d2939;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { font-size: var(--fs); -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--text);
  font-optical-sizing: auto;
  line-height: 1.7;
}
img, video { max-width: 100%; height: auto; display: block; }
a { color: inherit; }
h1, h2, h3 { font-family: var(--display); font-weight: 600; line-height: 1.15; letter-spacing: -0.01em; margin: 0; }
:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; }
.tone-lime :focus-visible, a.band:focus-visible { outline-color: var(--ink-fixed); }

/* ---------- home ---------- */
.masthead { max-width: 1100px; margin: 0 auto; padding: 2.2rem 16px 1.4rem; }
.masthead h1 { font-size: clamp(2.1rem, 9vw, 4.6rem); font-weight: 800; letter-spacing: -0.03em; }
.masthead p { margin: .35rem 0 0; font-style: italic; color: var(--muted); font-size: 1.05rem; }

.hero { max-width: 1100px; margin: 0 auto 2.5rem; padding: 0 16px; }
.hero img, .hero video { width: 100%; background: #000; }
.hero-caption { padding: .8rem 0 0; }
.hero-caption h2 { font-size: 1.4rem; }
.hero-caption p { margin: .2rem 0 0; color: var(--muted); }
.hero .epigraph { font-size: 1.15rem; font-style: italic; color: var(--ink); }

/* The stack: one solid band per book, slightly misaligned like books piled on a table. */
.stack { max-width: 1100px; margin: 0 auto 3rem; padding: 0 16px; }
.band {
  --bg: var(--ink-fixed); --on: #fff;
  display: grid;
  background: var(--bg);
  color: var(--on);
  text-decoration: none;
  border-top: 3px solid var(--ink-fixed);
  transition: transform .25s ease;
}
.band:last-child { border-bottom: 3px solid var(--ink-fixed); }
.band.tone-lime { --bg: var(--lime); --on: var(--ink-fixed); margin-right: 4%; }
.band.tone-cyan { --bg: var(--cyan); --on: var(--ink-fixed); margin-left: 3%; }
.band.tone-magenta { --bg: var(--magenta); --on: #fff; margin-right: 1.5%; margin-left: 1%; }
.band.tone-sun { --bg: var(--sun); --on: var(--ink-fixed); margin-left: 5%; margin-right: 2%; }
.band:hover { transform: translateX(10px); }
.band-text { padding: 1.3rem 1.2rem 1.4rem; }
.band h2 { font-size: clamp(1.45rem, 5.4vw, 2.7rem); font-weight: 700; }
.band .subtitle { margin: .3rem 0 0; font-style: italic; }
.band .blurb { margin: .6rem 0 0; max-width: 34em; }
.band .meta { margin: .6rem 0 0; font-family: var(--display); font-size: .72rem; font-weight: 500; opacity: .85; }
.band img { width: 100%; aspect-ratio: 16 / 7; object-fit: cover; order: -1; }
@media (min-width: 760px) {
  .band.has-cover { grid-template-columns: 1fr 38%; }
  .band.has-cover img { order: 0; aspect-ratio: auto; height: 100%; min-height: 230px; }
  .band-text { padding: 1.8rem 2rem 2rem; }
}

.foot { max-width: 1100px; margin: 0 auto; padding: 1rem 16px 3rem; color: var(--muted); font-size: .85rem; }

/* ---------- top bar (book and chapter pages) ---------- */
.bar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .55rem 16px;
  background: var(--paper);
  border-bottom: 5px solid var(--tone);
  font-family: var(--display); font-size: .78rem; font-weight: 500;
}
.bar-book { text-decoration: none; padding: .5rem 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-book::before { content: "‹ "; }
.fs { display: flex; gap: .4rem; flex: none; }
.fs button {
  font: inherit; font-size: .9rem; min-width: 2.9rem; min-height: 2.6rem;
  color: var(--ink); background: transparent; border: 2px solid var(--ink); border-radius: .4rem; cursor: pointer;
}

/* ---------- book page ---------- */
.book-band { display: grid; background: var(--tone); color: var(--on-tone); }
.book-band-text { padding: 2rem 16px 2rem; max-width: 1100px; }
.book-band h1 { font-size: clamp(1.8rem, 7vw, 3.6rem); font-weight: 700; }
.book-band .subtitle { margin: .4rem 0 0; font-style: italic; font-size: 1.1rem; }
.book-band .meta { margin: .8rem 0 0; font-family: var(--display); font-size: .75rem; font-weight: 500; }
.book-cover { width: 100%; aspect-ratio: 16 / 8; object-fit: cover; order: -1; }
@media (min-width: 760px) {
  .book-band { grid-template-columns: 1fr 40%; }
  .book-cover { order: 0; aspect-ratio: auto; height: 100%; }
  .book-band-text { padding: 3rem 2.5rem; }
}
.book-intro, .toc { max-width: var(--measure); margin: 0 auto; padding: 0 16px; }
.annotation { margin: 1.8rem 0 1.2rem; }
.actions { display: flex; flex-wrap: wrap; gap: .7rem; margin-bottom: 2.5rem; }
.btn {
  display: inline-block; text-decoration: none;
  font-family: var(--display); font-weight: 500; font-size: .8rem; line-height: 1.3;
  padding: .85em 1.2em; border-radius: .4rem;
  background: var(--ink); color: var(--paper); border: 2px solid var(--ink);
}
.btn.ghost { background: transparent; color: var(--ink); }
.toc-title { font-size: 1.3rem; margin: 0 0 .6rem; }
.toc h2:not(.toc-title) { font-size: 1rem; margin: 2rem 0 .3rem; padding-top: .8rem; border-top: 5px solid var(--tone); }
.toc ol, .toc ul { list-style: none; margin: 0; padding: 0; }
.toc li a {
  display: flex; gap: .8rem; align-items: baseline;
  padding: .6rem 0; min-height: 2.8rem;
  text-decoration: none; border-bottom: 1px solid var(--rule);
}
.toc li a:hover { text-decoration: underline; text-decoration-color: var(--tone); text-decoration-thickness: 3px; }
.toc .n { flex: none; min-width: 2.2em; font-family: var(--display); font-size: .7rem; color: var(--muted); }
.toc-front li a, .toc .intro a { font-style: italic; }
.toc { padding-bottom: 4rem; }

/* ---------- reader ---------- */
.reader { padding: 0 16px; }
.chapter-head, .text, .pager { max-width: var(--measure); margin-left: auto; margin-right: auto; }
.chapter-head { padding: 2rem 0 1.3rem; }
.where { margin: 0 0 .5rem; color: var(--muted); font-size: .85rem; }
.chapter-head h1 { font-size: clamp(1.5rem, 6vw, 2.5rem); font-weight: 700; }
.epigraph { font-style: italic; margin: 1rem 0 0; }
.text { hyphens: auto; -webkit-hyphens: auto; overflow-wrap: break-word; }
.text p { margin: 0 0 1em; }
.text h2 { font-size: 1.15rem; margin: 2.2rem 0 .8rem; }
.text figure { margin: 1.2rem 0 1.6rem; }
.text figure img { width: 100%; }
.text blockquote { margin: 1.4rem 0; padding: .2rem 0 .2rem 1rem; border-left: 5px solid var(--tone); font-style: italic; }
.text .sign { text-align: right; font-style: italic; }
.pager { display: grid; gap: .8rem; margin-top: 2.5rem; padding-bottom: 4rem; }
.pager a {
  display: block; text-decoration: none; padding: .9rem 1rem; line-height: 1.35;
  border: 2px solid var(--ink); border-radius: .4rem; font-weight: 600;
}
.pager a span { display: block; font-family: var(--display); font-weight: 500; font-size: .7rem; color: var(--muted); margin-bottom: .25rem; }
.pager .next { order: -1; background: var(--tone); color: var(--on-tone); border-color: var(--tone); }
.pager .next span { color: inherit; opacity: .8; }
@media (min-width: 640px) {
  .pager { grid-template-columns: 1fr 1fr; }
  .pager .next { order: 0; text-align: right; }
}

@media (prefers-reduced-motion: reduce) {
  .band { transition: none; }
  .band:hover { transform: none; }
}

/* film series */
.hero-caption a { color: inherit; text-decoration-thickness: 2px; text-underline-offset: 3px; }
.episodes { max-width: 1100px; margin: -1rem auto 2.5rem; padding: 0 16px; }
.episodes h2 { font-size: 1.1rem; margin: 0 0 .8rem; }
.episodes ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.episodes a { display: block; text-decoration: none; }
.episodes img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; }
.ep-n { display: block; margin-top: .4rem; font-family: var(--display); font-size: .7rem; font-weight: 500; color: var(--muted); }
.ep-t { display: block; font-weight: 600; line-height: 1.3; }
.film-page { max-width: 1100px; margin: 0 auto; padding: 1rem 16px 3rem; }
.film-page video { width: 100%; background: #000; }
.film-page h1 { font-size: 1.6rem; }
