/* Home only: keep the four category tabs and native filters in their own roles. */
#page.voicepa-homepage .vp-home-tools {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-width: 0;
  max-width: 100%;
  margin: 0 0 9px;
}

#page.voicepa-homepage .vp-home-tools--unfiltered {
  grid-template-columns: minmax(0, 1fr);
}

#page.voicepa-homepage .vp-home-tools > .vp-home-filter {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  gap: 6px;
}

#page.voicepa-homepage .vp-home-tools .vp-home-filter__label {
  padding-inline: 5px;
  font-size: 11px;
  white-space: nowrap;
}

#page.voicepa-homepage .vp-home-tools .vp-home-filter select {
  min-width: 0;
  width: 100%;
}

#page.voicepa-homepage .vp-home-ranking {
  position: relative;
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  min-width: 0;
  gap: 2px;
  color: #5f6977;
}

#page.voicepa-homepage .vp-home-tools--unfiltered .vp-home-ranking {
  margin-left: auto;
}

#page.voicepa-homepage .vp-home-ranking__orders {
  display: inline-flex;
  align-items: stretch;
  min-width: 0;
  box-sizing: border-box;
  padding: 2px;
  border: 1px solid #e2e4e8;
  border-radius: 8px;
  background: #f7f8fa;
  gap: 2px;
}

#page.voicepa-homepage .vp-home-ranking__order {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 58px;
  min-height: 34px;
  box-sizing: border-box;
  margin: 0;
  padding: 6px 8px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: #646c78;
  font-family: inherit;
  font-size: 12px;
  font-weight: 650;
  line-height: 1.35;
  letter-spacing: 0;
  white-space: nowrap;
  appearance: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

#page.voicepa-homepage .vp-home-ranking svg {
  display: block;
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
}

#page.voicepa-homepage .vp-home-ranking__order[aria-pressed="true"] {
  background: #fff;
  color: #98385f;
  box-shadow: inset 0 -2px 0 #b84175;
}

#page.voicepa-homepage .vp-home-ranking__order:hover {
  background: #f1eaf0;
  color: #913357;
}

#page.voicepa-homepage .vp-home-ranking__order:focus-visible,
#page.voicepa-homepage .vp-home-ranking__info > summary:focus-visible {
  outline: 2px solid #a73569;
  outline-offset: 2px;
}

#page.voicepa-homepage .vp-home-ranking__info {
  position: relative;
  flex: 0 0 auto;
  margin: 0;
}

#page.voicepa-homepage .vp-home-ranking__info > summary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  min-height: 40px;
  box-sizing: border-box;
  margin: 0;
  padding: 5px;
  border: 0;
  border-radius: 6px;
  color: #7e8794;
  background: transparent;
  list-style: none;
  cursor: pointer;
  touch-action: manipulation;
}

#page.voicepa-homepage .vp-home-ranking__info > summary::-webkit-details-marker {
  display: none;
}

#page.voicepa-homepage .vp-home-ranking__info > summary:hover,
#page.voicepa-homepage .vp-home-ranking__info[open] > summary {
  color: #95385f;
  background: #f8edf3;
}

#page.voicepa-homepage .vp-home-ranking__note {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  z-index: 8;
  width: 242px;
  max-width: calc(100vw - 36px);
  box-sizing: border-box;
  padding: 11px 12px;
  border: 1px solid #dedce2;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 4px 16px rgba(36, 29, 42, .12);
  color: #5a5662;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.65;
}

#page.voicepa-homepage .vp-home-ranking__note > :is(strong, span) {
  display: block;
}

#page.voicepa-homepage .vp-home-ranking__note > strong {
  margin-bottom: 4px;
  color: #34313a;
  font-size: 12px;
  font-weight: 700;
}

#page.voicepa-homepage .vp-home-ranking-status {
  grid-column: 1 / -1;
  margin: 0;
  color: #766673;
  font-size: 11px;
  line-height: 1.5;
}

#page.voicepa-homepage .vp-home-ranking-status[hidden] {
  display: none !important;
}

#page.voicepa-homepage .vp-home-rank-badge {
  position: absolute;
  top: 5px;
  right: 6px;
  z-index: 6;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  max-width: calc(100% - 12px);
  box-sizing: border-box;
  padding: 4px 6px;
  border: 1px solid #e1d3aa;
  border-radius: 6px;
  background: #fff1c9;
  color: #745211;
  font-family: inherit;
  font-size: 11px;
  font-weight: 750;
  line-height: 1.35;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  pointer-events: none;
}

#page.voicepa-homepage .vp-home-rank-badge svg {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
}

#page.voicepa-homepage .vp-home-rank-badge--silver {
  border-color: #d7dce5;
  background: #f0f2f7;
  color: #4f5b6c;
}

#page.voicepa-homepage .vp-home-rank-badge--bronze {
  border-color: #e6cbb9;
  background: #fbe9dc;
  color: #805035;
}

#page.voicepa-homepage .vp-home-rank-badge--plain {
  border-color: #e0e2e8;
  background: #fff;
  color: #59616e;
}

/* Keep age information in a second row below the right-hand ranking badge. */
#page.voicepa-homepage [data-vp-home-feed] > .vp-home-ranked-card > :is(.featured-thumbnail-frontmaintop, .featured-thumbnail-frontmaintop2) > :is(.voicepa-age-label, .age-label) {
  /* The shared premium grid stylesheet also positions these with !important. */
  top: 36px !important;
  right: 6px !important;
}

/* Include the ribbon's 12px triangle tip and up to three ranking digits. */
#page.voicepa-homepage [data-vp-home-feed] > .vp-home-ranked-card > [class*="indexribbon"] {
  max-width: calc(100% - 84px) !important;
}

#page.voicepa-homepage .vp-home-ranked-card > [class*="indexribbon"] .ribbon-naibu {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 900px) {
  #page.voicepa-homepage .vp-home-tools {
    gap: 8px;
  }

  #page.voicepa-homepage .vp-home-tools .vp-home-filter select {
    min-height: 44px;
    font-size: 16px;
  }

  #page.voicepa-homepage .vp-home-ranking__order {
    min-height: 44px;
  }

  #page.voicepa-homepage .vp-home-ranking__info > summary {
    min-width: 44px;
    min-height: 44px;
  }
}

@media (max-width: 640px) {
  #page.voicepa-homepage .vp-home-tools {
    grid-template-columns: minmax(0, 1fr);
    gap: 7px;
  }

  #page.voicepa-homepage .vp-home-tools > .vp-home-filter,
  #page.voicepa-homepage .vp-home-tools > .vp-home-ranking {
    flex: 1 0 100%;
    width: 100%;
  }

  #page.voicepa-homepage .vp-home-ranking {
    gap: 5px;
  }

  #page.voicepa-homepage .vp-home-ranking__orders {
    display: flex;
    flex: 1 1 auto;
  }

  #page.voicepa-homepage .vp-home-ranking__order {
    flex: 1 1 0;
    min-width: 0;
    min-height: 44px;
    padding-inline: 5px;
    font-size: 13px;
  }
}

/* A wide touch screen keeps the desktop row but still needs touch-sized controls. */
@media (hover: none) and (pointer: coarse) {
  #page.voicepa-homepage .vp-home-tools .vp-home-filter select {
    min-height: 44px;
    font-size: 16px;
  }

  #page.voicepa-homepage .vp-home-ranking__order {
    min-height: 44px;
  }

  #page.voicepa-homepage .vp-home-ranking__info > summary {
    min-width: 44px;
    min-height: 44px;
  }
}

@media (forced-colors: active) {
  #page.voicepa-homepage .vp-home-ranking__order[aria-pressed="true"] {
    outline: 2px solid Highlight;
    outline-offset: -2px;
  }
}
