/* =====================================================================
   PERFORMANCE & TABLET STABILITY
   Loaded last. Nothing here changes the design on desktop except the
   shorter intro; on touch devices (phones, tablets) it switches off the
   effects that make mobile GPUs repaint the whole screen every frame,
   which is what showed up as flickering and slow scrolling.
   ===================================================================== */

/* ---- Hero: size to the *small* viewport so the hero doesn't jump when the
   tablet/phone browser bar shows or hides while scrolling. ---- */
@supports (height: 100svh) {
  .s-hero { min-height: 100svh; }
}

/* ---- Showreel background: fades in only once the video is really playing
   (see initReelBg in app.js), so YouTube's black/title frame never flashes. ---- */
.m-reel__video { opacity: 0; transition: opacity 0.8s var(--ease); }
/* still frame of the reel, visible instantly while the player boots */
.m-reel__poster { position: absolute; inset: 0; z-index: 0; width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.m-reel__video video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.m-reel__video.is-ready { opacity: 1; }

/* ---- Intro title-card: same choreography, about half as long ---- */
.m-intro__bars::before, .m-intro__bars::after { transition: transform 0.7s var(--ease-out) 0s; }
.m-intro__mark { transition: opacity 0.6s var(--ease-out) 0.05s, transform 0.7s var(--ease-out) 0.05s; }
.m-intro__wm span { transition: transform 0.6s var(--ease-out); }
.m-intro__rule { transition: width 0.6s var(--ease-out) 0.3s; }
.m-intro__tag { transition: opacity 0.5s var(--ease) 0.4s; }
.m-intro__corner { transition: opacity 0.5s var(--ease) 0.2s; }
.m-intro.is-done { transition: opacity 0.5s var(--ease); }

/* ---- Touch devices (tablets & phones) ---- */
@media (hover: none), (pointer: coarse) {
  /* Full-screen fixed grain with mix-blend-mode makes iOS/Android re-blend
     the entire page on every scroll frame — the main flicker culprit. */
  .s-grain { display: none !important; }

  /* Frosted-glass blur on fixed bars/overlays is very expensive on tablets;
     use solid fills instead (visually almost identical on the dark theme). */
  .s-nav.is-scrolled { backdrop-filter: none; -webkit-backdrop-filter: none; background: rgba(8,8,8,0.97); }
  .s-drawer, .m-modal__overlay { backdrop-filter: none; -webkit-backdrop-filter: none; }
  .m-modal__overlay { background: rgba(8,8,8,0.92); }
  .m-hud, .m-reelbtn, [class*="m-hud"] { backdrop-filter: none; -webkit-backdrop-filter: none; }

  /* Hero: keep one still frame behind the video instead of a 6-layer
     cross-fading, scaling montage + light sweep running forever. */
  .m-reel__frame { animation: none; opacity: 0; }
  .m-reel__frame:first-child { opacity: 0.9; }
  .m-reel__sweep { display: none; }

  /* Gradient "shimmer" on every gradient word repaints text each frame. */
  .s-root.m-shimmer .s-grad { animation: none; }

  /* Gear backdrop: huge blurred orbs, animated — keep them still and lighter. */
  .g-bg__orb { animation: none; filter: blur(60px); }

  /* Permanent will-change on many elements exhausts tablet GPU memory and
     makes layers drop out (flashing tiles). Nothing moves with the mouse
     on touch, so release them. */
  .s-proj, .m-magnetic, .m-reelbtn, .s-hero__orb, .m-reel__frame { will-change: auto; }
}
