/* ═══════════════════════════════════════════════════════════
   MOTION LAYER — Liberty Basketball
   Анимации: плавный скролл, раскрытие текста, карточки,
   вкладки, модалки, навигация. Работает вместе с motion.js.
   ═══════════════════════════════════════════════════════════ */

/* ── Lenis smooth scroll ── */
html.lenis, html.lenis body { height: auto; }
.lenis.lenis-smooth { scroll-behavior: auto !important; }
.lenis.lenis-smooth [data-lenis-prevent] { overscroll-behavior: contain; }
.lenis.lenis-stopped { overflow: hidden; }

/* ── Scroll progress bar ── */
.m-progress {
  position: fixed; top: 0; left: 0; right: 0; height: 2px; z-index: 1001;
  background: linear-gradient(90deg, #2dd4bf, var(--blue-600) 55%, var(--orange-500));
  transform-origin: 0 50%; transform: scaleX(0); pointer-events: none;
}

/* ── Preloader: curtain exit instead of fade ── */
#preloader { transition: clip-path 1s cubic-bezier(.77,0,.18,1), visibility 0s linear 1s !important; clip-path: inset(0 0 0 0); }
#preloader.hidden { opacity: 1 !important; clip-path: inset(0 0 100% 0); }
#preloader .pre-ball { animation: m-pre-bounce .9s cubic-bezier(.33,0,.67,1) infinite; }
#preloader .pre-text { animation: m-pre-text 1.2s var(--ease) both; }
@keyframes m-pre-bounce {
  0%   { transform: translateY(-34px) scale(1,1); animation-timing-function: cubic-bezier(.55,0,1,.45); }
  46%  { transform: translateY(0) scale(1,1); }
  50%  { transform: translateY(2px) scale(1.18,.8); animation-timing-function: cubic-bezier(0,.55,.45,1); }
  56%  { transform: translateY(0) scale(.94,1.06); }
  100% { transform: translateY(-34px) scale(1,1); }
}
@keyframes m-pre-text { from { opacity: 0; letter-spacing: 14px; } to { opacity: 1; } }

/* ── Nav: hide on scroll down, sliding active pill ── */
.nav.m-nav-hidden { transform: translateY(-110%); }
.nav-links { position: relative; }
.m-nav-pill {
  position: absolute; top: 0; left: 0; height: 0; width: 0; z-index: -1;
  border-radius: var(--radius-sm); background: var(--blue-50);
  opacity: 0; pointer-events: none;
}
.nav-links a.active { background: transparent !important; }

/* ── Split text (masks) ── */
.m-w { display: inline-block; overflow: hidden; vertical-align: top;
       padding-bottom: .14em; margin-bottom: -.14em; padding-right: .02em; }
.m-wi { display: inline-block; }
.m-q { transition: none; }

/* ── Elements in flight: kill CSS transitions so GSAP is smooth ── */
.m-anim { transition: none !important; }

/* ── Tabs: sliding pill ── */
.tabs { position: relative; isolation: isolate; }
.m-tab-pill {
  position: absolute; top: 0; left: 0; z-index: -1; pointer-events: none;
  border-radius: var(--radius-full); background: var(--blue-600);
  box-shadow: 0 4px 14px rgba(37,99,235,.3);
}
.tabs.m-has-pill .tab-btn.active { background: transparent; box-shadow: none; }
.m-tab-pill.m-pill-tr { transition: transform .3s cubic-bezier(.2, .8, .2, 1), width .3s cubic-bezier(.2, .8, .2, 1); }

/* ── Player stat bars driven by transform ── */
.player-stat-fill { transition: none !important; transform-origin: 0 50%; }

/* ── 3D tilt + glare on cards ── */
.m-tilt { transition-property: box-shadow, background, border-color !important; }
.m-tilt::before {
  content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; z-index: 3;
  background: radial-gradient(420px circle at var(--mx,50%) var(--my,50%), rgba(255,255,255,.55), transparent 45%);
  opacity: 0; transition: opacity .4s var(--ease); mix-blend-mode: soft-light;
}
.m-tilt:hover::before { opacity: 1; }
.m-tilt { position: relative; }

/* ── Magnetic buttons ── */
.btn-primary, .nav-cta { position: relative; overflow: hidden; isolation: isolate; }
.btn-primary::after, .nav-cta::after {
  content: ''; position: absolute; inset: 0; z-index: -1; border-radius: inherit;
  background: linear-gradient(105deg, transparent 20%, rgba(255,255,255,.35) 45%, transparent 70%);
  transform: translateX(-120%); transition: transform .9s var(--ease);
}
.btn-primary:hover::after, .nav-cta:hover::after { transform: translateX(120%); }

/* ── Timeline: progress line + active dots ── */
.timeline::before { opacity: .35; }
.m-tl-progress {
  position: absolute; top: 0; bottom: 0; left: 24px; width: 2px; z-index: 0;
  background: linear-gradient(to bottom, var(--blue-500), var(--cyan-400));
  transform-origin: 50% 0; transform: scaleY(0); border-radius: 2px;
}
.tl-dot { z-index: 1; transition: transform .6s cubic-bezier(.34,1.56,.64,1), box-shadow .6s var(--ease), background .4s; transform: scale(.6); background: var(--blue-200); }
.tl-item.m-on .tl-dot { transform: scale(1); background: var(--blue-600); box-shadow: 0 0 0 3px var(--blue-200), 0 0 0 10px rgba(59,130,246,.12), 0 2px 8px rgba(37,99,235,.25); }

/* ── Quote: words light up as you scroll ── */
.quote-text .m-qw { display: inline; color: inherit; opacity: .14; transition: none; }

/* ── Hero floating photos: calm, no colour flashes ── */
/* Safari/iOS: 3D layers under the container mask are re-drawn on the CPU every frame (laggy scroll)
   and stretched when they come closer (blurry faces). There the flight is a flat 2D zoom that stops
   at natural size: smooth and sharp. */
.is-webkit .floating-photos { perspective: none; }
.is-webkit .photo-float { animation-name: photo-fly-wk; }
@keyframes photo-fly-wk {
  0%   { transform: translate(var(--x),var(--y)) rotate(var(--rot)) scale(.3); opacity: 0; }
  18%  { opacity: .55; }
  45%  { opacity: .85; }
  80%  { opacity: .7; }
  100% { transform: translate(var(--x2),var(--y2)) rotate(var(--rot2)) scale(1); opacity: 0; }
}
/* Safari: frosted-glass blur on dozens of cards makes every scroll frame expensive; cards get a solid tint instead */
.is-webkit .glass { -webkit-backdrop-filter: none; backdrop-filter: none; background: rgba(255,255,255,.86); }
.is-webkit .tabs, .is-webkit .video-play-btn { -webkit-backdrop-filter: none; backdrop-filter: none; }
.photo-float::after { display: none !important; }
.floating-photos { transition: none; }
@keyframes photo-fly {
  0%   { transform: translate3d(var(--x),var(--y),-1800px) rotate(var(--rot)) scale(.6); opacity: 0; }
  18%  { opacity: .55; }
  45%  { opacity: .85; }
  80%  { opacity: .7; }
  100% { transform: translate3d(var(--x2),var(--y2),300px) rotate(var(--rot2)) scale(1.3); opacity: 0; }
}

/* ── Modal (driven by GSAP) ── */
.modal { animation: none !important; }
.modal-overlay { transition: none !important; }

/* ── CTA ball ── */
.cta-icon { display: inline-block; }

@media (max-width: 768px) { .m-nav-pill { display: none; } }

/* ── Reduced motion: everything calm ── */
@media (prefers-reduced-motion: reduce) {
  .photo-float { animation-duration: 60s !important; }
  #preloader .pre-ball, #preloader .pre-text, .scroll-ind, .ball-tooltip { animation: none !important; }
  .m-tilt::before { display: none; }
  .tl-dot { transform: none; background: var(--blue-600); }
  .quote-text .m-qw { opacity: 1; }
}
