/* GREAT WALL — оформление сайта.
   Цвет числом задан только в :root. Кегли, отступы и колонки берутся из рядов ниже:
   значение вне ряда — ошибка. Точек перелома две: 760 и 1040 px. */

:root {
  /* цвет — эти же имена читает kit.js */
  --screen: #17191b;                     /* фон страницы, шапки, меню */
  --panel: #202326;                      /* только инструменты: карта, схема, поле обучения, пример сообщения */
  --ink: #121416;                        /* текст на оранжевой кнопке и на известковых плашках */
  --bone: #ede9e0;                       /* основной текст, название */
  --bone-2: #c4c1ba;                     /* вторичный текст: описания, пункты меню */
  --ash: #a9a69f;                        /* подписи, примечания, шапка таблицы, подвал, пустой квадрат */
  --rule: rgba(237, 233, 224, .16);      /* линейки таблицы, низ шапки, основание шкалы шагов */
  --fire: #ff8a2a;                       /* «сейчас», вычисленное комплексом, команда человека */
  --fire-hover: #ffa04d;
  --fire-press: #e6791f;
  --bone-80: rgba(237, 233, 224, .8);    /* пройденные зубцы шкалы */
  --bone-20: rgba(237, 233, 224, .2);    /* будущие зубцы шкалы */
  --veil-90: rgba(23, 25, 27, .9);       /* графит поверх сцены: 90 и 60 %; 86 % — плашка подписи */
  --veil-86: rgba(23, 25, 27, .86);
  --veil-60: rgba(23, 25, 27, .6);
  --veil-0: rgba(23, 25, 27, 0);

  /* шрифты */
  --f-text: "Sofia Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-head: "Sofia Sans Extra Condensed", "GW Head Fallback", "Arial Narrow", "Roboto Condensed", sans-serif;
  --f-code: ui-monospace, "Cascadia Mono", Consolas, "SF Mono", Menlo, monospace;

  /* кегли: телефон → широкий экран */
  --t-head: clamp(2.5rem, 5.9722vw, 5.375rem);       /* заголовок раздела */
  --t-brief: clamp(1.75rem, 3.8194vw, 3.4375rem);    /* крупный абзац */
  --t-sub: clamp(1.5625rem, 2.4306vw, 2.1875rem);    /* подзаголовок, заголовок шага */
  --t-name: clamp(1.3125rem, 1.9444vw, 1.75rem);     /* название строки */
  --t-lede: clamp(1.1875rem, 1.5625vw, 1.40625rem);  /* вводный абзац, текст первого экрана */
  --t-text: clamp(1.0625rem, 1.25vw, 1.125rem);      /* основной текст */
  --t-small: .9rem;                                  /* меню, подписи, примечания */
  --t-menu: 2.5rem;                                  /* меню на телефоне */
  --t-code: .8125rem;

  /* отступы */
  --s1: .5rem;
  --s2: 1rem;
  --s3: 1.5rem;
  --s4: 2.5rem;
  --s5: 4rem;
  --s6: 6.5rem;
  --s7: 10.5rem;

  /* роли отступов; на телефоне каждая на ступень ниже */
  --gap-head: var(--s4);                 /* заголовок → вводный абзац */
  --gap-lede: var(--s5);                 /* вводный абзац → содержимое */
  --gap-sub: var(--s3);                  /* подзаголовок → его блок */
  --gap-note: var(--s2);                 /* содержимое → примечание */
  --gap-row: var(--s4);                  /* строка → строка */
  --gap-block: var(--s6);                /* блок → блок в разделе */
  --pad-sec: var(--s6);                  /* поля раздела сверху и снизу */
  --pad-brief: var(--s7);                /* поля абзаца о задаче */

  /* сетка: один контейнер, 12 колонок */
  --pad: max(clamp(1.25rem, 5vw, 5.25rem), env(safe-area-inset-left, 0px), env(safe-area-inset-right, 0px));
  --gut: clamp(1rem, 1.667vw, 1.5rem);
  --cols: repeat(12, minmax(0, 1fr));
  --measure: min(100%, 33rem);           /* колонка чтения в наборе; от 1040 px — пять колонок из двенадцати */
  --measure-half: min(100%, 33rem);      /* она же внутри правой половины; от 1040 px — пять колонок из шести */

  /* левая линия набора и шаг колонки для блоков во всю ширину окна:
     проценты считаются там, где переменная применена, и означают долю этой ширины */
  --line: calc(50% - min(50%, 45rem) + var(--pad));
  --step: calc((min(100%, 90rem) - 2 * var(--pad) + var(--gut)) / 12);

  --top-h: 4rem;                         /* высота шапки */
  --tap: 2.75rem;                        /* наименьшая область нажатия */
  --mark: .75rem;                        /* квадрат состояния */
  --ease: cubic-bezier(.2, .7, .1, 1);
}

@media (min-width: 1040px) {
  :root {
    --measure: calc((100% - 11 * var(--gut)) * 5 / 12 + 4 * var(--gut));
    --measure-half: calc((100% - 5 * var(--gut)) * 5 / 6 + 4 * var(--gut));
  }
}

@media (max-width: 760px) {
  :root {
    --gap-head: var(--s3);
    --gap-lede: var(--s4);
    --gap-sub: var(--s2);
    --gap-note: var(--s1);
    --gap-row: var(--s3);
    --gap-block: var(--s5);
    --pad-sec: var(--s5);
    --pad-brief: var(--s6);
  }
}

/* ── основа ─────────────────────────────────────────────────────────────── */

/* запасной шрифт заголовков, пока не пришёл или недоступен сетевой: системный узкий жирный,
   уменьшенный до ширины основного, чтобы строки заголовков не переламывались иначе */
@font-face {
  font-family: "GW Head Fallback";
  src: local("Impact");
  size-adjust: 82%;
}

*, *::before, *::after { box-sizing: border-box; }

/* шире 1440 × 900 вёрстка растёт целиком: все размеры заданы в rem */
html {
  font-size: clamp(100%, min(1.1111vw, 1.7778vh), 125%);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background: var(--screen);
}

body {
  margin: 0;
  background: var(--screen);
  color: var(--bone);
  font: 400 var(--t-text)/1.5 var(--f-text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-wrap: break-word;
}

h1, h2, h3, h4, p, ol, ul, dl, dt, dd, figure, pre, table, th, td { margin: 0; padding: 0; }
ol, ul { list-style: none; }
a { color: inherit; text-decoration: none; }
i { font-style: normal; }
th { font-weight: inherit; text-align: left; }
canvas, svg { display: block; }
button {
  margin: 0; padding: 0; border: 0; border-radius: 0;
  background: none; color: inherit; font: inherit; text-align: inherit;
  cursor: pointer; -webkit-appearance: none; appearance: none;
}
code, kbd, pre { font-family: var(--f-code); }

p, li, dd, td, figcaption { text-wrap: pretty; }
h2, h3, h4, dt, th { text-wrap: balance; }

::selection { background: var(--bone); color: var(--ink); }
:focus-visible { outline: 2px solid var(--fire); outline-offset: 3px; }

.wrap { width: 100%; max-width: 90rem; margin-inline: auto; padding-inline: var(--pad); }

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

.skip {
  position: fixed; left: var(--s2); top: var(--s2); z-index: 60;
  display: flex; align-items: center; min-height: var(--tap); padding-inline: var(--s2);
  background: var(--bone); color: var(--ink); font-size: var(--t-small); font-weight: 700;
  transform: translateY(-200%);
}
.skip:focus { transform: none; }

/* подсказки под способ управления: по умолчанию — касание */
.for-mouse { display: none; }
@media (hover: hover) and (pointer: fine) {
  .for-mouse { display: block; }
  .for-touch { display: none; }
}

/* ── текст: роли ────────────────────────────────────────────────────────── */

h2 {
  max-width: 11.5em; margin-left: -.035em;
  font: 800 var(--t-head)/.92 var(--f-head); letter-spacing: 0; text-transform: uppercase;
}
h3 { font: 700 var(--t-sub)/1.15 var(--f-text); letter-spacing: -.01em; }
h4, dt { font: 700 var(--t-name)/1.2 var(--f-text); }

.lede { max-width: var(--measure); font-size: var(--t-lede); line-height: 1.4; }
.note { max-width: var(--measure); margin-top: var(--gap-note); font-size: var(--t-small); color: var(--ash); }
.sub { margin-bottom: var(--gap-sub); }

.sec-head { margin-bottom: var(--gap-lede); }
.sec-head .lede { margin-top: var(--gap-head); }

/* узкий экран: переносы — только в основном и мелком тексте, длинные слова не рвут строку */
@media (max-width: 480px) {
  p, li, dd, td, figcaption { -webkit-hyphens: auto; hyphens: auto; hyphenate-limit-chars: 8 3 3; }
  .hero-text, .brief-text, .lede, .lede p { -webkit-hyphens: manual; hyphens: manual; }
}

/* ── квадрат состояния: пустой — «нет», известковый — «да», оранжевый — «сейчас» ── */

.deck-stages li, .deck-gates li, .limits-list button, .ready .st, .lock-group li {
  position: relative; padding-left: calc(var(--mark) * 2);
}
.deck-stages li::before, .deck-gates li::before, .limits-list button::before, .ready .st::before, .lock-group li::before {
  content: ""; position: absolute; left: 0; top: calc((1.5em - var(--mark)) / 2);
  width: var(--mark); height: var(--mark); border: 1px solid var(--ash);
}
.deck-stages .is-done::before, .deck-gates .is-on::before, .ready .is-live .st::before {
  border-color: var(--bone); background: var(--bone);
}
.deck-stages .is-now::before, .limits-list [aria-pressed="true"]::before, .limits-list .is-on::before {
  border-color: var(--fire); background: var(--fire);
}
.ready .is-test .st::before {
  border-color: var(--bone); background: linear-gradient(90deg, var(--bone) 50%, transparent 0);
}

/* ── зубцы: край между сценой и графитом ────────────────────────────────────
   Зуб и проём равны половине шага колонки, зуб начинается на левой линии набора.
   Блок растянут во всю ширину окна, поэтому проценты в --line и --step — доли этой ширины. */

.solid-start::before, .finale::before, .story-steps::before {
  position: absolute; left: 0; right: 0; height: 0; padding-top: calc(var(--step) / 4);
  background: var(--screen); pointer-events: none;
  -webkit-mask-image: repeating-linear-gradient(90deg,
    #000 var(--line), #000 calc(var(--line) + var(--step) / 2),
    transparent calc(var(--line) + var(--step) / 2), transparent calc(var(--line) + var(--step)));
  mask-image: repeating-linear-gradient(90deg,
    #000 var(--line), #000 calc(var(--line) + var(--step) / 2),
    transparent calc(var(--line) + var(--step) / 2), transparent calc(var(--line) + var(--step)));
}
.solid-start::before { content: ""; bottom: calc(100% - 1px); }   /* над моделью: стена поднимается из кадра */
.finale::before { content: ""; top: -1px; }                       /* перед последним кадром: зубцы смотрят вниз */

/* ── сцена за страницей ─────────────────────────────────────────────────── */

#world, #world-labels {
  position: fixed; left: 0; top: 0; width: 100%;
  height: 100vh; height: 100lvh;         /* по большому окну: адресная строка телефона не меняет размер холста */
  transition: opacity .4s linear;
}
#world { z-index: 0; background: var(--screen); }
#world-labels { z-index: 1; overflow: hidden; pointer-events: none; }
#world.is-off, #world-labels.is-off { opacity: 0; }

/* верх кадра уходит в графит: шапка читается над любым местом сцены, куда бы ни ушла прокрутка.
   Слой лежит над холстом и под содержимым страницы, поэтому текст разделов он не трогает. */
#world-labels::before {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: var(--s7);
  background: linear-gradient(var(--veil-90), var(--veil-60) var(--top-h), var(--veil-0));
}

/* подписи сцены: плашка и плашка события */
.wl {
  position: absolute; left: 0; top: 0; padding: .25rem .5rem;
  background: var(--veil-86); color: var(--bone);
  font: 500 var(--t-small)/1.5 var(--f-text); white-space: nowrap;
  opacity: 0; transition: opacity .2s linear; will-change: transform, opacity;
}
.wl-flag { background: var(--bone); color: var(--ink); font-weight: 700; }

/* затемнение сцены под текстом — пятно от левого края, а не полоса:
   --spot-x — правый край текста от края окна, --spot-y — середина текста от низа кадра.
   Радиусы пятна — только длины: проценты вперемешку с длинами здесь не принимаются. */
.hero, .story-pin {
  --edge: calc(max(0px, 50vw - 45rem) + var(--pad));
  --spot-x: calc(var(--edge) + min(100vw - 2 * var(--pad), 33rem));
  --spot: calc(2 * var(--spot-x)) 22rem at 0 calc(100% - var(--spot-y));
}
@media (min-width: 1040px) {
  .hero { --spot-x: calc(var(--edge) + (min(100vw, 90rem) - 2 * var(--pad) - 11 * var(--gut)) * 5 / 12 + 4 * var(--gut)); }
}

/* ── шапка ──────────────────────────────────────────────────────────────── */

.top {
  position: fixed; left: 0; right: 0; top: 0; z-index: 50; height: var(--top-h);
  transition: background-color .2s linear, box-shadow .2s linear;
}
.top[data-state="solid"] { background: var(--screen); box-shadow: 0 1px 0 var(--rule); }
.menu-open .top { background: var(--screen); box-shadow: none; }

.top-row { display: flex; align-items: center; height: 100%; }

.brand { display: inline-flex; align-items: center; margin-right: auto; padding-block: var(--s1); }
.brand-logo { width: auto; height: 2rem; }
.brand-word { transition: opacity .3s linear; }
.top.is-home .brand-word { opacity: 0; }       /* пока название на экране, в шапке только знак */

.top-nav a, .lang, .foot-top, .story-skip {
  display: inline-flex; align-items: center; min-height: var(--tap);
  font-size: var(--t-small); font-weight: 500; color: var(--bone-2);
}
.lang { justify-content: flex-end; min-width: var(--tap); }
.menu-note { display: none; }

.burger { display: none; place-content: center; gap: .4375rem; width: 3rem; height: 3rem; margin-right: -.75rem; }
.burger i { display: block; width: 1.5rem; height: 2px; background: var(--bone); transition: transform .25s var(--ease); }
.burger[aria-expanded="true"] i:first-child { transform: translateY(.28125rem) rotate(45deg); }
.burger[aria-expanded="true"] i:last-child { transform: translateY(-.28125rem) rotate(-45deg); }
.burger:active i { background: var(--bone-2); }

@media (hover: hover) {
  .top-nav a:hover, .lang:hover, .foot-top:hover, .story-skip:hover { color: var(--bone); }
}

/* широкий экран: текущий пункт — известь с оранжевой чертой, под курсором — серая черта */
@media (min-width: 1040px) {
  .top-nav ul { display: flex; }
  .top-nav a { position: relative; padding-inline: var(--s2); }
  .top-nav a::after {
    content: ""; position: absolute; left: var(--s2); right: var(--s2); bottom: var(--s1); height: 2px;
  }
  .top-nav a[aria-current="true"] { color: var(--bone); }
  .top-nav a[aria-current="true"]::after { background: var(--fire); }
}
@media (min-width: 1040px) and (hover: hover) {
  .top-nav a:not([aria-current="true"]):hover::after { background: var(--ash); }
}

/* меню на телефоне: графитовый экран, пункты прижаты к низу, текущий отмечен квадратом */
@media (max-width: 1039.98px) {
  .brand, .lang, .burger { position: relative; z-index: 2; }
  .burger { display: grid; }
  .lang { margin-right: var(--s1); }
  .top .brand-logo { height: 1.75rem; }

  .top-nav {
    position: fixed; left: 0; right: 0; top: 0; bottom: 0; z-index: 1;
    display: flex; flex-direction: column;
    padding: calc(var(--top-h) + var(--s3)) var(--pad) calc(var(--s4) + env(safe-area-inset-bottom, 0px));
    background: var(--screen); overflow-y: auto; overscroll-behavior: contain;
    visibility: hidden; opacity: 0;
    transition: opacity .2s linear, visibility 0s linear .2s;
  }
  .menu-open .top-nav { visibility: visible; opacity: 1; transition-delay: 0s; }
  .menu-open, .menu-open body { overflow: hidden; }

  .top-nav ul { margin-top: auto; }
  .top-nav a {
    display: flex; min-height: 3rem;
    font: 800 var(--t-menu)/1.1 var(--f-head); text-transform: uppercase; color: var(--bone);
  }
  .top-nav a[aria-current="true"]::before {
    content: ""; flex: none; width: var(--mark); height: var(--mark); margin-right: var(--mark);
    background: var(--fire);
  }
  .menu-note { display: block; max-width: 20rem; margin-top: var(--s4); font-size: var(--t-small); color: var(--ash); }
}

/* ── первый экран ───────────────────────────────────────────────────────── */

.hero {
  /* высота названия: ширина набора на пропорцию знака; от неё отсчитывается середина абзаца */
  --title-h: min((min(100vw, 90rem) - 2 * var(--pad)) * .1629, 46vh);
  --spot-y: calc(var(--title-h) + var(--gap-head) + 5.5rem);
  position: relative; z-index: 2;
  display: flex; flex-direction: column;
  min-height: 100vh; min-height: 100svh;
  background: radial-gradient(var(--spot), var(--veil-90) 0, var(--veil-60) 45%, var(--veil-0) 100%);
}

/* подпись кадра: малые зубцы и фраза текущего события на общей плашке, как подписи сцены.
   В обоих кадрах стоит на одной высоте от верха кадра. Поехав при прокрутке к шапке, гаснет сразу,
   чтобы не проезжать под логотипом, а вернувшись на место, проявляется. */
.caption {
  display: flex; padding-top: calc(var(--top-h) + var(--s2));
  font-size: var(--t-small); font-weight: 500;
  transition: opacity .2s linear;
}
.caption.is-off { opacity: 0; transition-duration: 0s; }
.caption > span { padding-block: .25rem; background: var(--veil-86); }
.caption > span:last-child { padding-right: .5rem; }
.caption-marks { position: relative; display: flex; flex: none; align-items: center; gap: .25rem; padding-inline: .5rem .75rem; }
.caption-marks::after {
  content: ""; position: absolute; left: .5rem; right: .75rem; top: calc(50% + .125rem); height: .125rem;
  background: var(--rule);
}
.caption-marks i { width: .5rem; height: .375rem; margin-top: -.125rem; background: var(--bone-20); }
.caption-marks i.is-done { background: var(--bone-80); }
.caption-marks i.is-now { background: var(--fire); }

/* абзац стоит над названием, хотя в разметке идёт после него */
.hero-foot { display: grid; row-gap: var(--gap-head); margin-top: auto; padding-top: var(--s5); }
.hero-text { order: 1; max-width: var(--measure); font-size: var(--t-lede); font-weight: 500; line-height: 1.4; }
.hero-title { order: 2; }
.hero-letters { width: 100%; height: auto; max-height: 46vh; max-height: 46svh; overflow: hidden; color: var(--bone); }
.hero-letters.hero-letters-stack, .hero-text-short { display: none; }

/* телефон: GREAT над WALL во всю ширину набора; абзац без первой фразы — её говорит само название */
@media (max-width: 760px) {
  .hero { --title-h: min((100vw - 2 * var(--pad)) * .6948, 46vh); }
  .hero-letters { display: none; }
  .hero-letters.hero-letters-stack { display: block; }
  .hero-text-full { display: none; }
  .hero-text-short { display: inline; }
}

@media (max-height: 520px) {
  .hero-foot { padding-top: var(--s3); }       /* лежачий телефон: абзац и название остаются в одном экране */
}

/* единственное поставленное движение страницы: буквы поднимаются из-за нижней кромки */
.hero-letters path { animation: rise 1s var(--ease) backwards; animation-delay: calc(var(--i) * 55ms + 200ms); }
@keyframes rise { from { transform: translateY(var(--lift, 105px)); } }

/* ── задача ─────────────────────────────────────────────────────────────── */

.brief { position: relative; z-index: 2; padding-block: var(--pad-brief); background: var(--screen); }
.brief-text { font: 500 var(--t-brief)/1.16 var(--f-text); letter-spacing: -.012em; }
/* мера крупного абзаца — в его кегле, а не в колонках: так строки ломаются одинаково на любом
   широком экране. 20.1em — около десяти колонок с межколонником; при ней оба языка ложатся ровным краем,
   а при десяти колонках ровно русский текст даёт короткую вторую строку */
@media (min-width: 1040px) {
  .brief-text { max-width: 20.1em; }
}

/* ── как работает ───────────────────────────────────────────────────────────
   Без сцены это обычный раздел: заголовок слева, шесть шагов списком справа. */

.story {
  position: relative; z-index: 2; padding-block: var(--pad-sec); background: var(--screen);
  scroll-margin-top: calc(var(--top-h) + var(--s3) - var(--pad-sec));
}
.story-pin { width: 100%; max-width: 90rem; margin-inline: auto; padding-inline: var(--pad); }
.story-head, .story-steps { display: contents; }
.story-title { margin-bottom: var(--gap-lede); }
.step + .step { margin-top: var(--gap-row); }
.step h3 { margin-bottom: var(--s2); }
.step p { max-width: var(--measure-half); }
.story-bar { display: none; }

@media (min-width: 1040px) {
  .story-pin { display: grid; grid-template-columns: var(--cols); column-gap: var(--gut); row-gap: var(--gap-row); }
  .story-title { grid-column: 1 / span 5; grid-row: 1 / span 6; margin-bottom: 0; }
  .step { grid-column: 7 / -1; }
  .step + .step { margin-top: 0; }
}

/* шкала шагов: шесть зубцов-кнопок одной высоты на общем основании */
.story-marks {
  --crenel: .75rem;
  position: relative; display: grid;
  grid-template-columns: repeat(5, calc((100% - 5 * var(--crenel)) / 6 + var(--crenel))) 1fr;
}
.story-marks::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: .875rem; height: .25rem;
  background: var(--rule); pointer-events: none;
}
.story-marks button { position: relative; display: block; width: 100%; height: var(--tap); }
.story-marks i {
  position: absolute; left: 0; right: var(--crenel); bottom: 1.125rem; height: .75rem; background: var(--bone-20);
}
.story-marks li:last-child i { right: 0; }
.story-marks .is-done i { background: var(--bone-80); }
.story-marks .is-now i { background: var(--fire); }
@media (hover: hover) {
  .story-marks li:not(.is-now) button:hover i { background: var(--bone); }
}

.story-count { font-size: var(--t-small); font-weight: 500; color: var(--bone-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.story-count b { color: var(--bone); font-weight: 700; }
.story-skip { justify-self: end; }

/* закреплённый кадр — когда есть скрипты, WebGL2 и окно выше 520 px */
@media (min-height: 520.02px) {
  .js:not(.no-webgl) .story {
    height: 580vh; height: 580lvh; padding-block: 0; background: none; scroll-margin-top: 0;
  }
  /* вход в кадр: графит растворяется в сцену */
  .js:not(.no-webgl) .story::before {
    content: ""; position: absolute; left: 0; right: 0; top: 0; height: var(--s7);
    background: linear-gradient(var(--screen), var(--veil-0)); pointer-events: none;
  }
  .js:not(.no-webgl) .story-pin {
    --spot-x: calc(var(--edge) + 27rem);
    --spot-y: 14rem;
    position: sticky; top: 0;
    display: flex; flex-direction: column;
    max-width: none; height: 100vh; height: 100lvh;
    padding-inline: 0; padding-bottom: calc(100lvh - 100svh);   /* текст и шкала остаются в малом окне */
  }
  .js:not(.no-webgl) .story-pin::before {
    content: ""; position: absolute; left: 0; right: 0; top: 0; bottom: 0; z-index: -1;
    background: radial-gradient(var(--spot), var(--veil-90) 0, var(--veil-60) 45%, var(--veil-0) 100%);
    transition: opacity .25s linear; pointer-events: none;
  }

  /* заголовок раздела виден только на входе; пока он на экране, верх кадра ещё в графите,
     и кадр открывается целиком, когда заголовок уходит */
  .js:not(.no-webgl) .story-head { display: block; padding-top: calc(var(--top-h) + var(--gap-head)); }
  .js:not(.no-webgl) .story-title { margin-bottom: 0; transition: opacity .25s linear; }
  .js:not(.no-webgl) .story-pin::after {
    content: ""; position: absolute; left: 0; right: 0; top: 0; z-index: -1;
    height: calc(var(--top-h) + var(--gap-head) + 2 * var(--t-head) + var(--s6));
    background: linear-gradient(var(--veil-90), var(--veil-60) calc(100% - var(--s6)), var(--veil-0));
    transition: opacity .25s linear; pointer-events: none;
  }
  .js:not(.no-webgl) .story.is-in .story-title, .js:not(.no-webgl) .story.is-in .story-pin::after { opacity: 0; }

  /* шаги лежат в одной ячейке: её высоту задаёт самый длинный, поэтому верх блока не прыгает;
     смена без наложения — старый гаснет, затем проявляется новый */
  .js:not(.no-webgl) .story-steps {
    display: grid; align-content: end; flex: 1; min-height: 0; padding-bottom: var(--s3);
  }
  .js:not(.no-webgl) .step {
    grid-area: 1 / 1; width: min(27rem, 100%); margin: 0;
    opacity: 0; pointer-events: none; -webkit-user-select: none; user-select: none;
    transition: opacity .15s linear;
  }
  .js:not(.no-webgl) .step.is-on {
    opacity: 1; pointer-events: auto; -webkit-user-select: text; user-select: text;
    transition: opacity .25s linear .15s;
  }
  .js:not(.no-webgl) .step p { max-width: none; font-weight: 500; }

  /* хвост рассказа: текст ушёл, затемнение снято */
  .js:not(.no-webgl) .story.is-tail .step { opacity: 0; pointer-events: none; transition: opacity .15s linear; }
  .js:not(.no-webgl) .story.is-tail .story-pin::before { opacity: 0; }

  .js:not(.no-webgl) .story-bar {
    display: grid; grid-template-columns: minmax(0, 27rem) auto 1fr; align-items: center; column-gap: var(--s3);
    padding-bottom: var(--s3);
  }
  /* счётчик и ссылка стоят прямо на сцене: им нужны плашки, как подписям сцены */
  .js:not(.no-webgl) .story-count { padding: .25rem .5rem; background: var(--veil-86); }
  .js:not(.no-webgl) .story-skip {
    padding-inline: .5rem;
    background: linear-gradient(var(--veil-86), var(--veil-86)) center / 100% 1.85rem no-repeat;
  }

  /* телефон: окно сцены сверху, графитовая панель с зубчатым верхом снизу */
  @media (max-width: 760px) {
    .js:not(.no-webgl) .story-pin { padding-bottom: 0; }
    .js:not(.no-webgl) .story-pin::before { content: none; }
    .js:not(.no-webgl) .story-steps {
      position: relative; flex: none; align-content: start; margin-top: auto;
      min-height: calc(max(42vh, 340px) - 4.375rem);
      min-height: calc(max(42svh, 340px) - 4.375rem);
      padding-block: var(--s2) var(--s1);
      background: var(--screen);
    }
    .js:not(.no-webgl) .story-steps::before { content: ""; bottom: calc(100% - 1px); }
    .js:not(.no-webgl) .step { width: auto; }
    .js:not(.no-webgl) .story.is-tail .step:last-child {
      opacity: 1; pointer-events: auto; -webkit-user-select: text; user-select: text;
    }
    .js:not(.no-webgl) .step h3 { margin-bottom: var(--s1); }
    .js:not(.no-webgl) .step p { font-weight: 400; }

    /* счётчик и ссылка стоят на шкале во всю ширину; области нажатия выходят за строки, не пересекаясь */
    .js:not(.no-webgl) .story-bar {
      position: relative;
      grid-template-columns: 1fr auto; grid-template-rows: 1.375rem 2.5rem; row-gap: .25rem; align-items: start;
      height: calc(4.375rem + 100lvh - 100svh); padding-bottom: 0;
      background: var(--screen);
    }
    .js:not(.no-webgl) .story-count { grid-area: 1 / 1; padding: 0; background: none; line-height: 1.375rem; }
    .js:not(.no-webgl) .story-skip {
      grid-area: 1 / 2; align-items: flex-end; margin-top: calc(1.375rem - var(--tap)); padding-inline: 0;
      background: none; line-height: 1.375rem;
    }
    .story-marks { --crenel: .5rem; grid-area: 2 / 1 / 3 / -1; }
    .story-marks::after { top: 1rem; bottom: auto; }
    .story-marks i { top: .25rem; bottom: auto; }
  }
}

/* ── разделы на графите ─────────────────────────────────────────────────── */

.solid {
  position: relative; z-index: 2; padding-block: var(--pad-sec); background: var(--screen);
  /* по пункту меню содержимое встаёт на --s3 ниже шапки */
  scroll-margin-top: calc(var(--top-h) + var(--s3) - var(--pad-sec));
}
.anchor { position: absolute; top: 0; }

.split { display: grid; row-gap: var(--gap-lede); }
.split > .sec-head { margin-bottom: 0; }
.prose, .limits-list, .rows dd { max-width: 33rem; }     /* одна колонка: строка не длиннее колонки чтения */

/* чтение — колонки 1–5, материал — колонки 7–12 */
@media (min-width: 1040px) {
  .split, .sec-head-split, .locks, .limits, .deck {
    display: grid; grid-template-columns: var(--cols); column-gap: var(--gut);
  }
  .split > :first-child, .limits-list { grid-column: 1 / span 5; }
  .split > :last-child, .limits-viz { grid-column: 7 / -1; }
}

/* ── модель ─────────────────────────────────────────────────────────────── */

@media (min-width: 1040px) {
  /* строка заголовка: абзац стоит на нижней линии заголовка и набран основным кеглем */
  .sec-head-split { align-items: end; align-items: last baseline; margin-bottom: var(--gap-head); }
  .sec-head-split h2 { grid-column: 1 / span 8; }
  .sec-head-split .lede { grid-column: 9 / -1; max-width: none; margin-top: 0; font-size: var(--t-text); line-height: 1.5; }
}

.deck { display: grid; row-gap: var(--s3); }
.deck-map {
  position: relative; aspect-ratio: 1; overflow: hidden;
  background: var(--panel); cursor: default; touch-action: pan-y;
}
.deck-map canvas { position: absolute; left: 0; top: 0; width: 100%; height: 100%; }

/* плашка режима; когда беспилотник ведёт посетитель — плашка события */
.deck-mode {
  position: absolute; left: var(--s2); top: var(--s2); max-width: calc(100% - 2 * var(--s2)); padding: .25rem .5rem;
  background: var(--screen); color: var(--bone); font-size: var(--t-small); font-weight: 500;
  pointer-events: none;
}
.deck-mode:empty { display: none; }
.deck.is-manual .deck-mode { background: var(--bone); color: var(--ink); font-weight: 700; }

.deck-side { display: flex; flex-direction: column; font-size: var(--t-small); }

/* этапы: у текущего крупное название и абзац-пояснение */
.deck-stages { display: grid; row-gap: var(--s1); color: var(--bone-2); }
.deck-stages b { font-weight: 400; }
.deck-stages .is-now::before { top: calc((1.2 * var(--t-name) - var(--mark)) / 2); }
.deck-stages .is-now b { display: block; color: var(--bone); font: 700 var(--t-name)/1.2 var(--f-text); }
.deck-stages p { margin-top: var(--s1); font-variant-numeric: tabular-nums; }
.deck-stages li:not(.is-now) p, .deck-stages p:empty { display: none; }

.deck-h { margin-bottom: var(--s1); font-size: var(--t-text); line-height: 1.5; letter-spacing: 0; }
.deck-gates { display: grid; row-gap: var(--s1); color: var(--bone-2); }
.deck-gates .is-on { color: var(--bone); }

/* кнопка команды: тёмный текст на оранжевом; клавиша видна только при мыши */
.deck-btn {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s2);
  width: 100%; min-height: 3.5rem; padding: var(--s1) var(--s2);
  background: var(--fire); color: var(--ink);
  font-size: var(--t-text); font-weight: 700; line-height: 1.2;
}
.deck-btn kbd { display: none; flex: none; padding: .25rem .375rem; border: 1px solid; font-size: var(--t-code); line-height: 1; }
.deck-btn:focus-visible { outline-color: var(--bone); }
@media (hover: hover) and (pointer: fine) {
  .deck-btn:hover { background: var(--fire-hover); }
  .deck-btn kbd { display: block; }
}
.deck-btn:active { background: var(--fire-press); }
.deck-btn:disabled { background: none; box-shadow: inset 0 0 0 1px var(--rule); color: var(--ash); cursor: default; }
.deck-reason { min-height: 3em; margin-top: var(--s1); color: var(--ash); }

/* телефон: карта → текущий этап → кнопка → условия; место под этап постоянное, кнопка не прыгает */
@media (max-width: 760px) {
  .deck-stages { order: 1; align-content: start; min-height: 9.5rem; }
  .deck-stages li:not(.is-now) { display: none; }
  .deck-act { order: 2; margin-top: var(--s2); }
  .deck-h { order: 3; margin-top: var(--s3); }
  .deck-gates { order: 4; }
  .deck + .note { margin-top: var(--s3); }     /* над примечанием здесь список, а не край панели */
}

/* планшет: карта во всю ширину, под ней этапы слева, условия и кнопка справа */
@media (min-width: 760.02px) and (max-width: 1039.98px) {
  .deck-map { aspect-ratio: 3 / 2; }
  .deck-side { display: grid; grid-template-columns: var(--cols); grid-template-rows: auto auto 1fr; column-gap: var(--gut); }
  .deck-stages { grid-column: 1 / span 6; grid-row: 1 / -1; align-content: start; }
  .deck-h, .deck-gates, .deck-act { grid-column: 7 / -1; }
  .deck-act { margin-top: var(--s3); }
}

/* широкий экран: карта в колонках 1–8; этапы, условия и кнопка — в колонках 9–12, на одной вертикали
   с вводным абзацем. Высота такова, что на 1440 × 900 заголовок, карта и кнопка видны вместе.
   Этапы, условия и кнопка идут подряд, без провала между ними. Список этапов занимает место
   с пояснением в четыре строки, поэтому условия и кнопка стоят на месте, какое бы пояснение ни было открыто:
   пять строк этапов, название текущего, пояснение и отступы между ними */
@media (min-width: 1040px) {
  #console { scroll-margin-top: calc(var(--top-h) + var(--s2) - var(--pad-sec)); }
  .deck { min-height: clamp(32.5rem, 100vh - 14.5rem, 42rem); min-height: clamp(32.5rem, 100svh - 14.5rem, 42rem); }
  .deck-map { grid-column: 1 / span 8; aspect-ratio: auto; }
  .deck-side { grid-column: 9 / -1; }
  .deck-stages { align-content: start; min-height: calc(15.15rem + 1.2 * var(--t-name)); }
  .deck-h { padding-top: var(--s4); }
  .deck-act { margin-top: var(--s3); }
}

/* низкое окно (не выше 860 px, например 1280 × 720 и 1366 × 768): заголовок, карта и кнопка всё равно
   видны вместе. Отступы внутри блока меньше. Высота панели идёт от высоты окна: окно минус шапка,
   поле над заголовком, строка заголовка (строка h2 и --s1 на абзац рядом), отступ до панели и поле под ней */
@media (min-width: 1040px) and (max-height: 860px) {
  .sec-head-split { margin-bottom: var(--s2); }
  .deck {
    min-height: calc(100vh - var(--top-h) - 2 * var(--s2) - 2 * var(--s1) - .92 * var(--t-head));
    min-height: calc(100svh - var(--top-h) - 2 * var(--s2) - 2 * var(--s1) - .92 * var(--t-head));
  }
  .deck-h { padding-top: var(--s2); }
  .deck-act { margin-top: var(--s2); }
}

/* ── безопасность ───────────────────────────────────────────────────────── */

/* замки перехвата: два проверяет комплекс, два решают люди — каждая пара под своей подписью.
   Главный замок — запрет взлёта в полётном контроллере — набран известью и жирным */
.locks { display: grid; row-gap: var(--gap-row); margin-bottom: var(--gap-block); }
.lock-who { margin-bottom: var(--s2); font-size: var(--t-small); color: var(--ash); }
.lock-group ul { display: grid; row-gap: var(--s3); }
.lock-group li { max-width: 33rem; font-size: var(--t-lede); font-weight: 500; line-height: 1.4; color: var(--bone-2); }
.lock-group li::before { top: calc((1.4em - var(--mark)) / 2); }
.lock-group .is-key { color: var(--bone); font-weight: 700; }
@media (min-width: 760.02px) {
  .locks { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: var(--gut); }
}
@media (min-width: 1040px) {
  .locks { grid-template-columns: var(--cols); }
  .lock-group { grid-column: span 6; }
  .lock-group ul { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: var(--gut); }
}

/* пределы: кнопки слева, схема справа, верх и низ совпадают */
.limits { display: grid; row-gap: var(--s3); }
.limits-list { display: flex; flex-direction: column; margin-top: calc(-1 * var(--s2)); }
.limits-list button { display: block; width: 100%; padding-block: var(--s2); }
.limits-list button::before { top: calc(var(--s2) + (1.2 * var(--t-name) - var(--mark)) / 2); }
.limits-list b { display: block; font: 700 var(--t-name)/1.2 var(--f-text); }
.limits-list span { display: block; margin-top: var(--s1); color: var(--bone-2); }
@media (hover: hover) {
  .limits-list button:not(.is-on):not([aria-pressed="true"]):hover::before { border-color: var(--bone); }
}
.limits-list .note { max-width: none; margin-top: auto; padding-top: var(--gap-note); }

.limits-viz { position: relative; aspect-ratio: 16 / 9.4; background: var(--panel); }
.limits-viz canvas { position: absolute; left: 0; top: 0; width: 100%; height: 100%; }
@media (max-width: 760px) {
  .limits-viz { aspect-ratio: 4 / 3; }
}

/* ── на объекте ─────────────────────────────────────────────────────────── */

.rows { display: grid; row-gap: var(--gap-row); align-content: start; }
.rows dd { margin-top: var(--s1); color: var(--bone-2); }

/* панель в колонках материала: пример сообщения, под ним запросы REST */
.wire-col { min-width: 0; }
.wire { padding: var(--s3); background: var(--panel); }
.wire-msg, .wire-rest { min-width: 0; }
.wire-rest { margin-top: var(--s4); }
.wire-col .note { max-width: none; }
.wire figcaption, .wire-rest h3 {
  margin-bottom: var(--s2); color: var(--ash);
  font: 400 var(--t-small)/1.5 var(--f-text); letter-spacing: 0; text-wrap: pretty;
}
.code { overflow-x: auto; color: var(--ash); font-size: var(--t-code); line-height: 1.7; tab-size: 2; }
.code .s, .code .n, .wire-rest code { color: var(--bone); }
.code .fix { color: var(--fire); }      /* координаты цели — то, что вычислил комплекс */
.wire-rest li { font-size: var(--t-code); line-height: 1.7; }

/* ── симуляция ──────────────────────────────────────────────────────────── */

.prose p + p { margin-top: var(--s3); }

.field canvas { width: 100%; height: auto; aspect-ratio: 3 / 2; background: var(--panel); }
.field-ctl { display: flex; align-items: center; gap: var(--s3); margin-top: var(--s1); font-size: var(--t-small); }
.field-ctl label { flex: none; color: var(--bone-2); }
.field-range { display: flex; flex: 1; align-items: center; gap: var(--s2); color: var(--ash); }
.field .note { max-width: var(--measure-half); margin-top: 0; }

/* ползунок: волосная дорожка и известковый бегунок, область нажатия во всю высоту строки */
input[type="range"] {
  flex: 1; min-width: 0; width: 100%; height: var(--tap); margin: 0;
  background: none; cursor: pointer; -webkit-appearance: none; appearance: none;
}
input[type="range"]::-webkit-slider-runnable-track { height: 2px; background: var(--rule); }
input[type="range"]::-moz-range-track { height: 2px; background: var(--rule); }
input[type="range"]::-webkit-slider-thumb {
  width: .875rem; height: .875rem; margin-top: calc(1px - .4375rem);
  border: 0; border-radius: 0; background: var(--bone); -webkit-appearance: none; appearance: none;
}
input[type="range"]::-moz-range-thumb { width: .875rem; height: .875rem; border: 0; border-radius: 0; background: var(--bone); }
input[type="range"]:focus-visible { outline: none; }
input[type="range"]:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 3px var(--screen), 0 0 0 5px var(--fire); }
input[type="range"]:focus-visible::-moz-range-thumb { box-shadow: 0 0 0 3px var(--screen), 0 0 0 5px var(--fire); }

@media (max-width: 760px) {
  .field canvas { aspect-ratio: 4 / 3; }
  .field-ctl { display: block; margin-top: var(--s2); }
}

/* ── готовность: таблица по сетке, единственное место с волосными линейками ── */

.ready, .ready thead, .ready tbody, .ready th, .ready td { display: block; }
.ready tr { display: grid; grid-template-columns: var(--cols); column-gap: var(--gut); align-items: baseline; }
.ready thead th { padding-bottom: var(--s2); font-size: var(--t-small); color: var(--ash); }
.ready tbody tr { padding-block: var(--s3); border-top: 1px solid var(--rule); }
.ready tbody tr:last-child { border-bottom: 1px solid var(--rule); }
.ready tr > :nth-child(1) { grid-column: 1 / span 4; }
.ready tr > :nth-child(2) { grid-column: 5 / span 5; }
.ready tr > :nth-child(3) { grid-column: 10 / -1; }
.ready tbody th { font: 700 var(--t-name)/1.2 var(--f-text); }
.ready td { color: var(--bone-2); }
.ready .st { color: var(--bone); font-weight: 700; }
.ready .is-dev .st { font-weight: 400; }

@media (max-width: 760px) {
  .ready thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .ready tr { display: block; }
  .ready td { margin-top: var(--s1); }
  .ready .st { margin-top: var(--s2); }
}

/* ── последний кадр: сцена в покое, подпись кадра и контакты ─────────────── */

/* --finale-add ставит main.js: если в конце страницы шапка легла бы на зубцы, кадр удлиняется до верха окна */
.finale {
  --edge: calc(max(0px, 50vw - 45rem) + var(--pad));
  --spot-x: calc(var(--edge) + min(100vw - 2 * var(--pad), 33rem));
  --spot-y: 7rem;
  --spot: calc(2 * var(--spot-x)) 18rem at 0 calc(100% - var(--spot-y));
  position: relative; z-index: 2;
  display: flex; flex-direction: column;
  min-height: calc(70vh + var(--finale-add, 0px)); min-height: calc(70svh + var(--finale-add, 0px));
  background: radial-gradient(var(--spot), var(--veil-90) 0, var(--veil-60) 45%, var(--veil-0) 100%);
}
/* кадр, ушедший верхом за край окна, держит подпись под шапкой */
.finale .caption { position: sticky; top: 0; }
.finale-foot { margin-top: auto; padding-block: var(--s5) var(--s5); }
.finale-foot h2 { margin-bottom: var(--gap-sub); }
.contact { margin: 0; padding: 0; list-style: none; display: flex; flex-wrap: wrap; column-gap: var(--s4); row-gap: var(--s1); }
.contact a {
  display: inline-flex; align-items: center; min-height: var(--tap);
  font: 700 var(--t-name)/1.2 var(--f-text); color: var(--bone);
  text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: .22em;
  text-decoration-color: var(--bone-20);
  transition: text-decoration-color .2s linear;
}
@media (hover: hover) {
  .contact a:hover { text-decoration-color: var(--bone); }
}
@media (max-width: 760px) {
  .finale { --spot-y: 6rem; --spot: calc(2 * var(--spot-x)) 16rem at 0 calc(100% - var(--spot-y)); }
  .contact { flex-direction: column; }
}

/* ── подвал: одна строка по сетке ───────────────────────────────────────── */

.foot { position: relative; z-index: 2; padding-block: var(--s4); background: var(--screen); font-size: var(--t-small); color: var(--ash); }
.foot-row { display: grid; grid-template-columns: 1fr auto; align-items: center; row-gap: var(--s1); }
.foot .brand { justify-self: start; margin-right: 0; }
.foot .brand-logo { height: 1.75rem; }
.foot-tag { grid-column: 1 / -1; }
.foot-top { justify-self: end; }
@media (min-width: 1040px) {
  .foot-row { grid-template-columns: var(--cols); column-gap: var(--gut); }
  .foot .brand { grid-column: 1 / span 3; }
  .foot-tag { grid-column: 4 / span 6; }
  .foot-copy, .foot-top { grid-column: 10 / -1; grid-row: 1; }
}

/* ── запасные виды ──────────────────────────────────────────────────────── */

/* нет скриптов или WebGL2: ровный графит вместо сцены; подписи кадра и последний кадр не нужны */
.no-js #world, .no-js #world-labels, .no-webgl #world, .no-webgl #world-labels,
.no-js .caption, .no-webgl .caption { display: none; }
/* последний кадр без сцены — просто контакты на графите */
.no-js .finale, .no-webgl .finale { min-height: 0; background: none; }
.no-js .finale::before, .no-webgl .finale::before { display: none; }
.no-js .finale-foot, .no-webgl .finale-foot { padding-block: var(--pad-sec); }
.no-js .top, .no-webgl .top { background: var(--screen); box-shadow: 0 1px 0 var(--rule); }
.no-js .hero, .no-webgl .hero { min-height: 0; padding-top: var(--top-h); }

/* нет скриптов: инструменты на холстах не работают — они убраны целиком, без пустых панелей */
.no-js #console, .no-js .limits-viz, .no-js .field, .no-js .burger, .no-js a[href="#console"] { display: none; }
.no-js .limits-list button { padding-left: 0; cursor: default; }
.no-js .limits-list button::before { content: none; }

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