/*
 * Backpack - Skyscanner's Design System
 *
 * Copyright 2016 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.scss';

$bpk-spacing-v2: true;

@mixin fullscreen() {
  display: flex;
  margin: 0;
  flex-direction: column;
  border-radius: 0;
  box-shadow: none;
}

.bpk-modal {
  z-index: $bpk-zindex-modal;
  width: 100%;
  max-width: $bpk-modal-max-width;
  margin: auto;
  transform: scale(1);
  transition: opacity $bpk-duration-sm ease-in-out,
    transform $bpk-duration-sm ease-in-out;
  outline: 0;
  background-color: $bpk-modal-background-color;
  opacity: $bpk-modal-opacity;

  // required to prevent the header extending beyond the rounded corners
  overflow: hidden;

  // FIX: Prevents ugly flickering when tapping inside the modal in Mobile Safari
  -webkit-tap-highlight-color: transparent;

  @include bpk-box-shadow-xl;
  @include bpk-border-radius-sm;

  &--full-screen-mobile {
    @include bpk-breakpoint-mobile {
      @include fullscreen;
    }
  }

  &--full-screen {
    max-width: none;

    @include fullscreen;
  }

  &--wide {
    @include bpk-breakpoint-above-mobile {
      max-width: $bpk-modal-wide-max-width;
    }
  }

  &--appear {
    transform: scale(0.9);
    opacity: $bpk-modal-initial-opacity;
  }

  &--appear-active {
    transform: scale(1);
    opacity: $bpk-modal-opacity;
  }

  &__header {
    @include bpk-border-bottom-sm($bpk-line-day);
  }

  &__navigation {
    display: flex;
    justify-content: space-between;
    background-color: $bpk-modal-background-color;
  }

  &__heading {
    @include bpk-text;
    @include bpk-label-1;
  }

  &__close-button {
    position: relative; // Override position: absolute coming from BpkNavigationBar
    right: auto;

    @include bpk-margin-leading(bpk-spacing-base());

    @include bpk-rtl {
      left: auto;
    }
  }

  &__accessory-view {
    position: relative; // Override position: absolute coming from BpkNavigationBar
    left: auto;
    margin-right: bpk-spacing-base();

    @include bpk-rtl {
      right: auto;
      margin-left: bpk-spacing-base();
    }
  }

  &__content {
    flex: 1;
    overflow-y: auto;

    &--padded {
      padding: $bpk-modal-content-padding;
    }
  }
}
