/* This stylesheet is loaded only by the Chinese and English homepages. */
#article-container .home-favorites {
  margin: 12px 0 16px;
  padding: 0;
  border: 0;
}

#page .page-title {
  color: var(--cotm-effective);
}

#article-container .favorite-card__name::before {
  display: none;
}

#article-container .home-favorites ol {
  display: grid;
  gap: 18px;
  margin: 0;
  padding: 0;
  list-style: none;
}

#article-container .home-favorites .home-favorites__podium {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: auto auto;
  row-gap: 0;
  align-items: stretch;
}

/* Share the artwork baseline and text-row height without shifting the podium. */
#article-container .home-favorites__podium .favorite-card {
  display: grid;
  grid-row: 1 / span 2;
  grid-template-rows: subgrid;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

#article-container .home-favorites__podium .favorite-card__artwork {
  grid-row: 1;
  align-self: end;
  border: 1px solid var(--light-grey);
  border-bottom: 0;
  border-radius: 9px 9px 0 0;
}

#article-container .home-favorites__podium .favorite-card__info {
  grid-row: 2;
  border: 1px solid var(--light-grey);
  border-top: 0;
  border-radius: 0 0 9px 9px;
  background: #f4f4f4;
}

#article-container .home-favorites .home-favorites__others {
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 14px;
  margin-top: 22px;
  padding: 2px 1px 10px;
}

#article-container .favorite-card {
  position: relative;
  min-width: 0;
  overflow: visible;
  border: 1px solid var(--light-grey);
  border-radius: 9px;
  background: #f4f4f4;
  box-shadow: 0 3px 10px rgb(0 0 0 / 4%);
  list-style: none;
}

/* Separate native links keep the Logo destination independent of the card. */
#article-container .favorite-card__link {
  position: absolute;
  z-index: 2;
  inset: 0;
  border-radius: 9px;
}

/* Keep the DOM in ranking order for screen readers; display 2 / 1 / 3. */
.favorite-card--rank-1 { grid-column: 2; grid-row: 1; }
.favorite-card--rank-2 { grid-column: 1; grid-row: 1; }
.favorite-card--rank-3 { grid-column: 3; grid-row: 1; }

.favorite-card__artwork {
  --face-size: 36;
  --face-eye-top: 92cqw;
  position: relative;
  container-type: inline-size;
  overflow: hidden;
  aspect-ratio: 1 / 1.9;
  background-color: var(--character-color);
  border-radius: 9px 9px 0 0;
}

.favorite-card--rank-1 .favorite-card__artwork { aspect-ratio: 3 / 4.4; }
.favorite-card--rank-2 .favorite-card__artwork { aspect-ratio: 3 / 4; }
.favorite-card--rank-3 .favorite-card__artwork { aspect-ratio: 3 / 3.6; }

.home-favorites__podium .favorite-card__artwork {
  --face-size: 23;
  /* Keep compact headroom on each podium step and clear the rank badge. */
  --face-eye-top: max(38cqw, 46px);
}

#article-container .favorite-card__portrait {
  position: absolute;
  top: calc(var(--face-eye-top) - var(--face-size) * var(--portrait-eye-offset) * 1cqw);
  left: calc(50% + var(--face-size) * var(--portrait-center-offset) * 1cqw);
  width: calc(var(--face-size) * var(--portrait-scale) * 1cqw);
  max-width: none;
  height: auto;
  margin: 0;
  border-radius: 0;
  transform: translateX(-50%);
}

.favorite-card__rank {
  position: absolute;
  z-index: 1;
  top: 10px;
  left: 10px;
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 5px;
  background: rgb(20 17 28 / 64%);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
}

.favorite-card--rank-1 .favorite-card__rank {
  background: #cc2d69;
}

.favorite-card__info {
  position: relative;
  padding: 6px 6px 10px;
  color: #292630;
  text-align: center;
}

.favorite-card__band {
  --band-logo-height: 26px;
  display: flex;
  height: 32px;
  margin-bottom: 4px;
  align-items: center;
  justify-content: center;
}

#article-container .favorite-card__band-target {
  position: relative;
  z-index: 3;
  display: inline-flex;
  width: min(72%, 106px, calc(var(--band-aspect-ratio) * var(--band-logo-height)));
  max-width: min(72%, 106px);
  align-items: center;
  justify-content: center;
  color: inherit;
  text-decoration: none;
  cursor: help;
}

#article-container a.favorite-card__band-target {
  cursor: pointer;
}

#article-container .favorite-card__band img {
  width: 100%;
  max-width: 100%;
  max-height: var(--band-logo-height);
  height: auto;
  margin: 0;
  border-radius: 0;
  cursor: inherit;
}

.favorite-card__band-tooltip {
  --tooltip-edge-gap: 4px;
  position: absolute;
  z-index: 3;
  /* The caption starts exactly at the artwork's bottom edge. */
  bottom: calc(100% + var(--tooltip-edge-gap));
  left: 50%;
  width: max-content;
  max-width: calc(100% - 8px);
  padding: 8px 10px;
  border: 1px solid rgb(255 255 255 / 16%);
  border-radius: 8px;
  background: #292630;
  box-shadow: 0 4px 12px rgb(0 0 0 / 24%);
  color: #fff;
  font-size: 11px;
  line-height: 1.5;
  text-align: center;
  overflow-wrap: anywhere;
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%);
  transition: opacity 150ms ease;
}

.favorite-card__band-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  width: 10px;
  /* Include the bubble's 1px border so the triangle ends at the artwork edge. */
  height: calc(var(--tooltip-edge-gap) + 1px);
  background: #292630;
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  transform: translateX(-50%);
}

.favorite-card__band-tooltip-name,
.favorite-card__band-tooltip-role {
  display: block;
}

.favorite-card__band-tooltip-role {
  color: #d8d5df;
}

.favorite-card__band-target:hover + .favorite-card__band-tooltip,
.favorite-card__band-target:focus-visible + .favorite-card__band-tooltip {
  visibility: visible;
  opacity: 1;
}

#article-container .favorite-card:has(.favorite-card__band-target:is(:hover, :focus-visible)) {
  position: relative;
  z-index: 3;
}

@media (prefers-reduced-motion: reduce) {
  .favorite-card__band-tooltip {
    transition: none;
  }
}

/* The cable-tie emblem needs more height than the horizontal band wordmarks. */
#article-container .favorite-card--rank-1 .favorite-card__band {
  --band-logo-height: 38px;
}

/* Give the square Angels of Delusion emblem comparable visual weight. */
#article-container .favorite-card--rank-8 .favorite-card__band {
  --band-logo-height: 32px;
}

#article-container .favorite-card__name {
  margin: 0 0 1px;
  padding: 0;
  color: #292630;
  font-size: clamp(10px, 1.3vw, 15px);
  font-weight: 700;
  line-height: 1.5;
}

#article-container .home-favorites__podium .favorite-card__name {
  font-size: clamp(12px, 1.6vw, 18px);
}

#article-container .favorite-card__anime {
  margin: 0;
  color: #726d79;
  font-size: 10px;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

#article-container .home-favorites__scroll-hint {
  display: none;
}

.home-favorites__sources {
  margin-top: 14px;
  color: var(--font-color);
  font-size: 14px;
  line-height: 1.8;
}

.home-favorites__sources summary {
  width: fit-content;
  cursor: pointer;
}

.home-favorites :focus-visible,
.home-favorites__sources :focus-visible {
  outline: 2px solid var(--cotm-effective);
  outline-offset: 4px;
}

/* Hovering either the artwork or caption highlights the same card. */
@media (hover: hover) and (pointer: fine) {
  #article-container .favorite-card:hover {
    filter: drop-shadow(0 10px 16px rgb(0 0 0 / 28%))
      drop-shadow(0 0 8px color-mix(in srgb, var(--character-color) 45%, transparent));
  }
}

@media (hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference) {
  #article-container .favorite-card {
    transition: filter 180ms ease;
  }

  #article-container .favorite-card__portrait {
    transition: transform 180ms ease;
  }

  #article-container .favorite-card:hover .favorite-card__portrait {
    transform: translate(-50%, -7px);
  }
}

@media (max-width: 720px) {
  #article-container .home-favorites ol {
    gap: 9px;
  }

  #article-container .home-favorites .home-favorites__others {
    grid-template-columns: repeat(6, calc((100% - 18px) / 3 * 0.8));
    gap: 9px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-width: thin;
  }

  #article-container .home-favorites__scroll-hint {
    display: block;
    margin: 18px 0 -12px;
    color: var(--font-color);
    font-size: 12px;
  }

  .favorite-card__rank {
    top: 7px;
    left: 7px;
    width: 24px;
    height: 24px;
    font-size: 12px;
  }

  .favorite-card__info {
    padding: 5px 4px 8px;
  }

  .favorite-card__band {
    --band-logo-height: 21px;
    height: 26px;
    margin-bottom: 3px;
  }

  #article-container .favorite-card--rank-1 .favorite-card__band {
    --band-logo-height: 29px;
  }

  #article-container .home-favorites__others .favorite-card__name {
    font-size: 11px;
  }

  #article-container .home-favorites__others .favorite-card__artwork {
    --face-size: 28;
    --face-eye-top: max(58cqw, 44px);
    aspect-ratio: 1 / 1.15;
  }

  #article-container .home-favorites__others .favorite-card__info {
    padding: 4px 3px 6px;
  }

  #article-container .home-favorites__others .favorite-card__band {
    --band-logo-height: 16px;
    height: 20px;
    margin-bottom: 2px;
  }

  #article-container .home-favorites__others .favorite-card--rank-8 .favorite-card__band {
    --band-logo-height: 22px;
  }

  #article-container .home-favorites__others .favorite-card__anime {
    font-size: 9px;
    line-height: 1.5;
  }

  #article-container .home-favorites__podium .favorite-card__anime {
    font-size: 10px;
  }
}
