/* Popovers/Menus */

$popover_arrow_height: 12px;

//.the popover itself
.popup-menu-boxpointer {
  -arrow-border-radius: $modal_radius;
  -arrow-background-color: transparent;
  -arrow-border-width: 0;
  -arrow-border-color: transparent;
  -arrow-base: $popover_arrow_height;
  -arrow-rise: $popover_arrow_height / 2;
  -arrow-box-shadow: none; // dreaming bugzilla #689995
}

// container of the popover menu
.popup-menu {
  min-width: 15em;
  color: $fg_color;
  padding: 0;
  background: none;
  border-image: none;
  @include fontsize($base_font_size - 1);

  //.popup-status-menu-item { font-weight: normal;  color: pink; } //dunno what that is
  &.panel-menu {
    -boxpointer-gap: $base_margin; // distance from the panel
    margin-bottom: 1.75em;
  }

  .search-entry {
    color: $alt_fg_color;
    caret-color: $alt_fg_color;
    background-color: rgba($fg_color, 0.10);
    border-color: $borders_color;

    &:hover {
      background-color: rgba($fg_color, 0.15);
      border-color: $borders_color;
      color: $fg_color;
    }

    &:focus, &:focus:hover {
      background-color: rgba($fg_color, 0.15);
      color: $fg_color;
      border-color: $selected_bg_color;
    }

    StLabel.hint-text {
      color: $insensitive_fg_color;
    }
  }
}

.popup-menu-content {
  padding: $base_padding 0;
  margin: 0 $base_margin 10px 8px;
  color: $fg_color !important;
  @extend %theme_dialogs;
}

// menu items
.popup-menu-item {
  spacing: $base_padding;
  padding: $base_padding $base_padding * 2;
  margin: 0;
  border-radius: 0 !important;
  color: $alt_fg_color !important;

  &:checked {
    box-shadow: inset 0 1px $borders_color !important;
    border: none;
    border-image: none;
    background-color: if($variant == 'light', rgba(black, 0.05), rgba(black, 0.15)) !important;
    color: $fg_color !important;
  }

  &:selected, &:hover, &:focus {
    color: $selected_fg_color !important;
    background-color: $selected_bg_color !important;
    border-image: none;
  }

  &:active {
    background-color: darken($selected_bg_color, 5%) !important;
    color: $selected_fg_color !important;
  }

  &:insensitive { color: $insensitive_fg_color !important; }

  // add margin to switches in menu items
  .toggle-switch {
    &:ltr { margin-left: $base_margin; }
    &:rtl { margin-right: $base_margin; }
  }
}

.popup-ornamented-menu-item {
  &:ltr {padding-left: $base_padding;}
  &:rtl {padding-right: $base_padding;}
}

// all icons and other graphical elements
.popup-inactive-menu-item {
  color: $fg_color;

  &:insensitive { color: $insensitive_fg_color; }
}

// symbolic icons in popover
.popup-menu-arrow,
.popup-menu-icon { icon-size: $scalable_icon_size !important; }

// popover submenus
.popup-sub-menu {
  background-color: if($variant == 'light', rgba(black, 0.05), rgba(black, 0.15)) !important;
  border-image: none;
  box-shadow: inset 0 -1px $borders_color !important;
  border: none;
  border-radius: 0 !important;
  margin: 0;

  .popup-menu-ornament {
    min-width: $base_icon_size !important;
  }

  // submenu specific styles
  .popup-menu-item {
    border-radius: 0 !important;
    border-top-width: 0;
    background-color: transparent;

    &:last-child {
      border-radius: 0 !important;
      border-bottom-width: 0;
    }
  }

  .popup-menu-section {
    .popup-menu-item:last-child {
      &:hover, &:focus { border-radius: 0 !important; }
    }

    &:last-child .popup-menu-item:last-child {
      border-radius: 0 !important;
    }
  }
}

// container for radio and check boxes
.popup-menu-ornament {
  @extend %heading;
  width: 1.2em;
  text-align: center !important;

  &:ltr { text-align: right; }
  &:rtl { text-align: left; }
}

// separator
.popup-separator-menu-item {
  border: none !important;
  padding: $base_padding 0 !important;

  .popup-separator-menu-item-separator {
    height: 1px; //not really the whole box
    background-color: $borders_color;
  }

  .popup-menu-ornament {
    width: 0 !important;
  }

  // separators in submenus
  .popup-sub-menu & {
    background-color: transparent;

    // account for ornament
    &:ltr { margin-right: 2.5em; }
    &:rtl { margin-left: 2.5em; }

    .popup-separator-menu-item-separator {
      background-color: $borders_color;
    }
  }
}

// desktop background menu
.background-menu {
  -boxpointer-gap: $base_margin;
  -arrow-rise: 0px; // hide the beak on the menu
}

// system status menu
.aggregate-menu {
  min-width: 21em;

  // lock screen, shutdown, etc. buttons
  .popup-menu-icon {
    padding: 0;
    margin: 0 $base_margin;
    -st-icon-style: symbolic;
  }

  .popup-menu-item > :first-child {
    &:ltr { padding-left: 0 !important; margin-left: 0 !important; }
    &:rtl { padding-right: 0 !important; margin-right: 0 !important; }
  }

  .popup-sub-menu .popup-menu-item > :first-child {
    &:ltr { padding-left: $base_padding * 2 !important; margin-left: $base_padding / 2 !important; }
    &:rtl { padding-right: $base_padding * 2 !important; margin-right: $base_padding / 2 !important; }
  }
}

.system-menu-action {
  color: $alt_fg_color;
  border-radius: $circular_radius;
  padding: $base_padding * 2;
  border: none;
  background-color: rgba($fg_color, 0.05);
  -st-icon-style: symbolic; // >= 3.29.90

  &:hover, &:focus {
    background-color: rgba($fg_color, 0.1);
    color: $fg_color;
    border: none;
    padding: $base_padding * 2;
  }

  &:active {
    background-color: rgba($fg_color, 0.15);
    color: $fg_color;
  }

  & > StIcon { icon-size: $base_icon_size; }
}

// right-click (and panel) app menu
.app-menu {
  max-width: 27.25em;

   // this is unneeded at the top-level in this menu, hide it
  .popup-menu-ornament { width: 0 !important; }

  .popup-inactive-menu-item:first-child {
    padding: $base_padding $base_padding * 2 !important;

    // "Open Windows" label
    > StLabel {
      @extend %caption_heading;
      &:ltr { margin-right: $base_margin * 2; }
      &:rtl { margin-left: $base_margin * 2; }
    }
  }
}
