@use 'sass:math';

@use 'mixins/mixins' as *;
@use 'mixins/var' as *;
@use 'mixins/utils' as *;
@use 'common/var' as *;

@include b(carousel) {
  // @include set-component-css-var('carousel', $carousel);

  position: relative;

  @include m(horizontal) {
    overflow-x: hidden;
  }

  @include m(vertical) {
    overflow-y: hidden;
  }

  @include e(container) {
    position: relative;
    height: 300px;
  }

  @include e(arrow) {
    border: none;
    outline: none;
    padding: 0;
    margin: 0;
    height: 32px;
    width: 32px;
    cursor: pointer;
    transition: getCssVar('transition', 'duration');
    border-radius: 50%;
    background-color: rgba(0, 0, 0, 0.2);
    color: getCssVar('color-white');
    position: absolute;
    top: 50%;
    z-index: 10;
    transform: translateY(-50%);
    text-align: center;
    font-size: 12px;

    @include utils-inline-flex-center;

    @include m(left) {
      left: 16px;
    }

    @include m(right) {
      right: 16px;
    }

    &:hover {
      background-color: rgba(0, 0, 0, 0.4);
      box-shadow: getCssVar('box-shadow-lv2');
    }

    & .#{$namespace}-icon {
      cursor: pointer;
    }
  }

  @include e(indicators) {
    position: absolute;
    list-style: none;
    margin: 0;
    padding: 0;
    line-height: 1;
    z-index: calc(#{getCssVar('index-normal')} + 1);

    @include m(horizontal) {
      bottom: 0;
      left: 50%;
      transform: translateX(-50%);
    }

    @include m(vertical) {
      right: 0;
      top: 50%;
      transform: translateY(-50%);
    }

    @include m(outside) {
      text-align: center;
      position: static;
      transform: none;

      .#{$namespace}-carousel__indicator:hover button {
        opacity: 0.64;
      }

      button {
        color: getCssVar('color-white');
        background-color: getCssVar('color-neutral-6');
        opacity: 0.24;
      }
    }

    @include m(labels) {
      left: 0;
      right: 0;
      transform: none;
      text-align: center;

      .#{$namespace}-carousel__button {
        height: auto;
        width: auto;
        padding: 2px 8px;
        font-size: 8px;
        font-weight: 600;
      }

      .#{$namespace}-carousel__indicator {
        padding: 4px 2px;
      }
    }
  }

  @include e(indicator) {
    background-color: transparent;
    cursor: pointer;

    &:hover button {
      opacity: 0.72;
    }

    @include m(horizontal) {
      display: inline-block;
      padding: 8px 4px;
    }

    @include m(vertical) {
      padding: 2px 8px;

      .#{$namespace}-carousel__button {
        width: 6px;
        height: 6px;
      }
    }

    @include when(active) {
      button {
        opacity: 1;
        box-shadow: getCssVar('box-shadow-lv1');
      }
    }
  }

  @include e(button) {
    display: block;
    opacity: 0.48;
    width: 16px;
    height: 2px;
    background-color: getCssVar('color-white');
    border: none;
    border-radius: getCssVar('border-radius-max');
    outline: none;
    padding: 0;
    margin: 0;
    cursor: pointer;
    transition: getCssVar('transition-duration');
  }
}

.carousel-arrow-left-enter-from,
.carousel-arrow-left-leave-active {
  transform: translateY(-50%) translateX(-10px);
  opacity: 0;
}

.carousel-arrow-right-enter-from,
.carousel-arrow-right-leave-active {
  transform: translateY(-50%) translateX(10px);
  opacity: 0;
}
