/*
 * Backpack - Skyscanner's Design System
 *
 * Copyright 2016-2021 Skyscanner Ltd
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

@import '~bpk-mixins/index';

@mixin bpk-image__spinner {
  position: absolute;
  top: 50%;
  left: 50%;
  display: block;
  align-items: center;
  transform: translate(-50%, -50%);

  &--hidden {
    transition: opacity $bpk-duration-base ease-in-out;
    opacity: 0;
  }

  &--shown {
    transition: opacity $bpk-duration-base ease-in-out;
    opacity: 1;
  }
}

@mixin bpk-image__img {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  display: block;
  width: 100%;
  transition: opacity $bpk-duration-base ease-in-out;

  &--hidden {
    opacity: 0;
  }
}

@mixin bpk-image--no-background {
  background-color: transparent;
}

@mixin bpk-image {
  position: relative;
  display: block;
  max-width: 100%;
  transition: background-color $bpk-duration-base ease-in-out;
  background-color: $bpk-color-sky-gray-tint-06;
  overflow: hidden;
  transition-delay: $bpk-duration-base;
}

.bpk-image {
  opacity: 1;

  @include bpk-image;

  &__img {
    @include bpk-image__img;
  }

  &__spinner {
    @include bpk-image__spinner;
  }

  &--no-background {
    @include bpk-image--no-background;
  }

  &--border-radius-sm {
    @include bpk-border-radius-sm;
  }
}
