/* Favourite teams and players on the Home (SP_HOME_FAVORITES; pages/home/favorites.py, assets/home_favorites.js).
   Three parts: the star on the main bar, the marks on the Home, the picker. Colours and type are the Home's own
   tokens (--hh-*, assets/zz_home.css), so the light mode follows without rules of its own. */

/* ---- 1. the star on the main bar (layout.py #favorites-toggle) ------------------------------------------------ */
/* Favourites act on the Home only, so the button is there only. On the desktop sidebar it is a row like Pin menu
   (the shared .sp-sidebar-pin rules of assets/zz_site_chrome.css); on the phone header an icon beside the light
   switch. */
body:not(.sp-route-home) .sp-favorites-toggle {
  display: none !important;
}
@media (max-width: 1024px) {
  .sp-top-actions .sp-favorites-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--hl-pi, var(--sp-text));
    cursor: pointer;
  }
  .sp-top-actions .sp-favorites-toggle .sp-sidebar-label {
    display: none;
  }
}
/* filled and orange while anything is picked */
.sp-favorites-toggle[data-on] svg {
  color: var(--hl-tape, #FF7A1A);
}
.sp-favorites-toggle[data-on] svg path {
  fill: currentColor;
}

/* ---- 2. the marks: a small star on the logo or the face of a picked team or player ---------------------------- */
.sp-home-hub .hh-fav-star {
  position: absolute;
  right: -5px;
  bottom: -4px;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: var(--hh-tape);
  color: var(--hh-tapeink);
  box-shadow: 0 0 0 1.5px var(--hh-paper);
  pointer-events: none;
}
.sp-home-hub .hh-fav-star svg {
  display: block;
  width: 11px;
  height: 11px;
  fill: currentColor;
}
/* the picture lets the star stand over its edge; a portrait keeps its circle by itself */
.sp-home-hub .hh-stk.hh-fav-pic,
.sp-home-hub .cmp-ranking-avatar.hh-fav-pic {
  position: relative;
  overflow: visible;
}
.sp-home-hub .hh-stk.hh-fav-pic img {
  border-radius: 50%;
}
.sp-home-hub .hh-dark .hh-fav-star,
.sp-home-hub .hh-res .hh-fav-star {
  box-shadow: 0 0 0 1.5px var(--hh-k);
}
/* the scores: small logos, a small star */
.sp-home-hub .hh-res .hh-fav-star {
  right: -4px;
  bottom: -3px;
  width: 13px;
  height: 13px;
  box-shadow: 0 0 0 1px var(--hh-k);
}
.sp-home-hub .hh-res .hh-fav-star svg {
  width: 8px;
  height: 8px;
}
/* the phone's row of bigger tiles (assets/zz_home.css, below 1000 px): the logo is 26 px, the star a little bigger */
@container sp-home (width < 1000px) {
  .sp-home-hub .hh-res .hh-fav-star {
    width: 14px;
    height: 14px;
  }
  .sp-home-hub .hh-res .hh-fav-star svg {
    width: 9px;
    height: 9px;
  }
}
/* the team map: the logo comes forward and carries the star on its edge */
.sp-home-hub .hh-mt.hh-fav-pic {
  overflow: visible;
  z-index: 1;
}
.sp-home-hub .hh-mt.hh-fav-pic img {
  border-radius: 50%;
}
.sp-home-hub .hh-mt .hh-fav-star {
  right: -5px;
  bottom: -5px;
  width: 14px;
  height: 14px;
  box-shadow: 0 0 0 1px var(--hh-k);
}
.sp-home-hub .hh-mt .hh-fav-star svg {
  width: 9px;
  height: 9px;
}
/* a row without a picture (the race's legend, the narrow rows of the longer list): the star stands before the name */
.sp-home-hub .hh-fav-star--inline {
  position: relative;
  right: auto;
  bottom: auto;
  display: inline-grid;
  flex: none;
  margin-right: 6px;
  vertical-align: -3px;
  box-shadow: none;
}
.sp-home-hub .hh-nr-name > .hh-fav-star--inline {
  margin-right: 0;
}
/* a picked team below tenth place: its copy stands under the fold while the fold is closed */
.sp-home-hub .hh-st-fold:not([hidden]) ~ .hh-fav-copy {
  display: none;
}

/* ---- 3. the picker: the Home's dialog; a sheet from the bottom on a phone, a panel on a wide screen ----------- */
.sp-home-hub .hh-fav {
  position: fixed;
  inset: auto 0 0 0;
  box-sizing: border-box;
  width: 100%;
  max-width: none;
  max-height: 78dvh;
  margin: 0;
  padding: 0;
  border: 0;
  background: var(--hh-paper);
  color: var(--hh-pi);
  box-shadow: inset 0 0 0 2px var(--hh-rim);
  overflow: hidden;
}
.sp-home-hub .hh-fav[open] {
  display: flex;
}
.sp-home-hub .hh-fav::backdrop {
  background: rgba(2, 2, 3, 0.5);
}
.sp-home-hub .hh-fav-sheet {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  padding: 14px 14px max(14px, env(safe-area-inset-bottom, 0px));
}
.sp-home-hub .hh-fav-head,
.sp-home-hub .hh-fav-search,
.sp-home-hub .hh-fav-tabs {
  flex: none;
}
.sp-home-hub .hh-fav-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.sp-home-hub .hh-fav-title {
  margin: 0;
  font-stretch: 62%;
  font-weight: 900;
  font-size: 26px;
  line-height: 1;
  outline: 0;
}
.sp-home-hub .hh-fav-search {
  box-sizing: border-box;
  width: 100%;
  height: 44px;
  margin-top: 10px;
  padding: 0 12px;
  border: 0;
  border-radius: 0;
  outline: 0;
  background: var(--hh-k);
  color: var(--hh-kink);
  box-shadow: inset 0 0 0 2px var(--hh-rimk);
  font: inherit;
  font-weight: 600;
  font-size: 16px;
}
.sp-home-hub .hh-fav-search::placeholder {
  color: var(--hh-kmuted);
}
.sp-home-hub .hh-fav-search:focus {
  box-shadow: inset 0 0 0 2px var(--hh-tape);
}
.sp-home-hub .hh-fav-tabs {
  display: flex;
  margin-top: 10px;
}
.sp-home-hub .hh-fav-tabs[hidden] {
  display: none;
}
.sp-home-hub .hh-fav-tabs button {
  flex: 1 1 0;
  height: 40px;
  margin-left: -2px;
  border: 2px solid var(--hh-edge);
  background: var(--hh-paper);
  color: var(--hh-pi);
  font-stretch: 75%;
  font-weight: 800;
  font-size: 16px;
}
.sp-home-hub .hh-fav-tabs button:first-child {
  margin-left: 0;
}
.sp-home-hub .hh-fav-tabs button[aria-pressed="true"] {
  border-color: var(--hh-sel);
  background: var(--hh-sel);
  color: var(--hh-selink);
}
.sp-home-hub .hh-fav-tabs i {
  margin-left: 5px;
  font-style: normal;
  font-weight: 600;
  opacity: 0.7;
}
.sp-home-hub .hh-fav-body {
  flex: 1 1 auto;
  min-height: 120px;
  margin-top: 10px;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.sp-home-hub .hh-fav-body h3 {
  margin: 14px 0 8px;
  font-stretch: 62%;
  font-weight: 900;
  font-size: 19px;
  line-height: 1;
}
.sp-home-hub .hh-fav-body h3:first-child {
  margin-top: 0;
}
.sp-home-hub .hh-fav-none {
  margin: 0;
  padding: 12px 0;
  color: var(--hh-muted);
  font-size: 13px;
}
/* thirty logos, six in a row; a picked team is the white block of a chosen tab with the star on its logo */
.sp-home-hub .hh-fav-teams {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 5px;
}
.sp-home-hub .hh-fav-team {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 3px;
  min-height: 58px;
  padding: 5px 0 4px;
  background: var(--hh-k);
  color: var(--hh-kink);
  font-weight: 800;
  font-size: 11px;
  line-height: 1;
}
.sp-home-hub .hh-fav-team .hh-stk {
  width: 34px;
  height: 34px;
}
.sp-home-hub .hh-fav-team[aria-pressed="true"] {
  position: relative;
  background: var(--hh-sel);
  color: var(--hh-selink);
}
.sp-home-hub .hh-fav-team .hh-fav-star {
  top: 3px;
  right: 3px;
  bottom: auto;
  box-shadow: 0 0 0 1.5px var(--hh-sel);
}
/* players: the face, the name over the team, and the star that picks */
.sp-home-hub .hh-fav-list {
  display: grid;
}
.sp-home-hub .hh-fav-row {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) 44px;
  gap: 10px;
  align-items: center;
  width: 100%;
  min-height: 50px;
  border-top: 1px solid color-mix(in srgb, var(--hh-pi) 35%, transparent);
  color: inherit;
  text-align: left;
}
.sp-home-hub .hh-fav-row:first-child {
  border-top: 0;
}
.sp-home-hub .hh-fav-row .hh-stk {
  width: 36px;
  height: 36px;
}
.sp-home-hub .hh-fav-who {
  min-width: 0;
}
.sp-home-hub .hh-fav-who b {
  display: block;
  overflow: hidden;
  font-weight: 700;
  font-size: 14px;
  line-height: 1.2;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.sp-home-hub .hh-fav-who small {
  display: block;
  color: var(--hh-muted);
  font-size: 12px;
  line-height: 1.25;
}
.sp-home-hub .hh-fav-tick {
  display: grid;
  place-items: center;
  width: 44px;
  height: 32px;
  box-shadow: inset 0 0 0 2px var(--hh-pi);
}
.sp-home-hub .hh-fav-tick .hh-fav-star {
  width: auto;
  height: auto;
  margin: 0;
  background: none;
  color: var(--hh-pi);
}
.sp-home-hub .hh-fav-tick .hh-fav-star svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linejoin: round;
}
.sp-home-hub .hh-fav-row[aria-pressed="true"] .hh-fav-tick {
  background: var(--hh-tape);
  box-shadow: none;
}
.sp-home-hub .hh-fav-row[aria-pressed="true"] .hh-fav-tick .hh-fav-star {
  color: var(--hh-tapeink);
}
.sp-home-hub .hh-fav-row[aria-pressed="true"] .hh-fav-tick .hh-fav-star svg {
  fill: currentColor;
}
.sp-home-hub .hh-fav :focus-visible {
  outline: 2px solid var(--hh-tape);
  outline-offset: 2px;
}
@media (min-width: 768px) {
  .sp-home-hub .hh-fav {
    inset: 0;
    width: 440px;
    max-height: min(680px, 86dvh);
    margin: auto;
  }
}
@media (prefers-reduced-motion: no-preference) {
  .sp-home-hub .hh-fav[open] {
    animation: hh-fav-up 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
  }
  @keyframes hh-fav-up {
    from { transform: translateY(24px); opacity: 0.4; }
    to { transform: none; opacity: 1; }
  }
}
