@import "./modal";
@import "./modal.ios.vars";

// iOS Modals
// --------------------------------------------------

:host:first-of-type {
  --backdrop-opacity: var(--ion-backdrop-opacity, 0.4);
}

@media only screen and (min-width: $modal-inset-min-width) and (min-height: $modal-inset-min-height-small) {
  :host {
    --border-radius: #{$modal-ios-border-radius};
  }
}

.modal-wrapper {
  // hidden by default to prevent flickers, the animation will show it
  @include transform(translate3d(0, 100%, 0));
}

@media screen and (max-width: 767px) {
  @supports (width: max(0px, 1px)) {
    :host(.modal-card) {
      --height: calc(100% - max(30px, var(--ion-safe-area-top)) - 10px);
    }
  }

  @supports not (width: max(0px, 1px)) {
    :host(.modal-card) {
      --height: calc(100% - 40px);
    }
  }

  :host(.modal-card) .modal-wrapper {
    @include border-radius($modal-ios-border-radius, $modal-ios-border-radius, 0, 0);
  }

  :host(.modal-card) {
    --backdrop-opacity: 0;
    --width: 100%;

    align-items: flex-end;
  }

  :host(.modal-card) .modal-shadow {
    display: none;
  }

  :host(.modal-card) ion-backdrop {
    pointer-events: none;
  }
}

@media screen and (min-width: 768px) {
  :host(.modal-card) {
    --width: calc(100% - 120px);
    --height: calc(100% - (120px + var(--ion-safe-area-top) + var(--ion-safe-area-bottom)));
    --max-width: 720px;
    --max-height: 1000px;
  }

  :host(.modal-card) {
    --backdrop-opacity: 0;

    transition: all 0.5s ease-in-out;

    &:first-of-type {
      --backdrop-opacity: 0.18;
    }
  }

  :host(.modal-card) .modal-shadow {
    box-shadow: 0px 0px 30px 10px rgba(0, 0, 0, 0.1);
  }
}
