/*
 * Shared brand-wordmark presentation adapter.
 * It changes only visible logo text; brand images, copy and document identity
 * remain owned by each SiteProfile/template.
 */
@keyframes moviecmsBrandWordmarkSheenR1 {
  0%,
  12% {
    background-position: -160% 0, 0 0;
  }

  30%,
  100% {
    background-position: 180% 0, 0 0;
  }
}

body.tpl-haoju
  :is(
    .ds3-logo > .haoju-logo-copy > strong,
    .haoju-global-brand > .haoju-logo-copy > strong,
    .news-brand > span:last-child > strong
  ) {
  --brand-wordmark-fallback: var(--accent, #d83f4d);
  --brand-wordmark-gradient: linear-gradient(
    92deg,
    var(--accent, #d83f4d) 0%,
    var(--accent-2, #f0b24b) 46%,
    var(--haoju-cyan, #67e8f9) 74%,
    var(--accent, #d83f4d) 100%
  );
}

body.tpl-keke:not(.site-oletv) .keke-brand > span > strong {
  --brand-wordmark-fallback: var(--keke-ui-accent, #0f8f78);
  --brand-wordmark-gradient: linear-gradient(
    92deg,
    var(--keke-ui-accent, #0f8f78) 0%,
    var(--keke-ui-accent-2, #d3a33d) 52%,
    var(--keke-ui-accent, #0f8f78) 100%
  );
}

body.site-oletv.tpl-keke
  :is(
    .keke-brand > span > strong,
    .keke-sidebar-brand > span > strong
  ) {
  --brand-wordmark-fallback: #5eead4;
  --brand-wordmark-gradient: linear-gradient(
    92deg,
    #5eead4 0%,
    #fde047 36%,
    #c4b5fd 70%,
    #67e8f9 100%
  );
}

:root[data-portal-theme="light"]
  body.site-oletv.tpl-keke
  :is(
    .keke-brand > span > strong,
    .keke-sidebar-brand > span > strong
  ) {
  --brand-wordmark-fallback: #0f766e;
  --brand-wordmark-gradient: linear-gradient(
    92deg,
    #0f766e 0%,
    #b45309 36%,
    #7c3aed 70%,
    #0e7490 100%
  );
}

body.tpl-iqiyi
  :is(
    .iqiyi-brand > span:last-child > strong,
    .haoju-global-brand > .haoju-logo-copy > strong,
    .news-brand > span:last-child > strong
  ) {
  --brand-wordmark-fallback: var(--iq-accent, #3fdf7b);
  --brand-wordmark-gradient: linear-gradient(
    92deg,
    var(--iq-accent, #3fdf7b) 0%,
    #5cd6e8 48%,
    var(--iq-accent-strong, #26c964) 76%,
    var(--iq-accent, #3fdf7b) 100%
  );
}

html:root body[class].front.portal.tpl-haoju
    :is(
      .ds3-logo > .haoju-logo-copy > strong,
      .haoju-global-brand > .haoju-logo-copy > strong,
      .news-brand > span:last-child > strong
    ),
html:root
  body[class].front.portal.tpl-keke.keke-template:not(.site-oletv)
  .keke-brand
  > span
  > strong,
html:root body[class].front.portal.site-oletv.tpl-keke.keke-template
    :is(
      .keke-brand > span > strong,
      .keke-sidebar-brand > span > strong
    ),
html:root body[class].front.portal.tpl-iqiyi.iqiyi-template
    :is(
      .iqiyi-brand > span:last-child > strong,
      .haoju-global-brand > .haoju-logo-copy > strong,
      .news-brand > span:last-child > strong
    )
{
  color: var(--brand-wordmark-fallback, #0f766e) !important;
}

@supports ((background-clip: text) or (-webkit-background-clip: text)) {
  html:root body[class].front.portal.tpl-haoju
      :is(
        .ds3-logo > .haoju-logo-copy > strong,
        .haoju-global-brand > .haoju-logo-copy > strong,
        .news-brand > span:last-child > strong
      ),
  html:root
    body[class].front.portal.tpl-keke.keke-template:not(.site-oletv)
    .keke-brand
    > span
    > strong,
  html:root body[class].front.portal.site-oletv.tpl-keke.keke-template
      :is(
        .keke-brand > span > strong,
        .keke-sidebar-brand > span > strong
      ),
  html:root body[class].front.portal.tpl-iqiyi.iqiyi-template
      :is(
        .iqiyi-brand > span:last-child > strong,
        .haoju-global-brand > .haoju-logo-copy > strong,
        .news-brand > span:last-child > strong
      )
  {
    background-image:
      linear-gradient(
        105deg,
        transparent 43%,
        rgb(255 255 255 / 0.08) 47%,
        rgb(255 255 255 / 0.58) 50%,
        rgb(255 255 255 / 0.08) 53%,
        transparent 57%
      ),
      var(--brand-wordmark-gradient) !important;
    background-position: -160% 0, 0 0 !important;
    background-size: 260% 100%, 100% 100% !important;
    background-repeat: no-repeat !important;
    background-clip: text !important;
    -webkit-background-clip: text !important;
    color: transparent !important;
    -webkit-text-fill-color: transparent !important;
    animation: moviecmsBrandWordmarkSheenR1 10s ease-in-out infinite !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  html:root body[class].front.portal.tpl-haoju
      :is(
        .ds3-logo > .haoju-logo-copy > strong,
        .haoju-global-brand > .haoju-logo-copy > strong,
        .news-brand > span:last-child > strong
      ),
  html:root
    body[class].front.portal.tpl-keke.keke-template:not(.site-oletv)
    .keke-brand
    > span
    > strong,
  html:root body[class].front.portal.site-oletv.tpl-keke.keke-template
      :is(
        .keke-brand > span > strong,
        .keke-sidebar-brand > span > strong
      ),
  html:root body[class].front.portal.tpl-iqiyi.iqiyi-template
      :is(
        .iqiyi-brand > span:last-child > strong,
        .haoju-global-brand > .haoju-logo-copy > strong,
        .news-brand > span:last-child > strong
      )
  {
    background-image: var(--brand-wordmark-gradient) !important;
    background-position: 0 0 !important;
    background-size: 100% 100% !important;
    color: transparent !important;
    -webkit-text-fill-color: transparent !important;
    animation: none !important;
  }
}

@media (forced-colors: active) {
  html:root body[class].front.portal.tpl-haoju
      :is(
        .ds3-logo > .haoju-logo-copy > strong,
        .haoju-global-brand > .haoju-logo-copy > strong,
        .news-brand > span:last-child > strong
      ),
  html:root
    body[class].front.portal.tpl-keke.keke-template:not(.site-oletv)
    .keke-brand
    > span
    > strong,
  html:root body[class].front.portal.site-oletv.tpl-keke.keke-template
      :is(
        .keke-brand > span > strong,
        .keke-sidebar-brand > span > strong
      ),
  html:root body[class].front.portal.tpl-iqiyi.iqiyi-template
      :is(
        .iqiyi-brand > span:last-child > strong,
        .haoju-global-brand > .haoju-logo-copy > strong,
        .news-brand > span:last-child > strong
      )
  {
    background: none !important;
    color: CanvasText !important;
    -webkit-text-fill-color: CanvasText !important;
    animation: none !important;
  }
}

/*
 * Global outer-shell flattening contract.  These are structural surfaces,
 * not interactive components: preserving border width, padding and geometry
 * keeps every established template layout unchanged while the transparent
 * paint lets the current light/dark page background flow through.  Header,
 * fixed navigation, ads, poster cards, controls, inputs and the video canvas
 * are deliberately excluded.
 */
html:root
  body[class].front.portal.tpl-haoju
    :is(
      .stream-info-card,
      .stream-showcase,
      .info-panel,
      .section-block,
      .rank-box,
      .ds3-rank-box,
      .player-side,
      .guest-comment-box
    ),
html:root
  body[class].front.portal.tpl-keke.keke-template:not(.site-oletv)
    :is(
      .keke-detail,
      #keke-summary-panel.keke-article,
      .keke-section.keke-info-card,
      article.keke-info-card,
      .keke-rank,
      .oletv-player-side
    ),
html:root
  body[class].front.portal.tpl-keke.keke-template.site-oletv
    :is(
      #keke-summary-panel.keke-article,
      .keke-section.keke-info-card,
      article.keke-info-card,
      .keke-rank
    ),
html:root
  body[class].front.portal.tpl-iqiyi.iqiyi-template
    :is(
      .section-block,
      .rank-box,
      .info-panel,
      .filter-panel,
      .list-hero,
      .player-side,
      .guest-comment-box
    )
{
  border-color: transparent !important;
  background: transparent !important;
  box-shadow: none !important;
}

/*
 * Navigation and footer surfaces still need an opaque interaction backdrop.
 * Remove only their ornamental separator/shadow; do not clear their fill.
 */
html:root
  body[class].front.portal.tpl-haoju
    :is(
      .haoju-global-header,
      .site-footer
    ),
html:root
  body[class].front.portal.tpl-keke.keke-template
    :is(.keke-topbar, .site-footer),
html:root
  body[class].front.portal.tpl-iqiyi.iqiyi-template
    :is(
      .portal-top.iqiyi-header,
      .site-footer
    )
{
  border-color: transparent !important;
  box-shadow: none !important;
}

/*
 * IQIYI-family poster lists use the available H5 width instead of two
 * oversize cards.  The #catalog-results branch intentionally raises the
 * whole :is() selector above the legacy app.css !important rules.  Scope is
 * limited to actual poster containers; news, rankings, hot search and nav do
 * not match.
 */
@media (max-width: 900px) {
  html
    body.front.portal.iqiyi-template.tpl-iqiyi
    :is(
      .portal-main-flow .channel-section > .poster-row,
      .search-page .poster-row.search-results,
      #catalog-results.movie-grid,
      .detail-main > .detail-related-grid.movie-grid,
      .player-related > .related-grid.movie-grid
    ) {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    grid-auto-flow: row !important;
    grid-auto-columns: unset !important;
    gap: 8px !important;
  }

  html
    body.front.portal.iqiyi-template.tpl-iqiyi
    :is(
      .portal-main-flow .channel-section > .poster-row,
      .search-page .poster-row.search-results,
      #catalog-results.movie-grid,
      .detail-main > .detail-related-grid.movie-grid,
      .player-related > .related-grid.movie-grid
    )
    > :is(.portal-card, .movie-card) {
    min-width: 0 !important;
  }

}
