/* Profiles use the same saved background/text pair as insight cards. */
:is(#player-profile, #team-profile, #coach-profile).profile-refresh [data-profile-palette] {
  --profile-banner-background: var(--card-background, var(--player-primary-color, var(--primary-color, #192b43)));
  --profile-banner-ink: var(--card-text, #fff);
  background: var(--profile-banner-background) !important;
  color: var(--profile-banner-ink);
}
:is(#player-profile, #team-profile, #coach-profile).profile-refresh [data-profile-palette] [data-testid="banner-bg"] { display: none; }
:is(#player-profile, #team-profile, #coach-profile).profile-refresh [data-profile-palette] :is(
  [data-testid="banner-text"], .player-name, .team-name, .player-meta-info,
  .player-meta-info .meta-item, .team-meta-info, .team-meta-info .meta-item,
  .team-meta-info .meta-item span, .team-meta-info .meta-item i, .stat-value, .stat-label,
  .share-btn, .bookmark-btn, .bookmark-btn i
) { color: var(--profile-banner-ink) !important; }
/* The strip belongs to the full banner, not its inset text or tab column.
   Paint below the content so artwork, tabs and season menus stay unobstructed. */
:is(#player-profile, #team-profile, #coach-profile).profile-refresh [data-profile-palette]::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 46px;
  border-radius: 0 0 18px 18px;
  background: color-mix(in srgb, var(--profile-banner-ink) 8%, var(--profile-banner-background));
  pointer-events: none;
  z-index: 0;
}
:is(#player-profile, #team-profile, #coach-profile).profile-refresh [data-profile-palette] [data-testid="player-tabs"] {
  background: transparent !important;
}
@media (max-width: 820px) {
  :is(#player-profile, #team-profile, #coach-profile).profile-refresh [data-profile-palette]::after { border-radius: 0; }
}
:is(#player-profile, #team-profile, #coach-profile).profile-refresh [data-profile-palette] [data-testid="player-tabs"] .nav-tab:not(.active) {
  color: var(--profile-banner-ink) !important;
}
:is(#player-profile, #team-profile, #coach-profile).profile-refresh [data-profile-palette] :is(button, a):focus-visible {
  outline-color: var(--profile-banner-ink) !important;
}
:is(#player-profile, #team-profile, #coach-profile).profile-refresh [data-profile-palette] .share-icon {
  background: currentColor;
  -webkit-mask: var(--share-icon-url) center / contain no-repeat;
  mask: var(--share-icon-url) center / contain no-repeat;
  filter: none;
}
:is(#player-profile, #team-profile, #coach-profile).profile-refresh [data-profile-palette] .bookmark-btn i.fa-bookmark {
  background: currentColor;
  -webkit-mask: var(--bookmark-icon-outline-url) center / contain no-repeat;
  mask: var(--bookmark-icon-outline-url) center / contain no-repeat;
  filter: none;
}
:is(#player-profile, #team-profile, #coach-profile).profile-refresh [data-profile-palette] .bookmark-btn i.fas.fa-bookmark {
  -webkit-mask-image: var(--bookmark-icon-filled-url);
  mask-image: var(--bookmark-icon-filled-url);
}
:is(#player-profile, #team-profile, #coach-profile).profile-refresh [data-profile-palette] :is(.bookmark-btn i.fa-bookmark, .share-icon) {
  width: 20px !important; height: 20px !important;
}

@media (max-width: 820px) {
  body.mobile-banner-page:not(.mobile-search-open) #searchArea .search-btn {
    background: var(--mobile-banner-color, var(--brand-blue));
    color: var(--mobile-banner-ink, #fff);
  }
  body.mobile-banner-page:not(.mobile-search-open) #searchArea .search-icon-arrow::before { background: currentColor; }
  body.mobile-banner-page:not(.mobile-search-open) #searchArea .search-icon-arrow::after { border-color: currentColor; }
  body.mobile-banner-page:not(.mobile-search-open) #searchArea .search-icon-clear { color: inherit; }

  /* Keep the original controls/handlers, positioned just above the tab strip. */
  :is(#player-profile, #team-profile, #coach-profile).profile-refresh .hero-section[data-profile-palette] :is(.share-btn, [data-testid="bookmark-btn"]) {
    position: absolute !important; top: auto !important; left: auto !important;
    bottom: 48px !important; right: 12px !important;
    width: 44px !important; height: 44px !important; min-width: 44px !important; min-height: 44px !important;
    margin: 0 !important; background: transparent !important; box-shadow: none !important;
  }
  :is(#player-profile, #team-profile, #coach-profile).profile-refresh .hero-section[data-profile-palette] .share-btn { right: 56px !important; }
  :is(#player-profile, #coach-profile).profile-refresh .hero-section[data-profile-palette] .player-image-container { height: 132px !important; }
  :is(#player-profile, #coach-profile).profile-refresh .hero-section[data-profile-palette] .player-title-row { padding: 10px 0 46px !important; }
  #coach-profile.profile-refresh .hero-section[data-profile-palette] .coach-no-image .player-title-row { padding: 16px 0 50px !important; }
  #team-profile.profile-refresh .hero-section[data-profile-palette] .team-header { padding: 14px 0 12px !important; }
  #team-profile.profile-refresh .team-banner-footer { padding-top: 2px; }
  #team-profile.profile-refresh .team-banner-season { margin: 0 auto 10px 0; }

  /* Let question copy determine height, with artwork and actions below it. */
  .query-bubble-section .top-bubble[data-testid="hero-banner"] {
    height: auto !important; min-height: 0 !important; padding: 12px 16px 0 !important;
  }
  .query-bubble-section .top-bubble .bubble-content {
    display: grid !important; grid-template-columns: 128px minmax(0, 1fr);
    grid-template-rows: auto 52px; gap: 10px 12px;
    height: auto !important; min-height: 0 !important; width: 100%;
  }
  .query-bubble-section .top-bubble:has(.top-player-image:not(.banner-image-fallback)) .bubble-content { grid-template-rows: auto 128px; }
  .query-bubble-section .top-bubble .question-text {
    position: static !important; inset: auto !important; transform: none !important;
    grid-column: 1 / -1; grid-row: 1; order: 0; padding: 0 !important; margin: 0 !important;
  }
  .query-bubble-section .top-bubble .top-player-image:not(.banner-image-fallback) {
    position: static !important; inset: auto !important; grid-column: 1; grid-row: 2;
    width: 128px !important; height: 128px !important; max-width: 100%; max-height: none !important;
    margin: 0 !important; align-self: end; background: transparent;
  }
  .query-bubble-section .top-bubble [data-testid="banner-actions"] {
    inset: auto 12px 8px auto !important; display: flex; flex-wrap: wrap; justify-content: flex-end;
    align-items: center; gap: 4px; width: calc(100% - 24px); height: auto;
  }
  .query-bubble-section .top-bubble:has(.top-player-image:not(.banner-image-fallback)) [data-testid="banner-actions"] { width: calc(100% - 156px); }
  .query-bubble-section .top-bubble [data-testid="banner-actions"] > :is(#questionBookmarkBubble, .share-btn, .export-image-btn, .question-publish-btn, .query-bubble-stat-guide) {
    position: relative !important; inset: auto !important; flex: 0 0 44px;
    width: 44px !important; min-width: 44px !important; height: 44px !important; min-height: 44px !important; margin: 0 !important; padding: 0;
    pointer-events: auto;
  }
  .query-bubble-section .top-bubble [data-testid="banner-actions"] #questionBookmarkBubble { order: 5; }
  .query-bubble-section .top-bubble [data-testid="banner-actions"] .share-btn { order: 4; }
  .query-bubble-section .top-bubble [data-testid="banner-actions"] :is(.bookmark-btn, .fs-bookmark-button, .stat-guide-hover-btn) {
    position: relative !important; inset: auto !important; width: 44px !important; height: 44px !important; min-width: 44px !important; min-height: 44px !important;
  }
  .query-bubble-section .top-bubble [data-testid="banner-actions"] :is([data-publish-label], .export-image-label, .stat-guide-hover-btn > span) {
    position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%);
  }
  .query-bubble-section .top-bubble .question-publish-feedback { top: auto; bottom: 48px; right: 0; }
}
