@import "../themes/ionic.skip-warns.scss";
@import "../themes/ionic.globals";
@import "../components/menu/menu.ios.vars";
@import "../components/menu/menu.md.vars";

// Ionic Font Family
// --------------------------------------------------

html.ios {
  --ion-default-font: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "Roboto", sans-serif;
}
html.md {
  --ion-default-font: "Roboto", "Helvetica Neue", sans-serif;
}

html {
  --ion-font-family: var(--ion-default-font);
}

body {
  background: var(--ion-background-color);
}

body.backdrop-no-scroll {
  overflow: hidden;
}

// TODO: Block scrolling in ion-content, breaks inside ion-modal
// body.backdrop-no-scroll .ion-page > ion-content {
//   --overflow: hidden;
// }

// Modal - Card Style
// --------------------------------------------------
// The card style does not reach all the way to
// the top of the screen, so there does not need
// to be any safe area padding added
html.ios ion-modal.modal-card .ion-page > ion-header > ion-toolbar:first-of-type {
  padding-top: 0px;
}

// .ion-page needs to explicitly inherit
// the border radius in safari otherwise
// modals will not show border radius properly
html.ios ion-modal .ion-page {
  border-radius: inherit;
}

// Ionic Colors
// --------------------------------------------------
// Generates the color classes and variables based on the
// colors map

@mixin generate-color($color-name) {
  $value: map-get($colors, $color-name);

  $base: map-get($value, base);
  $contrast: map-get($value, contrast);
  $shade: map-get($value, shade);
  $tint: map-get($value, tint);

  --ion-color-base: var(--ion-color-#{$color-name}, #{$base}) !important;
  --ion-color-base-rgb: var(--ion-color-#{$color-name}-rgb, #{color-to-rgb-list($base)}) !important;
  --ion-color-contrast: var(--ion-color-#{$color-name}-contrast, #{$contrast}) !important;
  --ion-color-contrast-rgb: var(--ion-color-#{$color-name}-contrast-rgb, #{color-to-rgb-list($contrast)}) !important;
  --ion-color-shade: var(--ion-color-#{$color-name}-shade, #{$shade}) !important;
  --ion-color-tint: var(--ion-color-#{$color-name}-tint, #{$tint}) !important;
}

@each $color-name, $value in $colors {
  .ion-color-#{$color-name} {
    @include generate-color($color-name);
  }
}


// Page Container Structure
// --------------------------------------------------

.ion-page {
  @include position(0, 0, 0, 0);

  display: flex;
  position: absolute;

  flex-direction: column;
  justify-content: space-between;

  contain: layout size style;
  overflow: hidden;
  z-index: $z-index-page-container;
}

.split-pane-visible > .ion-page.split-pane-main {
  position: relative;
}

ion-route,
ion-route-redirect,
ion-router,
ion-select-option,
ion-nav-controller,
ion-menu-controller,
ion-action-sheet-controller,
ion-alert-controller,
ion-loading-controller,
ion-modal-controller,
ion-picker-controller,
ion-popover-controller,
ion-toast-controller,
.ion-page-hidden,
[hidden] {
  /* stylelint-disable-next-line declaration-no-important */
  display: none !important;
}

.ion-page-invisible {
  opacity: 0;
}

.can-go-back > ion-header ion-back-button {
  display: block;
}


// Ionic Safe Margins
// --------------------------------------------------

html.plt-ios.plt-hybrid, html.plt-ios.plt-pwa {
  --ion-statusbar-padding: 20px;
}

@supports (padding-top: 20px) {
  html {
    --ion-safe-area-top: var(--ion-statusbar-padding);
  }
}

// TODO: remove once Safari 11.2 is no longer supported
@supports (padding-top: constant(safe-area-inset-top)) {
  html {
    --ion-safe-area-top: constant(safe-area-inset-top);
    --ion-safe-area-bottom: constant(safe-area-inset-bottom);
    --ion-safe-area-left: constant(safe-area-inset-left);
    --ion-safe-area-right: constant(safe-area-inset-right);
  }
}

@supports (padding-top: env(safe-area-inset-top)) {
  html {
    --ion-safe-area-top: env(safe-area-inset-top);
    --ion-safe-area-bottom: env(safe-area-inset-bottom);
    --ion-safe-area-left: env(safe-area-inset-left);
    --ion-safe-area-right: env(safe-area-inset-right);
  }
}


// Global Card Styles
// --------------------------------------------------

ion-card.ion-color .ion-inherit-color,
ion-card-header.ion-color .ion-inherit-color {
  color: inherit;
}


// Menu Styles
// TODO: Find a better long term solution for this
// --------------------------------------------------

.menu-content {
  @include transform(translate3d(0, 0, 0));
}

.menu-content-open {
  cursor: pointer;
  touch-action: manipulation;

  // the containing element itself should be clickable but
  // everything inside of it should not clickable when menu is open
  pointer-events: none;
}

.ios .menu-content-reveal {
  box-shadow: $menu-ios-box-shadow-reveal;
}

[dir=rtl].ios .menu-content-reveal {
  box-shadow: $menu-ios-box-shadow-reveal-rtl;
}

.ios .menu-content-push {
  box-shadow: $menu-ios-box-shadow-push;
}

.md .menu-content-reveal {
  box-shadow: $menu-md-box-shadow;
}

.md .menu-content-push {
  box-shadow: $menu-md-box-shadow;
}
