@import '../_mixins.scss';
@import '../_vars.scss';

@mixin visible-transform($placement) {
  @if ($placement == 'top') {
    transform: perspective(700px);
  } @else if ($placement == 'bottom') {
    transform: perspective(700px);
  } @else if ($placement == 'left') {
    transform: perspective(700px);
  } @else if ($placement == 'right') {
    transform: perspective(700px);
  }
}

@mixin hidden-transform($placement) {
  @if ($placement == 'top') {
    transform: perspective(700px) translateY(5px) rotateX(30deg);
  } @else if ($placement == 'bottom') {
    transform: perspective(700px) translateY(-5px) rotateX(-30deg);
  } @else if ($placement == 'left') {
    transform: perspective(700px) translateX(5px) rotateY(-30deg);
  } @else if ($placement == 'right') {
    transform: perspective(700px) translateX(-5px) rotateY(30deg);
  }
}

.#{$namespace-prefix}-box {
  &[data-animation='perspective-subtle'] {
    @each $placement in $placements {
      &[data-placement^='#{$placement}'] {
        transform-origin: nth($origins, index($placements, $placement));

        &[data-state='visible'] {
          @include visible-transform($placement);
        }

        &[data-state='hidden'] {
          @include hidden-transform($placement);
        }
      }
    }

    &[data-state='hidden'] {
      opacity: 0;
    }
  }
}
