/* The original site surface resumes after the first viewport. */
body:where(.front,.dpab) {
  --fold-base: var(--cinema-page, var(--bg, #f6f8fc));
  --fold-light: 40%;
  --fold-hue-a: #36cbaa;
  --fold-hue-b: #8b8cf3;
  --fold-a: color-mix(in srgb, var(--fold-hue-a) var(--fold-light), var(--fold-base));
  --fold-b: color-mix(in srgb, var(--fold-hue-b) var(--fold-light), var(--fold-base));
  --fold-depth: clamp(32rem, 100svh, 64rem);
  --fold-origin: 8%;
  --fold-opposite: 94%;
}

body.front:is(.tpl-nnyy24,.tpl-openframe) {
  --fold-hue-a: #27c898;
  --fold-hue-b: #4a9cf5;
}
body.front:is(.tpl-nnyyin,.tpl-anywhere) {
  --fold-hue-a: #f38859;
  --fold-hue-b: #ac6af0;
  --fold-origin: 88%;
  --fold-opposite: 4%;
}
body.front:is(.tpl-ddys,.tpl-jinpai) {
  --fold-hue-a: #f4ae46;
  --fold-hue-b: #ea765e;
}
body.front:is(.tpl-applecinema,.tpl-moviedb) {
  --fold-hue-a: #4b9dff;
  --fold-hue-b: #8b79f4;
}
body.front.tpl-dbku, body.dpab {
  --fold-hue-a: #42cbb5;
  --fold-hue-b: #7891f4;
}
body.front:is(.tpl-haoju,.haoju-template) {
  --fold-hue-a: #38c4c7;
  --fold-hue-b: #ef8c53;
}
body.front.iqiyi-template {
  --fold-hue-a: #30c878;
  --fold-hue-b: #59b1f2;
  --fold-origin: 20%;
}
body.front.keke-template {
  --fold-hue-a: #467cfa;
  --fold-hue-b: #5fd7d0;
  --fold-origin: 18%;
}
body.front:is(.tpl-oletv-direct-v2,.site-oletv) {
  --fold-hue-a: #24c96b;
  --fold-hue-b: #ec603d;
  --fold-opposite: 84%;
}

:root:is([data-portal-theme="dark"],[data-db-theme="dark"],[data-theme="dark"])
  body:is(.front,.dpab) {
  --fold-base: var(--cinema-page, var(--bg, #141924));
  --fold-light: 32%;
}

/* Match the reference-template background rules without changing inner cards. */
html:root body:is(.front,.dpab):is([class*="tpl-"],[data-site-id],.portal) {
  background-image:
    linear-gradient(180deg, transparent 32%, var(--fold-base) 99%),
    radial-gradient(ellipse at var(--fold-origin) 12%, var(--fold-a) 0%, transparent 58%),
    radial-gradient(ellipse at var(--fold-opposite) 42%, var(--fold-b) 0%, transparent 66%) !important;
  background-color: var(--fold-base) !important;
  background-repeat: no-repeat !important;
  background-position: center top !important;
  background-size: 100% var(--fold-depth) !important;
  background-attachment: scroll !important;
}

/* Navigation stays legible while fixed or sticky. */
html:root[data-portal-theme] body.front:has(> .ref-shell .ref-brand[data-cms-brand]) > .ref-shell,
html:root body.front > .ref-shell,
html:root body.front.portal :is(.ds3-head,.iqiyi-header,.keke-topbar),
html:root body.dpab[data-site-id] > .dpab-header {
  background:
    linear-gradient(108deg,
      color-mix(in srgb, var(--fold-a) 50%, var(--fold-base)),
      color-mix(in srgb, var(--fold-b) 38%, var(--fold-base))) !important;
}

@media (max-width: 720px) {
  body:is(.front,.dpab) {
    --fold-origin: 0%;
    --fold-opposite: 100%;
    --fold-depth: clamp(31rem, 100svh, 52rem);
  }
}

@media (forced-colors: active) {
  html:root body:is(.front,.dpab):is([class*="tpl-"],[data-site-id],.portal) {
    background: Canvas !important;
  }
  html:root[data-portal-theme] body.front:has(> .ref-shell .ref-brand[data-cms-brand]) > .ref-shell,
  html:root body.front > .ref-shell,
  html:root body.front.portal :is(.ds3-head,.iqiyi-header,.keke-topbar),
  html:root body.dpab[data-site-id] > .dpab-header {
    background: Canvas !important;
  }
}

/* Keep the category banner within the existing page column. */
body.front.portal.tpl-haoju.catalog-page .stream-category-mid-ad {
  max-width: 100%;
}
