/* Rating an item 1 to 3 stars, or clearing it: a row of choices in a menu, under the viewer's button for it, or in the
   selection bar's panel. They're all as tall as the stars with their numbers, the cross that clears included */
.rating-choices {
  display: flex;
  align-items: stretch;
  gap: var(--space-1);

  /* Below the cross, over what's under the row, rather than cut off at the top of a panel */
  --tooltip-top: calc(100% + var(--space-1));
  --tooltip-bottom: auto;

  /* button_to's */
  form {
    display: contents;
  }

  .rating-choice {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 2px;
    width: auto;
    padding: var(--space-1) var(--space-2);

    border: 1px solid var(--border-color);
    border-radius: var(--radius-m);
    background: none;
    color: var(--text-color);
    font: inherit;
    font-weight: 600;
    line-height: 1.5;
    cursor: pointer;

    .icon svg {
      width: 1.125rem;
      height: 1.125rem;
    }

    .icon-star_filled svg {
      fill: var(--star-color);
    }

    @media (hover: hover) {
      &:hover:not(:disabled) {
        background-color: var(--card-bg-hover-color);
      }
    }

    /* The item's rating now */
    &[aria-pressed="true"] {
      border-color: var(--star-color);
      background-color: color-mix(in srgb, var(--star-color) 20%, transparent);
    }

    /* While no items are selected */
    &:disabled {
      opacity: 0.4;
      cursor: not-allowed;
    }
  }
}

/* The selection bar's panel of only these has no more to scroll to, so the cross's tooltip can reach past it */
.bar-menu-panel:has(> .rating-choices:only-child) {
  overflow: visible;
}

/* A row of a menu, with its label before the choices */
.rating-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-1) var(--space-2);
}

.rating-row-label {
  display: flex;
  align-items: center;
  gap: var(--space-2);

  .icon svg {
    width: 1.25rem;
    height: 1.25rem;
  }
}

.rating-menu {
  /* The star of the viewer's button, once the item is rated */
  summary .icon-star_filled svg {
    fill: var(--star-color);
  }

  /* It opens only the row of choices, which needs no more room */
  .menu-items {
    min-width: 0;
  }
}
