@use "../../themes/mixins" as mixins;
@use "../../themes/functions.color" as colors;

// Chip: Common Styles
// --------------------------------------------------

:host {
  /**
   * @prop --ion-chip-margin-top: Top margin of the chip
   * @prop --ion-chip-margin-end: Right margin if direction is left-to-right, and left margin if direction is right-to-left of the chip
   * @prop --ion-chip-margin-bottom: Bottom margin of the chip
   * @prop --ion-chip-margin-start: Left margin if direction is left-to-right, and right margin if direction is right-to-left of the chip
   *
   * @prop --ion-chip-padding-top: Top padding of the chip
   * @prop --ion-chip-padding-end: Right padding if direction is left-to-right, and left padding if direction is right-to-left of the chip
   * @prop --ion-chip-padding-bottom: Bottom padding of the chip
   * @prop --ion-chip-padding-start: Left padding if direction is left-to-right, and right margin if direction is right-to-left of the chip
   *
   * @prop --ion-chip-font-weight: Font weight of the chip
   * @prop --ion-chip-letter-spacing: Letter spacing of the chip
   * @prop --ion-chip-line-height: Line height of the chip
   * @prop --ion-chip-gap: Gap between slotted elements in the chip
   *
   * Sizes
   * @prop --ion-chip-size-small-min-height: Minimum height of the `small` chip size
   * @prop --ion-chip-size-small-font-size: Font size of the `small` chip size
   * @prop --ion-chip-size-large-min-height: Minimum height of the `large` chip size
   * @prop --ion-chip-size-large-font-size: Font size of the `large` chip size
   *
   * Shapes
   * @prop --ion-chip-shape-soft-border-radius: Border radius of the `soft` chip shape
   * @prop --ion-chip-shape-round-border-radius: Border radius of the `round` chip shape
   * @prop --ion-chip-shape-rectangular-border-radius: Border radius of the `rectangular` chip shape
   *
   * Bold Solid
   * @prop --ion-chip-hue-bold-solid-default-color: Color of the `bold` hue and `solid` fill combination in the default state
   * @prop --ion-chip-hue-bold-solid-default-background: Background color of the `bold` hue and `solid` fill combination in the default state
   * @prop --ion-chip-hue-bold-solid-activated-background: Background color of the `bold` hue and `solid` fill combination in the activated state
   * @prop --ion-chip-hue-bold-solid-focus-background: Background color of the `bold` hue and `solid` fill combination in the focus state
   * @prop --ion-chip-hue-bold-solid-hover-background: Background color of the `bold` hue and `solid` fill combination in the hover state
   * @prop --ion-chip-hue-bold-solid-semantic-default-color: Color of the `bold` hue and `solid` fill combination when a semantic color is applied
   * @prop --ion-chip-hue-bold-solid-semantic-default-background: Background color of the `bold` hue and `solid` fill combination when a semantic color is applied
   * @prop --ion-chip-hue-bold-solid-semantic-activated-background: Background color of the `bold` hue and `solid` fill combination when a semantic color is applied and in the activated state
   * @prop --ion-chip-hue-bold-solid-semantic-focus-background: Background color of the `bold` hue and `solid` fill combination when a semantic color is applied and in the focus state
   * @prop --ion-chip-hue-bold-solid-semantic-hover-background: Background color of the `bold` hue and `solid` fill combination when a semantic color is applied and in the hover state
   *
   * Bold Outline
   * @prop --ion-chip-hue-bold-outline-default-color: Color of the `bold` hue and `outline` fill combination in the default state
   * @prop --ion-chip-hue-bold-outline-default-background: Background color of the `bold` hue and `outline` fill combination in the default state
   * @prop --ion-chip-hue-bold-outline-activated-background: Background color of the `bold` hue and `outline` fill combination in the activated state
   * @prop --ion-chip-hue-bold-outline-focus-background: Background color of the `bold` hue and `outline` fill combination in the focus state
   * @prop --ion-chip-hue-bold-outline-hover-background: Background color of the `bold` hue and `outline` fill combination in the hover state
   * @prop --ion-chip-hue-bold-outline-default-border-width: Border width of the `bold` hue and `outline` fill combination in the default state
   * @prop --ion-chip-hue-bold-outline-default-border-style: Border style of the `bold` hue and `outline` fill combination in the default state
   * @prop --ion-chip-hue-bold-outline-default-border-color: Border color of the `bold` hue and `outline` fill combination in the default state
   * @prop --ion-chip-hue-bold-outline-semantic-default-color: Color of the `bold` hue and `outline` fill combination when a semantic color is applied
   * @prop --ion-chip-hue-bold-outline-semantic-default-background: Background color of the `bold` hue and `outline` fill combination when a semantic color is applied
   * @prop --ion-chip-hue-bold-outline-semantic-activated-background: Background color of the `bold` hue and `outline` fill combination when a semantic color is applied and in the activated state
   * @prop --ion-chip-hue-bold-outline-semantic-focus-background: Background color of the `bold` hue and `outline` fill combination when a semantic color is applied and in the focus state
   * @prop --ion-chip-hue-bold-outline-semantic-hover-background: Background color of the `bold` hue and `outline` fill combination when a semantic color is applied and in the hover state
   * @prop --ion-chip-hue-bold-outline-semantic-default-border-width: Border width of the `bold` hue and `outline` fill combination when a semantic color is applied
   * @prop --ion-chip-hue-bold-outline-semantic-default-border-style: Border style of the `bold` hue and `outline` fill combination when a semantic color is applied
   * @prop --ion-chip-hue-bold-outline-semantic-default-border-color: Border color of the `bold` hue and `outline` fill combination when a semantic color is applied
   *
   * Subtle Solid
   * @prop --ion-chip-hue-subtle-solid-default-color: Color of the `subtle` hue and `solid` fill combination in the default state
   * @prop --ion-chip-hue-subtle-solid-default-background: Background color of the `subtle` hue and `solid` fill combination in the default state
   * @prop --ion-chip-hue-subtle-solid-activated-background: Background color of the `subtle` hue and `solid` fill combination in the activated state
   * @prop --ion-chip-hue-subtle-solid-focus-background: Background color of the `subtle` hue and `solid` fill combination in the focus state
   * @prop --ion-chip-hue-subtle-solid-hover-background: Background color of the `subtle` hue and `solid` fill combination in the hover state
   * @prop --ion-chip-hue-subtle-solid-semantic-default-color: Color of the `subtle` hue and `solid` fill combination when a semantic color is applied
   * @prop --ion-chip-hue-subtle-solid-semantic-default-background: Background color of the `subtle` hue and `solid` fill combination when a semantic color is applied
   * @prop --ion-chip-hue-subtle-solid-semantic-activated-background: Background color of the `subtle` hue and `solid` fill combination when a semantic color is applied and in the activated state
   * @prop --ion-chip-hue-subtle-solid-semantic-focus-background: Background color of the `subtle` hue and `solid` fill combination when a semantic color is applied and in the focus state
   * @prop --ion-chip-hue-subtle-solid-semantic-hover-background: Background color of the `subtle` hue and `solid` fill combination when a semantic color is applied and in the hover state
   *
   * Subtle Outline
   * @prop --ion-chip-hue-subtle-outline-default-color: Color of the `subtle` hue and `outline` fill combination in the default state
   * @prop --ion-chip-hue-subtle-outline-default-background: Background color of the `subtle` hue and `outline` fill combination in the default state
   * @prop --ion-chip-hue-subtle-outline-activated-background: Background color of the `subtle` hue and `outline` fill combination in the activated state
   * @prop --ion-chip-hue-subtle-outline-focus-background: Background color of the `subtle` hue and `outline` fill combination in the focus state
   * @prop --ion-chip-hue-subtle-outline-hover-background: Background color of the `subtle` hue and `outline` fill combination in the hover state
   * @prop --ion-chip-hue-subtle-outline-default-border-width: Border width of the `subtle` hue and `outline` fill combination in the default state
   * @prop --ion-chip-hue-subtle-outline-default-border-style: Border style of the `subtle` hue and `outline` fill combination in the default state
   * @prop --ion-chip-hue-subtle-outline-default-border-color: Border color of the `subtle` hue and `outline` fill combination in the default state
   * @prop --ion-chip-hue-subtle-outline-semantic-default-color: Color of the `subtle` hue and `outline` fill combination when a semantic color is applied
   * @prop --ion-chip-hue-subtle-outline-semantic-default-background: Background color of the `subtle` hue and `outline` fill combination when a semantic color is applied
   * @prop --ion-chip-hue-subtle-outline-semantic-activated-background: Background color of the `subtle` hue and `outline` fill combination when a semantic color is applied and in the activated state
   * @prop --ion-chip-hue-subtle-outline-semantic-focus-background: Background color of the `subtle` hue and `outline` fill combination when a semantic color is applied and in the focus state
   * @prop --ion-chip-hue-subtle-outline-semantic-hover-background: Background color of the `subtle` hue and `outline` fill combination when a semantic color is applied and in the hover state
   * @prop --ion-chip-hue-subtle-outline-semantic-default-border-width: Border width of the `subtle` hue and `outline` fill combination when a semantic color is applied
   * @prop --ion-chip-hue-subtle-outline-semantic-default-border-style: Border style of the `subtle` hue and `outline` fill combination when a semantic color is applied
   * @prop --ion-chip-hue-subtle-outline-semantic-default-border-color: Border color of the `subtle` hue and `outline` fill combination when a semantic color is applied
   *
   * States
   * @prop --ion-chip-state-focus-ring-color: Color of the focus ring
   * @prop --ion-chip-state-focus-ring-style: Style of the focus ring
   * @prop --ion-chip-state-focus-ring-width: Width of the focus ring
   * @prop --ion-chip-state-disabled-opacity: Opacity of the chip when it is disabled
   *
   * Slotted Icon
   * @prop --ion-chip-icon-color: Color of the slotted `ion-icon`
   * @prop --ion-chip-icon-font-size: Font size of the slotted `ion-icon`
   * @prop --ion-chip-icon-leading-margin-top: Top margin of the slotted `ion-icon` when it is the first child
   * @prop --ion-chip-icon-leading-margin-end: End margin of the slotted `ion-icon` when it is the first child
   * @prop --ion-chip-icon-leading-margin-bottom: Bottom margin of the slotted `ion-icon` when it is the first child
   * @prop --ion-chip-icon-leading-margin-start: Start margin of the slotted `ion-icon` when it is the first child
   * @prop --ion-chip-icon-trailing-margin-top: Top margin of the slotted `ion-icon` when it is the last child
   * @prop --ion-chip-icon-trailing-margin-end: End margin of the slotted `ion-icon` when it is the last child
   * @prop --ion-chip-icon-trailing-margin-bottom: Bottom margin of the slotted `ion-icon` when it is the last child
   * @prop --ion-chip-icon-trailing-margin-start: Start margin of the slotted `ion-icon` when it is the last child
   *
   * Slotted Avatar
   * @prop --ion-chip-avatar-width: Width of the slotted `ion-avatar`
   * @prop --ion-chip-avatar-height: Height of the slotted `ion-avatar`
   * @prop --ion-chip-avatar-leading-margin-top: Top margin of the slotted `ion-avatar` when it is the first child
   * @prop --ion-chip-avatar-leading-margin-end: End margin of the slotted `ion-avatar` when it is the first child
   * @prop --ion-chip-avatar-leading-margin-bottom: Bottom margin of the slotted `ion-avatar` when it is the first child
   * @prop --ion-chip-avatar-leading-margin-start: Start margin of the slotted `ion-avatar` when it is the first child
   * @prop --ion-chip-avatar-trailing-margin-top: Top margin of the slotted `ion-avatar` when it is the last child
   * @prop --ion-chip-avatar-trailing-margin-end: End margin of the slotted `ion-avatar` when it is the last child
   * @prop --ion-chip-avatar-trailing-margin-bottom: Bottom margin of the slotted `ion-avatar` when it is the last child
   * @prop --ion-chip-avatar-trailing-margin-start: Start margin of the slotted `ion-avatar` when it is the last child
   */

  @include mixins.font-smoothing();
  @include mixins.margin(
    var(--ion-chip-margin-top),
    var(--ion-chip-margin-end),
    var(--ion-chip-margin-bottom),
    var(--ion-chip-margin-start)
  );
  @include mixins.padding(
    var(--ion-chip-padding-top),
    var(--ion-chip-padding-end),
    var(--ion-chip-padding-bottom),
    var(--ion-chip-padding-start)
  );

  display: inline-flex;
  position: relative;

  align-items: center;
  justify-content: center;

  font-weight: var(--ion-chip-font-weight);

  letter-spacing: var(--ion-chip-letter-spacing);

  line-height: var(--ion-chip-line-height);

  cursor: pointer;
  gap: var(--ion-chip-gap);

  overflow: hidden;
  vertical-align: middle;
  box-sizing: border-box;
}

// Chip Sizes
// ---------------------------------------------

:host(.chip-size-small) {
  min-height: var(--ion-chip-size-small-min-height);

  font-size: var(--ion-chip-size-small-font-size);
}

:host(.chip-size-large) {
  min-height: var(--ion-chip-size-large-min-height);

  font-size: var(--ion-chip-size-large-font-size);
}

// Chip Shapes
// ---------------------------------------------

:host(.chip-shape-soft) {
  @include mixins.border-radius(var(--ion-chip-shape-soft-border-radius));
}

:host(.chip-shape-round) {
  @include mixins.border-radius(var(--ion-chip-shape-round-border-radius));
}

:host(.chip-shape-rectangular) {
  @include mixins.border-radius(var(--ion-chip-shape-rectangular-border-radius));
}

// Chip: Bold Solid
// ---------------------------------------------

// Default
:host(.chip-hue-bold.chip-fill-solid) {
  background: var(--ion-chip-hue-bold-solid-default-background);
  color: var(--ion-chip-hue-bold-solid-default-color);
}

// Default: Activated
:host(.chip-hue-bold.chip-fill-solid.ion-activated) {
  background: var(--ion-chip-hue-bold-solid-activated-background, var(--ion-chip-hue-bold-solid-default-background));
}

// Default: Focus
:host(.chip-hue-bold.chip-fill-solid.ion-focused) {
  background: var(--ion-chip-hue-bold-solid-focus-background, var(--ion-chip-hue-bold-solid-default-background));
}

@media (any-hover: hover) {
  // Default: Hover
  :host(.chip-hue-bold.chip-fill-solid:hover) {
    background: var(--ion-chip-hue-bold-solid-hover-background, var(--ion-chip-hue-bold-solid-default-background));
  }
}

// Colors
:host(.chip-hue-bold.chip-fill-solid.ion-color) {
  background: var(--ion-chip-hue-bold-solid-semantic-default-background);
  color: var(--ion-chip-hue-bold-solid-semantic-default-color);
}

// Colors: Activated
:host(.chip-hue-bold.chip-fill-solid.ion-color.ion-activated) {
  background: var(
    --ion-chip-hue-bold-solid-semantic-activated-background,
    var(--ion-chip-hue-bold-solid-semantic-default-background)
  );
}

// Colors: Focus
:host(.chip-hue-bold.chip-fill-solid.ion-color.ion-focused) {
  background: var(
    --ion-chip-hue-bold-solid-semantic-focus-background,
    var(--ion-chip-hue-bold-solid-semantic-default-background)
  );
}

@media (any-hover: hover) {
  // Colors: Hover
  :host(.chip-hue-bold.chip-fill-solid.ion-color:hover) {
    background: var(
      --ion-chip-hue-bold-solid-semantic-hover-background,
      var(--ion-chip-hue-bold-solid-semantic-default-background)
    );
  }
}

// Chip: Bold Outline
// ---------------------------------------------

// Default
:host(.chip-hue-bold.chip-fill-outline) {
  border-width: var(--ion-chip-hue-bold-outline-default-border-width);
  border-style: var(--ion-chip-hue-bold-outline-default-border-style);
  border-color: var(--ion-chip-hue-bold-outline-default-border-color);

  background: var(--ion-chip-hue-bold-outline-default-background);
  color: var(--ion-chip-hue-bold-outline-default-color);
}

// Default: Activated
:host(.chip-hue-bold.chip-fill-outline.ion-activated) {
  background: var(
    --ion-chip-hue-bold-outline-activated-background,
    var(--ion-chip-hue-bold-outline-default-background)
  );
}

// Default: Focus
:host(.chip-hue-bold.chip-fill-outline.ion-focused) {
  background: var(--ion-chip-hue-bold-outline-focus-background, var(--ion-chip-hue-bold-outline-default-background));
}

@media (any-hover: hover) {
  // Default: Hover
  :host(.chip-hue-bold.chip-fill-outline:hover) {
    background: var(--ion-chip-hue-bold-outline-hover-background, var(--ion-chip-hue-bold-outline-default-background));
  }
}

// Colors
:host(.chip-hue-bold.chip-fill-outline.ion-color) {
  border-width: var(--ion-chip-hue-bold-outline-semantic-default-border-width);
  border-style: var(--ion-chip-hue-bold-outline-semantic-default-border-style);
  border-color: var(--ion-chip-hue-bold-outline-semantic-default-border-color);

  background: var(--ion-chip-hue-bold-outline-semantic-default-background);
  color: var(--ion-chip-hue-bold-outline-semantic-default-color);
}

// Colors: Activated
:host(.chip-hue-bold.chip-fill-outline.ion-color.ion-activated) {
  background: var(
    --ion-chip-hue-bold-outline-semantic-activated-background,
    var(--ion-chip-hue-bold-outline-semantic-default-background)
  );
}

// Colors: Focus
:host(.chip-hue-bold.chip-fill-outline.ion-color.ion-focused) {
  background: var(
    --ion-chip-hue-bold-outline-semantic-focus-background,
    var(--ion-chip-hue-bold-outline-semantic-default-background)
  );
}

@media (any-hover: hover) {
  // Colors: Hover
  :host(.chip-hue-bold.chip-fill-outline.ion-color:hover) {
    background: var(
      --ion-chip-hue-bold-outline-semantic-hover-background,
      var(--ion-chip-hue-bold-outline-semantic-default-background)
    );
  }
}

// Chip: Subtle Solid
// ---------------------------------------------

// Default
:host(.chip-hue-subtle.chip-fill-solid) {
  background: var(--ion-chip-hue-subtle-solid-default-background);
  color: var(--ion-chip-hue-subtle-solid-default-color);
}

// Default: Activated
:host(.chip-hue-subtle.chip-fill-solid.ion-activated) {
  background: var(
    --ion-chip-hue-subtle-solid-activated-background,
    var(--ion-chip-hue-subtle-solid-default-background)
  );
}

// Default: Focus
:host(.chip-hue-subtle.chip-fill-solid.ion-focused) {
  background: var(--ion-chip-hue-subtle-solid-focus-background, var(--ion-chip-hue-subtle-solid-default-background));
}

@media (any-hover: hover) {
  // Default: Hover
  :host(.chip-hue-subtle.chip-fill-solid:hover) {
    background: var(--ion-chip-hue-subtle-solid-hover-background, var(--ion-chip-hue-subtle-solid-default-background));
  }
}

// Colors
:host(.chip-hue-subtle.chip-fill-solid.ion-color) {
  background: var(--ion-chip-hue-subtle-solid-semantic-default-background);
  color: var(--ion-chip-hue-subtle-solid-semantic-default-color);
}

// Colors: Activated
:host(.chip-hue-subtle.chip-fill-solid.ion-color.ion-activated) {
  background: var(
    --ion-chip-hue-subtle-solid-semantic-activated-background,
    var(--ion-chip-hue-subtle-solid-semantic-default-background)
  );
}

// Colors: Focus
:host(.chip-hue-subtle.chip-fill-solid.ion-color.ion-focused) {
  background: var(
    --ion-chip-hue-subtle-solid-semantic-focus-background,
    var(--ion-chip-hue-subtle-solid-semantic-default-background)
  );
}

@media (any-hover: hover) {
  // Colors: Hover
  :host(.chip-hue-subtle.chip-fill-solid.ion-color:hover) {
    background: var(
      --ion-chip-hue-subtle-solid-semantic-hover-background,
      var(--ion-chip-hue-subtle-solid-semantic-default-background)
    );
  }
}

// Chip: Subtle Outline
// ---------------------------------------------

// Default
:host(.chip-hue-subtle.chip-fill-outline) {
  border-width: var(--ion-chip-hue-subtle-outline-default-border-width);
  border-style: var(--ion-chip-hue-subtle-outline-default-border-style);
  border-color: var(--ion-chip-hue-subtle-outline-default-border-color);

  background: var(--ion-chip-hue-subtle-outline-default-background);
  color: var(--ion-chip-hue-subtle-outline-default-color);
}

// Default: Activated
:host(.chip-hue-subtle.chip-fill-outline.ion-activated) {
  background: var(
    --ion-chip-hue-subtle-outline-activated-background,
    var(--ion-chip-hue-subtle-outline-default-background)
  );
}

// Default: Focus
:host(.chip-hue-subtle.chip-fill-outline.ion-focused) {
  background: var(
    --ion-chip-hue-subtle-outline-focus-background,
    var(--ion-chip-hue-subtle-outline-default-background)
  );
}

@media (any-hover: hover) {
  // Default: Hover
  :host(.chip-hue-subtle.chip-fill-outline:hover) {
    background: var(
      --ion-chip-hue-subtle-outline-hover-background,
      var(--ion-chip-hue-subtle-outline-default-background)
    );
  }
}

// Colors
:host(.chip-hue-subtle.chip-fill-outline.ion-color) {
  border-width: var(--ion-chip-hue-subtle-outline-semantic-default-border-width);
  border-style: var(--ion-chip-hue-subtle-outline-semantic-default-border-style);
  border-color: var(--ion-chip-hue-subtle-outline-semantic-default-border-color);

  background: var(--ion-chip-hue-subtle-outline-semantic-default-background);
  color: var(--ion-chip-hue-subtle-outline-semantic-default-color);
}

// Colors: Activated
:host(.chip-hue-subtle.chip-fill-outline.ion-color.ion-activated) {
  background: var(
    --ion-chip-hue-subtle-outline-semantic-activated-background,
    var(--ion-chip-hue-subtle-outline-semantic-default-background)
  );
}

// Colors: Focus
:host(.chip-hue-subtle.chip-fill-outline.ion-color.ion-focused) {
  background: var(
    --ion-chip-hue-subtle-outline-semantic-focus-background,
    var(--ion-chip-hue-subtle-outline-semantic-default-background)
  );
}

@media (any-hover: hover) {
  // Colors: Hover
  :host(.chip-hue-subtle.chip-fill-outline.ion-color:hover) {
    background: var(
      --ion-chip-hue-subtle-outline-semantic-hover-background,
      var(--ion-chip-hue-subtle-outline-semantic-default-background)
    );
  }
}

// Chip States
// ---------------------------------------------

// Disabled
:host(.chip-disabled) {
  cursor: default;
  opacity: var(--ion-chip-state-disabled-opacity, 1);
  pointer-events: none;
}

// Focus
:host(.ion-focused) {
  @include mixins.focused-state(
    var(--ion-chip-state-focus-ring-width),
    var(--ion-chip-state-focus-ring-style),
    var(--ion-chip-state-focus-ring-color)
  );
}

// Chip Slotted Elements
// ---------------------------------------------

// Icon
::slotted(ion-icon) {
  font-size: var(--ion-chip-icon-font-size);
}

:host(:not(.ion-color)) ::slotted(ion-icon) {
  color: var(--ion-chip-icon-color);
}

::slotted(ion-icon:first-child) {
  @include mixins.margin(
    var(--ion-chip-icon-leading-margin-top),
    var(--ion-chip-icon-leading-margin-end),
    var(--ion-chip-icon-leading-margin-bottom),
    var(--ion-chip-icon-leading-margin-start)
  );
}

::slotted(ion-icon:last-child) {
  @include mixins.margin(
    var(--ion-chip-icon-trailing-margin-top),
    var(--ion-chip-icon-trailing-margin-end),
    var(--ion-chip-icon-trailing-margin-bottom),
    var(--ion-chip-icon-trailing-margin-start)
  );
}

// Avatar
::slotted(ion-avatar) {
  flex-shrink: 0;

  width: var(--ion-chip-avatar-width, revert-layer);
  height: var(--ion-chip-avatar-height, revert-layer);
}

::slotted(ion-avatar:first-child) {
  @include mixins.margin(
    var(--ion-chip-avatar-leading-margin-top),
    var(--ion-chip-avatar-leading-margin-end),
    var(--ion-chip-avatar-leading-margin-bottom),
    var(--ion-chip-avatar-leading-margin-start)
  );
}

::slotted(ion-avatar:last-child) {
  @include mixins.margin(
    var(--ion-chip-avatar-trailing-margin-top),
    var(--ion-chip-avatar-trailing-margin-end),
    var(--ion-chip-avatar-trailing-margin-bottom),
    var(--ion-chip-avatar-trailing-margin-start)
  );
}
