/* =====================================================================
   6. HOW IT WORKS — вкладки Consumers / Businesses, вступление и шаги.
   Компьютер: слева «липкая» картинка, справа шаги на таймлайне; активный шаг
   (тот, что посреди экрана) подсвечивается, картинка плавно меняется (js/main.js, п. 9).
   Планшет/телефон: обычная лента — у каждого шага своя картинка сверху.
   ===================================================================== */

.how { height: auto; padding: 40px 0 90px; }
.how .wrap { padding: 0 60px; }

.how__tabs { margin: 0 auto 56px; }
.how .panels > :not(.is-active) { display: none; }          /* неактивная вкладка не занимает места */
.how .panels > .is-active { animation: fade-in .6s ease both; }

/* ---------- вступление ---------- */
.how__intro { max-width: 764px; }
.how__eyebrow { font: 500 18px/1 var(--head); }
.how__title   { margin-top: 16px; font: 500 50px/50px var(--head); }
.how__text    { margin-top: 20px; line-height: 19.2px; }
.how__intro .btn { margin-top: 28px; width: auto; min-width: 179px; gap: 16px; }

/* ---------- шаги ---------- */
.how__steps {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 470px);
  gap: 70px; align-items: start; margin-top: 64px;
}
.how__media {
  position: sticky; top: calc(50vh - 170px);
  aspect-ratio: 716 / 322; border-radius: 20px; overflow: hidden; background: var(--media);
}
/* «колода»: уходящая картинка уезжает вверх, новая выезжает снизу; активная медленно приближается */
.how__media img {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
  opacity: 0; translate: 0 16%; scale: .92; filter: blur(8px);
  transition: opacity .7s ease, translate .9s cubic-bezier(.2, .8, .2, 1), scale .9s cubic-bezier(.2, .8, .2, 1), filter .7s ease;
}
.how__media img.is-past   { translate: 0 -12%; scale: 1.06; }
.how__media img.is-active { opacity: 1; translate: 0 0; scale: 1; filter: none; animation: how-zoom 9s ease-in-out .9s infinite alternate; }
@keyframes how-zoom { from { scale: 1; } to { scale: 1.07; } }

/* счётчик «01 / 05» и сегменты прогресса поверх картинки */
.how__counter {
  position: absolute; left: 20px; bottom: 20px; z-index: 1;
  display: flex; align-items: center; gap: 14px; padding: 10px 16px;
  border-radius: 12px; background: rgba(255, 255, 255, .55); border: 1px solid rgba(255, 255, 255, .8);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  font: 500 14px/1 var(--head); color: var(--navy);
}
.how__num { display: inline-block; min-width: 2ch; font-size: 22px; }
.how__num.is-rolling { animation: how-roll .45s cubic-bezier(.2, .8, .2, 1); }
@keyframes how-roll { from { opacity: 0; translate: 0 60%; } to { opacity: 1; translate: 0 0; } }
.how__bars { display: flex; gap: 5px; }
.how__bars i { width: 22px; height: 3px; border-radius: 2px; background: rgba(31, 63, 91, .2); transition: background-color .4s; }
.how__bars i.is-on { background: var(--cyan); }

/* таймлайн: вертикальная линия и ромб у каждого шага */
.how__list { position: relative; padding-left: 44px; }
/* линия идёт от первого ромба до последнего: --line-top / --line-h считает js/main.js */
.how__list::before, .how__list::after { content: ""; position: absolute; left: 8px; top: var(--line-top, 12px); width: 1px; background: var(--line); }
.how__list::before { height: var(--line-h, calc(100% - 24px)); }
.how-step { z-index: 1; }   /* ромбы шагов лежат поверх обеих линий */
/* бирюзовая линия заполняется по мере прокрутки (--progress от 0 до 1 ставит js/main.js) */
.how__list::after { width: 2px; margin-left: -.5px; height: calc(var(--line-h, 0px) * var(--progress, 0)); background: var(--cyan); border-radius: 2px; }

.how-step { position: relative; display: flex; flex-direction: column; justify-content: center; min-height: 52vh; padding: 32px 0; }
.how-step::before {
  content: ""; position: absolute; left: -41px; top: calc(50% - 6px); width: 12px; height: 12px;
  background: var(--line); rotate: 45deg; transition: background-color .4s, scale .4s;
}
.how-step__img { display: none; width: 100%; aspect-ratio: 716 / 322; object-fit: cover; border-radius: 16px; margin-bottom: 20px; }
.how-step__icon { width: 25px; margin-bottom: 14px; }
.how-step h3 { font: 500 24px/28.8px var(--head); }
.how-step h3 + * { margin-top: 12px; }
.how-step p, .how-step li { font-size: 15px; line-height: 1.4; }
.how-step p + p, .how-step p + ul, .how-step ul + p { margin-top: 10px; }
.how-step .label { font-weight: 600; }
.how-step strong { font-family: var(--head); font-weight: 700; }
.how-step .btn { margin-top: 24px; width: auto; min-width: 179px; gap: 16px; align-self: flex-start; }

.bullets li { position: relative; padding-left: 26px; }
.bullets li + li { margin-top: 6px; }
.bullets li::before {
  content: ""; position: absolute; left: 1px; top: 2px; width: 15px; height: 15px;
  background: url(../../img/icon-arrow-bullet.png) center / contain no-repeat; rotate: 45deg;
}

/* подсветка активного шага (только если работает JS) */
.how-step.is-active::before { background: var(--cyan); scale: 1.45; animation: how-glow 1.6s ease-in-out infinite; }
@keyframes how-glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(50, 206, 216, .7), 0 0 6px rgba(50, 206, 216, .5); }
  50%      { box-shadow: 0 0 0 14px rgba(50, 206, 216, 0), 0 0 26px rgba(50, 206, 216, .9); }
}
/* содержимое активного шага въезжает по строкам */
/* неактивные шаги приглушены (только содержимое — ромб остаётся непрозрачным поверх линии) */
.js .how-step > * { opacity: .35; translate: 0 12px; transition: opacity .4s, translate .6s cubic-bezier(.2, .8, .2, 1); }
.js .how-step.is-active > * { opacity: 1; translate: 0 0; }
.js .how-step.is-active > :nth-child(2) { transition-delay: .05s; }
.js .how-step.is-active > :nth-child(3) { transition-delay: .1s; }
.js .how-step.is-active > :nth-child(4) { transition-delay: .15s; }
.js .how-step.is-active > :nth-child(n+5) { transition-delay: .2s; }

/* без JS картинки показываются прямо в шагах */
html:not(.js) .how__media { display: none; }
html:not(.js) .how-step__img { display: block; }

/* desktop 1250–1439 */
@media (max-width: 1439px) {
  .how__steps { grid-template-columns: minmax(0, 1fr) minmax(0, 430px); gap: 50px; }
}

/* планшет и телефон: одна колонка, картинка у каждого шага */
@media (max-width: 1249px) {
  .how { padding: 30px 0 60px; }
  .how .wrap { padding: 0 30px; }
  .how__tabs { margin-bottom: 40px; }
  .how__title { font-size: 40px; line-height: 40px; }
  .how__text { font-size: 14px; line-height: 16.8px; }

  .how__steps { display: block; margin-top: 40px; }
  .how__media { display: none; }
  .how-step__img { display: block; }
  .how__list { padding-left: 34px; }
  .how__list::before, .how__list::after { left: 6px; }
  .how-step { min-height: 0; padding: 22px 0; }
  .how-step::before { left: -33px; top: 40px; }
  .js .how-step > * { opacity: 1; translate: none; }
  /* картинка «раскрывается», когда шаг появляется на экране */
  .js .how-step__img { clip-path: inset(10% 14% round 16px); opacity: .3; scale: 1.08;
    transition: clip-path .9s cubic-bezier(.2, .8, .2, 1), opacity .9s, scale 1.2s cubic-bezier(.2, .8, .2, 1); }
  .js .how-step.is-seen .how-step__img { clip-path: inset(0 round 16px); opacity: 1; scale: 1; }
}
@media (max-width: 739px) {
  .how .wrap { padding: 0; }
  .how__tabs { margin-bottom: 32px; }
  .how__eyebrow { font-size: 14px; }
  .how__title { margin-top: 10px; font-size: 25px; line-height: 25px; }
  .how__list { padding-left: 26px; }
  .how__list::before, .how__list::after { left: 4px; }
  .how-step::before { left: -27px; top: 30px; width: 10px; height: 10px; }
  .how-step h3 { font-size: 18px; line-height: 21.6px; }
  .how-step p, .how-step li { font-size: 13px; }
  .how-step__img { border-radius: 12px; margin-bottom: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  .how__media img, .how-step, .how-step > *, .how-step__img { transition: none !important; animation: none !important; }
}
