@import '../animation/variables.scss';

$name: 'ivue-chip';

:root {
  // size
  --#{$name}-radius: 32px;
  --#{$name}-font-size: 14px;
  --#{$name}-margin: 4px;

  // content
  --#{$name}-content-height: 32px;
  --#{$name}-content-radius: 28px;
  --#{$name}-content-padding: 0 12px;

  // 正方形
  --#{$name}-square-radius: 3px;

  // close->content
  --#{$name}-close-content-padding: 0 4px 0 12px;
  --#{$name}-close-font-size: 20px;
  --#{$name}-close-margin: 0 2px 0 8px;

  // color
  --#{$name}-bg: #e0e0e0;
  --#{$name}-disabled-color: #c5c8ce;
  --#{$name}-disabled-bg: #ededed;
  --#{$name}-outline-color: #9e9e9e;
  --#{$name}-depressed-shadow: 0px 3px 1px -2px rgba(0, 0, 0, 0.2),
    0px 2px 2px 0px rgba(0, 0, 0, 0.14), 0px 1px 5px 0px rgba(0, 0, 0, 0.12);
}

.#{$name} {
  position: relative;
  display: inline-flex;
  align-items: center;
  border-radius: var(--#{$name}-radius);
  font-size: var(--#{$name}-font-size);
  margin: var(--#{$name}-margin);
  outline: none;
  vertical-align: middle;
  transition: $ivue-transition-stand;
  background: var(--#{$name}-bg);
  color: var(--ivue-title-color);

  &::after {
    content: '';
    background: currentColor;
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 100%;
    opacity: 0;
    border-radius: inherit;
    transition: inherit;
    pointer-events: none;
  }

  .ivue-icon {
    margin: 0;
  }

  &--depressed {
    &:hover:not(.ivue-chip--disabled) {
      box-shadow: var(--#{$name}-depressed-shadow);

      &::after {
        opacity: 0.13;
      }
    }
  }

  // 内容
  &-content {
    display: flex;
    align-items: center;
    border-radius: var(--#{$name}-content-radius);
    cursor: default;
    justify-content: space-between;
    height: var(--#{$name}-content-height);
    padding: var(--#{$name}-content-padding);
    vertical-align: middle;
    white-space: nowrap;
    z-index: 1;
  }

  // 禁用
  &--disabled {
    color: var(--#{$name}-disabled-color);
    background-color: var(--#{$name}-disabled-bg);
  }

  // 轮廓
  &.#{$name}.#{$name}--outline {
    background: transparent !important;
    background-color: transparent !important;
    border: 1px solid currentColor;
    color: var(--#{$name}-outline-color);
    height: var(--#{$name}-content-height);
  }

  // 正方形
  &--square {
    border-radius: var(--#{$name}-square-radius);
  }

  // 关闭按钮
  &--close &-content {
    padding: var(--#{$name}-close-content-padding);
  }

  &-close {
    align-items: center;
    color: inherit;
    display: flex;
    font-size: var(--#{$name}-close-font-size);
    margin: var(--#{$name}-close-margin);
    text-decoration: none;
    user-select: none;

    & > .ivue-icon {
      color: inherit;
      font-size: var(--#{$name}-close-font-size);
      opacity: 0.5;
      margin: 0;
      cursor: pointer;
    }
  }
}
