/* «Окно перемен» — первый экран и «Как это работает» в одной сцене.
   Остановки: 0 — первый экран с заголовком, 1–5 — шаги. Кадры меняются при скролле, между шагами —
   переход из Kling (видео перематывается скроллом) или, пока его нет, «запотевание» стекла.
   Переменные (--fog, --steps, opacity слоёв) выставляет window.js. Без JS и при «меньше анимации» —
   статичный первый экран и список шагов. */

html.snap { scroll-snap-type: y proximity; scroll-padding-top: 0; }

.win { position: relative; background: #1d1219; color: #fff; --step: 100vh; --fog: 0; --steps: 1; --more: 1; }
.win-top { margin-top: -64px; } /* сцена уходит под шапку с самого верха страницы */
.win.is-animated { height: calc(100svh + 5 * var(--step)); }

.win-snaps span { position: absolute; left: 0; width: 1px; height: 1px; scroll-snap-align: start; }
.win-snaps span:nth-child(2) { top: calc(1 * var(--step)); }
.win-snaps span:nth-child(3) { top: calc(2 * var(--step)); }
.win-snaps span:nth-child(4) { top: calc(3 * var(--step)); }
.win-snaps span:nth-child(5) { top: calc(4 * var(--step)); }
.win-snaps span:nth-child(6) { top: calc(5 * var(--step)); }
.win:not(.is-animated) .win-snaps { display: none; }

/* Сцена занимает весь экран и уходит под шапку: шапка — стекло, сквозь неё видно комнату */
.win-sticky { position: relative; height: 100svh; min-height: 560px; overflow: hidden; }
.win.is-animated .win-sticky { position: sticky; top: 0; }

/* Кадр 16:9 покрывает экран; все слои позиционируются в % кадра */
.win-stage { position: absolute; inset: 0; overflow: hidden; }
.win-frame {
  --h: max(100svh, 560px);
  position: absolute; top: 50%; left: 50%;
  width: max(100%, calc(var(--h) * 16 / 9)); aspect-ratio: 16 / 9;
  transform: translate(-50%, -50%);
}
.win-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; opacity: 0; }
.win-img[data-step="0"] { opacity: 1; }

/* Видео перехода — только окно (+ ноутбук), обрезка 930×690 из кадра 1920×1080 с x=760, y=190.
   Комната и подоконник всё время показываются из чётких картинок. Маска с мягким краем идёт по раме. */
.win-trans {
  position: absolute; left: 39.5833%; top: 17.5926%; width: 48.4375%; height: 63.8889%;
  object-fit: fill; display: block; opacity: 0; background: transparent;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 930 690' preserveAspectRatio='none'%3E%3Cfilter id='f'%3E%3CfeGaussianBlur stdDeviation='3'/%3E%3C/filter%3E%3Cpath filter='url(%23f)' fill='white' d='M25 600V240C25 95 250 25 463.5 25S902 95 902 240V600H400V680H120V600Z'/%3E%3C/svg%3E") 0 0 / 100% 100% no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 930 690' preserveAspectRatio='none'%3E%3Cfilter id='f'%3E%3CfeGaussianBlur stdDeviation='3'/%3E%3C/filter%3E%3Cpath filter='url(%23f)' fill='white' d='M25 600V240C25 95 250 25 463.5 25S902 95 902 240V600H400V680H120V600Z'/%3E%3C/svg%3E") 0 0 / 100% 100% no-repeat;
}

/* «Живой» кадр (ambient.js): тот же кадр с эффектами, только на остановках; во время перехода скрыт */
.win-ambient { position: absolute; inset: 0; width: 100%; height: 100%; display: block; opacity: 0; transition: opacity .35s ease; pointer-events: none; }
.win-ambient.is-on { opacity: 1; }
.win:not(.is-animated) .win-ambient { display: none; }

/* Экран ноутбука (шаги 2–5). Макет 360×214, JS натягивает его на экран в кадре через matrix3d.
   Светлая точечная карта с маршрутом переезда (tools/gen-laptop-map.py) и мягким свечением. */
.win-screen {
  position: absolute; left: 0; top: 0; width: 360px; height: 214px; transform-origin: 0 0;
  font: 500 12px/1.3 var(--font); color: #1b2550; pointer-events: none;
}
.scr { /* светлый мини-сайт: тёплый белый, мягкие края и голубоватое свечение экрана — как часть рисунка */
  position: absolute; inset: 0; opacity: 0; overflow: hidden; border-radius: 3px;
  padding: 0 18px; color: #33212a; background: linear-gradient(180deg, #fbf8f2 0%, #efe3d8 100%);
  box-shadow: inset 0 0 16px 3px rgba(120, 160, 255, .45);
  filter: blur(.35px) saturate(.92);
}
.scr::after { /* блик стекла и голубоватая дымка */
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(125deg, rgba(255, 255, 255, .4) 0%, rgba(255, 255, 255, 0) 40%), rgba(150, 190, 255, .1);
}
.scr-bar { display: flex; align-items: center; gap: 6px; height: 30px; margin: 0 -18px 12px; padding: 0 18px; font-weight: 700; font-size: 12px; background: #fff; border-bottom: 1px solid #e3e2f0; }
.scr-logo { width: 13px; height: 13px; border-radius: 4px; background: #ffc27a; }
.scr-url { margin-left: auto; font-weight: 500; font-size: 10px; color: #7d78a0; }
.scr-map { position: absolute; inset: 0; width: 100%; height: 100%; }
.map-land circle { fill: #b3b4d2; }
.scr-map text { font: 600 9px/1 var(--font); fill: #3d3566; }
.home circle:not(.home-pulse) { fill: #e0703f; }
.home-pulse { fill: rgba(224, 112, 63, .25); transform-box: fill-box; transform-origin: center; animation: map-pulse 2.2s ease-out infinite; }
.home-label { fill: #e0703f; }
.route { fill: none; stroke: #8f86c4; stroke-width: 1.6; stroke-dasharray: 4 4; animation: map-dash 1.6s linear infinite; }
.route.is-faded { stroke: #dccbbf; animation: none; }
.route.is-main { stroke: #e9a24a; stroke-width: 2.4; }
.route.is-done { stroke-dasharray: none; }
.pin circle { fill: #6b62a8; stroke: #fff; stroke-width: 1.2; }
.pin.is-faded circle { fill: #dccbbf; }
.pin.is-main circle { fill: #e9a24a; }
.pin.is-main text { fill: #b0691d; }
.plane path { fill: #33212a; }
.scr-card {
  position: absolute; left: 12px; top: 38px; padding: 4px 10px; border-radius: 8px; /* в углу, где на карте океан */
  font-size: 11px; font-weight: 600; color: #33212a; background: rgba(255, 255, 255, .85); box-shadow: 0 2px 8px rgba(50, 30, 40, .15);
}
.scr-card b { color: #2f9a5e; }
@keyframes map-pulse { 0% { transform: scale(.4); opacity: 1; } 100% { transform: scale(1.4); opacity: 0; } }
@keyframes map-dash { to { stroke-dashoffset: -16; } }
.win:not(.is-animated) .win-screen { display: none; }

/* Запотевание стекла: дымка только по области окна (стекло ≈ x 41.8–85.8%, y 22.7–72.3% кадра) */
.win-fog {
  position: absolute; left: 41.8%; top: 22.7%; width: 44%; height: 49.6%;
  border-radius: 48% 48% 3% 3% / 34% 34% 3% 3%;
  background: radial-gradient(ellipse at 50% 60%, rgba(245, 234, 222, .55), rgba(235, 218, 205, .35) 60%, rgba(230, 212, 198, .15));
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  opacity: var(--fog);
  pointer-events: none;
}

/* Затемнение под текстом слева; на первом экране (--steps = 0) — гуще и шире, под крупный заголовок */
.win-shade { position: absolute; inset: 0; pointer-events: none; background:
  linear-gradient(180deg, rgba(33, 20, 28, 0) 80%, #1d1219 100%), /* низ сцены перетекает в следующий блок */
  linear-gradient(90deg, rgba(30, 18, 26, .55) 0%, rgba(30, 18, 26, .25) 30%, rgba(30, 18, 26, 0) 45%); }
.win-shade::before {
  content: ""; position: absolute; inset: 0; opacity: calc(1 - var(--steps));
  background: linear-gradient(90deg, rgba(29, 18, 25, .78) 0%, rgba(29, 18, 25, .55) 35%, rgba(29, 18, 25, 0) 62%);
}

/* ---------- Интерфейс ---------- */
.win-ui { position: relative; height: 100%; padding-top: 64px; display: flex; flex-direction: column; justify-content: center; pointer-events: none; }

/* Первый экран */
.win-hero { max-width: 560px; }
.win-hero .eyebrow { color: #ffc27a; }
.win-hero h1 {
  font-weight: 700; letter-spacing: var(--tracking-display);
  font-size: clamp(34px, 4.2vw, 54px); line-height: 1.12; letter-spacing: -.01em;
  text-shadow: 0 2px 24px rgba(24, 14, 20, .7);
}
.win-hero .lead { color: #efe3d8; max-width: 30em; text-shadow: 0 1px 12px rgba(24, 14, 20, .6); }
.win-hero .hero-actions { align-items: center; }
.win-hero .hero-facts { color: #dccbbf; }
.win-hero .hero-facts li::before { background: #ffc27a; }
.win-hint {
  position: absolute; left: 50%; bottom: 22px; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  font-size: 13px; color: #dccbbf; opacity: calc(1 - var(--steps) * 3);
}
.win-hint::after {
  content: ""; width: 10px; height: 10px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
  transform: rotate(45deg); animation: win-hint 1.8s ease-in-out infinite;
}
@keyframes win-hint { 0%, 100% { translate: 0 0; } 50% { translate: 0 5px; } }
.win:not(.is-animated) .win-hint { display: none; }

/* Шаги */
.win-title, .win-counter, .win-dots { opacity: var(--steps); }
.win-title { font-weight: 700; letter-spacing: var(--tracking-display); font-size: clamp(26px, 3vw, 38px); text-shadow: 0 2px 18px rgba(24, 14, 20, .6); }
.win-counter { margin-top: 10px; color: #ffc27a; font-weight: 600; font-size: 15px; }
.win-cards { position: relative; margin-top: 16px; max-width: 360px; min-height: 230px; }
/* Шаг — без карточки: контурный номер, тонкая линия и текст прямо на сцене.
   При наведении номер заливается тёплым градиентом снизу вверх, линия слева становится ярче и длиннее. */
.win-card { position: relative; padding: 6px 12px 10px 24px; }
.win-card::before { /* линия слева */
  content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 2px; border-radius: 2px; opacity: .55;
  background: linear-gradient(#ffc27a, rgba(255, 194, 122, 0)); transform-origin: top;
  transition: opacity var(--dur-slow) ease, transform var(--dur-slow) var(--ease-out);
}
.win-num {
  font-weight: 800; font-size: 64px; line-height: 1; color: transparent;
  -webkit-text-stroke: 1.5px #ffc27a;
  background: linear-gradient(180deg, #ffe0b0, #ffb066) 0 100% / 100% 0 no-repeat; -webkit-background-clip: text; background-clip: text;
  transition: background-size .3s var(--ease-out);
}
.win-kicker { margin-top: 6px; font-size: 13px; color: #ffc27a; letter-spacing: .04em; }
.win-card h3 { margin-top: 4px; font-weight: 700; letter-spacing: var(--tracking-display); font-size: 28px; text-shadow: 0 2px 16px rgba(24, 14, 20, .7); transition: color var(--dur-slow) ease; }
.win-card p:not(.win-kicker):not(.win-num) { margin-top: 8px; color: #efe3d8; text-shadow: 0 1px 10px rgba(24, 14, 20, .75); }
.win-card:focus-within::before { opacity: 1; transform: scaleY(1.06); }
@media (hover: hover) and (pointer: fine) { .win-card:hover::before { opacity: 1; transform: scaleY(1.06); } }
.win-card:focus-within .win-num { background-size: 100% 100%; }
@media (hover: hover) and (pointer: fine) { .win-card:hover .win-num { background-size: 100% 100%; } }
.win-card:focus-within h3 { color: #ffe6c4; }
@media (hover: hover) and (pointer: fine) { .win-card:hover h3 { color: #ffe6c4; } }
.win-cta { margin-top: 16px; }

.win-dots { display: flex; gap: 8px; margin-top: 18px; }
.win-dots i { width: 28px; height: 4px; border-radius: 2px; background: rgba(255, 255, 255, .28); transition: background-color .3s; }
.win-dots i.is-on { background: #ffc27a; }

/* Подсказка «листайте» под шагами (компьютер): видна с шага 1, гаснет на последнем шаге */
.win-more { display: flex; align-items: center; gap: 12px; margin-top: 22px; font-size: 15px; color: #efe3d8; opacity: calc(var(--steps) * var(--more)); text-shadow: 0 1px 10px rgba(24, 14, 20, .6); }
.win-mouse { position: relative; flex: none; width: 20px; height: 30px; border: 2px solid currentColor; border-radius: 11px; }
.win-mouse::after { /* колёсико прокручивается вниз */
  content: ""; position: absolute; left: 50%; top: 5px; width: 4px; height: 7px; margin-left: -2px;
  border-radius: 2px; background: #ffc27a; animation: win-wheel 1.6s ease-in-out infinite;
}
@keyframes win-wheel { 0% { transform: translateY(0); opacity: 1; } 70% { transform: translateY(9px); opacity: 0; } 100% { opacity: 0; } }
.win:not(.is-animated) .win-more { display: none; }

/* Анимированный режим: первый экран и карточки — слои, видимость задаёт JS */
.win.is-animated [data-panel] { opacity: 0; pointer-events: none; will-change: opacity, transform; }
.win.is-animated [data-panel].is-active { pointer-events: auto; }
.win.is-animated .win-hero {
  position: absolute; top: 64px; bottom: 0; left: var(--gutter); right: var(--gutter);
  display: flex; flex-direction: column; justify-content: center;
}
/* все шаги в одной ячейке сетки: блок по высоте самого высокого шага (с кнопкой), шкала шагов — всегда ниже */
.win.is-animated .win-cards { display: grid; min-height: 0; }
.win.is-animated .win-card { grid-area: 1 / 1; align-self: start; }

/* Без анимации: первый экран поверх кадра, ниже — все шаги списком */
.win:not(.is-animated) .win-sticky { height: auto; min-height: 100svh; }
.win:not(.is-animated) .win-shade { background: rgba(30, 18, 26, .7); }
.win:not(.is-animated) .win-ui { padding-top: 140px; padding-bottom: 72px; gap: 56px; justify-content: flex-start; pointer-events: auto; }
.win:not(.is-animated) .win-cards { display: grid; gap: 12px; max-width: none; min-height: 0; }
@media (min-width: 760px) { .win:not(.is-animated) .win-cards { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); } }
.win:not(.is-animated) .win-counter, .win:not(.is-animated) .win-dots { display: none; }

/* Телефон: окно сверху, текст снизу */
@media (max-width: 760px) {
  .win-stage { top: 40px; bottom: 42%; }
  .win-frame { width: max(100%, calc((100svh - 40px) * .58 * 16 / 9)); left: 36%; }
  .win-shade { background: linear-gradient(180deg, rgba(30, 18, 26, 0) 45%, rgba(33, 20, 28, .9) 58%, #1d1219 70%); }
  .win-shade::before { background: linear-gradient(180deg, rgba(29, 18, 25, 0) 30%, rgba(29, 18, 25, .85) 50%); }
  .win-ui { justify-content: flex-end; padding-bottom: 18px; }
  .win-title { display: none; }
  .win-cards { max-width: none; min-height: 200px; }
  .win-card { padding: 4px 8px 6px 18px; }
  .win-num { font-size: 44px; }
  .win-card h3 { font-size: 22px; }
  .win.is-animated .win-hero { justify-content: flex-end; padding-bottom: 56px; }
  .win-hero h1 { font-size: 30px; }
  .win-hero .lead { margin-top: 12px; font-size: 16px; }
  .win-hero .hero-actions { margin-top: 18px; }
  .win-hero .hero-ghost { display: none; }
  .win-hero .hero-facts { margin-top: 14px; font-size: 14px; gap: 4px 14px; }
  .win-hint { bottom: 14px; }
  .win-more { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .win-card::before, .win-card h3, .win-num, .win-dots i { transition: none; }
}
