/* ============================================================
   Turnleaves — chapter_reel.css: «Живая страница» (web/src/chapter_reel.ts; внутреннее имя — рилс главы).

   Вид — по макету `LivingPage.dc.html` (классы `.lp-*` там ↔ `.reel-*` здесь), на общих токенах styles.css
   (`--ink`, `--ink2`, `--ink3`, `--line`, `--line2`, `--raised`, `--surface`, `--gold`, `--gold-text`,
   `--on-gold`, `--shadow`, `--shadow-soft`, `--scrim`, `--font-ui`, `--font-serif`). `--sel` в проде есть только
   под `body.rd`; карточка при наведении — `--raised`, как в макете. Золото — только у кнопки подтверждения в листе, у кнопки
   тоста (как в проде) и у точки на «⋯» (07 §0 п. 10). Свои тёмные токены — только у просмотрщика (06 M11).
   ============================================================ */

/* UA-правило [hidden] слабее любого авторского display: без него скрытые кнопки кадра остаются видны. */
.chapter-reel [hidden], .reel-vwrap [hidden], .reel-modal [hidden], #book-menu .reel-bmdot[hidden] { display: none !important; }

.reel-vh {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
}

/* --- блок в конце главы: строка постоянной высоты, без кадра 9:16 (07 §5) --- */
.chapter-reel {
  max-width: 640px; margin: 36px auto 0; outline: none; font-family: var(--font-ui); color: var(--ink);
  scroll-margin-bottom: 150px;
}
.chapter-reel:focus-visible { outline: 2px solid var(--gold-text); outline-offset: 4px; border-radius: 8px; }
.reel-in { display: flex; flex-direction: column; justify-content: center; min-height: 88px; }
.chapter-reel.reel-compact .reel-in { min-height: 0; }

.reel-offer {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "btn desc quiet";
  align-items: center; column-gap: 16px; row-gap: 4px;
}
.reel-offer .reel-rbtn { grid-area: btn; }
.reel-offer .reel-rdesc { grid-area: desc; }
.reel-offer .reel-quiet { grid-area: quiet; }

/* Контурная кнопка строки («Оживить страницу», «Попробовать ещё раз»): без золота, перенос разрешён. */
.reel-rbtn {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px; min-height: 44px; padding: 0 18px;
  box-sizing: border-box; border: 1px solid var(--line2); border-radius: 12px; background: transparent;
  color: var(--ink); font: inherit; font-size: 14.5px; font-weight: 600; line-height: 1.25; text-align: center;
  cursor: pointer; transition: border-color .15s; max-width: 100%; overflow-wrap: anywhere;
}
.reel-rbtn:hover { border-color: var(--ink3); }
/* Тихая кнопка («Больше не предлагать», «Отменить», «К главе»): обычное начертание, подчёркивание при наведении. */
.reel-quiet {
  display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0; border: 0;
  background: none; color: var(--ink2); font: inherit; font-size: 13.5px; font-weight: 400; line-height: 1.25;
  white-space: nowrap; text-underline-offset: 3px; cursor: pointer;
}
.reel-quiet--lo { color: var(--ink3); }
.reel-quiet:hover { text-decoration: underline; }
.chapter-reel [aria-disabled="true"], .reel-modal [aria-disabled="true"] { opacity: .55; cursor: progress; }

.reel-rdesc, .reel-rnote { margin: 0; font-size: 13.5px; line-height: 1.45; color: var(--ink3); }
.reel-rmsg { margin: 0; font-size: 15px; line-height: 1.45; color: var(--ink2); }
.chapter-reel.reel-compact .reel-rmsg { font-size: 13.5px; color: var(--ink3); }
.reel-mrow { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 6px 16px; }
.reel-mcol { display: flex; flex-direction: column; gap: 2px; min-width: 0; }

/* Ход: подпись этапа и процент, сплошная линия, тихая строка (11). */
.reel-prog { display: flex; flex-direction: column; gap: 8px; }
.reel-prow { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; }
.reel-sline { display: flex; align-items: baseline; flex-wrap: wrap; gap: 2px 10px; min-width: 0; }
.reel-stage { font-size: 15px; line-height: 1.4; color: var(--ink); }
.reel-step { font-size: 13px; color: var(--ink3); font-variant-numeric: tabular-nums; white-space: nowrap; }
.reel-pbar { position: relative; height: 5px; border-radius: 3px; overflow: hidden; background: var(--line2); }
.reel-pbar--sm { height: 3px; border-radius: 2px; }
.reel-pbar i {
  position: absolute; left: 0; top: 0; bottom: 0; border-radius: inherit; background: var(--ink2);
  transition: width .5s linear; overflow: hidden;
}
.reel-pbar i.is-run::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, var(--shine, rgba(255, 250, 238, .5)), transparent);
  transform: translateX(-100%); animation: reel-shine 2.2s ease-in-out infinite;
}
@keyframes reel-shine { to { transform: translateX(100%); } }

/* Линии готовности других глав (11). */
.reel-others { display: flex; flex-direction: column; gap: 12px; padding: 6px 0; }
.reel-others.reel-with-own { padding-bottom: 16px; margin-bottom: 4px; border-bottom: 1px solid var(--line); }
.reel-orow { display: flex; flex-direction: column; gap: 6px; }
.reel-ohead { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.reel-olabel { font-size: 13.5px; line-height: 1.35; color: var(--ink2); }
.reel-opct { flex: none; font-size: 13px; color: var(--ink3); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Карточка готового видео: одна кнопка, плитка 9:16 с ▶, «Живая страница» и метка ИИ (RESOLUTION look 6). */
.reel-readyrow { display: flex; align-items: center; justify-content: space-between; gap: 8px 12px; }
.reel-againcol { align-items: flex-end; text-align: right; }
.reel-card {
  display: flex; align-items: center; gap: 14px; flex: 1 1 auto; min-width: 0; margin: 0 -8px; padding: 8px;
  border: 0; border-radius: 14px; background: transparent; color: var(--ink); font: inherit; text-align: left;
  cursor: pointer; transition: background .15s;
}
.reel-card:hover, .reel-card:focus-visible { background: var(--raised); }
.reel-card:hover .reel-cmeta, .reel-card:focus-visible .reel-cmeta { color: var(--ink2); }
.reel-tile {
  position: relative; flex: none; display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 72px; box-sizing: border-box; border: 1px solid var(--line2); border-radius: 6px;
  overflow: hidden; background: var(--img-bg, var(--raised)); color: var(--ink);
}
.reel-tile--empty { background: transparent; border-style: dashed; }
.reel-tpl {
  position: relative; display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px;
  border-radius: 50%; background: rgba(10, 8, 6, .55); color: #EEE7D9;
}
.reel-ctext { display: block; min-width: 0; }
.reel-ctitle { display: block; font-size: 15px; font-weight: 600; line-height: 1.35; }
.reel-cmeta { display: block; margin-top: 2px; font-size: 13.5px; line-height: 1.4; color: var(--ink3); }

/* Доставка: готовое видео другой главы ждёт в конце главы, которую читатель дочитывает (08). */
.reel-deliv { display: flex; align-items: center; min-height: 88px; }
.reel-deliv.reel-with-own { min-height: 0; padding-bottom: 12px; margin-bottom: 4px; border-bottom: 1px solid var(--line); }

@media (max-width: 719.9px) {
  .reel-in { min-height: 112px; }
  .reel-offer { grid-template-columns: auto minmax(0, 1fr); grid-template-areas: "btn quiet" "desc desc"; }
  .reel-offer .reel-quiet { justify-self: end; }
}
@media (max-width: 419.9px) {
  .reel-tile { width: 34px; height: 60px; }
  .reel-card { gap: 12px; }
  .reel-readyrow { flex-wrap: wrap; row-gap: 0; }
  .reel-readyrow .reel-quiet { margin-left: 46px; }
  .reel-againcol { align-items: flex-start; text-align: left; margin-left: 46px; }
  .reel-againcol .reel-quiet { margin-left: 0; }
}

/* --- «⋯»: точка на кнопке и у пункта ------------------------------------------ */
#book-menu-btn { position: relative; }
.reel-mdot {
  position: absolute; top: 7px; right: 8px; width: 8px; height: 8px; border-radius: 50%; background: var(--gold);
  box-shadow: 0 0 0 2px var(--surface); pointer-events: none;
}
.reel-bmdot { display: inline-block; flex: none; width: 7px; height: 7px; margin-left: 8px; border-radius: 50%; background: var(--gold); }

/* --- окна: лист раскрытия и список «Живые страницы» (прод .modal / .modal-card / .modal-head) --- */
.reel-modal .reel-dlg { display: flex; flex-direction: column; max-width: 520px; padding: 0; overflow: hidden; }
.reel-modal.reel-ls .reel-dlg { max-width: 520px; }
.reel-dbody { flex: 1 1 auto; min-height: 0; overflow: auto; padding: 24px 28px 0; }
.reel-modal .modal-head h3 { line-height: 1.3; }
.reel-modal .modal-head h3:focus-visible { outline: none; }
.reel-x { display: inline-flex; align-items: center; justify-content: center; margin-right: -10px; }
.reel-x:hover { color: var(--ink); }
.reel-dlead { margin: 0; font-size: 15px; line-height: 1.55; color: var(--ink2); }
.reel-dfine { margin: 12px 0 0; font-size: 13.5px; line-height: 1.5; color: var(--ink3); }
.reel-plan-note { margin: 12px 0 0; font-size: 14px; line-height: 1.5; color: var(--ink2); }
.reel-plan-note p { margin: 0; }
.reel-plan { width: 100%; margin: 12px 0; border-collapse: collapse; font-size: 13px; line-height: 1.4; }
.reel-plan th, .reel-plan td { padding: 6px 4px; text-align: end; vertical-align: bottom; }
.reel-plan th { font-weight: 500; overflow-wrap: anywhere; hyphens: auto; }
.reel-plan th[scope="row"] { width: 36%; padding-inline-start: 0; text-align: start; color: var(--ink2); }
.reel-plan thead { border-bottom: 1px solid var(--line); }
.reel-plan td { font-variant-numeric: tabular-nums; }
.reel-derr { margin: 12px 0 0; font-size: 13.5px; line-height: 1.45; color: var(--ink2); }
.reel-dfoot {
  flex: none; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px;
  padding: 18px 28px 26px; background: var(--surface);
}
.reel-pb { flex: 1 1 200px; min-height: 46px; }
.reel-gb { flex: none; min-width: 120px; min-height: 46px; }
.reel-lslist { list-style: none; margin: 0; padding: 0 0 22px; display: flex; flex-direction: column; gap: 4px; }
.reel-lsli { margin: 0; padding: 0; }
.reel-lsrow { width: calc(100% + 16px); box-sizing: border-box; }
.reel-lsstat { display: flex; align-items: center; gap: 14px; margin: 0 -8px; padding: 8px; }
.reel-lsstat .reel-ctext { flex: 1 1 auto; }
.reel-lsdot { margin-left: auto; margin-right: 6px; }
/* Уже 720 — нижний лист без ручки (перетаскивания нет). */
@media (max-width: 719.9px) {
  .reel-modal { align-items: flex-end; padding: 0; }
  .reel-modal .reel-dlg { max-width: none; max-height: 88vh; border-radius: 20px 20px 0 0; border-width: 0; }
  .reel-dbody { padding: 18px 18px 0; }
  .reel-dfoot { padding: 16px 18px calc(20px + env(safe-area-inset-bottom)); }
}
@media (max-width: 419.9px) {
  .reel-sheet .reel-pb, .reel-sheet .reel-gb { flex: 1 1 100%; }
}

/* --- просмотрщик: свои тёмные токены в обеих темах; уже 820 — во весь экран ---- */
.reel-vwrap {
  position: fixed; inset: 0; z-index: 130; display: flex; background: #0B0A09; color: #EEE7D9;
  font-family: var(--font-ui);
}
.reel-vwrap.hidden { display: none; }
.reel-vwrap :focus-visible { outline: 2px solid #D9B878; outline-offset: 2px; }
.reel-vcard { display: flex; flex-direction: column; width: 100%; height: 100%; outline: none; }
.reel-vtop {
  flex: none; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; box-sizing: border-box;
  padding: calc(10px + env(safe-area-inset-top)) 6px 10px 16px;
}
.reel-vtt { display: flex; flex-direction: column; gap: 2px; min-width: 0; padding-top: 2px; }
.reel-vtitle { margin: 0; font-size: 15px; font-weight: 600; line-height: 1.3; color: #EEE7D9; }
.reel-vtitle:focus-visible { outline: none; }
.reel-vch { display: none; margin: 0; }
.reel-vlabel { margin: 0; font-size: 13px; line-height: 1.4; color: #B0A38D; }
.reel-vx {
  flex: none; display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border: 0;
  border-radius: 10px; background: none; color: #B0A38D; cursor: pointer;
}
.reel-vx:hover { background: rgba(238, 231, 217, .08); color: #EEE7D9; }
.reel-vframe {
  position: relative; flex: 1 1 auto; min-height: 0; display: flex; align-items: center; justify-content: center;
  container-type: size;
}
.reel-vbox {
  position: relative; width: min(100cqw, calc(100cqh * 9 / 16)); height: min(100cqh, calc(100cqw * 16 / 9));
  overflow: hidden; background: #1E1A16;
}
.reel-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.reel-vbig {
  position: absolute; left: 50%; top: 50%; display: flex; align-items: center; justify-content: center;
  width: 64px; height: 64px; margin: -32px 0 0 -32px; border: 0; border-radius: 50%; background: rgba(10, 8, 6, .6);
  color: #EEE7D9; cursor: pointer;
}
.reel-vctl {
  position: absolute; left: 0; right: 0; bottom: 0; display: flex; align-items: flex-end; justify-content: space-between;
  gap: 8px; padding: 0 10px 14px;
}
.reel-vbtn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-width: 44px; height: 44px;
  box-sizing: border-box; padding: 0 14px; border: 0; border-radius: 999px; background: rgba(10, 8, 6, .6); color: #EEE7D9;
  font: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer;
}
.reel-vbtn--sq { padding: 0; }
.reel-vsp { width: 44px; height: 44px; }
.reel-vend { position: absolute; left: 0; right: 0; bottom: 22px; display: flex; justify-content: center; padding: 0 12px; }
.reel-vbar { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: rgba(238, 231, 217, .17); }
.reel-vbar i { display: block; width: 0; height: 100%; background: #EEE7D9; transition: width .2s linear; }
.reel-vload, .reel-vmsg {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; padding: 20px; box-sizing: border-box; text-align: center; font-size: 14.5px; line-height: 1.45;
}
.reel-vload { pointer-events: none; background: rgba(10, 8, 6, .35); }
.reel-vmsg { background: rgba(10, 8, 6, .72); }
.reel-vghost {
  min-height: 44px; padding: 0 16px; border: 1px solid rgba(238, 231, 217, .17); border-radius: 10px; background: none;
  color: #EEE7D9; font: inherit; font-size: 14px; cursor: pointer;
}
.reel-vghost:hover { border-color: #9A8E77; }
.reel-vbot { flex: none; display: flex; flex-direction: column; gap: 2px; padding: 8px 16px calc(8px + env(safe-area-inset-bottom)); }
.reel-vlinks { display: flex; flex-wrap: wrap; align-items: center; gap: 0 20px; }
.reel-vq {
  min-height: 44px; padding: 0; border: 0; background: none; color: #B0A38D; font: inherit; font-size: 13.5px;
  text-underline-offset: 3px; cursor: pointer;
}
.reel-vq:hover { color: #EEE7D9; text-decoration: underline; }
/* От 820 — диалог одной колонкой по ширине кадра (без описания сцены: его нет в DTO, RESOLUTION look 2). */
@media (min-width: 820px) {
  .reel-vwrap { align-items: center; justify-content: center; padding: 24px; box-sizing: border-box; background: rgba(10, 8, 6, .86); }
  .reel-vcard {
    display: grid; grid-template-columns: auto; grid-template-rows: auto auto auto; grid-template-areas: "top" "frame" "bot";
    width: auto; height: auto; max-height: 100%; padding: 20px 24px 12px; box-sizing: border-box;
    border: 1px solid rgba(238, 231, 217, .09); border-radius: 16px; background: #1C1916; box-shadow: 0 24px 60px rgba(0, 0, 0, .5);
  }
  .reel-vtop { grid-area: top; padding: 0 0 16px; }
  .reel-vframe { grid-area: frame; container-type: normal; flex: none; }
  .reel-vbox { width: auto; height: min(68vh, 640px); aspect-ratio: 9 / 16; border-radius: 10px; }
  .reel-vbot { grid-area: bot; justify-content: flex-start; padding: 6px 0 0; }
  .reel-vtitle { font-family: var(--font-serif); font-size: 20px; }
  .reel-vch { display: block; margin-top: 4px; font-size: 14px; line-height: 1.4; color: #B0A38D; }
  .reel-vlabel { margin-top: 6px; font-size: 13.5px; }
  .reel-vx { margin: -10px -10px 0 0; }
}

/* --- тост: кнопка 44 px модификатором (общий .toast-btn в проде 32 px, 07 §3.4) --- */
#toasts .toast-reel .toast-btn { min-height: 44px; }

/* --- меньше движения: без блика и плавного роста ширины (11; 07 §6) ------------ */
html[data-motion="reduce"] .reel-pbar i { transition: none; }
html[data-motion="reduce"] .reel-pbar i.is-run::after { display: none; }
@media (prefers-reduced-motion: reduce) {
  .reel-pbar i { transition: none; }
  .reel-pbar i.is-run::after { display: none; }
}

/* «Aa» читалки v2 (reader_v2_text.js): группа «Конец главы» под «Оформлением» — отступ как у соседних подписей. */
body.reader-v2 #rv2-text .rv2-t-reels-cap { margin-top: 18px; }
