/* Motion pack: power-on headline, typed subline, staggered hero tiles, counting numbers, steps that light up with the scroll, a header that steps aside.
   Only transform, opacity, clip-path and mask move. Everything is inside prefers-reduced-motion: no-preference; without it the page simply shows its final state. */

@media (prefers-reduced-motion: no-preference) {
  /* 1 · «OFFLINE» switches on: a soft edge sweeps over the letters left to right, the lamp flickers once, then the old glint passes */
  .hero .h1-big {
    -webkit-mask-image: linear-gradient(90deg, #000 66%, transparent 72%); mask-image: linear-gradient(90deg, #000 66%, transparent 72%);
    -webkit-mask-size: 300% 100%; mask-size: 300% 100%; -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat;
    animation: power-on 1s cubic-bezier(.5, 0, .45, 1) .25s both, lamp 1s linear .25s both, glint 1.5s cubic-bezier(.4, 0, .2, 1) 1.35s 1 both;
  }
  @keyframes power-on { from { -webkit-mask-position: 100% 0; mask-position: 100% 0; } to { -webkit-mask-position: 0% 0; mask-position: 0% 0; } }
  @keyframes lamp { 0% { opacity: 0; } 22% { opacity: .9; } 32% { opacity: .35; } 46% { opacity: 1; } 100% { opacity: 1; } }

  /* 2 · «версия твоего дома.» is typed once, right after the headline is on */
  .hero .h1-rest { animation: headline-in .7s cubic-bezier(.23, 1, .32, 1) .25s both; }
  @keyframes headline-in { from { opacity: 0; transform: translate3d(0, 16px, 0); } to { opacity: 1; transform: none; } }
  @keyframes type-line { from { clip-path: inset(-24px 100% -24px -24px); } to { clip-path: inset(-24px -24px -24px -24px); } }

  /* 10 · the four tiles arrive one after another, after the text */
  .hero-tile { animation: tile-in .3s cubic-bezier(.23, 1, .32, 1) both; animation-delay: calc(var(--i, 0) * 60ms + 1.75s); }
  .hero-tile:nth-child(1) { --i: 0; } .hero-tile:nth-child(2) { --i: 1; } .hero-tile:nth-child(3) { --i: 2; } .hero-tile:nth-child(4) { --i: 3; }
  @keyframes tile-in { from { opacity: 0; transform: translate3d(0, 14px, 0); } to { opacity: 1; transform: none; } }

  /* 11 · the installation steps: the coloured bar draws, the arrow appears and the number lights up as the scroll reaches each card */
  .how-step::before { transform-origin: 0 50%; transform: scaleX(var(--s, 1)); }
  .how-step:not(:last-child)::after { opacity: var(--a, 1); transform: translateY(-50%) scale(calc(.6 + .4 * var(--a, 1))); }
  .how-step .how-n { display: inline-block; transform-origin: 0 50%; transition: transform .28s cubic-bezier(.23, 1, .32, 1), opacity .28s; opacity: .55; }
  .how-step.is-lit .how-n { transform: scale(1.2); opacity: 1; }
  .how-step .how-ico { transition: transform .35s cubic-bezier(.23, 1, .32, 1); }
  .how-step.is-lit .how-ico { transform: translateY(-2px); }

  /* 13 · a new kit slides in when the calculation changes (only when the set of models really changed) */
  .calc-out.kit-swap > * { animation: kit-in .22s cubic-bezier(.23, 1, .32, 1) both; }
  @keyframes kit-in { from { opacity: 0; transform: translate3d(0, 8px, 0); } to { opacity: 1; transform: none; } }

  /* 17 · the header steps aside while you read down and returns when you scroll up */
  .chrome { transition: background-color .25s var(--ease), transform .24s cubic-bezier(.23, 1, .32, 1); }
  .chrome.is-away { transform: translate(-50%, -150%); }
}

.cnt { font-variant-numeric: tabular-nums lining-nums; }


/* ==== Scroll feel: the curtain, the lit sentence, the card stack ==== */
@media (prefers-reduced-motion: no-preference) {
  /* the hero stays pinned and the sentence slides over it like a curtain */
  .curtain { position: relative; }
  .curtain .hero { position: sticky; top: var(--hero-top, 0px); z-index: 0; }
  .curtain .hero-grid, .curtain .hero-tiles { transform: translate3d(0, calc(var(--cv, 0) * -44px), 0); opacity: calc(1 - var(--cv, 0) * .35); will-change: transform; }

  /* the sentence lights up word by word as it climbs the screen */
  .is-scrub .sw { display: inline-block; white-space: pre; opacity: calc(.14 + .86 * var(--k, 1)); filter: blur(calc((1 - var(--k, 1)) * 3px)); transform: translate3d(0, calc((1 - var(--k, 1)) * 10px), 0); }
  .is-scrub .sw.is-on { filter: none; transform: none; }
  .is-scrub .sw-space { display: inline; white-space: normal; }
}
/* installation steps become cards that stack on a phone */
@media (max-width: 600px) and (prefers-reduced-motion: no-preference) {
  .how-flow { gap: 16px; }
  .how-step { position: sticky; top: calc(var(--head, 76px) + var(--n, 0) * 12px); background: linear-gradient(180deg, #f6fbf3, #fff); box-shadow: 0 -12px 28px -18px rgba(24, 70, 104, .5), var(--card-shadow); }
  .how-step:not(:last-child)::after { display: none; }
  .how-step:nth-child(1) { --n: 0; } .how-step:nth-child(2) { --n: 1; } .how-step:nth-child(3) { --n: 2; } .how-step:nth-child(4) { --n: 3; } .how-step:nth-child(5) { --n: 4; }
}
