/* Shared popover surface + menu item (SDK control refresh 2d).
 * One floating surface and one row style for every menu, listbox and picker
 * dropdown. Positioning (fixed/absolute, z-index, width) stays with the
 * component; this file owns only the look.
 *
 *   <div class="mint-popover" role="menu">
 *     <button class="mint-menu-item" role="menuitem">Rename</button>
 *     <div class="mint-menu-separator" role="separator"></div>
 *     <button class="mint-menu-item mint-menu-item--danger" role="menuitem">Delete</button>
 *   </div>
 *
 * Rich rows: __text > __label + __description, then __meta, then __check
 * (render __check on every row of a selectable list so the column is
 * reserved; it shows only on --selected). A danger item is always preceded
 * by a .mint-menu-separator.
 */

.mint-popover {
  display: flex;
  box-sizing: border-box; /* component widths (e.g. 100% of the trigger) include the padding and border */
  flex-direction: column;
  padding: 4px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  box-shadow: var(--shadow-lg);
}

.mint-menu-item {
  display: flex;
  box-sizing: border-box; /* <a>/<li> rows are content-box by default and would overflow the list by the padding */
  width: 100%;
  min-height: 32px;
  align-items: center;
  gap: 8px;
  padding: 0 8px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.8125rem;
  line-height: 1.25;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  transition: background-color var(--mint-transition);
}

/* Two-line rows keep the 32px floor and grow with 6px vertical padding. */
.mint-menu-item:has(.mint-menu-item__description) {
  padding-top: 6px;
  padding-bottom: 6px;
}

/* Pointer hover and keyboard highlight look the same. */
.mint-menu-item:hover:not(:disabled, [aria-disabled='true']),
.mint-menu-item:focus-visible,
.mint-menu-item--active {
  outline: none;
  background: var(--bg-hover);
}

/* Real focus also gets the ring; --active (aria-activedescendant) keeps focus on its input. */
.mint-menu-item:focus-visible {
  box-shadow: var(--focus-ring-offset);
}

.mint-menu-item:disabled,
.mint-menu-item[aria-disabled='true'] {
  color: var(--text-muted);
  cursor: not-allowed;
}

.mint-menu-item__text {
  display: flex;
  min-width: 0;
  flex: 1;
  flex-direction: column;
}

.mint-menu-item__label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mint-menu-item:has(.mint-menu-item__description) .mint-menu-item__label {
  font-weight: 500;
}

.mint-menu-item__description {
  color: var(--text-secondary);
  font-size: 0.75rem;
}

/* --text-secondary drops to ~4.3:1 on --bg-hover in both themes. */
.mint-menu-item:hover:not(:disabled, [aria-disabled='true']) .mint-menu-item__description,
.mint-menu-item:focus-visible .mint-menu-item__description,
.mint-menu-item--active .mint-menu-item__description {
  color: var(--text-secondary-strong);
}

.mint-menu-item__meta {
  flex: none;
  color: var(--text-secondary-strong);
  font-family: var(--font-mono);
  font-size: 0.6875rem;
}

.mint-menu-item__check {
  display: inline-flex;
  width: 14px;
  height: 14px;
  flex: none;
  color: var(--color-primary);
  visibility: hidden;
}

/* Selected = trailing check + primary text, never a filled row. */
.mint-menu-item--selected {
  color: var(--_ink-primary);
}

.mint-menu-item--selected .mint-menu-item__check {
  visibility: visible;
}

.mint-menu-item--danger {
  color: var(--_ink-error);
}

/* Dark: the check matches the lifted selected ink. */
:where(html.dark) .mint-menu-item__check {
  color: var(--_ink-primary);
}

.mint-menu-item--danger:hover:not(:disabled, [aria-disabled='true']),
.mint-menu-item--danger:focus-visible,
.mint-menu-item--danger.mint-menu-item--active {
  background: color-mix(in srgb, var(--mint-error) 10%, transparent);
}

/* Light danger ink on the red tint is ~4.2:1; darken it toward --text-primary (>= 6:1). */
:where(html:not(.dark)) .mint-menu-item--danger:hover:not(:disabled, [aria-disabled='true']),
:where(html:not(.dark)) .mint-menu-item--danger:focus-visible,
:where(html:not(.dark)) .mint-menu-item--danger.mint-menu-item--active {
  color: color-mix(in srgb, var(--mint-error-hover) 70%, var(--text-primary));
}

.mint-menu-separator {
  height: 1px;
  flex: none;
  margin: 4px 0;
  background: var(--border-light);
}

/* Dark --border-light equals --bg-card, which hides every hairline inside a popover
   (separators, search and footer dividers); alias it to --border-color there. */
:where(html.dark) .mint-popover {
  --border-light: var(--border-color);
}
