// =============================================================================
// Floating Menu Styles
// Block-insert menu shown on empty paragraphs. Rendered by framework
// wrappers as a WAI-ARIA menu with role="menu"/"group"/"menuitem".
// =============================================================================

.dm-floating-menu {
  position: absolute;
  // Pin static position to parent top-left; otherwise the hidden box
  // inherits an end-of-content static position and inflates parent
  // scrollHeight. `positionFloating` overrides via transform on show.
  top: 0;
  left: 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 16rem;
  max-height: 22rem;
  overflow-y: auto;
  padding: 0.375rem;

  // Opaque background - plain color (not translucent) so nested content
  // under the menu is fully occluded. Fallback chain covers cases where
  // the menu is reparented outside `.dm-editor` and loses the variable.
  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));
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.15s ease, visibility 0.15s;
  z-index: var(--dm-z-popover, 50);

  // Slim, translucent scrollbar - Firefox via scrollbar-* properties,
  // Chrome/Safari/Edge via ::-webkit-scrollbar pseudo-elements. Colors are
  // tokenised so dark theme overrides keep contrast on dark surfaces.
  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;
    margin: 0.375rem 0;
  }
  &::-webkit-scrollbar-thumb {
    background: var(--dm-scrollbar-thumb, rgba(0, 0, 0, 0.18));
    border-radius: 3px;
    transition: background-color 0.15s;
  }
  &::-webkit-scrollbar-thumb:hover {
    background: var(--dm-scrollbar-thumb-hover, rgba(0, 0, 0, 0.28));
  }

  &[data-show] {
    visibility: visible;
    opacity: 1;
  }

  // ---------------------------------------------------------------------------
  // Group heading (e.g. "Basic", "Lists", "Media")
  // ---------------------------------------------------------------------------
  &-group-label {
    padding: 0.375rem 0.5rem 0.125rem;
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--dm-muted, #6b7280);
    user-select: none;
  }

  &-group {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;

    // Visual separator between unlabelled groups; labelled groups get
    // spacing from their label instead.
    & + &:not(:has(+ .dm-floating-menu-group-label)) {
      margin-top: 0.25rem;
    }
  }

  &-group-wrapper {
    display: flex;
    flex-direction: column;
  }

  // ---------------------------------------------------------------------------
  // Menu item button (single-line: icon + label + optional shortcut chip)
  // ---------------------------------------------------------------------------
  &-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-button-color, inherit);
    text-align: left;
    font: inherit;
    cursor: pointer;
    transition: background-color 0.12s;

    &:hover:not([aria-disabled="true"]),
    &:focus:not([aria-disabled="true"]) {
      background: var(--dm-button-hover-bg, rgba(0, 0, 0, 0.04));
    }

    &:focus-visible {
      outline: 2px solid var(--dm-accent, #2563eb);
      outline-offset: -2px;
    }

    &[aria-disabled="true"],
    &:disabled {
      opacity: var(--dm-button-disabled-opacity, 0.45);
      cursor: not-allowed;
    }
  }

  // Icon slot
  &-item-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.25rem;
    height: 1.25rem;
    flex-shrink: 0;
    color: var(--dm-editor-text, inherit);

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

  &-item-label {
    flex: 1;
    min-width: 0;
    font-size: 0.875rem;
    color: var(--dm-editor-text, inherit);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  // Shortcut hint chip (e.g. `# `, `> `, `[ ] `)
  &-item-shortcut {
    flex-shrink: 0;
    padding: 0.0625rem 0.375rem;
    font-family: var(--dm-code-font, ui-monospace, monospace);
    font-size: 0.6875rem;
    color: var(--dm-muted, #6b7280);
    background: var(--dm-surface, #f8f9fa);
    border: 1px solid var(--dm-border-color, #e5e7eb);
    border-radius: 0.25rem;
    user-select: none;
  }
}
