/* Главная страница: история по прокрутке (js/home.js — кадры видео на canvas) и финал под ней; плюс журнал копии
   для «Как работает». Без скриптов главы стоят текстом друг под другом; класс .is-live включает кадры фоном
   на весь экран (08.10.2026: холст fixed за всем содержимым, главы без плашек — на тени, которую рисует холст). */

/* ---------- история ---------- */
/* По умолчанию (без скриптов, «уменьшить движение»): картинка и главы друг под другом. */
.story { position: relative; }
.story-canvas, .story-steps, .scroll-hint { display: none; }
.story-poster { display: block; width: min(100%, 900px); height: auto; margin: 32px auto 0; padding: 0 20px; }
.story-text { display: grid; gap: 56px; padding: 40px 20px 24px; max-width: 1140px; margin: 0 auto; }
.chapter { max-width: 34rem; }
.chapter.intro { max-width: 40rem; }
/* Строка над заголовком — в одну строку на широком экране: справа от неё пусто, устройство ниже (15.10.2026). */
@media (min-width: 1200px) { .chapter.intro .eyebrow { white-space: nowrap; } }
.chapter h1 { font-family: var(--display); font-size: clamp(2.4rem, 4.8vw, 4.4rem); line-height: .97; letter-spacing: -.045em; font-weight: 800; margin-bottom: .42em; }
.chapter h1 em { font-style: normal; color: var(--accent-hi); }
.chapter h2 { font-family: var(--display); font-size: clamp(1.7rem, 3vw, 2.6rem); line-height: 1.02; letter-spacing: -.038em; font-weight: 800; margin-bottom: .5em; }
.chapter p { color: var(--ink-2); font-size: 1.06rem; }
.chapter .lead { font-size: 1.12rem; margin-bottom: 30px; color: #c3c7cf; }
/* Номер главы: моноширинный номер и слово — без капса и без цветной подписи. */
.step-no { display: flex; gap: 12px; align-items: baseline; margin-bottom: 16px; font-family: var(--mono); font-size: .86rem; color: var(--ink-2); }
.step-no b { font-weight: 500; color: var(--accent-hi); }
.step-no::after { content: ""; flex: 0 0 48px; height: 1px; background: var(--line-2); align-self: center; }
/* Что стоит за главой — строкой через косую черту, а не рядом меток. */
.chapter .proof { display: flex; flex-wrap: wrap; gap: 4px 0; margin: 20px 0 0; padding: 14px 0 0; list-style: none; border-top: 1px solid var(--line-2);
  font-family: var(--mono); font-size: .8rem; color: var(--ink-3); }
.chapter .proof li:not(:last-child)::after { content: "/"; margin: 0 10px; color: var(--line-2); }

.is-live { height: 520vh; }
.is-live .story-poster { display: none; }
/* Кадры — фоном на весь экран за всем содержимым страницы. */
.is-live .story-canvas { display: block; position: fixed; inset: 0; width: 100%; height: 100vh; z-index: 0; pointer-events: none; }
/* Затемнение (js/home.js) — свой холст над кадрами: перерисовывается только при смене размера окна. */
.is-live .story-veil { z-index: 0; }
/* Сцена с главами — под шапкой (64px), прозрачная: под ней холст. */
.is-live .story-stage { position: sticky; top: 64px; height: calc(100vh - 64px); height: calc(100svh - 64px); overflow: hidden; z-index: 1; }
.is-live .story-text { position: absolute; inset: 0; display: block; padding: 0; max-width: none; pointer-events: none; z-index: 1; }
.is-live .chapter {
  /* Левый край — по сетке сайта (.wrap); по высоте — по центру сцены. Сдвиг при появлении (--shift) задаёт js/home.js. */
  position: absolute; left: max(20px, calc((100% - 1140px) / 2 + 20px)); top: 50%;
  transform: translate3d(0, calc(-50% + var(--shift, 0px)), 0);
  width: clamp(22rem, 34vw, 30rem); pointer-events: auto; will-change: opacity, transform;
}
.is-live .chapter.intro { width: min(36rem, 42vw); }
/* Глава выше сцены (невысокий ноутбук; класс ставит js/home.js) — от верха сцены, а не по центру: иначе её начало
   («Резервные копии для 1С…») уходило под шапку. */
.is-live .chapter.tall { top: 20px; transform: translate3d(0, var(--shift, 0px), 0); }
/* Невысокий экран ноутбука: заголовок первого экрана по высоте окна, чтобы глава помещалась целиком. */
@media (min-width: 980px) and (max-height: 820px) { .is-live .chapter h1 { font-size: clamp(2.2rem, 7.2vh, 4.4rem); } }
.is-live .chapter p { color: #b9bdc6; }
/* Ход истории: четыре отрезка тонкой линии по сетке сайта, текущий заполняется малиновым. */
.is-live .story-steps {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; position: absolute; z-index: 1;
  left: max(20px, calc((100% - 1140px) / 2 + 20px)); right: max(20px, calc((100% - 1140px) / 2 + 20px)); bottom: 28px;
  margin: 0; padding: 0; list-style: none; font-family: var(--mono); font-size: .76rem; color: var(--ink-3);
  transition: opacity .4s;
}
.story-steps li { position: relative; padding-top: 12px; border-top: 1px solid rgba(255, 255, 255, .16); transition: color .3s; }
.story-steps li::before { content: ""; position: absolute; left: 0; top: -1px; height: 1px; width: 100%; background: var(--accent-hi);
  transform: scaleX(0); transform-origin: left; transition: transform .45s cubic-bezier(.2, .7, .2, 1); }
.story-steps li span { margin-right: 10px; }
.story-steps li.on { color: var(--ink); }
.story-steps li.on::before { transform: scaleX(1); }

.is-live .scroll-hint {
  display: flex; flex-direction: column; align-items: center; gap: 8px; position: absolute; right: max(20px, calc((100% - 1140px) / 2 + 20px)); bottom: 84px;
  font-family: var(--mono); font-size: .74rem; color: var(--ink-3); transition: opacity .4s; z-index: 1;
}
.scroll-hint::after {
  content: ""; width: 1px; height: 38px; background: linear-gradient(var(--ink-2), transparent);
  animation: hint 1.8s ease-in-out infinite; transform-origin: top;
}
.story-started .scroll-hint { opacity: 0; }
/* История досмотрена — полоса хода уходит, чтобы не висеть над финалом. */
.story-done .story-steps { opacity: 0; }
/* Невысокий экран ноутбука: строка-доказательство прячется, иначе глава налезает на полосу хода. */
@media (min-width: 980px) and (max-height: 760px) { .is-live .chapter .proof { display: none; } .is-live .chapter.intro .facts { margin-top: 18px; } }
@keyframes hint { 0% { transform: scaleY(0); } 60% { transform: scaleY(1); opacity: 1; } 100% { transform: scaleY(1); opacity: 0; } }

@media (max-width: 979px) {
  .is-live .chapter, .is-live .chapter.intro { top: auto; bottom: 28px; left: 20px; right: 20px; width: auto;
    transform: translate3d(0, var(--shift, 0px), 0); }
  .is-live .chapter .eyebrow { display: none; }
  .is-live .chapter.intro { bottom: 36px; }
  .is-live .chapter h1 { font-size: clamp(2rem, 8.6vw, 2.8rem); }
  .is-live .chapter h2 { font-size: clamp(1.6rem, 7vw, 2.2rem); }
  .is-live .chapter .lead, .is-live .chapter p { font-size: .98rem; }
  .is-live .chapter .lead { margin-bottom: 20px; }
  .is-live .chapter .facts, .is-live .story-steps, .is-live .scroll-hint { display: none; }
  .is-live .chapter .proof { margin-top: 14px; padding-top: 10px; font-size: .74rem; }
}
@media (max-width: 979px) and (max-height: 700px) { .is-live .chapter .proof { display: none; } }

/* ---------- финал под историей ---------- */
/* Лежит поверх последнего кадра (холст fixed): сверху прозрачно, книзу — цвет страницы, дальше подвал. */
.finale { position: relative; z-index: 1; padding: 22vh 0 40px;
  background: linear-gradient(180deg, rgba(8, 9, 12, 0) 0, rgba(8, 9, 12, .82) 18vh, var(--bg) 44vh); }
.finale-main { max-width: 46rem; }
.finale h2 { font-size: clamp(2rem, 4.2vw, 3.4rem); letter-spacing: -.045em; line-height: .98; margin-bottom: .45em; }
.finale .lead { color: #c3c7cf; margin-bottom: 30px; }
.index-links { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin-top: 88px; border-top: 1px solid var(--line-2); }
.index-links a { display: grid; gap: 6px; align-content: start; padding: 22px 24px 8px 0; color: var(--ink); }
.index-links a + a { padding-left: 24px; border-left: 1px solid var(--line); }
.index-links a:hover { text-decoration: none; }
.index-links b { font-family: var(--display); font-size: 1.2rem; font-weight: 700; letter-spacing: -.02em; }
.index-links b::after { content: " →"; color: var(--ink-3); transition: color .2s; }
.index-links a:hover b::after { color: var(--accent-hi); }
.index-links span { color: var(--ink-3); font-size: .92rem; }
@media (max-width: 860px) {
  .finale { padding-top: 16vh; }
  .index-links { grid-template-columns: 1fr 1fr; margin-top: 56px; }
  .index-links a:nth-child(3) { padding-left: 0; border-left: 0; }
  .index-links a:nth-child(n+3) { border-top: 1px solid var(--line); }
}
@media (max-width: 520px) {
  .index-links { grid-template-columns: 1fr; }
  .index-links a, .index-links a + a { padding: 16px 0; border-left: 0; }
  .index-links a + a { border-top: 1px solid var(--line); }
}

/* ---------- появление блоков ---------- */
.reveal-ready [data-reveal] { opacity: 0; transform: translateY(24px); transition: opacity .7s ease, transform .7s cubic-bezier(.2, .7, .2, 1); }
.reveal-ready [data-reveal].in { opacity: 1; transform: none; }

/* ---------- журнал одной копии («Как работает») ---------- */
.terminal { border-radius: 8px; border: 1px solid var(--line-2); background: #050608; overflow: hidden; }
.terminal-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 11px 16px;
  border-bottom: 1px solid var(--line); font-family: var(--mono); font-size: .76rem; color: var(--ink-3);
}
.terminal-bar .state { color: var(--ok); white-space: nowrap; }
.log { margin: 0; padding: 14px 0; list-style: none; font-family: var(--mono); font-size: .82rem; line-height: 1.5; overflow-x: auto; }
.log li { display: grid; grid-template-columns: 5.2rem 1fr; gap: 10px; padding: 3px 16px; white-space: nowrap; transition: opacity .35s, transform .35s; }
/* На телефоне строки журнала переносятся: прокрутку вбок внутри блока никто не замечал, и текст казался обрезанным. */
@media (max-width: 600px) { .log li { white-space: normal; grid-template-columns: 4.2rem 1fr; padding: 3px 12px; } .terminal-bar { flex-wrap: wrap; } }
.log li.wait { opacity: 0; transform: translateX(-8px); }
.log time { color: var(--ink-3); }
.log .ok { color: var(--ok); }
.log .ac { color: var(--accent-hi); }
.log .wr { color: var(--warn); }

@media (prefers-reduced-motion: reduce) {
  .scroll-hint::after { animation: none; }
  .reveal-ready [data-reveal] { opacity: 1; transform: none; }
  .story-steps li::before { transition: none; }
}
/* Полоса хода появляется, когда первый экран ушёл: на невысоком ноутбуке она ложилась на строки под кнопками. */
.is-live:not(.story-started) .story-steps { opacity: 0; }
/* Узкий ноутбук (1024): колонка первого экрана шире, строки с фактами уходят — иначе кнопки вставали столбиком,
   а факты доходили до края окна. */
@media (min-width: 980px) and (max-width: 1180px) {
  .is-live .chapter.intro { width: min(36rem, 50vw); }
  .is-live .chapter.intro .facts { display: none; }
}
