/**
 *
 * @ai-apps/angular v2.154.0-next.30 | _overflow-menu.scss
 *
 * Copyright 2014, 2024 IBM
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0

 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */


//
// Copyright IBM Corp. 2016, 2018
//
// This source code is licensed under the Apache-2.0 license found in the
// LICENSE file in the root directory of this source tree.
//

//-----------------------------
// Overflow Menu
//-----------------------------

@import '../../globals/scss/vars';
@import '../../globals/scss/helper-mixins';
@import '../../globals/scss/css--helpers';
@import '../../globals/scss/css--reset';
@import '../../globals/scss/layout';
@import '../../globals/scss/typography';
@import '../../globals/scss/vendor/@carbon/elements/scss/import-once/import-once';

/// Overflow menu styles
/// @access private
/// @group overflow-menu
@mixin overflow-menu {
  .#{$prefix}--overflow-menu,
  .#{$prefix}--overflow-menu__trigger {
    @include button-reset;
    @include reset;
    @include focus-outline('reset');

    position: relative;
    display: flex;
    width: to-rem(40px);
    height: to-rem(40px);
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: outline $duration--fast-02 motion(entrance, productive),
      background-color $duration--fast-02 motion(entrance, productive);

    &:focus {
      @include focus-outline('outline');
    }

    &:hover {
      background-color: $hover-ui;
    }
  }

  .#{$prefix}--overflow-menu--sm {
    width: to-rem(32px);
    height: to-rem(32px);
  }

  // TODO V11: Remove xl selector
  .#{$prefix}--overflow-menu--xl,
  .#{$prefix}--overflow-menu--lg {
    width: to-rem(48px);
    height: to-rem(48px);
  }

  // Overwrite Icon Tooltip focus styles
  .#{$prefix}--overflow-menu__trigger.#{$prefix}--tooltip--a11y.#{$prefix}--tooltip__trigger:focus {
    @include focus-outline('outline');

    svg {
      outline: none;
    }
  }

  .#{$prefix}--overflow-menu.#{$prefix}--overflow-menu--open,
  .#{$prefix}--overflow-menu.#{$prefix}--overflow-menu--open
    .#{$prefix}--overflow-menu__trigger {
    @include box-shadow;

    background-color: $field-01;
    transition: none;
  }

  .#{$prefix}--overflow-menu--light.#{$prefix}--overflow-menu--open,
  .#{$prefix}--overflow-menu--light.#{$prefix}--overflow-menu--open
    .#{$prefix}--overflow-menu__trigger {
    background-color: $field-02;
  }

  .#{$prefix}--overflow-menu__icon {
    width: to-rem(16px);
    height: to-rem(16px);
    fill: $icon-01;
  }

  .#{$prefix}--overflow-menu-options {
    @include reset;
    @include box-shadow;

    position: absolute;
    z-index: z('floating');
    top: 32px;
    left: 0;
    display: none;
    width: to-rem(160px);
    flex-direction: column;
    align-items: flex-start;
    background-color: $field-01;
    list-style: none;

    &::after {
      position: absolute;
      display: block;
      background-color: $field-01;
      content: '';
      transition: background-color $duration--fast-02
        motion(entrance, productive);

      @media screen and (prefers-reduced-motion: reduce) {
        transition: none;
      }
    }
  }

  .#{$prefix}--overflow-menu.#{$prefix}--overflow-menu--open:hover {
    background-color: $field-01;
  }

  .#{$prefix}--overflow-menu-options--light {
    background-color: $field-02;

    &::after {
      background-color: $field-02;
    }
  }

  .#{$prefix}--overflow-menu.#{$prefix}--overflow-menu--light.#{$prefix}--overflow-menu--open:hover {
    background-color: $field-02;
  }

  .#{$prefix}--overflow-menu-options[data-floating-menu-direction='bottom']::after {
    top: to-rem(-3px);
    left: 0;
    width: to-rem(40px);
    height: to-rem(3px);
  }

  .#{$prefix}--overflow-menu-options[data-floating-menu-direction='top']::after {
    bottom: to-rem(-8px);
    left: 0;
    width: to-rem(40px);
    height: to-rem(8px);
  }

  .#{$prefix}--overflow-menu-options[data-floating-menu-direction='left']::after {
    top: 0;
    right: to-rem(-6px);
    width: to-rem(6px);
    height: to-rem(40px);
  }

  .#{$prefix}--overflow-menu-options[data-floating-menu-direction='right']::after {
    top: 0;
    left: to-rem(-6px);
    width: to-rem(6px);
    height: to-rem(40px);
  }

  .#{$prefix}--overflow-menu-options--sm.#{$prefix}--overflow-menu-options {
    &[data-floating-menu-direction='bottom']::after,
    &[data-floating-menu-direction='top']::after {
      width: to-rem(32px);
    }

    &[data-floating-menu-direction='left']::after,
    &[data-floating-menu-direction='right']::after {
      height: to-rem(32px);
    }
  }

  // TODO V11: Remove xl selector
  .#{$prefix}--overflow-menu-options--xl.#{$prefix}--overflow-menu-options,
  .#{$prefix}--overflow-menu-options--lg.#{$prefix}--overflow-menu-options {
    &[data-floating-menu-direction='bottom']::after,
    &[data-floating-menu-direction='top']::after {
      width: to-rem(48px);
    }

    &[data-floating-menu-direction='left']::after,
    &[data-floating-menu-direction='right']::after {
      height: to-rem(48px);
    }
  }

  .#{$prefix}--overflow-menu--flip.#{$prefix}--overflow-menu-options[data-floating-menu-direction='top']::after,
  .#{$prefix}--overflow-menu--flip.#{$prefix}--overflow-menu-options[data-floating-menu-direction='bottom']::after {
    right: 0;
    left: auto;
  }

  .#{$prefix}--overflow-menu--flip.#{$prefix}--overflow-menu-options[data-floating-menu-direction='left']::after,
  .#{$prefix}--overflow-menu--flip.#{$prefix}--overflow-menu-options[data-floating-menu-direction='right']::after {
    top: auto;
    bottom: 0;
  }

  .#{$prefix}--overflow-menu-options--open {
    display: flex;
  }

  .#{$prefix}--overflow-menu-options__content {
    width: 100%;
  }

  .#{$prefix}--overflow-menu-options__option {
    @include reset;

    display: flex;
    width: 100%;
    height: to-rem(40px);
    align-items: center;
    padding: 0;
    background-color: transparent;
    transition: background-color $duration--fast-02 motion(entrance, productive);
  }

  .#{$prefix}--overflow-menu-options--sm
    .#{$prefix}--overflow-menu-options__option {
    height: to-rem(32px);
  }

  // TODO V11: Remove xl selector
  .#{$prefix}--overflow-menu-options--xl
    .#{$prefix}--overflow-menu-options__option,
  .#{$prefix}--overflow-menu-options--lg
    .#{$prefix}--overflow-menu-options__option {
    height: to-rem(48px);
  }

  .#{$prefix}--overflow-menu--divider {
    border-top: 1px solid $ui-03;
  }

  .#{$prefix}--overflow-menu--light .#{$prefix}--overflow-menu--divider {
    border-top: 1px solid $decorative-01;
  }

  a.#{$prefix}--overflow-menu-options__btn::before {
    display: inline-block;
    height: 100%;
    content: '';
    vertical-align: middle;
  }

  .#{$prefix}--overflow-menu-options__btn {
    @include reset;
    @include type-style('body-short-01');
    @include focus-outline('reset');

    display: inline-flex;
    width: 100%;
    max-width: 11.25rem;
    height: 100%;
    align-items: center;
    padding: 0 $carbon--spacing-05;
    border: none;
    background-color: transparent;
    color: $text-02;
    cursor: pointer;
    font-weight: 400;
    text-align: left;
    transition: outline $duration--fast-02 motion(entrance, productive),
      background-color $duration--fast-02 motion(entrance, productive),
      color $duration--fast-02 motion(entrance, productive);

    &:hover {
      color: $text-01;
    }

    &:focus {
      @include focus-outline('outline');
    }

    &::-moz-focus-inner {
      border: none;
    }
  }

  .#{$prefix}--overflow-menu-options__btn svg {
    fill: $icon-02;
  }

  .#{$prefix}--overflow-menu-options__btn:hover svg {
    fill: $icon-01;
  }

  .#{$prefix}--overflow-menu-options__option-content {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .#{$prefix}--overflow-menu-options__option:hover {
    background-color: $hover-ui;
  }

  .#{$prefix}--overflow-menu-options__option--danger
    .#{$prefix}--overflow-menu-options__btn:hover,
  .#{$prefix}--overflow-menu-options__option--danger
    .#{$prefix}--overflow-menu-options__btn:focus {
    background-color: $danger-01;
    color: $text-04;

    svg {
      fill: currentColor;
    }
  }

  .#{$prefix}--overflow-menu-options__option--disabled:hover {
    background-color: $ui-01;
    cursor: not-allowed;
  }

  .#{$prefix}--overflow-menu-options__option--disabled
    .#{$prefix}--overflow-menu-options__btn {
    color: $disabled-02;
    pointer-events: none;

    &:hover,
    &:active,
    &:focus {
      @include focus-outline('reset');

      background-color: $ui-01;
    }
  }

  .#{$prefix}--overflow-menu-options__option--disabled
    .#{$prefix}--overflow-menu-options__btn
    svg {
    fill: $disabled-02;
  }

  .#{$prefix}--overflow-menu--flip {
    left: -140px;

    &::before {
      left: 145px;
    }
  }

  // styles for "next" version
  .#{$prefix}--overflow-menu__container {
    display: inline-block;
  }

  // Windows HCM fix
  /* stylelint-disable */
  .#{$prefix}--overflow-menu:focus,
  .#{$prefix}--overflow-menu-options__btn:focus {
    @include high-contrast-mode('focus');
  }

  .#{$prefix}--overflow-menu svg {
    @include high-contrast-mode('icon-fill');
  }
  /*stylelint-enable */
}

@include exports('overflow-menu') {
  @include overflow-menu;
}
