/* EVO+ cross-device QA fixes.
   Loaded last so visual branding cannot replace the production navigation contract. */

/* The same primary navigation and toolbar are present in every catalogue view. */
#app.be-home-redesign .topbar-copy,
#app.be-home-redesign #mobileHomeBrand {
  display: none !important;
}

#app.be-home-redesign .home-layout-nav {
  display: flex !important;
  min-width: 0;
  flex: 1 1 auto;
  align-items: center;
  gap: clamp(14px, 1.7vw, 28px);
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
}

#app.be-home-redesign .home-layout-nav::-webkit-scrollbar { display: none; }
#app.be-home-redesign #homeSearchShortcut,
#app.be-home-redesign #homeFavoritesShortcut:not([hidden]) { display: grid !important; }
#app.be-home-redesign #fireTvSearchButton,
#app.be-home-redesign #webInstallAppButton { display: none !important; }
#app.be-home-redesign .top-actions > .search { display: none !important; }

/* Requested left-to-right order: expiry, time, weather, favorites, remote,
   search and profile. IDs cover native, web and controller variants. */
#app.be-home-redesign .top-actions > #homeAccountExpiry { order: 0; }
#app.be-home-redesign .top-actions > #deviceLocalTime { order: 1; }
#app.be-home-redesign .top-actions > #weatherButton { order: 2; }
#app.be-home-redesign .top-actions > :is(#apkFavoritesButton,#webFavoritesButton,#homeFavoritesShortcut) { order: 3; }
#app.be-home-redesign .top-actions > #apkRemoteControlButton { order: 4; }
#app.be-home-redesign .top-actions > #homeSearchShortcut { order: 5; }
#app.be-home-redesign .top-actions > .user-menu-shell { order: 6; }

#app.be-home-redesign .top-actions > :is(
  #weatherButton,#apkFavoritesButton,#webFavoritesButton,#homeFavoritesShortcut,
  #apkRemoteControlButton,#homeSearchShortcut
) {
  box-sizing: border-box !important;
  display: grid;
  width: 42px !important;
  min-width: 42px !important;
  height: 42px !important;
  min-height: 42px !important;
  flex: 0 0 42px !important;
  place-items: center;
  padding: 8px !important;
}

#app.be-home-redesign .top-actions > :is(
  #weatherButton,#apkFavoritesButton,#webFavoritesButton,#homeFavoritesShortcut,
  #apkRemoteControlButton,#homeSearchShortcut
) svg {
  display: block;
  width: 24px !important;
  height: 24px !important;
  flex: 0 0 24px;
}

/* The weather glyph has more internal whitespace than the other 24px icons.
   Optical scaling keeps its visible mark equal without changing the shared
   button hit area or the toolbar alignment. */
#app.be-home-redesign .top-actions > #weatherButton svg {
  transform: scale(1.16);
  transform-origin: center;
}

html.blackeye-apk-shell.blackeye-fire-tv #app.be-home-redesign .top-actions > :is(
  #weatherButton,#apkFavoritesButton,#homeFavoritesShortcut,
  #apkRemoteControlButton,#homeSearchShortcut
) {
  width: 48px !important;
  min-width: 48px !important;
  height: 48px !important;
  min-height: 48px !important;
  flex-basis: 48px !important;
  padding: 10px !important;
}

#app.be-home-redesign .top-actions > #deviceLocalTime {
  flex: 0 0 auto;
  margin: 0 4px !important;
}

#app.be-home-redesign .top-actions > #homeAccountExpiry {
  display: inline-flex;
  width: auto !important;
  max-width: min(245px, 21vw);
  align-items: center;
  overflow: hidden;
  margin: 0 5px 0 0 !important;
  padding: 0 !important;
  border: 0 !important;
  color: #79a5ff !important;
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Full-size focus frame. The previous inset shadows made artwork look smaller. */
.theme-blackeye :is(.movie-genre-scroller > .content-card,.content-grid > .content-card,.favorite-group-grid > .content-card):is(:focus,:focus-visible) > .poster,
.theme-blackeye .home-curation-card:is(:focus,:focus-visible) > .home-curation-poster,
.theme-blackeye .home-live-carousel-card:is(:focus,:focus-visible) .home-live-card-art,
.theme-blackeye .live-folder:is(:focus,:focus-visible) .live-folder-art,
.theme-blackeye .carousel-view-all:is(:focus,:focus-visible) .carousel-view-all-art {
  box-sizing: border-box !important;
  border-color: #a61f32 !important;
  outline: none !important;
  box-shadow:
    0 0 0 2px rgba(255, 244, 246, .98),
    0 0 0 6px #a61f32 !important;
  transform: none !important;
}

html.blackeye-apk-shell.blackeye-fire-tv #app :is(
  .content-card:focus > .poster,
  .home-curation-card:focus > .home-curation-poster,
  .home-live-carousel-card:focus .home-live-card-art,
  .live-folder:focus .live-folder-art
) {
  border-color: #a61f32 !important;
  box-shadow:
    0 0 0 2px rgba(255, 244, 246, .98),
    0 0 0 6px #a61f32 !important;
}

/* Disable the smaller frame injected by the native shell; the frame above has
   the same dimensions as the complete artwork and stays above every badge. */
html.blackeye-apk-shell.blackeye-fire-tv #app :is(
  .content-card:focus > .poster,
  .home-curation-card:focus > .home-curation-poster,
  .home-live-carousel-card:focus .home-live-card-art,
  .live-folder:focus .live-folder-art,
  .apk-preview-focused:not(.apk-preview-on-dismiss) > .poster,
  .apk-preview-focused:not(.apk-preview-on-dismiss) > .home-curation-poster
)::after {
  display: none !important;
}

.theme-blackeye :is(.movie-genre-scroller,.home-curation-scroller,.home-live-carousel,.sports-zone-rail) {
  box-sizing: border-box;
  padding: 10px 9px 14px !important;
  scroll-padding-inline: 9px;
}

/* Detail controls need enough breathing room for a complete circular frame. */
html body #detailDialog .series-control {
  overflow: visible !important;
  padding: 19px 20px !important;
}

html body #detailDialog :is(.series-control select,.subtitle-control select):is(:focus,:focus-visible) {
  border-color: #a61f32 !important;
  outline: none !important;
  box-shadow: 0 0 0 2px #fff, 0 0 0 6px #a61f32 !important;
}

html body #detailDialog #seriesContinue {
  box-sizing: border-box !important;
  width: calc(100% - 16px) !important;
  margin: 19px 8px 8px !important;
  padding-inline: 22px 16px !important;
  overflow: visible !important;
}

html body #detailDialog #seriesContinue:is(:focus,:focus-visible) {
  outline: none !important;
  box-shadow: 0 14px 34px #0007 !important;
}

html body #detailDialog #seriesContinue:is(:focus,:focus-visible) .series-continue-icon {
  box-sizing: border-box !important;
  width: 44px !important;
  height: 44px !important;
  flex: 0 0 44px !important;
  outline: none !important;
  box-shadow: 0 0 0 2px #fff, 0 0 0 6px #a61f32, 0 9px 22px #0008 !important;
}

html.blackeye-fire-tv .blackeye-tv-select-menu {
  padding: 19px !important;
  scroll-padding: 8px;
}

html.blackeye-fire-tv .blackeye-tv-select-option:is(:focus,:focus-visible) {
  outline: none !important;
  background: #700c1f !important;
  box-shadow: inset 0 0 0 3px #fff, inset 0 0 0 6px #a61f32 !important;
}

/* Sidebar and Sports Zone are scrolling surfaces; reserve space for their
   complete contours instead of clipping the top or left arc. */
.theme-blackeye .sidebar nav { padding: 7px !important; scroll-padding: 7px; }
.theme-blackeye .sidebar nav .nav-item:is(:focus,:focus-visible) {
  box-sizing: border-box !important;
  border-color: #a61f32 !important;
  outline: none !important;
  box-shadow: inset 0 0 0 2px #fff, inset 0 0 0 5px #a61f32 !important;
}

.theme-blackeye :is(.sports-zone-tabs,.sports-zone-filters) {
  padding: 8px 6px 11px !important;
  scroll-padding-inline: 6px;
}

.theme-blackeye .sports-zone :is(button,input,select):is(:focus,:focus-visible),
.theme-blackeye .sports-zone-detail button:is(:focus,:focus-visible) {
  outline: none !important;
  border-color: #a61f32 !important;
  box-shadow: 0 0 0 2px #fff, 0 0 0 5px #a61f32 !important;
}

/* Touch phones open the content sheet directly. A stale selected class must
   never replace the carousel with an inaudible/unclickable expanded card. */
@media (hover: none), (pointer: coarse) {
  html:not(.blackeye-fire-tv) .home-curation-card.is-selected {
    flex-basis: 118px !important;
    width: 118px !important;
    max-width: 118px !important;
  }
  html:not(.blackeye-fire-tv) .home-curation-card.is-selected > :is(.home-curation-poster,h4,p) {
    display: revert !important;
  }
  html:not(.blackeye-fire-tv) .home-curation-card.is-selected .home-card-expanded {
    display: none !important;
  }
}

/* Mobile: no expiry copy, no overlapping logo and the requested icons remain
   reachable in both orientations. */
@media (max-width: 760px), (max-width: 1180px) and (max-height: 820px) and (pointer: coarse) {
  html:not(.blackeye-fire-tv) #app.be-home-redesign .top-actions > #homeAccountExpiry { display: none !important; }
  #app.be-home-redesign #mobileHomeBrand { display: none !important; }
  #app.be-home-redesign .home-layout-nav button {
    flex: 0 0 auto;
    padding-block: 10px;
    font-size: 11px;
  }
  #app.be-home-redesign .top-actions {
    width: auto !important;
    min-width: 0;
    justify-content: flex-end;
    gap: 7px !important;
  }
  #app.be-home-redesign .top-actions > :is(
    #weatherButton,#apkFavoritesButton,#webFavoritesButton,#homeFavoritesShortcut,
    #apkRemoteControlButton,#homeSearchShortcut
  ) {
    width: 38px !important;
    min-width: 38px !important;
    height: 38px !important;
    min-height: 38px !important;
    flex-basis: 38px !important;
    padding: 7px !important;
  }
  #app.be-home-redesign .top-actions > .user-menu-shell,
  #app.be-home-redesign #userMenuButton {
    width: 38px !important;
    min-width: 38px !important;
    height: 38px !important;
    min-height: 38px !important;
    flex: 0 0 38px !important;
  }
  #app.be-home-redesign #deviceLocalTime {
    margin-inline: 1px !important;
    font-size: 11px !important;
  }
}

@media (orientation: portrait) and (max-width: 760px) {
  #app.be-home-redesign .topbar {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    align-items: center !important;
    gap: 5px !important;
  }
  #app.be-home-redesign .home-layout-nav { order: 0; width: 100%; gap: 18px; }
  #app.be-home-redesign .top-actions { order: 1; width: 100% !important; }
}

@media (orientation: landscape) and (max-width: 1180px) and (max-height: 820px) {
  #app.be-home-redesign .topbar {
    display: flex !important;
    width: auto !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 12px !important;
  }
  #app.be-home-redesign .home-layout-nav { order: 0; gap: 15px; }
  #app.be-home-redesign .top-actions { order: 1; flex: 0 0 auto !important; }
  #app.be-home-active .topbar {
    left: max(calc(var(--home-inline-inset, 12px) + 2%), calc(env(safe-area-inset-left) + 7px)) !important;
    right: max(calc(var(--home-inline-inset, 12px) + 2%), calc(env(safe-area-inset-right) + 7px)) !important;
  }
  #app.be-home-active .home-feature-copy { left: 2.5% !important; }
  body.theme-blackeye .app.sidebar-collapsed { grid-template-columns: 52px minmax(0, 1fr) !important; }
  body.theme-blackeye .app.sidebar-collapsed .main { padding-left: 10px !important; }
}

@media (prefers-reduced-motion: reduce) {
  .theme-blackeye :is(.content-card,.home-curation-card,.live-folder,.nav-item,button) {
    transition-duration: .01ms !important;
  }
}
