@import "../../themes/liberty.globals";
@import "button.vars";

/*
button {
    @include padding(10px, 15px, 10px, 15px);

    border:none;

    background:var(--primary-color, #256ec1);
    color:var(--secondary-text-color, white);

    text-align: center;
}
*/
// Button
// --------------------------------------------------

:host {
  /**
     * @prop --background: Background of the button
     * @prop --background-activated: Background of the button when activated
     * @prop --background-focused: Background of the button when focused
     * @prop --background-hover: Background of the button when hovered
     * @prop --background-hover-clear: Background of the clear button when hovered
     * @prop --background-hover-outline: Background of the outline button when hovered
     *
     * @prop --color: Text color of the button
     * @prop --color-activated: Text color of the button when activated
     * @prop --color-focused: Text color of the button when focused
     * @prop --color-hover-outline: Text color of the outline button when hovered
     *
     * @prop --transition: Transition of the button
     *
     * @prop --border-radius: Border radius of the button
     * @prop --border-width: Border width of the button
     * @prop --border-style: Border style of the button
     * @prop --border-color: Border color of the button
     * @prop --border-focus-color: Border color when focused
     *
     * @prop --box-shadow: Box shadow of the button
     * @prop --opacity: Opacity of the button
     *

     * @prop --button-height: Button Height
     * @prop --button-padding-top: Padding top of the button
     * @prop --button-padding-end: Padding end of the button
     * @prop --button-padding-bottom: Padding bottom of the button
     * @prop --button-padding-start: Padding start of the button
     * @prop --button-text-transformation: How to transform the text
     */
  --overflow: hidden;
  --border-width: initial;
  --border-color: initial;
  --border-style: initial;
  --box-shadow: none;
  --border-radius: #{$button-border-radius};
  --transition: box-shadow 280ms cubic-bezier(0.4, 0, 0.2, 1),
    background-color 15ms linear, color 15ms linear;
  --button-text-transformation: #{$button-text-transform};

  @include margin($button-margin-top,
    $button-margin-end,
    $button-margin-bottom,
    $button-margin-start);

  display: inline-block;

  width: auto;

  height: var(--button-height, #{$button-height});

  color: var(--color);

  font-family: $font-family-base;
  font-size: #{$button-font-size};
  font-weight: #{$button-font-weight};

  letter-spacing: #{$button-letter-spacing};

  text-align: center;
  text-decoration: none;
  text-overflow: ellipsis;

  text-transform: var(--button-text-transformation);

  white-space: nowrap;

  user-select: none;
  vertical-align: top; // the better option for most scenarios
  vertical-align: -webkit-baseline-middle; // the best for those that support it
  pointer-events: auto;

  font-kerning: none;
}

:host(.button-disabled) {
  pointer-events: none;
}

// Solid Button
// --------------------------------------------------

// Default Solid Color
:host(.button-solid) {
  --background: #{lu-color(primary_light, base)};
  --background-focused: #{lu-color(primary_light, shade)};
  --background-activated: var(--background);
  --background-hover: #{lu-color(primary_light, shade)};
  --box-shadow: none;
  --color: #{lu-color(primary_light, contrast)};
  --color-activated: #{lu-color(primary_light, contrast)};
  --color-focused: #{lu-color(primary_light, contrast)};
}

:host(.button-solid.activated) {
  --box-shadow: #{$button-box-shadow-activated};
}

// Solid Button with Color
:host(.button-solid.lu-color) .button-native {
  background: current-color(base);
  color: current-color(contrast);
}

// Focused/Activated Solid Button with Color
:host(.button-solid.lu-color.focused) .button-native {
  background: #{current-color(shade)};
}

// Round Button
// --------------------------------------------------

:host(.button-round) {
  --border-radius: #{$button-round-border-radius};
  --button-padding-top: #{$button-round-padding-top};
  --button-padding-start: #{$button-round-padding-start};
  --button-padding-end: #{$button-round-padding-end};
  --button-padding-bottom: #{$button-round-padding-bottom};
}

// Outline Button
// --------------------------------------------------

// Default Outline Color
:host(.button-outline) {
  --border-color: #{lu-color(neutral_lighter, base)};
  --background: transparent;
  --background-activated: transparent;
  --background-focused: #{lu-color(primary_light, base, 1)};
  --background-hover-outline: #{lu-color(primary_light, base, 1)};
  --border-width: 1px;
  --border-style: solid;
  --box-shadow: none;
  --color: #{lu-color(primary_light, base)};
  --color-focused: white;
  --color-activated: #{lu-color(primary_light, base)};
  --color-hover-outline: white;
}

:host(.button-outline.activated.lu-color) .button-native {
  background: transparent;
}

// Outline Button with Color
:host(.button-outline.lu-color) .button-native {
  border-color: current-color(base);

  background: transparent;
  color: current-color(base);
}

:host(.button-outline.focused.lu-color) .button-native {
  background: current-color(base, 0.1);
  color: current-color(base);
}

// Clear Button
// --------------------------------------------------

// Default Clear Color
:host(.button-clear) {
  --background-activated: transparent;
  --background-focused: #{lu-color(primary_light, base, 0.1)};
  --background-hover-clear: #{lu-color(primary_light, base, 0.04)};
  --background: transparent;
  --border-width: 0;
  --color-activated: #{lu-color(primary_light, base)};
  --color-focused: #{lu-color(primary_light, base)};
  --color: #{lu-color(primary_light, base)};
  --opacity: #{$button-clear-opacity};
}

// Clear Button with Color
:host(.button-clear.lu-color) .button-native {
  background: transparent;
  color: current-color(base);
}

// Focused Clear Button with Color
:host(.button-clear.focused.lu-color) .button-native {
  border: 1px solid var(--border-focused-color, current-color(base));

  background: var(--background-focused, current-color(base, 0.1));
  color: var(--color-focused, current-color(base))
}

// Activated Clear Button with Color
:host(.button-clear.activated.lu-color) .button-native {
  background: transparent;
}

// Button Sizes
// --------------------------------------------------

:host(.button-large) {
  --button-padding-top: #{$button-large-padding-top};
  --button-padding-start: #{$button-large-padding-start};
  --button-padding-end: #{$button-large-padding-end};
  --button-padding-bottom: #{$button-large-padding-bottom};

  height: #{$button-large-height};

  font-size: #{$button-large-font-size};
}

:host(.button-small) {
  --button-padding-top: #{$button-small-padding-top};
  --button-padding-start: #{$button-small-padding-start};
  --button-padding-end: #{$button-small-padding-end};
  --button-padding-bottom: #{$button-small-padding-bottom};

  height: #{$button-small-height};

  font-size: #{$button-small-font-size};
}

// strong Button
// --------------------------------------------------

:host(.button-strong) {
  font-weight: #{$button-strong-font-weight};
}

// Block Button
// --------------------------------------------------

:host(.button-block) {
  display: block;
}

:host(.button-block) .button-native {
  @include margin-horizontal(0);

  display: block;

  width: 100%;

  clear: both;

  contain: content;
}

:host(.button-block) .button-native::after {
  clear: both;
}

// Full Button
// --------------------------------------------------

:host(.button-full) {
  display: block;
}

:host(.button-full) .button-native {
  @include margin-horizontal(0);

  display: block;

  width: 100%;

  contain: content;
}

:host(.button-full:not(.button-round)) .button-native {
  @include border-radius(0);

  // border-right-width: 0;
  // border-left-width: 0;
}

.button-native {
  @include border-radius(var(--border-radius));
  @include font-smoothing();
  @include margin(0);
  @include padding(var(--button-padding-top, #{$button-padding-top}),
    var(--button-padding-end, #{$button-padding-end}),
    var(--button-padding-bottom, #{$button-padding-bottom}),
    var(--button-padding-start, #{$button-padding-start}));
  @include text-inherit();

  display: block;
  position: relative;

  width: 100%;
  height: 100%;

  transition: var(--transition);

  border-width: var(--border-width);
  border-style: var(--border-style);
  border-color: var(--border-color);

  outline: none;

  background: var(--background);

  line-height: 1;

  box-shadow: var(--box-shadow);
  contain: layout style;
  cursor: pointer;
  opacity: var(--opacity);
  overflow: var(--overflow);

  z-index: 0;
  box-sizing: border-box;
  appearance: none;
}

.button-native[disabled] {
  cursor: default;
  opacity: 0.5;
  pointer-events: none;
}

:host(.focused) .button-native {
  background: var(--background-focused);
  color: var(--color-focused);
}

:host(.activated) .button-native {
  background: var(--background-activated);
  color: var(--color-activated);
}

// .button > .button-container:hover {
//   opacity: var(--opacity-hover);
// }

.button-inner {
  display: flex;

  flex-flow: row nowrap;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;

  width: 100%;
  height: 100%;
}

// Button Icons
// --------------------------------------------------

::slotted(lu-icon) {
  font-size: 1.4em;
  pointer-events: none;
}

::slotted(lu-icon[slot="start"]) {
  @include margin(0, 0.3em, 0, -0.3em);
}

::slotted(lu-icon[slot="end"]) {
  @include margin(0, -0.2em, 0, 0.3em);
}

::slotted(lu-icon[slot="icon-only"]) {
  @include padding(0);
  font-size: 1.8em;
}

@media (any-hover: hover) {
  :host(.button-outline:hover) .button-native {
    background: var(--background-hover-outline);
    color: var(--color-hover-outline);
  }

  :host(.button-outline.lu-color:hover) .button-native {
    background: current-color(base, 1);
    color: white;
  }

  :host(.button-clear:hover) .button-native {
    background: var(--background-hover-clear);
  }

  :host(.button-clear.lu-color:hover) .button-native {
    background: current-color(base, 0.04);
  }

  :host(.button-solid:hover) .button-native {
    background: var(--background-hover);
  }

  :host(.button-solid.lu-color:hover) .button-native {
    background: current-color(shade);
  }
}
