/* Soft fade under the fixed navigation, on every page.
   The navigation uses mix-blend-mode:difference, so a background on the nav itself would invert whatever
   scrolls underneath. The fade is therefore its own layer (body::before) below the nav (z-index 100+).
   Two knobs:
     --nav-fade-height    how far the fade reaches (the nav itself is about 101px tall on desktop)
     --nav-fade-strength  opacity at the very top (0 to 1); the curve below goes smoothly down to 0
   The stops follow 1 - smoothstep(t), so no edge is visible. The layer is hidden until the page is scrolled
   (nav-fade.js sets html.nav-scrolled), otherwise it would dim the first screen.
   Colour: exactly two schemes, white by default and black for Polar Beat and iQIYI
   (add .nav-fade-black on <body>). */
:root{
  --nav-fade-rgb:255 255 255;
  --nav-fade-height:224px;
  --nav-fade-strength:.85;
}
body::before{
  content:"";
  position:fixed;
  inset:0 0 auto;
  height:var(--nav-fade-height);
  z-index:90;
  pointer-events:none;
  opacity:0;                       /* off on the first screen, on after scrolling (nav-fade.js) */
  transition:opacity .25s ease;
  background:linear-gradient(to bottom,
    rgb(var(--nav-fade-rgb) / calc(var(--nav-fade-strength) * 1)) 0%,
    rgb(var(--nav-fade-rgb) / calc(var(--nav-fade-strength) * .972)) 10%,
    rgb(var(--nav-fade-rgb) / calc(var(--nav-fade-strength) * .896)) 20%,
    rgb(var(--nav-fade-rgb) / calc(var(--nav-fade-strength) * .784)) 30%,
    rgb(var(--nav-fade-rgb) / calc(var(--nav-fade-strength) * .648)) 40%,
    rgb(var(--nav-fade-rgb) / calc(var(--nav-fade-strength) * .5)) 50%,
    rgb(var(--nav-fade-rgb) / calc(var(--nav-fade-strength) * .352)) 60%,
    rgb(var(--nav-fade-rgb) / calc(var(--nav-fade-strength) * .216)) 70%,
    rgb(var(--nav-fade-rgb) / calc(var(--nav-fade-strength) * .104)) 80%,
    rgb(var(--nav-fade-rgb) / calc(var(--nav-fade-strength) * .028)) 90%,
    rgb(var(--nav-fade-rgb) / 0) 100%);
}
html.nav-scrolled body::before{ opacity:1; }
@media (prefers-reduced-motion:reduce){ body::before{ transition:none; } }

/* Dark scheme, set on <body> for Polar Beat and iQIYI. */
.nav-fade-black{ --nav-fade-rgb:0 0 0; }
@media (max-width:767px){
  :root{ --nav-fade-height:136px; }
  /* The solid mobile bar ends at 82px; the fade begins directly below it. */
  body::before{ top:var(--mobile-nav-height, 82px); }
  /* When the bar slides away on scroll down (html.m-nav-hidden, set by site-nav-mobile.js) the fade slides
     up with it by the bar's height and fades out; it comes back with the bar. */
  html.nav-scrolled.m-nav-hidden body::before{
    opacity:0;
    transform:translateY(calc(-1 * var(--mobile-nav-height, 82px)));
  }
}
@media (max-width:767px) and (prefers-reduced-motion:no-preference){
  body::before{ transition:opacity .25s ease, transform .25s ease; }   /* same duration as the bar */
}
