/* Сайт целиком: меню «Главы», плашка, главная, подписка, конец главы, вопросник.
   Цвета, шрифты и отступы берутся из styles.css («бумажная книга»), тёмная тема работает через те же переменные.
   Логические свойства: готово к RTL. */

/* ---------- меню «Главы» в верхней панели ---------- */
.topbar-inner { position: relative; }
.brand { text-decoration: none; }
.menu summary { list-style: none; }
.menu summary::-webkit-details-marker { display: none; }
.menu-btn {
  display: inline-flex; align-items: center; gap: 6px;
  min-block-size: 44px; padding-inline: 14px;
  font: 700 15px/1 var(--serif); color: var(--ink);
  background: var(--paper); border: 1px solid var(--line); border-radius: 22px;
  cursor: pointer; user-select: none; white-space: nowrap;
}
.menu[open] .menu-btn { border-color: var(--accent); }
.menu-btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.menu-panel {
  position: absolute; inset-block-start: calc(100% + 4px); inset-inline: var(--gutter);
  max-inline-size: 22rem;
  padding: 6px; background: var(--paper);
  border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow);
  animation: appear .2s ease both;
}
.menu-list a, .menu-foot a {
  display: flex; align-items: center; gap: 12px;
  min-block-size: 48px; padding: 6px 10px; border-radius: 10px;
  font: 700 16px/1.3 var(--serif); color: var(--ink); text-decoration: none;
}
.menu-list a:hover, .menu-foot a:hover { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.menu-list { list-style: none; margin: 0; padding: 0; }
.menu-list a[aria-current="page"], .menu-foot a[aria-current="page"] { background: color-mix(in srgb, var(--accent) 16%, transparent); }
.menu-foot { margin-block-start: 4px; padding-block-start: 4px; border-block-start: 1px dashed var(--line); }
.menu-foot a { color: var(--accent); }
.menu-n { font: 600 24px/1 var(--hand); color: var(--accent); min-inline-size: 1ch; }

/* ---------- плашка «История начинается с главы 1» ---------- */
.start-banner {
  display: flex; align-items: center; gap: 4px;
  margin: 0 0 16px; padding: 2px 4px 2px 14px;
  background: color-mix(in srgb, var(--accent) 12%, var(--paper));
  border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
  border-radius: 12px;
}
.start-banner-link {
  flex: 1; display: flex; align-items: center; min-block-size: 48px;
  font: 700 16px/1.3 var(--serif); color: var(--accent); text-decoration: none;
}
.start-banner-link:hover { text-decoration: underline; text-underline-offset: 3px; }
.start-banner-close {
  flex: none; inline-size: 48px; block-size: 48px;
  background: none; border: 0; border-radius: 10px; cursor: pointer;
  font: 400 26px/1 var(--serif); color: var(--muted);
}
.arrow { display: inline-block; margin-inline-start: .25em; }
:dir(rtl) .arrow { transform: scaleX(-1); }

/* ---------- главная ---------- */
body.shelf-page, body.book-page, body.survey-page { padding-block-end: 40px; }
/* подзаголовок главной — обычная фраза, а не метка капсом */
body.book-page .kicker { text-transform: none; letter-spacing: 0; font-size: 18px; }
.about { margin-block: 20px 0; }
.about p { margin: 0 0 1em; }
.home-actions { display: grid; gap: 12px; margin: 24px 0 8px; }
.toc-title-h { margin-block: 32px 12px; }
.toc { list-style: none; margin: 0 0 8px; padding: 0; display: grid; gap: 10px; }
.toc-link {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 14px; min-block-size: 64px;
  background: var(--paper); border: 1px solid var(--line); border-radius: 14px;
  color: var(--ink); text-decoration: none;
}
a.toc-link { box-shadow: var(--shadow); }
a.toc-link:hover { border-color: var(--accent); }
.toc-thumb {
  flex: none; inline-size: 52px; block-size: 72px;
  border-radius: 6px; object-fit: cover; object-position: 50% 50%;
  border: 1px solid var(--line); background: var(--bg);
}
.toc-num {
  display: flex; align-items: center; justify-content: center;
  font: 600 34px/1 var(--hand); color: var(--muted); border-style: dashed;
}
.toc-body { flex: 1; min-inline-size: 0; display: flex; flex-direction: column; gap: 2px; }
.toc-kicker { font-size: 14px; line-height: 1.2; color: var(--muted); }
.toc-title { font-weight: 700; font-size: 19px; line-height: 1.25; }
.toc-desc { font-size: 15px; line-height: 1.45; color: var(--muted); }
.tag {
  flex: none; align-self: flex-start;
  padding: 3px 10px; border-radius: 999px;
  font: 700 13px/1.3 var(--serif); color: var(--muted);
  border: 1px solid var(--line);
}
.tag-new { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); }
.toc-item.is-soon .toc-link { background: transparent; border-style: dashed; box-shadow: none; }
.toc-item.is-soon .toc-title { color: var(--muted); }

/* ---------- подписка ---------- */
.subscribe {
  margin: 32px 0 8px; padding: 16px 16px 18px;
  background: var(--paper); border: 2px solid var(--ink); border-radius: 16px;
  box-shadow: 5px 5px 0 color-mix(in srgb, var(--ink) 25%, transparent);
}
.subscribe .sub { margin-block: 0 8px; }
.subscribe-lead { margin: 0 0 14px; }
.subscribe-form { display: grid; gap: 14px; }
.subscribe .fld input[type="text"], .survey .fld input[type="text"] { min-block-size: 52px; font-size: 18px; }
.subscribe .fld input[aria-invalid="true"], .survey .fld input[aria-invalid="true"] { border-color: var(--red); }
.consent {
  display: flex; align-items: flex-start; gap: 12px;
  min-block-size: 48px; padding: 6px 0; cursor: pointer; font-size: 16px; line-height: 1.4;
}
.consent input { inline-size: 24px; block-size: 24px; flex: none; margin: 0; accent-color: var(--accent); }
.subscribe-done { margin: 0; font: 600 28px/1.25 var(--hand); color: var(--accent); }

/* ---------- конец главы ---------- */
.chapter-end { margin-block-start: 8px; }
.next-chapter { margin: 28px 0 8px; display: grid; gap: 6px; justify-items: center; text-align: center; }
.next-chapter .btn { text-decoration: none; }
.next-title { font-size: 15px; color: var(--muted); }
.invite { margin: 28px 0 8px; padding-block-start: 4px; border-block-start: 1px dashed var(--line); }
.invite .sub { margin-block-start: 20px; }
.invite p { margin: 0 0 14px; }
.invite .btn { text-decoration: none; }
.chapter-end .subscribe { margin-block-start: 24px; }

/* ---------- вопросник ---------- */
.survey-intro { margin: 12px 0 0; color: var(--muted); font-size: 17px; }
.survey { display: grid; gap: 22px; margin-block-start: 20px; }
.survey .fld label, .survey .radios legend { display: block; font-weight: 700; font-size: 17px; color: var(--ink); margin-block-end: 6px; }
.survey .opt { font-weight: 400; font-size: 15px; color: var(--muted); }
.survey .fld textarea {
  inline-size: 100%; padding: 10px 12px; min-block-size: 112px; resize: vertical;
  font: 17px/1.5 var(--serif); color: var(--ink);
  background: var(--paper); border: 2px solid var(--line); border-radius: 10px;
}
.survey .fld textarea:focus, .survey .fld input:focus { border-color: var(--accent); }
.survey .radios { gap: 8px; }
.survey .radio { flex: 1 1 10rem; }
.survey .radio span { padding: 8px 12px; text-align: center; }
.survey .field-note { margin-block: 0 8px; }
.survey-done { text-align: start; }
.survey-done .thanks { margin-block-start: 28px; }
.survey-done .btn { text-decoration: none; margin-block-start: 8px; }

@media (min-width: 720px) {
  body.shelf-page, body.book-page, body.survey-page { padding-block-end: 64px; }
  .home-actions { grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); }
  .subscribe-form { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  .menu-panel { animation: none; }
}

/* ---------- платформа «Мадаф»: шапка, язык, крошки, полка ---------- */
.topbar-inner { gap: 8px; }
.brand { min-inline-size: 0; white-space: nowrap; }
.lang { display: flex; align-items: center; gap: 4px; flex: none; font: 700 14px/1 var(--serif); }
.lang-on, .lang-off {
  display: inline-flex; align-items: center; gap: 5px;
  min-block-size: 32px; padding-inline: 9px; border-radius: 16px;
}
.lang-on { color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent); }
.lang-off { color: var(--muted); border: 1px dashed var(--line); cursor: default; }
.lang-soon { font: 400 11px/1 var(--serif); }
.he-short { display: none; }
@media (max-width: 430px) {
  .he-full { display: none; }
  .he-short { display: inline; }
  .has-progress .lang-soon { display: none; }
  .has-progress .menu-label { display: none; }
  .has-progress .menu-btn { min-inline-size: 44px; padding-inline: 0; justify-content: center; }
  .has-progress .progress-label { font-size: 14px; }
  .topbar-inner { padding-inline: 12px; }
}
@media (max-width: 370px) {
  .has-progress .brand { font-size: 23px; }
  .topbar-inner { gap: 6px; }
  .lang-on, .lang-off { padding-inline: 7px; }
}

.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 0 8px; margin: 0 0 8px; font-size: 14px; line-height: 1.3; color: var(--muted); }
.crumbs a { display: inline-flex; align-items: center; min-block-size: 32px; color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.crumbs [aria-current="page"] { color: var(--ink); }

.shelf-lead { margin: 12px 0 0; font-size: 18px; color: var(--muted); }
.shelf { list-style: none; margin: 24px 0 8px; padding: 0; display: grid; gap: 12px; }
.book-card {
  display: flex; align-items: stretch; gap: 16px; padding: 14px;
  background: var(--paper); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow);
}
.book-cover {
  flex: none; display: block; inline-size: 96px; block-size: 128px;
  border: 1px solid var(--line); border-radius: 6px; overflow: hidden; background: var(--bg);
}
.book-cover img { display: block; inline-size: 100%; block-size: 100%; object-fit: cover; }
:root[data-theme="dark"] .book-cover img { filter: brightness(.88) saturate(.92); }
.book-info { flex: 1; min-inline-size: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.book-title { margin: 0; font-size: 22px; line-height: 1.2; }
.book-title a { color: inherit; text-decoration: none; }
.book-hero { margin: 0; font-size: 16px; line-height: 1.4; }
.book-progress { margin: 0 0 10px; font-size: 15px; color: var(--muted); }
.book-info .btn { margin-block-start: auto; text-decoration: none; }
.book-card-soon { align-items: center; background: transparent; border-style: dashed; box-shadow: none; }
.book-cover-soon { display: flex; align-items: center; justify-content: center; border-style: dashed; font: 600 44px/1 var(--hand); color: var(--muted); }
.book-soon-label { margin: 0; font-weight: 700; font-size: 18px; color: var(--muted); }
@media (min-width: 720px) {
  .shelf { grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr)); }
}
