/**
 * @license
 * Copyright 2023 Tyler Technologies, Inc. 
 * License: Apache-2.0
 */
//
// Copyright 2020 Google Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//

@use '@material/feature-targeting/feature-targeting' as mdc-feature-targeting;
@use '@material/theme/color-palette' as mdc-color-palette;
@use './button-base';
@use './button-filled';
@use './button-outlined';
@use './button-outlined-theme';
@use './button-protected';
@use './button-ripple';
@use './button-text';
@use './button-text-theme';
@use './button-shared-theme';
@use '../theme';

@mixin styles($query: mdc-feature-targeting.all()) {
  @include static-styles($query: $query);
  @include theme-styles($query: $query);

  // FORGE(new): add custom forge-specific styles
  @include forge-styles;
}

@mixin forge-styles() {
  .forge-button--dense {
    @include button-base.dense;
  }

  forge-button {
    @include host;
  }
  
  forge-button[hidden] {
    display: none;
  }
  
  forge-button[disabled] {
    cursor: not-allowed;
  }
  
  a.forge-hyperlink {
    @include anchor-link;
  }
  
  button.forge-hyperlink {
    @include link;
  }
}

@mixin theme-styles($query: mdc-feature-targeting.all()) {
  @include button-text.theme-styles(
    button-text-theme.$light-theme,
    $query: $query
  );
  @include button-filled.theme-styles($query: $query);
  @include button-protected.theme-styles($query: $query);
  @include button-outlined.theme-styles($query: $query);
}

@mixin static-styles($query: mdc-feature-targeting.all()) {
  @include button-base.static-styles($query: $query);
  @include button-text.static-styles($query: $query);
  @include button-filled.static-styles($query: $query);
  @include button-protected.static-styles($query: $query);
  @include button-outlined.static-styles($query: $query);
}

@mixin without-ripple($query: mdc-feature-targeting.all()) {
  @include button-base.static-styles-without-ripple($query: $query);
  @include button-text.static-styles($query: $query);
  @include button-filled.static-styles($query: $query);
  @include button-protected.static-styles($query: $query);
  @include button-outlined.static-styles($query: $query);
}

///
/// FORGE(new): additional Forge mixins
///

@mixin host() {
  display: inline-block;
}

@mixin link() {
  @include theme.property(color, primary);

  cursor: pointer;
  border: none;
  background-color: transparent;
  font-size: inherit;
  padding: 0;
  outline: none;
  text-align: left;

  &[disabled] {
    pointer-events: none;
    cursor: default;
  }

  &:hover:not([disabled]) {
    text-decoration: underline;
  }
}

@mixin anchor-link() {
  @include theme.property(color, primary);

  text-decoration: underline;
  cursor: pointer;
  
  &:visited {
    @include theme.property(color, primary);
  }

  &[disabled] {
    pointer-events: none;
    cursor: default;
  }
}
