/* GOFAR — анимации главной.
   1) Сцена «Самолётик летит в Австрию» (#ablauf). Логика: js/journey.js.
   2) Сквозной полёт через страницу (.flight). Логика: js/flight.js.
   Параметры обеих — js/journey-config.js.
   Весь сайт тёмный; класс .tone-light у секции оставлен на случай, если сцену
   понадобится показать светлой (брендбук), по умолчанию стоит .tone-dark. */

.journey {
  --j-bg: #0A0A0C;
  --j-text: #EEEEF2;
  --j-muted: #A0A0AB;
  --j-dim: #5d5d6b;
  --j-route: #C7C6FF;
  --j-lit: #7572FF;
  --j-trail: #FFFFFF;
  --j-plane: #FFFFFF;
  --j-plane-edge: #7572FF;
  --j-dest: #FFF29A;
  --j-grid: rgba(199,198,255,.12);
  --j-card: #131318;
  --j-border: #26262E;
  --j-accent: #7572FF;
  --j-head: #EEEEF2;
  --j-sub: #C7C6FF;
  /* фон прозрачный: под сценой тот же тёмный фон страницы, а сквозной
     полёт (слой ниже контента) виден до самой точки передачи */
  padding: var(--section) 0 clamp(40px, 5vw, 72px);
  color: var(--j-text);
  position: relative;
}
.journey.tone-light {
  --j-bg: #FFFFFF; --j-text: #000; --j-muted: #4B4C63; --j-dim: #B9BAD0;
  --j-route: #767CF6; --j-lit: #3075FC; --j-trail: #3075FC; --j-plane: #3075FC; --j-plane-edge: #fff;
  --j-dest: #FFF29A; --j-grid: rgba(118,124,246,.16); --j-card: #F5F6FF; --j-border: #E3E4F3;
  --j-accent: #3075FC; --j-head: #3075FC; --j-sub: #3075FC;
  background: var(--j-bg);
}
/* мягкое свечение, как на gofar.school (ниже слоя полёта) */
.journey.tone-dark::before {
  content: ""; position: absolute; z-index: 0; inset: 0; pointer-events: none;
  background:
    radial-gradient(36% 22% at 86% 8%, rgba(117,114,255,.20), transparent 70%),
    radial-gradient(32% 26% at 8% 62%, rgba(123,63,228,.14), transparent 70%);
}
.journey h2 { color: var(--j-head); }
.journey .sub { color: var(--j-sub); }
.journey-head { margin-bottom: clamp(16px, 3vw, 36px); }
.journey-head h2 { max-width: 14em; }
.journey-head .sub { max-width: 36em; }

/* ---- трек и липкая сцена ---- */
.journey-track { position: relative; }
.journey--live .journey-track { height: var(--journey-length, 340svh); }
.journey-stage { display: grid; grid-template-rows: minmax(0, 1fr) auto auto; gap: 14px; }
.journey--live .journey-stage {
  position: sticky; top: var(--header-h);
  height: calc(100vh - var(--header-h)); height: calc(100svh - var(--header-h));
  padding: 8px var(--gutter) 22px;
  max-width: var(--wrap); margin: 0 auto;
}
.journey--static .journey-stage { max-width: var(--wrap); margin: 0 auto; padding: 0 var(--gutter); }

.journey-map { position: relative; min-height: 0; }
.journey-svg { display: block; width: 100%; height: 100%; overflow: visible; }
.journey--static .journey-map { aspect-ratio: 1200 / 620; }

/* ---- SVG ---- */
.j-grid-dot { fill: var(--j-grid); }
.j-route-base { fill: none; stroke: var(--j-route); stroke-opacity: .35; stroke-width: 1.6; stroke-dasharray: 2 9; stroke-linecap: round; }
.j-route-lit { fill: none; stroke: var(--j-lit); stroke-width: 2.2; stroke-linecap: round; opacity: .9; }
.j-trail { fill: none; stroke: var(--j-trail); stroke-width: 3; stroke-linecap: round; }
.j-node-dot { fill: var(--j-dim); transition: fill .3s; }
.j-node-halo { fill: var(--j-lit); opacity: 0; transform-origin: 0 0; transition: opacity .4s; }
.j-node.is-on .j-node-dot { fill: var(--j-route); }
.j-node.is-on .j-node-halo { opacity: .22; }
.j-label {
  font-family: var(--display); font-weight: 700; font-size: var(--label, 20px); letter-spacing: -.01em;
  fill: var(--j-muted); transition: fill .3s; paint-order: stroke; stroke: var(--j-bg); stroke-width: 6px; stroke-linejoin: round;
}
.j-node.is-on .j-label { fill: var(--j-text); }
.j-dest-dot { fill: var(--j-dest); }
.j-dest-ring { fill: none; stroke: var(--j-dest); stroke-width: 2; opacity: .5; transform-origin: 0 0; }
.j-dest-label { fill: var(--j-text); font-weight: 800; font-size: calc(var(--label, 20px) * 1.25); }
.journey--live .j-dest-ring { animation: j-ring 2.4s ease-out infinite; }
@keyframes j-ring { from { transform: scale(.5); opacity: .8; } to { transform: scale(1.6); opacity: 0; } }
.j-plane-body { fill: var(--j-plane); stroke: var(--j-plane-edge); stroke-width: 1.6; stroke-linejoin: round; }
.j-plane { transition: opacity .35s ease; filter: drop-shadow(0 0 8px rgba(117,114,255,.7)); }
.is-caught .j-plane { opacity: 0; }
.journey--static .j-plane { display: none; }
/* стыковка со сквозным полётом: пока сцена не началась (p = 0), самолёт ведёт flight.js,
   свой самолёт сцены спрятан; переключение мгновенное, чтобы не было двух самолётов */
.flight-live .j-plane { transition: none; }
.flight-live .is-caught .j-plane { transition: opacity .35s ease; }
.flight-live .journey.is-pre .j-plane { opacity: 0; }

/* ---- маскот у точки назначения (позиция --vx/--vy считается в journey.js) ---- */
.journey-mascot {
  position: absolute; left: var(--vx, 14%); top: var(--vy, 55%);
  width: clamp(110px, 13vw, 200px); aspect-ratio: 1;
  transform: translate(-50%, 18px);
  pointer-events: none;
}
.journey-mascot img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 14px 24px rgba(0,0,0,.5)); transition: opacity .25s ease, transform .45s cubic-bezier(.3,1.6,.5,1); }
.journey-mascot .m-catch { opacity: 0; transform: scale(.85) translateY(6px); }
.is-caught .journey-mascot .m-wait { opacity: 0; transform: scale(.9); }
.is-caught .journey-mascot .m-catch { opacity: 1; transform: none; }
/* лёгкое «ожидание» пока самолёт в пути */
.journey--live.is-flying .journey-mascot .m-wait { animation: j-bob 2.2s ease-in-out infinite; }
@keyframes j-bob { 50% { transform: translateY(-5px) rotate(-2deg); } }

/* ---- шаги ---- */
.journey-steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
/* карточки непрозрачные (без opacity): иначе сквозь них просвечивает след самолёта */
.jstep { background: var(--j-card); border: 1px solid var(--j-border); border-radius: 18px; padding: 14px 16px 16px; transition: border-color .3s, background-color .3s; }
.jstep b { display: flex; align-items: center; gap: 10px; font-family: var(--display); font-weight: 700; font-size: 16.5px; letter-spacing: -.01em; color: var(--j-text); }
.jn { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; flex: none; font-size: 13px; font-weight: 800; border: 1.5px solid var(--j-route); color: var(--j-route); }
.jstep p { margin: 8px 0 0; font-size: 14.5px; line-height: 1.45; color: var(--j-muted); }
.journey--live .jstep:not(.is-active) b { color: #B4B4BE; }
.journey--live .jstep:not(.is-active):not(.is-done) .jn { border-color: #5d5d6b; color: #A0A0AB; }
.jstep.is-active { border-color: var(--j-accent); background: #16152a; }
.jstep.is-active .jn, .jstep.is-done .jn { background: var(--btn, #625EEB); border-color: var(--btn, #625EEB); color: #fff; }

.journey-progress { height: 3px; border-radius: 3px; background: var(--j-border); overflow: hidden; }
.journey-progress span { display: block; height: 100%; background: linear-gradient(90deg, var(--j-accent), var(--j-route)); transform-origin: 0 50%; transform: scaleX(0); }
.journey--static .journey-progress { display: none; }

@media (max-width: 1060px) {
  .jstep p { font-size: 13.5px; }
}
/* телефон: карта вертикальная, показываем только активный шаг */
@media (max-width: 759.98px) {
  .journey--live .journey-stage { padding-bottom: 14px; gap: 10px; }
  /* пустой коридор над картой: здесь самолёт выныривает из-за края (flight.mobile.corridor) */
  .flight-live .journey-head { margin-bottom: 132px; }
  .journey-steps { grid-template-columns: 1fr; }
  /* все шаги лежат в одной ячейке, видим только активный: высота блока шагов постоянная
     (по самому длинному шагу), поэтому карта не меняет размер при смене шага и след
     сквозного полёта не съезжает со стран (раньше display:none давал скачок ~10 px) */
  .journey--live .jstep { grid-area: 1 / 1; visibility: hidden; }
  .journey--live .jstep.is-active { visibility: visible; animation: j-in .35s ease; }
  .journey--static .journey-map { aspect-ratio: 600 / 900; max-width: 440px; margin: 0 auto; width: 100%; }
  .journey-mascot { width: clamp(96px, 30vw, 150px); transform: translate(-50%, 2px); }
}
@media (max-width: 759.98px) and (prefers-reduced-motion: reduce) {
  .journey-mascot { width: 120px; }
}
@keyframes j-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ============ Сквозной полёт (js/flight.js) ============
   Слой лежит в <main> под контентом (z-index 1; контент секций — z-index 2),
   поэтому самолёт никогда не перекрывает текст и кнопки и не ловит клики. */
main { position: relative; }
.flight { display: none; position: absolute; left: 0; top: 0; width: 100%; height: 0; z-index: 1; pointer-events: none; overflow: hidden; }
.flight-live .flight { display: block; }
.flight svg { position: absolute; left: 0; top: 0; overflow: visible; }
.f-route { fill: none; stroke: #C7C6FF; stroke-opacity: .26; stroke-width: 1.6; stroke-dasharray: 2 10; stroke-linecap: round; }
.f-glow { fill: none; stroke: #7572FF; stroke-opacity: .2; stroke-width: 9; stroke-linecap: round; }
.f-trail { fill: none; stroke: #C7C6FF; stroke-width: 2.2; stroke-linecap: round; stroke-opacity: .9; }
.f-plane { filter: drop-shadow(0 0 10px rgba(117,114,255,.75)); }
.f-plane-body { fill: #FFFFFF; stroke: #7572FF; stroke-width: 1.6; stroke-linejoin: round; }
.f-plane.is-hidden { visibility: hidden; }

@media (prefers-reduced-motion: reduce) {
  .journey-mascot img, .jstep { transition: none; }
  .flight { display: none !important; }
}
