@import '~@cainiaofe/cn-ui-m-theme/token.px.scss';
@import '../../styles/mixins.scss';

$class-prefix: 'cn-ui-m';
$sizes: small, medium, large;

$-cn-color-border: $m-color-bg;
$-height: calc(#{$m-s-120} * 2);
$-item-height: $m-s-34;
$-item-font-size: $m-s-16;

.#{$hashClassName}.#{$class-prefix}-picker-view {
  height: $-height;
  width: 100%;
  display: flex;
  position: relative;
  overflow: hidden;
  background: $m-color-bg-white;

  .#{$class-prefix}-picker-view-column {
    height: 100%;
    flex: 1;
    user-select: none;
    touch-action: none;
    position: relative;
    z-index: 0;

    &-wheel {
      width: 100%;
      cursor: grab;
      position: absolute;
      top: calc(50% - #{$-item-height} / 2);
      left: 0;

      &::before {
        content: ' ';
        display: block;
        position: absolute;
        width: 100%;
        height: 100vh;
        top: -100vh;
      }

      &::after {
        content: ' ';
        display: block;
        position: absolute;
        width: 100%;
        height: 100vh;
        bottom: -100vh;
      }
    }

    &-item {
      font-size: $-item-font-size;
      padding: 0 6px;
      height: $-item-height;
      display: flex;
      justify-content: center;
      align-items: center;

      &-label {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
      }
    }
  }

  .#{$class-prefix}-picker-view-column-accessible {
    width: 100%;
    height: 100%;
    pointer-events: none;
    opacity: 0;
    display: flex;
    flex-direction: column;
    position: relative;
    top: calc(#{$-item-height} * -1);
    z-index: 0;
    padding-bottom: $m-s-base;

    > * {
      flex: 1;
      text-overflow: ellipsis;
    }

    &-current {
      position: absolute;
      width: 100%;
      height: 100%;
    }

    &-button {
      width: 100%;
      height: 100%;
    }
  }

  .#{$class-prefix}-picker-view-mask {
    position: absolute;
    z-index: 100;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    pointer-events: none;

    &-top,
    &-bottom {
      flex: auto;
    }

    &-middle {
      height: $-item-height;
      box-sizing: border-box;
      flex: none;
      border-top: solid $m-s-base $-cn-color-border;
      border-bottom: solid $m-s-base $-cn-color-border;
    }

    &-top {
      background: $m-color-bg-white;
      mask: linear-gradient(
        0deg,
        rgba(0, 0, 0, 0.6) 0%,
        rgba(0, 0, 0, 0.8) 50%,
        rgba(0, 0, 0, 1) 100%
      );
      // 由于构建不会产生 mask 的兼容代码，临时手动追加
      -webkit-mask: linear-gradient(
        0deg,
        rgba(0, 0, 0, 0.6) 0%,
        rgba(0, 0, 0, 0.8) 50%,
        rgba(0, 0, 0, 1) 100%
      );
    }

    &-bottom {
      background: $m-color-bg-white;
      mask: linear-gradient(
        180deg,
        rgba(0, 0, 0, 0.6) 0%,
        rgba(0, 0, 0, 0.8) 50%,
        rgba(0, 0, 0, 1) 100%
      );
      // 由于构建不会产生 mask 的兼容代码，临时手动追加
      -webkit-mask: linear-gradient(
        180deg,
        rgba(0, 0, 0, 0.6) 0%,
        rgba(0, 0, 0, 0.8) 50%,
        rgba(0, 0, 0, 1) 100%
      );
    }
  }

  .#{$class-prefix}-picker-view-loading-content {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
  }

  .#{$class-prefix}-picker-view-item-height-measure {
    position: relative;
    left: 0;
    top: 0;
    height: $-item-height;
    width: 0;
    pointer-events: none;
  }
}
