$table--heading--resize--handle--width: 9px;
$table--heading--resize--indicator--width: 1px;

.table {
  &__row {
    &--heading {
      @include theme('background', 'table--heading--background');
      @include theme('box-shadow', 'table--heading--border');
      @include theme('color', 'table--heading--color');
      display: flex;
      height: 24px;
      min-height: 24px;
      overflow: hidden;
      font-size: 12px;
      white-space: nowrap;
      z-index: 1;
    }
  }

  &__heading {
    align-items: center;
    @include theme('border-right', 'table--heading--border--horizontal');
    cursor: pointer;
    display: flex;
    flex: 0 0 auto;
    position: relative;
    transition: color 0.15s;
    touch-action: none;

    &:last-child {
      border-right: none;
    }

    &:hover {
      @include theme('color', 'table--heading--color--hover');
    }

    &:after {
      border-left: 4px solid transparent;
      border-right: 4px solid transparent;
      border-top: 5px solid currentColor;
      content: '';
      margin-top: -3px;
      opacity: 0;
      position: absolute;
      right: 3px;
      top: 50%;
      transition: opacity 0.2s, transform 0.2s;
    }

    &--is-sorted {
      @include theme('color', 'table--heading--color--active');
      font-weight: 700;

      &:hover {
        @include theme('color', 'table--heading--color--active--hover');
      }

      &:after {
        opacity: 0.5;
      }
    }

    &--direction {
      &--asc {
        &:after {
          transform: rotate(180deg);
        }
      }
    }

    &--fill {
      flex: 1 1 auto;
      min-width: 0;

      &.table {
        &__heading {
          border: none;
          margin: 0;
          padding: 0;
        }
      }
    }

    &__handle {
      bottom: 0;
      cursor: col-resize;
      opacity: 0;
      position: absolute;
      right: $table--heading--resize--handle--width / -2;
      top: 0;
      transition: opacity 0.125s;
      width: $table--heading--resize--handle--width;
      z-index: 2;

      &:after {
        @include theme('background', 'table--heading--resize--indicator--background');
        bottom: 0;
        content: '';
        left: ($table--heading--resize--handle--width - $table--heading--resize--indicator--width) / 2;
        cursor: col-resize;
        position: absolute;
        top: 0;
        transition: opacity 0.125s;
        width: $table--heading--resize--indicator--width;
        z-index: 10;
      }

      &:hover {
        opacity: 1;
      }
    }

    &__label {
      flex: 1 1 auto;
      min-width: 0;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    &__resize-line {
      @include theme('background', 'table--heading--resize--indicator--background');
      bottom: 0;
      left: 0;
      opacity: 0;
      position: fixed;
      top: 0;
      transition: opacity 0.125s;
      will-change: opacity, transform;
      width: $table--heading--resize--indicator--width;
    }

    &__column-fill {
      @include theme('background', 'table--heading--resize--indicator--background');
      bottom: 0;
      left: 0;
      opacity: 0;
      position: absolute;
      top: 0;
      transition: opacity 0.125s;
      will-change: opacity, transform;
      width: 30px;
    }
  }

  &__cell {
    padding: 0 8px;
  }
}
