/* Общая вёрстка сайта. Цвета и шрифт заголовков приходят из темы страницы
   (themes.css, собирается из data/books.json и site/data/site.json). */
:root {
  --font-text: Lora, Georgia, "Times New Roman", serif;
  --font-code: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  --radius: 14px;
  --warn: #9b2f2f;
  --ok: #2f6b4f;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --warn: #ec9a96; --ok: #8ec5a5; }
}
:root[data-theme="dark"] { --warn: #ec9a96; --ok: #8ec5a5; }

* { box-sizing: border-box; }
html { background: var(--bg); color: var(--ink); -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(60rem 30rem at 85% -10%, color-mix(in srgb, var(--accent) 14%, transparent), transparent 70%),
    var(--bg);
  color: var(--ink);
  font-family: var(--font-text);
  font-size: 1.0625rem;
  line-height: 1.65;
}
main { flex: 1; }
img { max-width: 100%; display: block; }
a { color: var(--accent); text-underline-offset: 3px; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }

h1, h2, h3 { font-family: var(--font-display); font-weight: 700; line-height: 1.1; margin: 0; text-wrap: balance; }
h1 { font-size: clamp(2.3rem, 8vw, 4.2rem); letter-spacing: -.01em; }
h2 { font-size: clamp(1.6rem, 5vw, 2.3rem); }
h3 { font-size: 1.3rem; }
p { margin: 0 0 1em; }

.wrap { width: 100%; max-width: 72rem; margin: 0 auto; padding: 0 16px; }
@media (min-width: 720px) { .wrap { padding: 0 32px; } }
.narrow { max-width: 44rem; }

/* ---------- шапка ---------- */

.site-head {
  position: sticky; top: 0; z-index: 10; overflow-x: clip;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.site-head .wrap {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas: "brand tools" "nav nav";
  align-items: center;
  column-gap: 16px;
}
.brand {
  grid-area: brand;
  font-family: var(--font-display); font-weight: 700; font-size: 1.25rem;
  color: var(--ink); text-decoration: none; padding: 12px 0 4px; white-space: nowrap;
}
.tools { grid-area: tools; display: flex; gap: 6px; padding-top: 8px; }
.nav {
  grid-area: nav;
  display: flex; gap: 4px;
  overflow-x: auto; scrollbar-width: none;
  margin: 0 -16px; padding: 2px 12px 8px;
}
.nav::-webkit-scrollbar { display: none; }
.nav a {
  flex: 0 0 auto;
  padding: 6px 10px; border-radius: 999px;
  color: var(--muted); text-decoration: none; font-size: .95rem;
}
.nav a:hover { color: var(--ink); background: color-mix(in srgb, var(--ink) 6%, transparent); }
.nav a[aria-current="page"] { color: var(--accent-ink); background: var(--accent); }
@media (max-width: 400px) { .nav a, .nav-group > summary { font-size: .9rem; padding: 6px 8px; } }

/* Выпадающие группы меню. На телефоне панель — на всю ширину под шапкой, на компьютере — под пунктом. */
.site-head .wrap { position: relative; }
.nav-group { flex: 0 0 auto; }
.nav-group > summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 6px;
  padding: 6px 10px; border-radius: 999px; color: var(--muted); font-size: .95rem; white-space: nowrap;
}
.nav-group > summary::-webkit-details-marker { display: none; }
.nav-group > summary::after {
  content: ""; width: 6px; height: 6px; margin-top: -3px; border: solid currentColor; border-width: 0 1.5px 1.5px 0;
  transform: rotate(45deg); transition: transform .2s;
}
.nav-group[open] > summary::after { transform: translateY(3px) rotate(-135deg); }
.nav-group > summary:hover, .nav-group[open] > summary { color: var(--ink); background: color-mix(in srgb, var(--ink) 6%, transparent); }
.nav-group > summary.current { color: var(--accent-ink); background: var(--accent); }
.nav-group > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.nav-drop {
  position: absolute; left: 0; right: 0; top: 100%; z-index: 20;
  display: grid; gap: 14px 24px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  padding: 16px; border: 1px solid var(--line); border-radius: 0 0 var(--radius) var(--radius);
  background: color-mix(in srgb, var(--bg) 96%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 24px 40px -18px #000a;
}
.nav-col { display: grid; align-content: start; gap: 2px; }
.nav-col > b { font-size: .72rem; letter-spacing: .14em; text-transform: uppercase; color: var(--accent); padding: 0 10px 4px; }
.site-head .nav .nav-drop a {
  display: block; padding: 8px 10px; border-radius: 10px; font-size: .95rem; letter-spacing: 0; text-transform: none;
  color: var(--ink); white-space: normal; background: none;
}
.site-head .nav .nav-drop a:hover { background: color-mix(in srgb, var(--accent) 16%, transparent); }
.site-head .nav .nav-drop a[aria-current="page"] { color: var(--accent); background: none; font-weight: 600; }
@media (min-width: 860px) {
  .site-head .wrap { grid-template-columns: auto 1fr auto; grid-template-areas: "brand nav tools"; }
  .brand, .tools { padding: 14px 0; }
  .nav { margin: 0; padding: 0; justify-content: flex-end; overflow: visible; }
  .nav-group { position: relative; }
  .nav-drop { left: auto; right: 0; top: calc(100% + 12px); width: max-content; min-width: 220px; max-width: min(720px, 90vw); border-radius: var(--radius); }
  .nav-group.wide .nav-drop { grid-template-columns: repeat(3, minmax(170px, 1fr)); }
}
.acc-link {
  display: inline-flex; align-items: center; gap: 6px; height: 38px; padding: 0 14px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--surface);
  color: var(--ink); text-decoration: none; font-size: .88rem; white-space: nowrap;
}
.acc-link svg { width: 16px; height: 16px; flex: none; }
.acc-link.in { border-color: color-mix(in srgb, var(--accent) 60%, transparent); }
.acc-link.in svg { color: var(--accent); }
.acc-link[aria-current="page"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.acc-link[aria-current="page"] svg { color: currentColor; }
.icon-btn {
  width: 38px; height: 38px; display: grid; place-items: center;
  border: 1px solid var(--line); border-radius: 50%;
  background: var(--surface); color: var(--ink); cursor: pointer;
}
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn .moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon-btn .sun { display: none; }
  :root:not([data-theme="light"]) .icon-btn .moon { display: block; }
}
:root[data-theme="dark"] .icon-btn .sun { display: none; }
:root[data-theme="dark"] .icon-btn .moon { display: block; }

/* ---------- кнопки, метки ---------- */

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 11px 20px; border-radius: 999px;
  font-family: var(--font-text); font-size: 1rem; line-height: 1.2;
  text-decoration: none; cursor: pointer;
  border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink);
}
.btn:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; color: var(--accent); }
.btn small { opacity: .8; font-size: .8em; }
.btn.off { border-style: dashed; border-color: var(--line); background: none; color: var(--muted); cursor: default; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; }
.kicker {
  display: inline-block; margin-bottom: 14px;
  font-size: .78rem; letter-spacing: .14em; text-transform: uppercase; color: var(--accent);
}
.muted { color: var(--muted); }

/* ---------- секции ---------- */

.section { padding: 56px 0; }
.section + .section { padding-top: 0; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.section-head p { margin: 0; color: var(--muted); }
.band { background: var(--bg); color: var(--ink); border-block: 1px solid var(--line); }
.band .section { padding: 56px 0; }

/* ---------- первый экран ---------- */

.hero { padding: 48px 0 40px; }
.hero .wrap { display: grid; gap: 40px; align-items: center; }
@media (min-width: 860px) {
  .hero { padding: 80px 0 64px; }
  .hero .wrap { grid-template-columns: 1.25fr 1fr; gap: 64px; }
}
.hero .lede { font-size: clamp(1.1rem, 2.6vw, 1.3rem); max-width: 36rem; margin: 18px 0 26px; }
.motto { font-family: var(--font-display); font-size: clamp(1.15rem, 3.4vw, 1.5rem); color: var(--accent); margin: 12px 0 0; }
.tagline { font-style: italic; font-size: clamp(1.15rem, 3vw, 1.4rem); margin: 18px 0 22px; max-width: 34rem; }

.crumbs { font-size: .9rem; color: var(--muted); margin-bottom: 18px; }
.crumbs a { color: inherit; }

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

.cover {
  position: relative; aspect-ratio: 2 / 3; width: 100%;
  border-radius: 6px 14px 14px 6px; overflow: hidden;
  box-shadow: 0 1px 0 var(--line), 0 24px 50px -18px color-mix(in srgb, var(--ink) 55%, transparent);
  color: var(--accent-ink);
  background: linear-gradient(160deg, color-mix(in srgb, var(--accent) 80%, #000), color-mix(in srgb, var(--accent) 45%, #000));
}
.cover img { width: 100%; height: 100%; object-fit: cover; }
.cover svg.motif { position: absolute; inset: 0; width: 100%; height: 100%; }
.cover .cover-text {
  position: absolute; inset: auto 0 0; padding: 9% 9% 10%;
  display: grid; gap: 6px;
}
.cover .cover-title { font-family: var(--font-display); font-weight: 700; font-size: clamp(1.4rem, 3.4vw, 2.2rem); line-height: 1.05; color: #fff8ee; }
.cover .cover-author { font-size: .75rem; letter-spacing: .16em; text-transform: uppercase; color: #fff8eecc; }
.cover::after { content: ""; position: absolute; inset: 0 auto 0 0; width: 7%; background: linear-gradient(90deg, #0000002e, transparent); }
.hero .cover { max-width: 340px; justify-self: center; }

.fan { position: relative; display: flex; justify-content: center; min-height: 300px; }
.fan .cover { width: min(46%, 220px); }
.fan > :first-child { transform: rotate(-6deg) translateX(12%); }
.fan > :last-child { transform: rotate(5deg) translate(-12%, 14%); }

/* ---------- карточки книг ---------- */

.books { display: grid; gap: 20px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 30rem), 1fr)); }
.book-card {
  display: grid; grid-template-columns: 38% 1fr; gap: 20px;
  padding: 18px; border-radius: var(--radius);
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); text-decoration: none;
  font-family: var(--font-text);
}
.book-card:hover { border-color: var(--accent); }
.book-card .cover .cover-title { font-size: clamp(1rem, 3.6vw, 1.35rem); }
.book-card .cover .cover-author { font-size: .58rem; }
.book-card h3 { color: var(--ink); font-size: clamp(1.3rem, 4vw, 1.7rem); margin: 4px 0 8px; }
.book-card .kicker { margin: 0; font-size: .7rem; }
.book-card p { margin: 0 0 12px; font-size: .95rem; }
.book-card .more { color: var(--accent); font-size: .95rem; }

/* ---------- страница книги ---------- */

.switcher { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 26px; }
.switcher a {
  padding: 5px 12px; border-radius: 999px; font-size: .88rem;
  border: 1px solid var(--line); color: var(--muted); text-decoration: none;
}
.switcher a[aria-current="page"] { border-color: var(--accent); color: var(--accent); }
.meta { display: grid; grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr)); gap: 12px 20px; margin: 0 0 26px; }
.meta div { border-top: 1px solid var(--line); padding-top: 8px; }
.meta dt { font-size: .75rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.meta dd { margin: 0; }
.prose { font-size: 1.12rem; }
.prose p:first-child::first-letter {
  font-family: var(--font-display); float: left; font-size: 3.1em; line-height: .8;
  margin: .1em .12em 0 0; color: var(--accent);
}

.stories { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 19rem), 1fr)); }
.story-tile {
  padding: 20px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line);
  display: grid; gap: 6px; align-content: start;
}
.story-tile h3 { font-size: 1.2rem; }
.story-tile p { margin: 0; color: var(--muted); }
.lock { font-size: .8rem; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }

/* ---------- подкаст ---------- */

.player {
  display: grid; gap: 18px; padding: 22px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line);
}
@media (min-width: 640px) { .player { grid-template-columns: auto 1fr; align-items: center; padding: 28px; } }
.play {
  width: 84px; height: 84px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink); text-decoration: none;
}
.play svg { width: 34px; height: 34px; margin-left: 5px; }
.player h3 { font-size: clamp(1.5rem, 4vw, 2rem); margin: 4px 0 6px; }
.player p { margin: 0; color: var(--muted); }
.player iframe { width: 100%; border: 0; border-radius: 10px; grid-column: 1 / -1; }
.platforms { display: flex; flex-wrap: wrap; gap: 10px; }

.pod-card {
  display: grid; gap: 22px; padding: 28px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line);
}
@media (min-width: 860px) { .pod-card { grid-template-columns: 1fr 1.2fr; align-items: center; padding: 40px; } }
.pod-card h2 { font-size: clamp(2.2rem, 7vw, 3.4rem); }

/* ---------- автор и ссылки ---------- */

.socials { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 15rem), 1fr)); }
.social {
  display: grid; gap: 2px; padding: 16px 18px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line);
  color: var(--ink); text-decoration: none;
}
a.social:hover { border-color: var(--accent); }
.social span { color: var(--muted); font-size: .9rem; }
.social.off { border-style: dashed; }

.portrait {
  aspect-ratio: 4 / 5; width: 100%; max-width: 340px; justify-self: center;
  border-radius: 200px 200px var(--radius) var(--radius);
  background: linear-gradient(170deg, var(--accent), color-mix(in srgb, var(--accent) 40%, var(--bg)));
  display: grid; place-items: center; overflow: hidden;
  color: var(--accent-ink); font-family: var(--font-display); font-size: 5rem;
}
.portrait img { width: 100%; height: 100%; object-fit: cover; }

.dlc-teaser {
  display: grid; gap: 14px; padding: 28px; border-radius: var(--radius);
  border: 1px dashed var(--accent); background: color-mix(in srgb, var(--accent) 6%, var(--surface));
}
@media (min-width: 860px) { .dlc-teaser { grid-template-columns: 1fr auto; align-items: center; } }
.dlc-teaser p { margin: 0; }

/* ---------- подвал ---------- */

.site-foot { border-top: 1px solid var(--line); margin-top: 40px; }
.site-foot .wrap { padding-block: 26px 40px; display: flex; flex-wrap: wrap; gap: 10px 26px; justify-content: space-between; color: var(--muted); font-size: .9rem; }
.site-foot nav { display: flex; flex-wrap: wrap; gap: 6px 18px; }
.site-foot a { color: inherit; }

@media (prefers-reduced-motion: no-preference) {
  .book-card, .social, .btn, .nav a { transition: border-color .15s ease, background-color .15s ease, filter .15s ease; }
}
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Пресс-кит */
.press-books { display: grid; gap: 28px; }
.press-book { display: grid; grid-template-columns: minmax(0, 220px) 1fr; gap: 32px; align-items: start;
  padding: 28px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); color: var(--ink); }
.press-book h3 { font-family: var(--font-display); font-size: clamp(1.6rem, 3vw, 2.2rem); margin: 6px 0 16px; color: var(--accent); }
/* «Скоро» — в гамме будущей книги: чёрный космос и оранжевый. */
.press-soon { --surface: #0b0706; --line: #ff8a2a40; --accent: #ff8a2a; --ink: #f3efe8; --muted: #c9b8a6; }
.press-text p:first-child::first-letter { all: unset; }
.press-text { font-size: 1.02rem; }
.press-book .actions { flex-wrap: wrap; }
button.btn { font: inherit; cursor: pointer; }
@media (max-width: 700px) {
  .press-book { grid-template-columns: 1fr; padding: 20px; }
  .press-book .cover { max-width: 200px; }
}

/* Компактный первый экран для служебных разделов (фан-арт, дневник) */
.page-hero { min-height: 0 !important; padding: 48px 0 8px !important; }

/* Фан-арт */
.fan-filter { margin-bottom: 22px; }
.fan-grid { columns: 3 16rem; column-gap: 16px; }
.fan-grid[aria-busy="true"] { opacity: .5; }
.fan-card { break-inside: avoid; margin: 0 0 16px; border-radius: var(--radius); overflow: hidden; background: var(--surface); border: 1px solid var(--line); }
.fan-card > a { display: block; background: color-mix(in srgb, var(--ink) 6%, transparent); }
.fan-card img { width: 100%; height: auto; }
.fan-card figcaption { display: grid; gap: 2px; padding: 12px 14px 14px; font-size: .92rem; }
.fan-cap { color: var(--ink); }
.fan-credit { color: var(--muted); }
.fan-credit::before { content: "— "; }
.fan-book { font-size: .72rem; letter-spacing: .12em; text-transform: uppercase; color: var(--accent); margin-top: 4px; }
.fan-empty { display: grid; gap: 10px; justify-items: start; }
.fan-empty p { margin: 0; }
.fan-row { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(11rem, 15rem); gap: 14px; overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: 6px; }
.fan-row .fan-card { margin: 0; scroll-snap-align: start; }
.fan-row .fan-card img { aspect-ratio: 4 / 5; object-fit: cover; }

/* Дневник автора */
.diary { display: grid; gap: 18px; }
.diary-post { border-radius: var(--radius); overflow: hidden; background: var(--surface); border: 1px solid var(--line); }
.diary-img { display: block; background: color-mix(in srgb, var(--ink) 6%, transparent); }
.diary-img img { width: 100%; max-height: 420px; object-fit: cover; }
.diary-body { padding: 18px 20px 16px; }
.diary-body .kicker { margin-bottom: 8px; }
.diary-text { white-space: pre-line; overflow-wrap: anywhere; max-height: 15em; overflow: hidden; }
.diary-post.open .diary-text { max-height: none; }
.diary-foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 16px; margin-top: 12px; font-size: .92rem; }
.diary-foot a { margin-left: auto; }
.diary-more { background: none; border: 0; padding: 0; cursor: pointer; font: inherit; color: var(--accent); }
.diary-all { margin: 6px 0 0; text-align: center; }
.diary-all .btn { display: inline-flex; }
.diary-off { display: grid; gap: 10px; justify-items: start; }
.diary-off p { margin: 0; }
.diary-note { margin: 0 0 14px; }
[data-skin~="cinema"] .fan-card, [data-skin~="cinema"] .diary-post {
  background: #ffffff0c; border-color: #ffffff1c;
  backdrop-filter: blur(18px) saturate(1.3); -webkit-backdrop-filter: blur(18px) saturate(1.3);
}

/* Новости через бота и лист ожидания новой книги (главная) */
.optin .wrap { padding-block: 40px 8px; }
.optin-grid { display: grid; gap: 16px; }
@media (min-width: 760px) { .optin-grid { grid-template-columns: 1.2fr 1fr; } }
.optin-card { padding: 24px clamp(18px, 3vw, 30px); border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); }
[data-skin~="cinema"] .optin-card { background: #ffffff0c; border-color: #ffffff1c; backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); }
.optin-wait { border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.optin-card h2, [data-skin] .optin-card h2 { margin: 8px 0 10px; font-size: clamp(1.15rem, 3vw, 1.5rem); line-height: 1.15; }
.optin-card .muted { margin: 0 0 18px; }
.optin-msg { margin: 12px 0 0; font-size: .92rem; color: var(--accent); }

/* Поле-ловушка для ботов в форме регистрации: человек его не видит. */
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
