// =============================================================================
// Block Context Menu
// Compact popup shown when the user clicks the ⋮⋮ BlockHandle drag button
// without dragging. Offers Delete / Duplicate / Turn into options for the
// targeted top-level block.
// =============================================================================

.dm-block-context-menu {
  position: absolute;
  display: none;
  flex-direction: column;
  min-width: 12rem;
  max-height: 20rem;
  overflow-y: auto;
  // Stop wheel-delta chaining to the page once the menu hits its
  // own scroll edges. The plugin's JS gate handles the no-overflow
  // case where this property doesn't apply.
  overscroll-behavior: contain;
  padding: 0.25rem;
  background: var(--dm-toolbar-bg, var(--dm-bg, #ffffff));
  border: 1px solid var(--dm-border-color, #e5e7eb);
  border-radius: var(--dm-toolbar-border-radius, 0.5rem);
  box-shadow: var(--dm-popover-shadow,
    0 10px 25px rgba(0, 0, 0, 0.08),
    0 4px 10px rgba(0, 0, 0, 0.04));
  z-index: var(--dm-z-popover, 50);

  &[data-show] {
    display: flex;
  }

  // Slim scrollbar (matches slash-command + floating-menu).
  scrollbar-width: thin;
  scrollbar-color: var(--dm-scrollbar-thumb, rgba(0, 0, 0, 0.18)) transparent;

  &::-webkit-scrollbar {
    width: 6px;
  }
  &::-webkit-scrollbar-track {
    background: transparent;
  }
  &::-webkit-scrollbar-thumb {
    background: var(--dm-scrollbar-thumb, rgba(0, 0, 0, 0.18));
    border-radius: 3px;
  }
  &::-webkit-scrollbar-thumb:hover {
    background: var(--dm-scrollbar-thumb-hover, rgba(0, 0, 0, 0.28));
  }

  &-group {
    display: flex;
    flex-direction: column;
    gap: 1px;
  }

  // Label doubles as the visual separator above its group.
  // `.dm-block-context-menu-group-label` is only emitted by the plugin for
  // the "Turn into" section, so it naturally appears above the second
  // group. Using the label as the divider (instead of styling the group
  // itself) avoids the "double border" case where a labeled group follows
  // another labeled group.
  &-group-label {
    padding: 0.5rem 0.5rem 0.125rem;
    margin-top: 0.25rem;
    border-top: 1px solid var(--dm-border-color, #e5e7eb);
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--dm-muted, #6b7280);
    user-select: none;
  }

  &-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.3125rem 0.5rem;
    border: none;
    border-radius: var(--dm-button-border-radius, 0.375rem);
    background: transparent;
    color: var(--dm-editor-text, inherit);
    text-align: left;
    font: inherit;
    font-size: 0.875rem;
    cursor: pointer;
    transition: background-color 0.1s;

    &:hover,
    &:focus-visible {
      background: var(--dm-button-hover-bg, rgba(0, 0, 0, 0.04));
    }

    &:focus-visible {
      // INSET ring (-2px): menu items are tightly packed; an outset ring
      // would overlap the neighbour. -2px keeps the ring fully inside the
      // hover background fill.
      outline: 2px solid var(--dm-accent, #2563eb);
      outline-offset: -2px;
    }
  }

  &-item-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.125rem;
    height: 1.125rem;
    flex-shrink: 0;
    color: var(--dm-muted, #6b7280);

    svg {
      width: 1rem;
      height: 1rem;
    }
  }

  &-item-label {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

// =============================================================================
// Active block highlight
// Class applied via PM Decoration on the block whose BlockContextMenu is open.
// =============================================================================

.ProseMirror .dm-block-context-active {
  background-color: var(--dm-block-context-active-bg, rgba(55, 53, 47, 0.06));
  border-radius: 0.25rem;
  // box-shadow expands the tint past the block's content box without
  // affecting layout (negative margins would shift neighbours).
  box-shadow: 0 0 0 4px var(--dm-block-context-active-bg, rgba(55, 53, 47, 0.06));
  transition: background-color 0.12s ease, box-shadow 0.12s ease;
}

