/* ======================================================================== *
 * Copyright 2025 HCL America Inc.                                          *
 * 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.                                           *
 * ======================================================================== */

@use "sass:map";
@use "../../common/palette";
@use "../../common/themeMap.module";

@mixin enchanted-menu-base-styles {
  &::part(menu-root) {
    position: fixed;
    z-index: 1300;
    inset: 0px;
  }

  &::part(backdrop) {
    opacity: 1;
    transition: opacity 225ms cubic-bezier(0.4, 0, 0.2, 1);
    position: fixed;
    display: flex;
    -webkit-box-align: center;
    align-items: center;
    -webkit-box-pack: center;
    justify-content: center;
    inset: 0px;
    -webkit-tap-highlight-color: transparent;
    background-color: transparent;
  }

  &::part(paper-root) {
    opacity: 1;
    transform: none;
    transition: opacity 228ms cubic-bezier(0.4, 0, 0.2, 1), transform 152ms cubic-bezier(0.4, 0, 0.2, 1);
    transform-origin: 0px 0px;
    display: flex;
    flex-direction: column;
    background-color: palette.clr(light, background, paper);
    color: palette.clr(light, text, primary);
    box-shadow: #{map.get(themeMap.$enchantedPalette, shadows2)};
    position: absolute;
    overflow-y: auto;
    overflow-x: hidden;
    // The min-width can be overridden by setting the --dropdown-menu-min-width CSS variable and it will be set by actual UI side as required.
    min-width: var(--dropdown-menu-min-width, 16px);
    min-height: 16px;
    max-height: calc(100% - 32px);
    width: auto;
    border-radius: 4px;
    outline: 0px;
    padding: 0px;
  }

  &::part(unordered-list) {
    padding: 5px 0px;
  }

  &[size="sm"] enchanted-menu-item::part(menu-item) {
    font-size: 12px;
    line-height: 16px;
    min-height: 20px;
    padding: 3px 0px;
  }

  &[size="sm"]::part(unordered-list) {
    padding: 4px 0px;
  }
  
  &[size="sm"]::part(paper-root),
  &[size="md"]::part(paper-root) {
    width: auto;
    max-width: calc(100% - 32px);
  }
}
