/* A button that opens a short list of actions below it */
.menu {
  position: relative;

  summary {
    list-style: none;

    &::-webkit-details-marker {
      display: none;
    }
  }
}

.menu-items {
  position: absolute;
  right: 0;
  z-index: 20;

  display: flex;
  flex-direction: column;
  min-width: 14rem;
  margin-top: var(--space-1);
  padding: var(--space-2);

  background-color: var(--card-bg-color);
  border-radius: var(--radius-s);
  box-shadow: 0 4px 12px var(--drop-shadow-color);

  :where(a, button) {
    width: 100%;
    padding: var(--space-2);
    border-radius: var(--radius-s);
    background: none;
    color: var(--text-color);
    text-align: left;
    text-decoration: none;
    cursor: pointer;

    &:hover {
      background-color: var(--card-bg-hover-color);
    }

    &:has(.icon) {
      display: flex;
      align-items: center;
      gap: var(--space-2);
    }

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

    &.danger {
      color: var(--danger-color);
    }
  }
}

/* Actions that are buttons on wider screens and in a menu on phones (menu_on_phones) */
.menu-buttons {
  display: none;
  align-items: center;
  gap: var(--space-2);
}

@media (min-width: 800px) {
  .menu-buttons {
    display: flex;
  }

  .phone-menu {
    display: none;
  }
}

/* Until there's room for their labels too, only the icons, with the labels as tooltips */
@media (min-width: 800px) and (max-width: 1199px) {
  .menu-buttons .button:has(.icon) {
    padding: var(--space-1);
    --tooltip-display: block;

    > span:not(.icon) {
      display: none;
    }

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

/* The viewer's actions for a grid tile, where it's right-clicked or a finger is held on it (context_menu_controller).
   The finger is still down as it opens, so its text can't be selected */
.context-menu {
  position: fixed;
  right: auto;
  z-index: 1500;
  margin: 0;
  user-select: none;
  -webkit-user-select: none;

  turbo-frame, .context-menu-selection {
    display: contents;
  }
}

/* How many selected items the menu's actions are for */
.menu-heading {
  margin: 0 0 var(--space-1);
  padding: var(--space-1) var(--space-2) var(--space-2);
  border-bottom: 1px solid var(--border-color);
  color: var(--meta-text-color);
  font-size: var(--fs-small);
}
