/*
  Интерфейс презентации.

  Кадр принадлежит схеме. Рассказ ведут пять носителей, и выбор носителя —
  часть режиссуры:

    hero    — полноэкранный титул, только в начале и в конце;
    quote   — тезис во весь кадр: одна фраза, ради которой снята сцена;
    center  — инфоблок по центру: им открывается тема;
    drawer  — панель у края экрана: подробности, пока на схеме идёт действие;
    chip    — короткая метка, привязанная к точке в 3D.

  Ни один носитель не держится на экране дольше своей сцены — иначе рассказ
  превращается в стену текста поверх схемы.

  Шрифты: гарнитуры Manrope и Golos Text подхватываются, если установлены в
  системе; иначе используется системный стек. Файлы шрифтов сюда намеренно не
  положены — проект остаётся без внешних зависимостей.
*/

:root {
  --ink:      #eef4f0;
  --ink-2:    #b9c9c2;
  --ink-3:    #81958d;
  --acc:      #35c98d;
  --data:     #4cc4e0;
  --warn:     #f0b23f;
  --alert:    #ff6b4a;
  --line:     rgba(238, 244, 240, .15);
  --glass:    rgba(7, 13, 12, .84);

  --f-head: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --f-body: 'Golos Text', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --f-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: #05090b; color: var(--ink);
  font-family: var(--f-body);
  -webkit-font-smoothing: antialiased;
  cursor: pointer;
  user-select: none;
}

#stage { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }

/* Затемнение по краям: текст читается поверх светящихся узлов */
.vignette {
  position: fixed; inset: 0; pointer-events: none; z-index: 1;
  background:
    linear-gradient(0deg, rgba(3,6,8,.72) 0%, rgba(3,6,8,0) 26%),
    radial-gradient(130% 95% at 50% 45%, transparent 40%, rgba(3,6,8,.62) 100%);
}

.hud { position: fixed; inset: 0; z-index: 2; pointer-events: none; }
.say { position: fixed; inset: 0; z-index: 3; pointer-events: none; }
.pins { position: fixed; inset: 0; z-index: 4; pointer-events: none; }
.hud button { pointer-events: auto; }

/* ───────────── Верхняя строка ───────────── */

.topbar {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; align-items: center; justify-content: space-between;
  gap: 24px; padding: 20px 30px;
  font-family: var(--f-mono); font-size: 9.5px;
  letter-spacing: .18em; text-transform: uppercase; color: var(--ink-3);
}
.brand { display: inline-flex; align-items: center; gap: 10px; }
.mark { width: 7px; height: 7px; background: var(--acc); box-shadow: 0 0 12px rgba(53,201,141,.8); }

.acts { display: flex; gap: 18px; }
.act { position: relative; transition: color .3s ease; white-space: nowrap; }
.act.is-on { color: var(--ink); }
.act.is-on::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: -7px; height: 1px; background: var(--acc);
}
.act.is-done { color: var(--ink-3); opacity: .55; }

/* ───────────── Общие приёмы появления ───────────── */

@keyframes riseIn { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
@keyframes slideRight {
  from { opacity: 0; transform: translateY(-50%) translateX(34px); }
  to { opacity: 1; transform: translateY(-50%); }
}
@keyframes slideLeft {
  from { opacity: 0; transform: translateY(-50%) translateX(-34px); }
  to { opacity: 1; transform: translateY(-50%); }
}
@keyframes popIn {
  from { opacity: 0; transform: translate(-50%, -50%) scale(.94); }
  to { opacity: 1; transform: translate(-50%, -50%); }
}
/* Карточки на схеме центрируются только по горизонтали */
@keyframes pinIn { from { opacity: 0; transform: translate(-50%, 14px); } to { opacity: 1; transform: translate(-50%, 0); } }
@keyframes chipIn { from { opacity: 0; transform: translate(-50%, -40%); } to { opacity: 1; transform: translate(-50%, -50%); } }

/* ───────────── Титул ───────────── */

.hero {
  position: absolute; inset: 0;
  display: grid; place-items: center; text-align: center;
  padding: 60px;
}
.hero-inner {
  max-width: 900px; position: relative; padding: 40px;
  animation: riseIn .8s cubic-bezier(.2,.7,.3,1) both;
}
/* Мягкое затемнение под титулом: текст читается поверх любой части кадра */
.hero-inner::before {
  content: ''; position: absolute; inset: -26% -30%;
  background:
    radial-gradient(58% 52% at 50% 48%, rgba(3,7,6,.99) 0%, rgba(3,7,6,.96) 42%, rgba(3,7,6,.72) 66%, rgba(3,7,6,.2) 88%, transparent 100%);
  z-index: -1;
}
.hero .kicker { justify-content: center; }
.hero h1 {
  font-family: var(--f-head); font-weight: 800;
  font-size: clamp(40px, 6.4vw, 96px); line-height: .98; letter-spacing: -.045em;
  margin: 0 0 22px; text-wrap: balance;
  text-shadow: 0 4px 40px rgba(0,0,0,.6);
}
.hero .lead { font-size: clamp(15px, 1.5vw, 19px); max-width: 62ch; margin: 0 auto; }
.hero .stats { justify-content: center; margin-top: 34px; }

/* ───────────── Тезис ───────────── */

/*
  Тезис не панель: у него нет рамки и подложки-плашки, только затемнение.
  Рамка превратила бы утверждение в карточку, а это то, ради чего снята
  вся сцена, — оно должно лежать прямо на кадре.
*/
.quote {
  position: absolute; inset: 0;
  display: grid; place-items: center; text-align: center;
  padding: 60px 8vw;
}
.quote-inner {
  max-width: 1080px; position: relative; padding: 36px 40px;
  animation: riseIn .7s cubic-bezier(.2,.7,.3,1) both;
}
.quote-inner::before {
  content: ''; position: absolute; inset: -40% -26%;
  background: radial-gradient(56% 50% at 50% 50%, rgba(3,7,6,.97) 0%, rgba(3,7,6,.9) 46%, rgba(3,7,6,.5) 72%, transparent 100%);
  z-index: -1;
}
.quote .kicker { justify-content: center; }
.quote h1 {
  font-family: var(--f-head); font-weight: 800;
  font-size: clamp(26px, 3.6vw, 54px); line-height: 1.12; letter-spacing: -.035em;
  margin: 0; text-wrap: balance;
  text-shadow: 0 4px 34px rgba(0,0,0,.65);
}
.quote .lead {
  font-size: clamp(14px, 1.35vw, 17px); max-width: 68ch; margin: 20px auto 0;
}
/* Тонкие черты сверху и снизу: цитата отделена от кадра, но не заперта в рамку */
.quote-inner::after {
  content: ''; position: absolute; left: 32%; right: 32%; bottom: 0; height: 1px;
  background: linear-gradient(90deg, transparent, var(--acc), transparent);
  opacity: .7;
}
.quote-inner.tone-data::after { background: linear-gradient(90deg, transparent, var(--data), transparent); }
.quote-inner.tone-warn::after { background: linear-gradient(90deg, transparent, var(--warn), transparent); }

/* ───────────── Инфоблок по центру ───────────── */

.center {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(640px, calc(100vw - 80px));
  background: var(--glass);
  border: 1px solid var(--line);
  backdrop-filter: blur(14px);
  padding: 30px 34px 32px;
  animation: popIn .55s cubic-bezier(.2,.7,.3,1) both;
  box-shadow: 0 30px 90px rgba(0,0,0,.5);
}
.center h2 {
  font-family: var(--f-head); font-weight: 800;
  font-size: clamp(25px, 2.8vw, 39px); line-height: 1.07; letter-spacing: -.035em;
  margin: 0 0 14px; text-wrap: balance;
}
.center .lead { font-size: 15px; }

/* ───────────── Дровер у края ───────────── */

.drawer {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: min(430px, 34vw);
  max-height: calc(100vh - 120px); overflow: hidden;
  background: var(--glass);
  border: 1px solid var(--line);
  backdrop-filter: blur(14px);
  padding: 26px 28px 28px;
  box-shadow: 0 24px 70px rgba(0,0,0,.5);
}
.drawer.is-right { right: 30px; animation: slideRight .5s cubic-bezier(.2,.7,.3,1) both; }
.drawer.is-left { left: 30px; animation: slideLeft .5s cubic-bezier(.2,.7,.3,1) both; }
.drawer h2 {
  font-family: var(--f-head); font-weight: 800;
  font-size: clamp(20px, 1.95vw, 28px); line-height: 1.12; letter-spacing: -.03em;
  margin: 0 0 12px; text-wrap: balance;
}
/* Цветная грань по краю панели: задаёт тему сцены */
.drawer::before {
  content: ''; position: absolute; top: 0; bottom: 0; width: 2px; background: var(--acc);
}
.drawer.is-right::before { left: -1px; }
.drawer.is-left::before { right: -1px; }
.drawer.tone-data::before { background: var(--data); }
.drawer.tone-warn::before { background: var(--warn); }
.drawer.tone-alert::before { background: var(--alert); }

/* ───────────── Общие элементы содержимого ───────────── */

.kicker {
  display: flex; align-items: center; gap: 9px;
  font-family: var(--f-mono); font-size: 9.5px; letter-spacing: .2em;
  text-transform: uppercase; color: var(--acc); margin-bottom: 14px;
}
.kicker::before { content: ''; width: 16px; height: 1px; background: currentColor; flex: none; }
.tone-data .kicker { color: var(--data); }
.tone-warn .kicker { color: var(--warn); }
.tone-alert .kicker { color: var(--alert); }

.lead {
  font-size: 14.5px; line-height: 1.6; color: var(--ink-2); margin: 0;
  text-shadow: 0 1px 12px rgba(0,0,0,.5);
}

.stats { display: flex; gap: 24px; flex-wrap: wrap; margin-top: 22px; }
.stat .v {
  font-family: var(--f-head); font-weight: 800; font-size: 27px; line-height: 1;
  letter-spacing: -.03em; color: var(--acc); font-variant-numeric: tabular-nums;
  display: flex; align-items: baseline; gap: 5px;
}
.stat .v small { font-family: var(--f-body); font-size: 12px; font-weight: 500; color: var(--ink-2); }
.stat .k {
  margin-top: 7px; font-family: var(--f-mono); font-size: 8.5px;
  letter-spacing: .13em; text-transform: uppercase; color: var(--ink-3);
  max-width: 16ch; line-height: 1.5;
}
.tone-data .stat .v { color: var(--data); }
.tone-warn .stat .v { color: var(--warn); }
.tone-alert .stat .v { color: var(--alert); }

.steps { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 18px; }
.steps span {
  font-family: var(--f-mono); font-size: 9px; letter-spacing: .1em;
  text-transform: uppercase; color: var(--ink-2);
  border: 1px solid var(--line); padding: 7px 10px;
  background: rgba(255,255,255,.03);
}
.steps span + span::before { content: '→ '; color: var(--acc); }

.bullets { list-style: none; margin: 18px 0 0; padding: 0; display: flex; flex-direction: column; gap: 9px; }
.bullets li {
  position: relative; padding-left: 18px; font-size: 13.5px; line-height: 1.5; color: var(--ink-2);
}
.bullets li::before {
  content: ''; position: absolute; left: 0; top: 7px; width: 7px; height: 7px;
  border: 1.5px solid var(--acc); border-right-color: transparent; border-bottom-color: transparent;
  transform: rotate(45deg);
}
.tone-data .bullets li::before { border-color: var(--data); border-right-color: transparent; border-bottom-color: transparent; }
.tone-warn .bullets li::before { border-color: var(--warn); border-right-color: transparent; border-bottom-color: transparent; }
.tone-alert .bullets li::before { border-color: var(--alert); border-right-color: transparent; border-bottom-color: transparent; }
.bullets li b { color: var(--ink); font-weight: 600; }

/* «Было → стало» */
.deltas { margin-top: 20px; display: flex; flex-direction: column; gap: 0; }
.delta {
  display: flex; align-items: baseline; justify-content: space-between; gap: 16px;
  padding: 11px 0; border-top: 1px solid var(--line);
}
.delta:last-child { border-bottom: 1px solid var(--line); }
.dk {
  font-family: var(--f-mono); font-size: 9px; letter-spacing: .13em;
  text-transform: uppercase; color: var(--ink-3);
}
.dv { display: inline-flex; align-items: baseline; gap: 10px; }
.was {
  font-size: 13px; color: var(--ink-3); text-decoration: line-through;
  text-decoration-color: rgba(255,107,74,.7);
}
.was::after { content: '→'; margin-left: 10px; color: var(--ink-3); text-decoration: none; display: inline-block; }
.now {
  font-family: var(--f-head); font-weight: 700; font-size: 15px;
  letter-spacing: -.015em; color: var(--acc);
}

.note {
  margin-top: 18px; font-size: 12.5px; line-height: 1.55; color: var(--ink-3);
  border-left: 1px solid var(--line); padding-left: 12px;
}

/* Подписи титула: авторы и сторона поддержки стоят раздельно */
.credits {
  display: flex; flex-wrap: wrap; gap: 0;
  margin-top: 30px; padding-top: 24px; border-top: 1px solid var(--line);
  justify-content: center; align-items: stretch; text-align: left;
}
.credit {
  padding: 0 36px; position: relative;
  display: flex; flex-direction: column; align-items: flex-start; gap: 10px;
  min-width: 200px;
}
.credit + .credit::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0;
  width: 1px; background: var(--line);
}
.credit .role {
  font-family: var(--f-mono); font-size: 8.5px; letter-spacing: .18em;
  text-transform: uppercase; color: var(--ink-3);
}
.credit .names { display: flex; flex-direction: column; gap: 5px; }
.credit .name {
  font-family: var(--f-head); font-size: 15.5px; font-weight: 700;
  letter-spacing: -.015em; color: var(--ink);
}
.credit .detail {
  font-size: 11.5px; line-height: 1.45; color: var(--ink-3); max-width: 26ch;
}
/*
  Эмблема на тёмном фоне: исходный знак свёрстан для белой бумаги, его зелёный
  текст на чёрном не читается. Осветляем целиком — на титуле нужен силуэт,
  а не воспроизведение фирменных цветов.
*/
.credit-logo {
  height: 40px; width: auto; display: block; margin-bottom: 8px;
  filter: brightness(0) invert(1); opacity: .92;
}

/* ───────────── Карточка на схеме ───────────── */

.pin {
  position: absolute; z-index: 4; pointer-events: none;
  width: 226px; transform: translate(-50%, 0);
  animation: pinIn .45s cubic-bezier(.2,.7,.3,1) both;
}
.pin-inner {
  background: var(--glass); border: 1px solid var(--line);
  backdrop-filter: blur(12px); overflow: hidden;
  box-shadow: 0 16px 44px rgba(0,0,0,.55);
}
.pin-body { padding: 12px 13px 13px; }
.pin-title {
  font-family: var(--f-head); font-size: 13.5px; font-weight: 700;
  letter-spacing: -.015em; line-height: 1.25; margin-bottom: 5px;
}
.pin-text { font-size: 11.5px; line-height: 1.45; color: var(--ink-2); }
.pin-tag {
  display: inline-block; margin-bottom: 7px;
  font-family: var(--f-mono); font-size: 8px; letter-spacing: .14em;
  text-transform: uppercase; color: var(--acc);
}
.pin.tone-data .pin-tag { color: var(--data); }
.pin.tone-warn .pin-tag { color: var(--warn); }
.pin.tone-alert .pin-tag { color: var(--alert); }

/*
  Выноска к объекту: карточка стоит сбоку, а линия показывает, к чему она
  относится. Длина и наклон задаются из скрипта — они зависят от того, где
  объект оказался в кадре.
*/
.pin::before {
  content: ''; position: absolute;
  left: 50%; top: 30px;
  width: var(--lead-len, 0px); height: 1px;
  transform-origin: 0 50%;
  transform: rotate(var(--lead-angle, 0deg));
  background: linear-gradient(90deg, currentColor 0%, currentColor 55%, transparent 100%);
  color: var(--acc);
  opacity: .85; pointer-events: none;
}
.pin.tone-data::before { color: var(--data); }
.pin.tone-warn::before { color: var(--warn); }
.pin.tone-alert::before { color: var(--alert); }

/* Точка на конце выноски — она и стоит на объекте */
.pin::after {
  content: ''; position: absolute;
  left: calc(50% + var(--lead-x, 0px)); top: calc(30px + var(--lead-y, 0px));
  width: 7px; height: 7px; margin: -3px 0 0 -3px;
  background: var(--acc); border-radius: 50%;
  box-shadow: 0 0 10px currentColor; pointer-events: none;
}
.pin.tone-data::after { background: var(--data); }
.pin.tone-warn::after { background: var(--warn); }
.pin.tone-alert::after { background: var(--alert); }

/* Маленькая метка без карточки */
.chip {
  position: absolute; z-index: 4; pointer-events: none;
  transform: translate(-50%, -50%);
  background: rgba(5, 10, 9, .92); border: 1px solid var(--line);
  padding: 9px 14px; backdrop-filter: blur(10px);
  font-family: var(--f-mono); font-size: 11px; font-weight: 500; letter-spacing: .14em;
  text-transform: uppercase; color: var(--ink);
  animation: chipIn .4s ease both; white-space: nowrap;
  box-shadow: 0 10px 30px rgba(0,0,0,.55);
}
.chip.tone-acc { border-color: rgba(53,201,141,.5); color: var(--acc); }
.chip.tone-data { border-color: rgba(76,196,224,.5); color: var(--data); }
.chip.tone-warn { border-color: rgba(240,178,63,.5); color: var(--warn); }
.chip.tone-alert { border-color: rgba(255,107,74,.5); color: var(--alert); }

/* ───────────── Нижняя строка ───────────── */

.bottombar {
  position: absolute; left: 0; right: 0; bottom: 0;
  display: flex; align-items: center; gap: 18px; padding: 18px 30px;
}
.counter {
  font-family: var(--f-mono); font-size: 10.5px; letter-spacing: .06em;
  color: var(--ink); font-variant-numeric: tabular-nums;
}
.counter i { color: var(--ink-3); font-style: normal; margin-left: 4px; }

.progress { flex: 1; display: flex; gap: 2px; }
.progress button {
  flex: 1; height: 14px; background: none; border: 0; padding: 0; position: relative; cursor: pointer;
}
.progress button::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: 5px; height: 2px;
  background: rgba(238,244,240,.16); transition: background .25s ease, height .2s ease;
}
.progress button.is-done::after { background: rgba(238,244,240,.4); }
.progress button.is-on::after { background: var(--acc); height: 4px; }
.progress button:hover::after { background: var(--ink); height: 5px; }
/* Первый сегмент акта отмечен ярче — по нему видно границы глав */
.progress button.is-act::after { background: rgba(53,201,141,.5); }

.controls { display: flex; gap: 6px; }
.controls button {
  width: 28px; height: 28px; display: grid; place-items: center;
  background: rgba(8,16,14,.6); border: 1px solid var(--line);
  color: var(--ink-2); cursor: pointer;
  transition: border-color .2s, color .2s, background .2s;
}
.controls button:hover { border-color: var(--ink-3); color: var(--ink); background: rgba(14,26,22,.85); }
.controls button:disabled { opacity: .3; cursor: default; }

/* ───────────── Загрузчик ───────────── */

.loader {
  position: fixed; inset: 0; z-index: 20; display: grid; place-items: center;
  background: #05090b; transition: opacity .9s ease;
}
.loader.is-done { opacity: 0; pointer-events: none; }
.loader-inner { width: min(300px, 60vw); text-align: center; }
.loader-bar { height: 2px; background: rgba(238,244,240,.12); overflow: hidden; }
.loader-bar i { display: block; height: 100%; width: 0; background: var(--acc); transition: width .4s ease; }
.loader-text {
  margin-top: 14px; font-family: var(--f-mono); font-size: 10px;
  letter-spacing: .18em; text-transform: uppercase; color: var(--ink-3);
}

.hint {
  position: fixed; bottom: 54px; left: 50%; transform: translateX(-50%); z-index: 3;
  font-family: var(--f-mono); font-size: 9px; letter-spacing: .16em;
  text-transform: uppercase; color: var(--ink-3);
  background: rgba(6,12,10,.7); border: 1px solid var(--line); padding: 7px 13px;
  transition: opacity .6s ease; pointer-events: none;
}
.hint.is-gone { opacity: 0; }

/* ───────────── Узкий экран ───────────── */

@media (max-width: 1180px) {
  .acts { gap: 12px; font-size: 8.5px; }
}

@media (max-width: 900px) {
  .acts { display: none; }
  .topbar { padding: 14px 18px; }
  .bottombar { padding: 12px 18px; }
  .drawer {
    left: 16px; right: 16px; width: auto;
    top: auto; bottom: 60px; transform: none;
    max-height: 48vh; overflow-y: auto;
  }
  .drawer.is-right, .drawer.is-left { animation: riseIn .5s ease both; transform: none; }
  .center { width: calc(100vw - 32px); padding: 22px 20px 24px; }
  .quote { padding: 40px 24px; }
  .pin { width: 180px; }
  .delta { flex-direction: column; align-items: flex-start; gap: 4px; }
}

@media (prefers-reduced-motion: reduce) {
  .hero-inner, .quote-inner, .center, .drawer, .pin, .chip { animation: none; }
}
