/* Cinematic motion: the first screen opening and leaving, and the catalog arriving.
   Scripts: js/motion.js (opening, catalog), js/story.js (leaving, --exit). */

/* the blurred copy of the photo: invisible, until the hero leaves (--exit, 0 → 1) */
.hero__blur { pointer-events: none; opacity: var(--exit, 0); }
.hero__media::after { content: ""; position: absolute; inset: 0; background: #101014; opacity: calc(var(--exit, 0) * .42); pointer-events: none; }
.hero__line { display: block; }

/* ───────────── The first screen opens ─────────────
   <html class="intro"> holds everything at its first frame; .intro-go lets it run; both classes
   are removed when it is over, so nothing here keeps hold of the page afterwards. */
@media (prefers-reduced-motion: no-preference) {
  /* the house stands still and sharp from the first frame; only the light comes up on it */
  .intro .hero__photo { animation: hero-light 2.4s cubic-bezier(.16, 1, .3, 1) both paused; }
  /* the name rises from behind the roof (it lies under the cut-out house) */
  .intro .hero__wordmark { animation: word-rise 2s cubic-bezier(.16, 1, .3, 1) .25s both paused; }
  .intro .overline { animation: focus-rise 1.1s cubic-bezier(.16, 1, .3, 1) .7s both paused; }
  .intro .hero__line { animation: focus-rise 1.4s cubic-bezier(.16, 1, .3, 1) calc(.82s + var(--l) * .16s) both paused; }
  .intro .panel { animation: panel-rise 1.5s cubic-bezier(.16, 1, .3, 1) .75s both paused; }
  .intro .header { animation: header-drop 1.1s cubic-bezier(.16, 1, .3, 1) 1s both paused; }
  .intro-go .hero__photo, .intro-go .hero__wordmark, .intro-go .overline, .intro-go .hero__line,
  .intro-go .panel, .intro-go .header { animation-play-state: running; }

  /* photo and cut-out house take the same light, so they stay one picture */
  @keyframes hero-light { from { filter: brightness(.62) saturate(.85); } to { filter: none; } }
  @keyframes word-rise { from { opacity: 0; transform: translate3d(0, 46%, 0); filter: blur(18px); } to { opacity: 1; transform: none; filter: blur(0); } }
  @keyframes focus-rise { from { opacity: 0; translate: 0 .5em; filter: blur(16px); } to { opacity: 1; translate: 0 0; filter: blur(0); } }
  @keyframes panel-rise { from { opacity: 0; translate: 0 36%; } to { opacity: 1; translate: 0 0; } }
  @keyframes header-drop { from { opacity: 0; translate: 0 -22px; filter: blur(8px); } to { opacity: 1; translate: 0 0; filter: blur(0); } }

  /* ───────────── The catalog arrives ─────────────
     motion.js marks the pieces (data-arrive, --n = place in the wave) and moves their group from
     .is-waiting to .is-arriving as it comes into view. */
  .is-waiting [data-arrive] { opacity: 0; }
  .is-arriving [data-arrive] { animation: tile-arrive 1.25s cubic-bezier(.16, 1, .3, 1) calc(var(--n) * 90ms) backwards; }
  .is-arriving .tile__photo { animation: photo-settle 2s cubic-bezier(.16, 1, .3, 1) calc(var(--n) * 90ms) backwards; }
  /* the «Ще в каталозі» row is text to read: it fades up and is never blurred */
  .more.is-arriving [data-arrive] { animation-name: chip-arrive; }
  @keyframes chip-arrive { from { opacity: 0; translate: 0 24px; } to { opacity: 1; translate: 0 0; } }
  @keyframes tile-arrive { from { opacity: 0; translate: 0 70px; scale: .95; filter: blur(16px); } 55% { opacity: 1; filter: blur(3px); } to { opacity: 1; translate: 0 0; scale: 1; filter: blur(0); } }
  @keyframes photo-settle { from { scale: 1.28; } to { scale: 1; } }

  /* the product comes a little closer under the pointer */
  .tile--category .tile__photo, .tile--kits .tile__photo { transition: scale 1.1s cubic-bezier(.16, 1, .3, 1); }
}
@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  .tile--category:hover .tile__photo, .tile--kits:hover .tile__photo { scale: 1.06; }
}
@media (max-width: 767px) and (prefers-reduced-motion: no-preference) {
  /* here the panel is the only thing under the photo: rising, it would leave a flat blue band */
  .intro .panel { animation: none; }
  /* gentler on a phone: lighter blur, shorter way */
  @keyframes tile-arrive { from { opacity: 0; translate: 0 40px; filter: blur(8px); } to { opacity: 1; translate: 0 0; filter: blur(0); } }
  @keyframes word-rise { from { opacity: 0; transform: translate3d(0, 40%, 0); filter: blur(10px); } to { opacity: 1; transform: none; filter: blur(0); } }
}
/* a menu or the search pointing at a tile wins over its arrival */
.catalog .tile.is-flash { animation: tile-flash 2.4s ease; }
