/* Сцена первого экрана и новые общие блоки: вступление, четыре плитки
   статистики, знаки «Коротко», путь подключения, появление ступенями.

   Здесь раскладка и роли цвета через токены. Сырой цвет и характер подачи
   живут в файле версии (look-noir, look-bordo, look-rose), сборка кладёт
   его в css/theme.css. */

:root { --top-h: 73px; }

/* ── сцена ───────────────────────────────────────────────────── */

/* Высота секции = кадр плюс путь прокрутки, на котором график раскладывается. */
.stage { position: relative; height: calc(100vh + 150vh); height: calc(100svh + 150svh); }
.stage-pin {
  position: sticky; top: var(--top-h);
  height: calc(100vh - var(--top-h)); height: calc(100svh - var(--top-h));
  display: grid; grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
}
.stage-head { width: 100%; padding-top: clamp(16px, 3.6vh, 46px); }
.stage .kicker { margin: 0 0 clamp(10px, 1.6vh, 18px); }
.stage .display { font-size: clamp(34px, 4.6vw, 70px); line-height: 1.02; max-width: 26ch; margin: 0; text-wrap: balance; }
/* строки заголовков уравниваются: без висящего последнего слова */
.h2, .cap b { text-wrap: balance; }

.stage-body {
  width: 100%; min-height: 0;
  display: grid; grid-template-rows: minmax(0, 1fr) auto; gap: clamp(8px, 1.6vh, 18px);
  padding-top: clamp(10px, 2.4vh, 28px);
}
.stage-frame { position: relative; min-height: 0; }
.chart.stage-chart { position: absolute; inset: 0; width: auto; }
.stage-chart svg { width: 100%; height: 100%; overflow: visible; }

/* итог всего срока: левый верхний угол кадра, там кривая всегда низко */
.stage-end {
  position: absolute; z-index: 3; pointer-events: none;
  opacity: 0; transform: translateY(8px);
  transition: opacity 700ms var(--ease), transform 700ms var(--ease);
}
.stage-end.on { opacity: 1; transform: none; }
/* ореол цветом фона: рамки годов и линии сетки не прорезают цифру */
.stage-end-n, .stage-end-k { text-shadow: 0 0 12px var(--night), 0 0 3px var(--night); }
.stage-end-n {
  display: block; font-family: var(--f-num), Georgia, serif; font-weight: var(--w-num);
  font-size: clamp(34px, 4.4vw, 66px); line-height: .95; letter-spacing: -.01em;
  color: var(--gold); font-variant-numeric: lining-nums tabular-nums; white-space: nowrap;
}
.stage-end-k {
  display: block; margin-top: 8px; font-size: 11.5px; letter-spacing: .14em;
  text-transform: uppercase; color: var(--cream-3);
}

/* карточки точек истории (подача rose): места считает сцена */
.stage-tiles { position: absolute; inset: 0; pointer-events: none; z-index: 2; }
.st-tile {
  position: absolute; box-sizing: border-box; overflow: hidden; opacity: 0;
  display: flex; flex-direction: column; justify-content: center; gap: 5px;
  padding: 10px 16px; border-radius: var(--r-m);
  background: var(--card); border: 1px solid var(--line);
  transform-origin: 50% 50%; pointer-events: auto;
}
.st-k { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--cream-3); line-height: 1.2; }
.st-v {
  font-family: var(--f-num), Georgia, serif; font-weight: var(--w-num);
  font-size: clamp(22px, 2.2vw, 32px); line-height: 1; color: var(--gold);
  font-variant-numeric: lining-nums tabular-nums; white-space: nowrap;
}
.st-tile.neg .st-v { color: var(--rose); }
.st-d { font-size: 12.5px; color: var(--cream-2); font-variant-numeric: tabular-nums; }

/* подписи шагов раскладки: в одном месте, сменяют друг друга */
.stage-caps {
  display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: start; gap: 22px;
  min-height: clamp(74px, 11vh, 100px);
}
.cap-dots { list-style: none; display: flex; gap: 6px; padding-top: 9px; margin: 0; }
.cap-dots li { width: 20px; height: 2px; background: var(--line-2); transition: background 400ms var(--ease); }
.cap-dots li.on { background: var(--gold); }
.cap-list { display: grid; }
.cap {
  grid-area: 1 / 1; max-width: 76ch;
  opacity: 0; transform: translateY(10px);
  transition: opacity 500ms var(--ease), transform 500ms var(--ease);
}
.cap.on { opacity: 1; transform: none; }
.cap-n { display: none; }
.cap b {
  display: block; font-family: var(--f-display), Georgia, serif; font-weight: 500;
  font-size: clamp(19px, 1.7vw, 25px); line-height: 1.15; color: var(--cream);
}
.cap-x { display: block; margin-top: 6px; font-size: clamp(14px, 1.15vw, 16px); line-height: 1.55; color: var(--cream-2); }

/* приглашение листать: пропадает, как только раскладка началась */
.stage-cue {
  display: flex; align-items: center; justify-content: center; gap: 12px; margin: 0;
  padding: 2px 0 clamp(10px, 2vh, 18px);
  font-size: 12.5px; letter-spacing: .08em; color: var(--cream-3);
  transition: opacity 400ms var(--ease);
}
.stage-cue i {
  display: block; width: 1px; height: 22px; transform-origin: top;
  background: linear-gradient(var(--gold), transparent);
  animation: cue 1.9s var(--ease) infinite;
}
@keyframes cue { 0% { transform: scaleY(0); opacity: 1; } 70% { transform: scaleY(1); opacity: 1; } 100% { transform: scaleY(1); opacity: 0; } }
.stage.moved .stage-cue { opacity: 0; }

/* ── svg сцены ───────────────────────────────────────────────── */

.s-grid { stroke: var(--line); stroke-width: 1; }
.s-lbl { fill: var(--cream-3); font: 400 11px "Golos", sans-serif; letter-spacing: .04em; }
.s-line { fill: none; stroke: var(--gold); stroke-width: 2.4; stroke-linejoin: round; stroke-linecap: round; }
.s-halo { fill: none; stroke: var(--gold); stroke-width: 7; opacity: .12; stroke-linejoin: round; stroke-linecap: round; }
.s-halo-2 { stroke-width: 16; opacity: .045; }
.s-stop-a { stop-color: var(--gold); stop-opacity: .26; }
.s-stop-b { stop-color: var(--gold); stop-opacity: 0; }
.s-tip-dot { fill: var(--gold); }
.s-tip-halo { fill: var(--gold); opacity: .2; transform-box: fill-box; transform-origin: center; }
.stage.ready .s-tip-halo { animation: tip 2.6s var(--ease) infinite; }
@keyframes tip { 0% { transform: scale(.5); opacity: .4; } 100% { transform: scale(1.9); opacity: 0; } }

.s-bar { fill: var(--gold); opacity: .85; }
.s-bar-neg { fill: var(--rose); opacity: .9; }
.s-dd-fill { fill: var(--rose-soft); }
.s-dd-line { fill: none; stroke: var(--rose); stroke-width: 1.4; }
.s-tier { fill: var(--cream-2); font: 600 10.5px "Golos", sans-serif; letter-spacing: .14em; }
.s-cap { fill: var(--gold); }
.s-cap.neg { fill: var(--rose); }
.s-ddv {
  fill: var(--rose); font: 600 12px "Golos", sans-serif; font-variant-numeric: tabular-nums;
  paint-order: stroke; stroke: var(--night); stroke-width: 4px; stroke-linejoin: round;
}
.s-frame { stroke: var(--line-2); stroke-width: 1; }
.s-year { fill: var(--cream); font-family: var(--f-display), Georgia, serif; font-style: italic; font-size: 21px; }
.s-ytot { fill: var(--gold); font: 600 13px "Golos", sans-serif; font-variant-numeric: tabular-nums; }
.s-ytot.neg { fill: var(--rose); }
.s-pt-dot { fill: var(--night); stroke: var(--gold); stroke-width: 2; }
.s-pt.neg .s-pt-dot { stroke: var(--rose); }
.s-pt-halo { fill: var(--gold); opacity: .16; }
.s-pt.neg .s-pt-halo { fill: var(--rose); }
.s-pt-lbl {
  fill: var(--cream-2); font: 500 11.5px "Golos", sans-serif; letter-spacing: .03em;
  paint-order: stroke; stroke: var(--night); stroke-width: 4px; stroke-linejoin: round;
}
.s-wire { stroke: var(--gold); stroke-width: 1; stroke-dasharray: 2 3; }
.s-sheen-0 { stop-color: var(--sheen); stop-opacity: 0; }
.s-sheen-1 { stop-color: var(--sheen); stop-opacity: .55; }
.s-sheen { opacity: 0; transform-box: fill-box; }
.s-sheen.go { animation: sheen 2.4s var(--ease) 1 both; }
@keyframes sheen { 0% { transform: translateX(0); opacity: 1; } 90% { opacity: 1; } 100% { transform: translateX(360%); opacity: 0; } }

/* ── вступление после сцены ──────────────────────────────────── */

.intro { padding: clamp(56px, 7vw, 100px) 0 clamp(40px, 5vw, 72px); position: relative; }
.intro-in > * + * { margin-top: 24px; }
@media (min-width: 1040px) {
  .intro-in {
    display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, .95fr);
    column-gap: clamp(48px, 6vw, 96px); align-items: center;
  }
  .intro-in > * { grid-column: 1; margin-top: 0; }
  .intro-in > .hero-cta { margin-top: 30px; }
  .intro-in > .micro { margin-top: 14px; }
  .intro-in > .hero-figs {
    grid-column: 2; grid-row: 1 / span 3; margin-top: 0;
    grid-template-columns: 1fr 1fr; gap: 1px; padding: 0;
    background: var(--line); border: 1px solid var(--line); border-radius: var(--r-l); overflow: hidden;
  }
  .intro-in > .hero-figs .fig { border: 0; border-radius: 0; background: var(--card); padding: clamp(24px, 2.4vw, 34px) clamp(20px, 2vw, 30px); }
  .intro-in > .hero-figs .fig-n { font-size: clamp(34px, 3.3vw, 48px); }
}

/* ── «Коротко»: знак и номер у каждой плитки ─────────────────── */

.brief-item { position: relative; overflow: hidden; }
.brief-ic {
  display: grid; place-items: center; width: 48px; height: 48px; margin-bottom: 20px;
  border-radius: 50%; border: 1px solid var(--line-2); color: var(--gold);
}
/* знак рисуется маской цвета текста: подача красит его через color */
.brief-ic::before {
  content: ""; width: 22px; height: 22px; background: currentColor;
  -webkit-mask: var(--ic) center / contain no-repeat; mask: var(--ic) center / contain no-repeat;
}
.brief-item:nth-child(1) .brief-ic { --ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 18l5-6 4 3 8-9'/%3E%3Ccircle cx='20' cy='6' r='1.6'/%3E%3C/svg%3E"); }
.brief-item:nth-child(2) .brief-ic { --ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='4' y='10' width='16' height='10' rx='2'/%3E%3Cpath d='M8 10V7a4 4 0 0 1 8 0v3'/%3E%3Ccircle cx='12' cy='15' r='1.3'/%3E%3C/svg%3E"); }
.brief-item:nth-child(3) .brief-ic { --ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='7.5' cy='7.5' r='2.5'/%3E%3Ccircle cx='16.5' cy='16.5' r='2.5'/%3E%3Cpath d='M18 6L6 18'/%3E%3C/svg%3E"); }
.brief-item:nth-child(4) .brief-ic { --ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cellipse cx='12' cy='6.5' rx='7' ry='2.5'/%3E%3Cpath d='M5 6.5v5c0 1.4 3.1 2.5 7 2.5s7-1.1 7-2.5v-5'/%3E%3Cpath d='M5 11.5v5c0 1.4 3.1 2.5 7 2.5s7-1.1 7-2.5v-5'/%3E%3C/svg%3E"); }
.brief-n {
  position: absolute; top: clamp(24px, 2.8vw, 34px); right: clamp(24px, 2.8vw, 34px);
  font-family: var(--f-display), Georgia, serif; font-size: 15px; letter-spacing: .1em; color: var(--cream-3);
}

/* ── четыре плитки статистики ────────────────────────────────── */

.xstats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-bottom: clamp(44px, 5vw, 68px); }
.xs {
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; gap: 12px;
  padding: clamp(22px, 2.4vw, 30px);
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-m);
}
.xs-k { font-size: 11.5px; letter-spacing: .13em; text-transform: uppercase; color: var(--cream-3); }
.xs-n {
  font-family: var(--f-num), Georgia, serif; font-weight: var(--w-num);
  font-size: clamp(36px, 3.6vw, 50px); line-height: 1; color: var(--cream);
  font-variant-numeric: lining-nums tabular-nums;
}
.xs-n .of { font-size: .48em; color: var(--cream-3); margin-left: 6px; }
.xs-n .neg { color: var(--rose); margin-left: 16px; }
.xs-viz { min-height: 54px; margin-top: 4px; }
.xs-x { font-size: 14px; line-height: 1.6; color: var(--cream-2); margin-top: auto; }

.xs-bar { display: flex; height: 12px; border-radius: 999px; overflow: hidden; background: var(--line); gap: 2px; }
.xs-up { background: var(--gold); border-radius: 999px 0 0 999px; }
.xs-dn { background: var(--rose); border-radius: 0 999px 999px 0; opacity: .9; }
.xs-legend { display: flex; flex-wrap: wrap; gap: 6px 20px; margin-top: 12px; font-size: 13px; color: var(--cream-2); }
.xs-legend i { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 8px; }
.xs-legend i.up { background: var(--gold); }
.xs-legend i.dn { background: var(--rose); }

.xs-cal { display: grid; grid-template-columns: 38px repeat(12, minmax(0, 1fr)); gap: 4px; align-items: center; }
.xs-yr { font-size: 11px; color: var(--cream-3); font-variant-numeric: tabular-nums; }
.xs-cell { aspect-ratio: 1; border-radius: 3px; }
.xs-cell.up { background: var(--gold); opacity: var(--a, 1); }
.xs-cell.dn { background: var(--rose); opacity: var(--a, 1); }
.xs-cell.flat { background: var(--line-2); }
.xs-cell.void { border: 1px dashed var(--line); }

.xs-pfrow { display: grid; grid-template-columns: 76px minmax(0, 1fr); align-items: center; gap: 12px; }
.xs-pfrow + .xs-pfrow { margin-top: 10px; }
.xs-pfk { font-size: 13px; color: var(--cream-2); }
.xs-pfbar { display: block; height: 14px; border-radius: 999px; overflow: hidden; background: var(--line); }
.xs-pfbar i { display: block; height: 100%; border-radius: 999px; }
.xs-pfbar i.up { background: var(--gold); }
.xs-pfbar i.dn { background: var(--rose); }

.xs-viz svg { display: block; width: 100%; height: auto; }
.xs-tk { fill: none; stroke-width: 1; }
.xs-tk.up { stroke: var(--gold); opacity: .42; }
.xs-tk.dn { stroke: var(--rose); opacity: .5; }
.xs-zero { stroke: var(--cream-2); stroke-width: 1; }
.xs-rl { fill: var(--cream-3); font: 500 11.5px "Golos", sans-serif; font-variant-numeric: tabular-nums; }

/* ── путь до первой сделки: шаги связаны линией ──────────────── */

.steps .step { position: relative; }
.steps .step + .step::before {
  content: ""; position: absolute; left: clamp(32px, 3.6vw, 40px); top: -15px; width: 1px; height: 15px;
  background: var(--line-2);
}

/* ── появление ступенями и рост столбиков ────────────────────── */

/* Анимация, а не переход: заполнение backwards держит начальное состояние
   только до старта, после конца у плитки снова свои переходы при наведении. */
.stg:not(.in) > * { opacity: 0; }
.stg.in > * { animation: stg-in 760ms var(--ease) backwards; animation-delay: calc(var(--i, 0) * 75ms + 40ms); }
@keyframes stg-in { from { opacity: 0; transform: translateY(18px); } }

.mo-fill, .dist-in, .sym-in, .xs-up, .xs-pfbar i { transform-origin: left center; }
.mo-fill.neg, .xs-dn { transform-origin: right center; }
.grow:not(.in) .mo-fill, .grow:not(.in) .dist-in, .grow:not(.in) .sym-in,
.grow:not(.in) .xs-up, .grow:not(.in) .xs-dn, .grow:not(.in) .xs-pfbar i { transform: scaleX(0); }
.grow:not(.in) .xs-cell, .grow:not(.in) .xs-tk { opacity: 0; }
.grow.in .mo-fill, .grow.in .dist-in, .grow.in .sym-in,
.grow.in .xs-up, .grow.in .xs-dn, .grow.in .xs-pfbar i {
  animation: bar-in 900ms var(--ease) backwards; animation-delay: calc(var(--i, 0) * 32ms + 80ms);
}
.grow.in .xs-cell { animation: cell-in 520ms var(--ease) backwards; animation-delay: calc(var(--i, 0) * 14ms + 60ms); }
.grow.in .xs-tk { animation: fade-in 1200ms var(--ease) backwards .1s; }
@keyframes bar-in { from { transform: scaleX(0); } }

/* ответ в вопросах проявляется, а не выскакивает */
.faq details[open] .ans { animation: ans-in 420ms var(--ease) both; }
@keyframes ans-in { from { opacity: 0; transform: translateY(-6px); } }
@keyframes cell-in { from { transform: scale(.2); opacity: 0; } }
@keyframes fade-in { from { opacity: 0; } }

/* ── адаптив ─────────────────────────────────────────────────── */

@media (max-width: 860px) {
  /* снизу на телефоне висит панель с кнопкой: кадр сцены кончается над ней */
  .stage { height: calc(100vh + 130vh); height: calc(100svh + 130svh); }
  .stage-pin {
    height: calc(100vh - var(--top-h) - 70px - env(safe-area-inset-bottom));
    height: calc(100svh - var(--top-h) - 70px - env(safe-area-inset-bottom));
  }
  .stage-cue { display: none; }
  .stage .display { font-size: clamp(29px, 8.4vw, 44px); line-height: 1.04; }
  .stage-caps { grid-template-columns: 1fr; gap: 10px; min-height: 104px; }
  .cap-dots { padding-top: 0; }
  .cap b { font-size: 18px; }
  .cap-x { font-size: 14px; line-height: 1.5; }
  .stage-end-n { font-size: clamp(28px, 8.2vw, 40px); }
  .stage-end-k { font-size: 10.5px; margin-top: 6px; }
  .st-tile { padding: 6px 11px; gap: 2px; }
  .st-v { font-size: 20px; }
  .st-k { font-size: 9.5px; letter-spacing: .1em; }
  .st-d { font-size: 11px; }
  .xstats { grid-template-columns: 1fr; }
}
@media (max-width: 380px) {
  .stage .display { font-size: 27px; }
}

/* без движения: сцена не закрепляется, раскладка показана готовой */
.stage.rm { height: auto; }
.stage.rm .stage-pin { position: relative; top: 0; height: auto; overflow: visible; }
.stage.rm .stage-frame { height: min(72vh, 600px); }
.stage.rm .cap-list { gap: 18px; }
.stage.rm .cap { grid-area: auto; opacity: 1; transform: none; }
.stage.rm .cap-dots, .stage.rm .stage-cue { display: none; }
.stage.rm .stage-end { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  .stg:not(.in) > *, .grow:not(.in) .xs-cell, .grow:not(.in) .xs-tk { opacity: 1; }
  .grow:not(.in) .mo-fill, .grow:not(.in) .dist-in, .grow:not(.in) .sym-in,
  .grow:not(.in) .xs-up, .grow:not(.in) .xs-dn, .grow:not(.in) .xs-pfbar i { transform: none; }
  .stage-cue i { animation: none; }
}
