/* Лорбокс — макеты версии 2.
   Один файл на все страницы. Палитра, шрифты и правила — из docs/45-dizayn-v2.md. */

:root {
  --paper: #fbfaf7;
  --ink: #1c1f22;
  --muted: #5c6266;
  --line: #e3e0d8;
  --line-strong: #8E8B82;
  --accent: #2f6f6a;
  --action: #b4552d;
  --danger: #8c3b32;
  --radius-card: 12px;
  --radius-btn: 10px;
  --gap: 8px;
  --max: 1120px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #141618;
    --ink: #e8e6e1;
    --muted: #a1a6a8;
    --line: #2a2d30;
    --line-strong: #616668;
    --accent: #7fb3ac;
    --action: #b4552d;
    --danger: #d9867c;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 16px/1.55 "PT Sans", "Segoe UI", system-ui, sans-serif;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { font-family: "PT Serif", Georgia, serif; font-weight: 600; line-height: 1.25; margin: 0; }
h1 { font-size: 30px; }
h2 { font-size: 22px; }
h3 { font-size: 18px; }

.wrap { max-width: var(--max); margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }

/* Шапка */

.topbar {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
}
.topbar__in { display: flex; align-items: center; gap: 12px; height: 56px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 700; }
.brand:hover { text-decoration: none; }
.brand__mark {
  width: 32px; height: 32px; border: 1.5px solid var(--ink); border-radius: 8px;
  display: grid; place-items: center; font: 700 13px/1 "PT Sans", sans-serif; letter-spacing: .5px;
}
.brand__name { font-family: "PT Serif", Georgia, serif; font-size: 18px; }
.topnav { margin-left: auto; display: flex; gap: 16px; align-items: center; }
.topnav a { color: var(--muted); font-size: 15px; }

/* Кнопки */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-btn);
  background: transparent; color: var(--ink);
  font: 500 16px/1 "PT Sans", sans-serif; cursor: pointer;
}
.btn:hover { border-color: var(--muted); text-decoration: none; }
.btn--action { background: var(--action); border-color: var(--action); color: #fff; }
.btn--action:hover { filter: brightness(.95); }
.btn--block { width: 100%; }
.btn--quiet { border-color: transparent; color: var(--muted); padding: 0 8px; }

/* Герой */

.hero { padding: 40px 0 24px; }
.hero h1 { max-width: 18ch; }
.hero p { max-width: 46ch; color: var(--muted); margin: 12px 0 20px; }
.hero__actions { display: flex; flex-wrap: wrap; gap: 10px; }

/* Секции и карточки */

section { padding: 24px 0; }
.section-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 14px; }
.section-head a { margin-left: auto; font-size: 15px; }

.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }

.card {
  display: flex; flex-direction: column;
  border: 1px solid var(--line); border-radius: var(--radius-card);
  overflow: hidden; background: var(--paper); color: var(--ink);
}
.card:hover { text-decoration: none; border-color: var(--muted); }
.card__cover { aspect-ratio: 3 / 4; background: var(--line); display: grid; place-items: center; }
.card__cover span { font: 700 13px/1 "PT Sans", sans-serif; color: var(--muted); letter-spacing: .08em; text-transform: uppercase; }
.card__body { padding: 10px 12px 14px; display: grid; gap: 6px; }
.card__title { font-family: "PT Serif", Georgia, serif; font-size: 17px; font-weight: 600; }
.card__meta { font-size: 13px; color: var(--muted); }

/* Метки */

.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  border: 1px solid var(--line); font-size: 12px; color: var(--muted);
}
.badge--paid { border-color: var(--action); color: var(--action); }
.badge--free { border-color: var(--accent); color: var(--accent); }

/* Библиотека */

.filters { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 18px; }
.filters input, .filters select {
  min-height: 44px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: var(--radius-btn);
  background: var(--paper); color: var(--ink); font: 400 15px "PT Sans", sans-serif;
}
.filters input { flex: 1 1 220px; }

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

.book { display: grid; gap: 18px; grid-template-columns: 1fr; padding: 24px 0; }
@media (min-width: 760px) { .book { grid-template-columns: 260px 1fr; } }
.book__cover { aspect-ratio: 3 / 4; border: 1px solid var(--line); border-radius: var(--radius-card); display: grid; place-items: center; }
.book__cover span { color: var(--muted); text-transform: uppercase; letter-spacing: .08em; font-size: 13px; }
.book h1 { font-size: 28px; }
.book__meta { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 12px; }
.book__desc { color: var(--muted); max-width: 56ch; }
.rules { border-top: 1px solid var(--line); padding-top: 14px; margin-top: 16px; display: grid; gap: 8px; }
.rules div { display: flex; gap: 10px; font-size: 15px; }
.rules b { min-width: 84px; }

/* Читалка */

.reader { max-width: 720px; margin: 0 auto; padding: 20px 16px 96px; }
.reader__top { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; font-size: 14px; color: var(--muted); margin-bottom: 18px; }
.reader__top > span:not(.reader__stats) { white-space: nowrap; }
.reader__stats { display: flex; gap: 10px; margin-left: auto; }
.stat { border: 1px solid var(--line); border-radius: 999px; padding: 2px 9px; font-size: 12px; color: var(--ink); white-space: nowrap; }
.reader h2 { font-size: 22px; margin-bottom: 12px; }
.reader p { font-size: 19px; line-height: 1.65; margin: 0 0 16px; }
.reader em { color: var(--muted); }

.choices { display: grid; gap: 10px; margin: 22px 0; }
.choice {
  display: flex; align-items: center; gap: 12px; width: 100%;
  min-height: 52px; padding: 12px 14px; text-align: left;
  border: 1px solid var(--line-strong); border-radius: var(--radius-card);
  background: transparent; color: var(--ink); font: 400 16px "PT Sans", sans-serif; cursor: pointer;
}
.choice:hover { border-color: var(--accent); }
.choice__cost { margin-left: auto; font-size: 13px; color: var(--action); white-space: nowrap; }

.progress { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); }
.progress__bar { flex: 1; height: 2px; background: var(--line); border-radius: 2px; overflow: hidden; }
.progress__bar i { display: block; height: 100%; width: 34%; background: var(--accent); }

.rewind { margin-top: 10px; font-size: 14px; color: var(--muted); }

/* Смерть и реклама */

.death { max-width: 640px; margin: 0 auto; padding: 40px 16px; text-align: left; }
.death h1 { margin-bottom: 10px; }
.death__actions { display: grid; gap: 10px; margin: 22px 0; }

.ad {
  border: 1px dashed var(--line); border-radius: var(--radius-card);
  padding: 14px; display: grid; gap: 10px; margin-top: 8px;
}
.ad__label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.ad__box { min-height: 96px; display: grid; place-items: center; color: var(--muted); font-size: 14px; }
.ad__close { justify-self: start; }
.ad[hidden] { display: none; }

/* Подписка */

.plans { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 760px) { .plans { grid-template-columns: 1fr 1fr; } }
.plan { border: 1px solid var(--line); border-radius: var(--radius-card); padding: 20px; display: grid; gap: 12px; }
.plan--main { border-color: var(--accent); }
.plan h2 { font-size: 24px; }
.plan ul { margin: 0; padding-left: 18px; color: var(--muted); display: grid; gap: 6px; }
.plan__price { font-family: "PT Serif", Georgia, serif; font-size: 28px; }

/* Нижняя панель и подвал */

.sheet { border: 1px solid var(--line); border-radius: var(--radius-card); padding: 16px; margin: 16px 0; display: grid; gap: 10px; }
.sheet[hidden] { display: none; }
.sheet label { font-size: 14px; color: var(--muted); display: grid; gap: 6px; }
.sheet textarea, .sheet select, .sheet input[type="text"] {
  width: 100%; padding: 10px; border: 1px solid var(--line-strong); border-radius: var(--radius-btn);
  background: var(--paper); color: var(--ink); font: 400 15px "PT Sans", sans-serif;
}
.rating { display: flex; gap: 6px; flex-wrap: wrap; }
.rating button { min-width: 40px; min-height: 40px; border: 1px solid var(--line); border-radius: 8px; background: transparent; color: var(--ink); cursor: pointer; }
.rating button[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }

footer { border-top: 1px solid var(--line); margin-top: 32px; padding: 22px 0 40px; color: var(--muted); font-size: 14px; }
footer nav { display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 10px; }

.fab {
  position: fixed; right: 16px; bottom: 16px; z-index: 20;
  width: 48px; height: 48px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--paper); color: var(--ink); font-size: 20px; cursor: pointer;
}

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* Узкие телефоны: шапка в три ссылки должна помещаться */
@media (max-width: 520px) {
  .topnav { gap: 10px; }
  .topnav a { font-size: 13px; }
  .brand__name { font-size: 16px; }
  .brand__mark { width: 28px; height: 28px; font-size: 12px; }
}

/* Иллюстрации в макетах */
.card__cover img, .book__cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.book__cover { overflow: hidden; }
.reader__art { margin: 0 0 18px; border: 1px solid var(--line); border-radius: var(--radius-card); overflow: hidden; }
.reader__art img { display: block; width: 100%; height: auto; }
.gallery { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.gallery figure { margin: 0; }
.gallery img { width: 100%; height: auto; display: block; border: 1px solid var(--line); border-radius: var(--radius-card); }
.gallery figcaption { font-size: 13px; color: var(--muted); margin-top: 6px; }

/* Читалка на телефоне: текст не должен уезжать за край */
.reader p, .reader h2 { overflow-wrap: break-word; }
@media (max-width: 520px) {
  .topnav__book { display: none; }
  .reader { padding-left: 12px; padding-right: 12px; }
}

/* Узкий экран: ресурсы уходят на свою строку, а не сжимают текст */
@media (max-width: 560px) {
  .reader__top { display: block; }
  .reader__stats { margin-left: 0; margin-top: 8px; flex-wrap: wrap; }
  .reader__stats .stat { font-size: 12px; }
}
