/* ============================================================================
   Momo UI — единственный файл стилей сайта.
   Подключается и статическими страницами, и SSR-хендлерами из api/,
   поэтому заголовок, абзац, кнопка, панель и полка выглядят одинаково везде.
   Порядок: токены → база → типографика → кнопки → панели → полка →
   компоненты страницы книги → 3D-книжка на главной → мелочи.
   На статических страницах подключается ДО tailwind.css, чтобы утилиты
   Tailwind при необходимости перебивали базовые правила.
   ========================================================================== */

/* --- Токены ------------------------------------------------------------- */
:root {
  --sky: #007DAD;

  --text: #ffffff;
  --text-soft: rgba(255, 255, 255, 0.85);
  --text-muted: rgba(255, 255, 255, 0.7);
  --text-faint: rgba(255, 255, 255, 0.55);

  --panel-bg: rgba(255, 255, 255, 0.22);
  --panel-bg-hover: rgba(255, 255, 255, 0.32);
  --panel-line: rgba(255, 255, 255, 0.28);
  --panel-shadow: 0 10px 30px rgba(0, 60, 90, 0.18);
  --radius: 1.25rem;
  --radius-sm: 0.75rem;

  /* Ширина колонки контента. Совпадает с max-w-5xl на главной, поэтому
     логотип и кнопки в шапке стоят ровно по краям контента страницы. */
  --content-max: 1024px;
  --content-pad: 16px;

  --font-title: 'Alice', Georgia, serif;
  --font-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

  /* Полка: высота картинки доски. Дерево занимает верхние ~17px из 106px,
     ниже — прозрачная тень. Книга ставится вплотную на кромку доски. */
  --shelf-h: 106px;
  --shelf-shadow-cut: calc(var(--shelf-h) * -0.585);
}

@media (max-width: 560px) {
  :root { --shelf-h: 78px; }
}

/* --- База --------------------------------------------------------------- */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

html { margin: 0; padding: 0; overflow-x: hidden; }

body {
  margin: 0;
  overflow-x: hidden;
  font-family: var(--font-body);
  color: var(--text);
  background-color: var(--sky);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

.relative.min-h-screen,
.page-shell {
  min-height: 100vh;
  min-height: 100dvh;
  position: relative;
}

/* Фон-небо */
.page-bg-video,
.page-bg-video.inset-style {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  object-fit: cover;
  z-index: 0;
  pointer-events: none;
}

.video-gradient-overlay-top,
.video-gradient-overlay-bottom {
  position: fixed;
  left: 0;
  width: 100vw;
  height: 50vh;
  pointer-events: none;
  z-index: 1;
  display: none;
}

.video-gradient-overlay-top {
  top: 0;
  background: linear-gradient(180deg, #007DAD 0%, rgba(0,125,173,0.99) 6.67%, rgba(0,125,173,0.96) 13.33%, rgba(0,125,173,0.92) 20%, rgba(0,125,173,0.85) 26.67%, rgba(0,125,173,0.77) 33.33%, rgba(0,125,173,0.67) 40%, rgba(0,125,173,0.56) 46.67%, rgba(0,125,173,0.44) 53.33%, rgba(0,125,173,0.33) 60%, rgba(0,125,173,0.23) 66.67%, rgba(0,125,173,0.15) 73.33%, rgba(0,125,173,0.08) 80%, rgba(0,125,173,0.04) 86.67%, rgba(0,125,173,0.01) 93.33%, rgba(0,125,173,0) 100%);
}

.video-gradient-overlay-bottom {
  bottom: 0;
  background: linear-gradient(180deg, rgba(0,125,173,0) 0%, rgba(0,125,173,0.01) 6.67%, rgba(0,125,173,0.04) 13.33%, rgba(0,125,173,0.08) 20%, rgba(0,125,173,0.15) 26.67%, rgba(0,125,173,0.23) 33.33%, rgba(0,125,173,0.33) 40%, rgba(0,125,173,0.44) 46.67%, rgba(0,125,173,0.56) 53.33%, rgba(0,125,173,0.67) 60%, rgba(0,125,173,0.77) 66.67%, rgba(0,125,173,0.85) 73.33%, rgba(0,125,173,0.92) 80%, rgba(0,125,173,0.96) 86.67%, rgba(0,125,173,0.99) 93.33%, #007DAD 100%);
}

@media screen and (max-width: 768px) {
  .video-gradient-overlay-top,
  .video-gradient-overlay-bottom { display: block; }

  /* Safe area на контейнере контента */
  .relative.min-h-screen > .mx-auto,
  .content-wrap {
    padding-top: max(16px, env(safe-area-inset-top));
    padding-bottom: max(16px, env(safe-area-inset-bottom));
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
  }
}

/* --- Типографика -------------------------------------------------------- */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-title);
  color: var(--text);
  line-height: 1.2;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

h1 { font-size: 2.25rem; font-weight: 700; }
h2 { font-size: 1.6rem; font-weight: 700; }
h3 { font-size: 1.15rem; font-weight: 700; }
h4 { font-size: 1rem; font-weight: 700; }

@media (max-width: 640px) {
  h1 { font-size: 1.75rem; }
  h2 { font-size: 1.35rem; }
}

p {
  color: var(--text-soft);
  line-height: 1.7;
}

/* Вводный абзац под заголовком секции */
.lead {
  font-size: 1.1rem;
  color: var(--text-soft);
  line-height: 1.6;
}

.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }

/* Мелкая надпись капсом: категория книги, номер главы, метка секции */
.eyebrow {
  font-family: var(--font-title);
  font-size: 0.75rem;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-muted);
}

.section-title {
  text-align: center;
  margin-bottom: 20px;
}

/* --- Ссылки и кнопки ---------------------------------------------------- */
a { color: inherit; }

.link-subtle {
  color: var(--text-muted);
  text-decoration: underline;
  transition: color 0.2s ease;
}
.link-subtle:hover { color: var(--text); }

.btn {
  display: inline-block;
  font-weight: 700;
  font-size: 1.05rem;
  padding: 14px 32px;
  border-radius: 9999px;
  border: 2px solid transparent;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.25s ease, color 0.25s ease, transform 0.25s ease, box-shadow 0.25s ease;
}

.btn-primary {
  background: #ffffff;
  color: #111111;
}
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
}

.btn-outline {
  background: transparent;
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.85);
}
.btn-outline:hover {
  background: #ffffff;
  color: #111111;
}

.btn-sm { font-size: 0.9rem; padding: 10px 22px; }

/* Исторический класс кнопки на SSR-страницах — тот же вид, что .btn .btn-primary */
.cta-button {
  display: inline-block; font-weight: 700; font-size: 1.05rem;
  padding: 14px 32px; border-radius: 9999px; border: none; cursor: pointer;
  background: #ffffff; color: #111111; text-decoration: none;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}
.cta-button:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(0,0,0,0.2); }

/* Колонка текста на страницах книги и лендингах */
article { max-width: 680px; margin: 0 auto; }

/* --- Панели и разделители ----------------------------------------------- */
/* Подложка есть только у того, что можно нажать. Текстовые блоки живут
   прямо на небе — их держат заголовок и разделители, а не рамка.
   Раньше все блоки были rgba(255,255,255,0.1) с белым контуром и читались
   как пустые рамки вокруг текста. */
.glass-panel,
.glass-card {
  background: none;
  box-shadow: none;
  border: none;
  border-radius: var(--radius);
}

.glass-panel { overflow: hidden; }

/* Панель без подложки, но с контуром — когда блок надо отделить от неба,
   не заливая его. */
.glass-panel.is-outlined { border: 1px solid var(--panel-line); }

/* Кликабельные поверхности: ссылка-плитка, кнопка-панель */
a.glass-card,
.panel-grid > a,
.surface {
  background: var(--panel-bg);
  -webkit-backdrop-filter: blur(16px) saturate(120%);
  backdrop-filter: blur(16px) saturate(120%);
  box-shadow: var(--panel-shadow);
  transition: background 0.25s ease, box-shadow 0.25s ease, transform 0.25s ease;
}
a.glass-card:hover,
.surface:hover {
  background: var(--panel-bg-hover);
  box-shadow: 0 14px 36px rgba(0, 60, 90, 0.24);
}

/* Соседние блоки — ячейки одной панели, разделённые линиями, а не отдельные
   плитки с полями. Границы на ячейках (а не gap), чтобы линии доходили до
   краёв панели и не рвали полупрозрачный фон. */
.panel-grid { display: grid; grid-template-columns: 1fr; }
.panel-grid > * { padding: 24px; }
.panel-grid > * + * { border-top: 1px solid var(--panel-line); }
.panel-grid > a { text-decoration: none; color: inherit; }
.panel-grid > a:hover { background: var(--panel-bg-hover); }

.panel-grid.cols-2-sm { grid-template-columns: 1fr 1fr; }
.panel-grid.cols-2-sm > * { border-top: none; }
.panel-grid.cols-2-sm > *:nth-child(even) { border-left: 1px solid var(--panel-line); }
.panel-grid.cols-2-sm > *:nth-child(n+3) { border-top: 1px solid var(--panel-line); }

@media (min-width: 768px) {
  .panel-grid.cols-2 { grid-template-columns: 1fr 1fr; }
  .panel-grid.cols-2 > * { border-top: none; border-left: none; }
  .panel-grid.cols-2 > *:nth-child(even) { border-left: 1px solid var(--panel-line); }
  .panel-grid.cols-2 > *:nth-child(n+3) { border-top: 1px solid var(--panel-line); }

  .panel-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
  .panel-grid.cols-3 > * { border-top: none; border-left: none; }
  .panel-grid.cols-3 > *:not(:nth-child(3n+1)) { border-left: 1px solid var(--panel-line); }
  .panel-grid.cols-3 > *:nth-child(n+4) { border-top: 1px solid var(--panel-line); }
}

.section-divider {
  height: 1px;
  border: 0;
  max-width: 900px;
  margin: 0 auto;
  background: linear-gradient(90deg, rgba(255,255,255,0) 0%, rgba(255,255,255,0.4) 50%, rgba(255,255,255,0) 100%);
}

/* --- Полка -------------------------------------------------------------- */
/* Одна доска на весь сайт: главная, страница книги, главы серии, списки книг.
   Ширина торцов считается от --shelf-h, иначе при ужимании только ширины
   background-size:contain съезжает и по высоте — торцы уходят ниже доски. */
.shelf-plank {
  display: flex;
  align-items: flex-end;
  height: var(--shelf-h);
  position: relative;
  z-index: 1;
}

.shelf-plank .shelf-left-edge,
.shelf-plank .shelf-right-edge {
  width: calc(var(--shelf-h) * 120 / 106);
  height: var(--shelf-h);
  flex-shrink: 0;
  background-size: contain;
}
.shelf-plank .shelf-left-edge { background: url('/images/shelf-left-edge.png') no-repeat left center; background-size: contain; }
.shelf-plank .shelf-right-edge { background: url('/images/shelf-right-edge.png') no-repeat right center; background-size: contain; }
.shelf-plank .shelf-middle {
  flex: 1;
  min-width: 0;
  height: var(--shelf-h);
  background: url('/images/shelf-middle.png') repeat-x center center;
  background-size: auto var(--shelf-h);
}

@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .shelf-plank .shelf-left-edge { background-image: url('/images/shelf-left-edge@2x.png'); }
  .shelf-plank .shelf-right-edge { background-image: url('/images/shelf-right-edge@2x.png'); }
  .shelf-plank .shelf-middle { background-image: url('/images/shelf-middle@2x.png'); }
}

/* Шапка страницы книги: название сверху, категория и номер главы под ним */
.hero-title { font-family: var(--font-title); font-size: 2rem; font-weight: 700; line-height: 1.2; color: var(--text); }
.hero-category { font-family: var(--font-body); font-size: 0.85rem; color: var(--text-muted); margin-top: 6px; }
.hero-chapter { font-size: 0.8rem; color: var(--text-faint); margin-top: 4px; }
@media (max-width: 560px) { .hero-title { font-size: 1.6rem; } }

/* Одна книга на полке — шапка страницы книги */
.hero-shelf { width: 100%; max-width: 520px; margin: 20px auto var(--shelf-shadow-cut); }
.hero-cover { position: relative; display: block; width: 180px; height: 271px; margin: 0 auto; z-index: 2; }
@media (max-width: 560px) {
  .hero-cover { width: 150px; height: 226px; }
}

/* Сетка полок для списков книг: секция = одна книга + её отрезок доски.
   Сколько книг в линии, решает грид: 4 / 3 / 2 по ширине экрана. Колонки
   фиксированной ширины, крайние шире — за счёт этого доска заметно выступает
   за крайние книги, а расстояния между всеми книгами в линии одинаковые
   (по 10px отступа с каждой стороны книги = 20px между соседями). */
.shelf-grid {
  --slot: 154px;
  --slot-edge: 200px;
  display: grid;
  grid-template-columns: var(--slot-edge) var(--slot-edge);
  justify-content: center;
  align-items: stretch;
  margin: 0 auto;
}
@media (min-width: 640px) {
  .shelf-grid { grid-template-columns: var(--slot-edge) var(--slot) var(--slot-edge); }
}
@media (min-width: 880px) {
  .shelf-grid { grid-template-columns: var(--slot-edge) var(--slot) var(--slot) var(--slot-edge); }
}

.shelf-unit {
  margin-bottom: var(--shelf-shadow-cut);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.shelf-slot {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0 10px;
  min-height: 250px;
}

.shelf-book {
  position: relative;
  z-index: 2;
  flex-shrink: 0;
  text-align: center;
  text-decoration: none;
  color: var(--text);
  transition: transform 0.3s ease;
}
.shelf-book:hover { transform: translateY(-5px); }

.shelf-book-title {
  font-family: var(--font-title);
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.shelf-book-meta {
  font-family: var(--font-body);
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.shelf-book-cover { position: relative; margin: 0 auto; }
.shelf-book-cover .art { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.shelf-book-cover .frame { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 10; pointer-events: none; }
.shelf-book-cover .placeholder { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 2rem; background: rgba(255,255,255,0.12); }
.shelf-age-badge {
  position: absolute; top: 6px; right: 6px; z-index: 11;
  background: rgba(0,0,0,0.55); color: #fff;
  font-size: 0.65rem; font-weight: 700; padding: 2px 7px; border-radius: 9999px;
}

/* Торцы доски — только по краям линии. Внутренние отрезки идут серединной
   текстурой, поэтому стыков не видно. Крайние книги прижимаем к внутренней
   стороне своей колонки, чтобы вылет доски ушёл наружу. */
/* Прячем только внутри сетки списков: у одиночных полок (шапка страницы книги,
   полка глав) торцы нужны всегда. */
.shelf-grid .shelf-left-edge,
.shelf-grid .shelf-right-edge { display: none; }

@media (max-width: 639px) {
  .shelf-unit:nth-child(2n+1) .shelf-left-edge,
  .shelf-unit:nth-child(2n) .shelf-right-edge { display: block; }
  .shelf-unit:nth-child(2n+1) .shelf-slot { justify-content: flex-end; }
  .shelf-unit:nth-child(2n) .shelf-slot { justify-content: flex-start; }
  /* одинокая книга в последнем ряду: доска с обоими торцами шире колонки */
  .shelf-unit:last-child:nth-child(2n+1) .shelf-plank { width: 240px; margin-left: -20px; }
}
@media (min-width: 640px) and (max-width: 879px) {
  .shelf-unit:nth-child(3n+1) .shelf-left-edge,
  .shelf-unit:nth-child(3n) .shelf-right-edge { display: block; }
  .shelf-unit:nth-child(3n+1) .shelf-slot { justify-content: flex-end; }
  .shelf-unit:nth-child(3n) .shelf-slot { justify-content: flex-start; }
  .shelf-unit:last-child:nth-child(3n+1) .shelf-plank { width: 240px; margin-left: -20px; }
}
@media (min-width: 880px) {
  .shelf-unit:nth-child(4n+1) .shelf-left-edge,
  .shelf-unit:nth-child(4n) .shelf-right-edge { display: block; }
  .shelf-unit:nth-child(4n+1) .shelf-slot { justify-content: flex-end; }
  .shelf-unit:nth-child(4n) .shelf-slot { justify-content: flex-start; }
  .shelf-unit:last-child:nth-child(4n+1) .shelf-plank { width: 240px; margin-left: -20px; }
}

/* Последняя секция всегда закрывает доску торцом, даже если ряд неполный */
.shelf-unit:last-child .shelf-right-edge { display: block; }

@media (max-width: 560px) {
  .shelf-grid { --slot: 140px; --slot-edge: 168px; }
  .shelf-slot { min-height: 210px; }
}

/* Полка глав серии — горизонтальный скролл внутри себя */
.chapters-scroll { overflow-x: auto; overflow-y: visible; -webkit-overflow-scrolling: touch; display: flex; }
.chapters-content { display: inline-block; min-width: min-content; margin: 0 auto; }
.chapters-row { display: flex; align-items: flex-end; justify-content: center; gap: 28px; padding: 0 40px; }
.chapter-card {
  position: relative; z-index: 2; flex-shrink: 0; width: 110px;
  text-align: center; text-decoration: none; color: var(--text);
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.chapter-card:hover { transform: translateY(-4px); }
.chapter-num { font-size: 0.65rem; letter-spacing: 1px; text-transform: uppercase; color: var(--text-muted); margin-bottom: 4px; }
.chapter-name {
  font-family: var(--font-title); font-size: 0.8rem; line-height: 1.25; margin-bottom: 8px;
  overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.chapter-cover { position: relative; width: 110px; height: 166px; }
.chapter-cover .art { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.chapter-cover .frame { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; z-index: 10; pointer-events: none; }
.chapter-card.is-current .chapter-num { color: var(--text); }
.chapter-card.is-current .chapter-cover::after {
  content: ''; position: absolute; inset: -4px; z-index: 11;
  border: 2px solid rgba(255,255,255,0.85); border-radius: 4px;
}
.chapters-nav {
  display: flex; flex-wrap: wrap; gap: 16px; justify-content: center;
  margin-top: calc(var(--shelf-shadow-cut) + 28px); font-size: 0.85rem;
}
.chapters-nav a { color: rgba(255,255,255,0.85); text-decoration: underline; }

@media (max-width: 560px) {
  .chapters-row { gap: 18px; padding: 0 20px; }
}

/* --- Компоненты страницы книги ------------------------------------------ */
.story-text { font-size: 1.1rem; line-height: 1.4; color: rgba(255,255,255,0.95); margin-bottom: 16px; }

/* Превью истории: максимум 10 строк, дальше — разворот. Гасим не подложкой,
   а маской по самому тексту, иначе градиент не совпал бы с фоном-небом. */
.story-preview { overflow: hidden; }
.story-preview:not(.is-open) {
  max-height: calc(10 * 1.4 * 1.1rem);
  -webkit-mask-image: linear-gradient(180deg, #000 62%, transparent 100%);
  mask-image: linear-gradient(180deg, #000 62%, transparent 100%);
}
/* Свёрнутый текст сам является кнопкой: клик по нему раскрывает историю.
   Подпись-подсказку сюда не поставить — маска затухания гасит и псевдоэлемент. */
.story-preview.is-clickable { cursor: pointer; }

/* Плавающая кнопка «читать историю» */
.cta-float {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: max(20px, env(safe-area-inset-bottom));
  z-index: 60;
  display: inline-block;
  padding: 14px 32px;
  border-radius: 9999px;
  background: #ffffff;
  color: #111111;
  font-weight: 700;
  font-size: 1rem;
  text-decoration: none;
  box-shadow: 0 8px 28px rgba(0, 40, 60, 0.35);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}
.cta-float:hover { transform: translateX(-50%) translateY(-2px); box-shadow: 0 12px 34px rgba(0, 40, 60, 0.42); }

/* Плавающая кнопка перекрывает низ страницы — освобождаем под неё место */
body:has(.cta-float) { padding-bottom: 96px; }
.story-illustration { width: 100%; max-width: 480px; margin: 24px auto; border-radius: 12px; display: block; }

.story-meta { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 16px; }
.meta-pill {
  display: inline-flex; align-items: center; gap: 4px;
  background: rgba(255,255,255,0.15); border: 1px solid rgba(255,255,255,0.25);
  border-radius: 9999px; padding: 5px 14px; font-size: 0.8rem; color: rgba(255,255,255,0.9);
}
.meta-pill svg { width: 14px; height: 14px; opacity: 0.8; }

.cta-box {
  background: none;
  border-radius: var(--radius);
  padding: 32px;
  text-align: center;
  margin: 40px 0;
}

/* Фильтры в каталоге */
.filter-btn {
  display: inline-block; padding: 6px 16px; border-radius: 9999px;
  background: rgba(255,255,255,0.14); color: var(--text);
  font-size: 0.85rem; text-decoration: none; transition: background 0.2s ease;
}
.filter-btn:hover { background: rgba(255,255,255,0.24); }
.filter-btn.active { background: #ffffff; color: #111111; font-weight: 700; }

/* --- 3D-книжка на полке главной ----------------------------------------- */
.featured-books-shelves {
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  margin-bottom: -128px;
}

.shelf-container { position: relative; margin-bottom: 40px; padding-bottom: 20px; }

.shelf-scroll-wrapper {
  width: 100%;
  overflow-x: auto;
  overflow-y: visible;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.3) transparent;
  display: flex;
}
.shelf-scroll-wrapper::-webkit-scrollbar { height: 8px; }
.shelf-scroll-wrapper::-webkit-scrollbar-track { background: transparent; }
.shelf-scroll-wrapper::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.3); border-radius: 4px; }
.shelf-scroll-wrapper::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.5); }

.shelf-content { display: inline-block; min-width: min-content; margin: 0 auto; }

/* Нижнего отступа быть не должно: книга стоит прямо на кромке доски.
   Раньше здесь было padding-bottom: 20px, которое ровно гасилось
   margin-top: -20px у доски. */
.books-row {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 36px;
  padding: 0 40px;
  min-height: 280px;
  margin: 0 auto;
}

.book-card {
  opacity: 1;
  transition: opacity 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  flex-shrink: 0;
  position: relative;
  z-index: 10;
  cursor: pointer;
  transform-style: preserve-3d;
  perspective: 1200px;
  animation: momoFadeIn 0.5s ease forwards;
}
.shelf-content:has(.book-card:hover) .book-card:not(:hover) { opacity: 0.3; }
.shelf-content .book-card:hover { opacity: 1; }

.empty-shelf-message {
  display: flex; align-items: center; justify-content: center; height: 200px;
  font-family: var(--font-title); font-size: 24px; color: var(--text-muted);
}

.book-link { text-decoration: none; color: inherit; display: block; position: relative; transform-style: preserve-3d; }

.book-spine {
  position: absolute; left: 0;
  background: linear-gradient(90deg, #8B4513 0%, #654321 50%, #8B4513 100%);
  border-radius: 4px 4px 0 0; z-index: 0;
}

.book-cover-container {
  position: relative;
  transform-style: preserve-3d;
  -webkit-transform-style: preserve-3d;
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: transform;
  transform-origin: left center;
  z-index: 4;
  border-radius: 4px 4px 0 0;
}
.book-cover-container::after {
  content: '';
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  background: #f5f5dc;
  transform: rotateY(180deg);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: 4px 4px 0 0;
}

.book-cover-front {
  position: absolute; left: 0;
  transform-style: preserve-3d;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: 4px 4px 0 0;
}

.book-cover-back {
  position: absolute; left: 0;
  background: #f5f5dc;
  border-radius: 4px 4px 0 0;
  transform: rotateY(180deg);
  transform-style: preserve-3d;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  opacity: 1; z-index: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 20px 12px;
}

.book-author-info { text-align: center; font-family: var(--font-title); color: #2c2c2c; }
.book-author-label { font-size: 11px; color: #666; margin-bottom: 6px; line-height: 1.2; }
.book-author-name { font-size: 16px; font-weight: 600; margin-bottom: 4px; line-height: 1.3; color: #2c2c2c; }
.book-author-age { font-size: 13px; color: #666; line-height: 1.2; }

.book-page-text {
  font-family: var(--font-title); font-size: 11px; line-height: 1.4; color: #2c2c2c;
  text-align: left; overflow: hidden; text-overflow: ellipsis;
  display: -webkit-box; -webkit-box-orient: vertical;
  word-wrap: break-word; width: 100%; padding: 16px 12px;
}

.book-cover-image { position: absolute; left: 0; object-fit: cover; object-position: center; border-radius: 4px 4px 0 0; }
.book-cover-layer { position: absolute; left: 0; z-index: 10; object-fit: contain; object-position: center; border-radius: 4px 4px 0 0; }

.book-info { margin-bottom: 12px; text-align: center; padding: 0 8px; }
.book-title {
  font-family: var(--font-title); font-size: 16px; color: var(--text); font-weight: 600;
  line-height: 1.3; margin-bottom: 4px;
  overflow: hidden; text-overflow: ellipsis;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.book-category {
  font-family: var(--font-body); font-size: 12px; color: var(--text-muted);
}

.book-shine {
  position: absolute; inset: 0; width: 100%; height: 100%;
  border-radius: 4px 4px 0 0; pointer-events: none;
  opacity: 0; transition: opacity 0.3s ease; z-index: 15; mix-blend-mode: overlay;
}

.book-page {
  position: absolute; left: 0;
  transform-style: preserve-3d; transform-origin: left center;
  transition: transform 0.5s ease-in-out, box-shadow 0.35s ease-in-out;
  background: #f5f5f5; border-radius: 4px 4px 0 0;
}
.book-page-1 { background: #efefef; z-index: 3; }
.book-page-2 { background: #f0f0f0; z-index: 2; }
.book-page-3 { background: #f5f5f5; z-index: 1; }

.book-card:hover .book-cover-container { transform: rotateY(-150deg) scale(1.05); }
.book-card:hover .book-page-1 { transform: rotateY(-32deg) scale(1.02); }
.book-card:hover .book-page-2 { transform: rotateY(-24deg) scale(1.02); }
.book-card:hover .book-page-3 { transform: rotateY(-16deg) scale(1.02); }

@media (max-width: 1400px) { .books-row { gap: 30px; } }
@media (max-width: 1024px) {
  .books-row { gap: 24px; }
  .shelf-container { margin-bottom: -60px; padding-bottom: 80px; }
  .book-title { font-size: 14px; }
  .book-category { font-size: 11px; }
}
@media (max-width: 768px) {
  .books-row { gap: 20px; min-height: 240px; padding: 0 40px; }
  .shelf-container { margin-bottom: -50px; padding-bottom: 70px; }
  .book-title { font-size: 13px; }
  .book-category { font-size: 10px; }
  .book-info { margin-top: 8px; }
}
@media (max-width: 480px) {
  .books-row { gap: 16px; min-height: 220px; }
}

.shelf-loading {
  display: flex; justify-content: center; align-items: center; min-height: 300px;
  font-family: var(--font-title); font-size: 18px; color: var(--text-muted);
}

@keyframes momoFadeIn {
  from { transform: translateY(20px); }
  to { transform: translateY(0); }
}

/* --- Мелочи ------------------------------------------------------------- */
.phone-frame { max-width: 100%; height: auto; transition: transform 0.3s ease; }
.phone-scroll-container { -webkit-overflow-scrolling: touch; scrollbar-width: none; -ms-overflow-style: none; }
.phone-scroll-container::-webkit-scrollbar { display: none; }

input, textarea { background: rgba(255, 255, 255, 0.1); }
input:focus, textarea:focus {
  outline: none;
  border-color: rgba(255, 255, 255, 0.4);
  background: rgba(255, 255, 255, 0.15);
}

/* --- Шапка сайта ---------------------------------------------------------
   Поведение как на tryclue.app: наверху прозрачная и висит над контентом,
   после ~80px прокрутки заливается и получает тень. Слева логотип, справа
   ссылка на каталог. sticky, а не fixed, чтобы контент не приходилось
   подпирать отступом на каждой странице. */
/* fixed, а не sticky: у html/body стоит overflow-x: hidden, из-за чего body
   становится скролл-контейнером и sticky перестаёт цепляться за вьюпорт.
   Высоту шапки компенсируем отступом сверху у body. */
.site-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  background-color: transparent;
  transition: background-color 0.3s ease, box-shadow 0.3s ease, backdrop-filter 0.3s ease;
}
.site-nav.is-scrolled {
  background-color: rgba(0, 105, 146, 0.78);
  -webkit-backdrop-filter: blur(14px) saturate(120%);
  backdrop-filter: blur(14px) saturate(120%);
  box-shadow: 0 4px 20px rgba(0, 40, 60, 0.18);
}

/* Отступы у самой шапки, ограничение по ширине — у строки. Ровно та же схема,
   что у секций главной (px-4 sm:px-6 lg:px-10 + max-w-5xl mx-auto), поэтому
   края шапки совпадают с краями контента. */
.site-nav {
  padding-left: max(var(--content-pad), env(safe-area-inset-left));
  padding-right: max(var(--content-pad), env(safe-area-inset-right));
}

.site-nav-row {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 14px 0;
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  transition: padding 0.3s ease;
}
.site-nav.is-scrolled .site-nav-row { padding-top: 8px; padding-bottom: 8px; }

.site-nav-logo { display: inline-flex; align-items: center; }
.site-nav-logo img { height: 40px; width: auto; display: block; transition: height 0.3s ease; }
.site-nav.is-scrolled .site-nav-logo img { height: 32px; }

.site-nav-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: 9999px;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  background: rgba(255, 255, 255, 0.18);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  transition: background 0.25s ease, color 0.25s ease;
}
.site-nav-link:hover { background: #ffffff; color: #111111; }

.site-nav-actions { display: flex; align-items: center; gap: 10px; }

/* Кнопка скачивания в шапке подхватывает эстафету у геройской: появляется,
   когда та ушла с экрана. До этого её нет, чтобы на первом экране не было
   двух одинаковых кнопок. */
.site-nav-download {
  background: #ffffff;
  color: #111111;
  /* Схлопывается по ширине, а не просто прячется: иначе «Browse Books» стоял бы
     на месте, оставив справа пустоту. Появляясь, кнопка сдвигает его влево. */
  opacity: 0;
  pointer-events: none;
  max-width: 0;
  padding-left: 0;
  padding-right: 0;
  overflow: hidden;
  white-space: nowrap;
  transition: opacity 0.3s ease, max-width 0.35s ease, padding 0.35s ease, background 0.25s ease, color 0.25s ease;
}
.site-nav.show-cta .site-nav-download {
  opacity: 1;
  pointer-events: auto;
  max-width: 260px;
  padding-left: 18px;
  padding-right: 18px;
}
.site-nav-download img { width: 16px; height: 16px; }

body { padding-top: 72px; }

@media (min-width: 640px) { :root { --content-pad: 24px; } }
@media (min-width: 1024px) { :root { --content-pad: 40px; } }

@media (max-width: 560px) {
  body { padding-top: 60px; }
  .site-nav-row { min-height: 60px; padding-top: 10px; padding-bottom: 10px; }
  .site-nav-logo img { height: 32px; }
  .site-nav-link { padding: 7px 14px; font-size: 0.85rem; }
}

/* Кнопка App Store: иконка Apple + подпись, как на tryclue.app */
.btn-appstore { display: inline-flex; align-items: center; gap: 8px; }
.btn-appstore img { width: 18px; height: 18px; display: block; }

/* Небольшая кнопка-ссылка: полупрозрачная подложка с блюром. Для второстепенных
   переходов вроде «Learn more about how Momo works». */
.link-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  border-radius: 9999px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  background: rgba(255, 255, 255, 0.16);
  -webkit-backdrop-filter: blur(10px) saturate(120%);
  backdrop-filter: blur(10px) saturate(120%);
  transition: background 0.25s ease, color 0.25s ease, transform 0.25s ease;
}
.link-pill:hover { background: #ffffff; color: #111111; transform: translateY(-1px); }
