
$layer-padding: 1.5rem;

body .application > div:not(.layer)
{
  transition: opacity 200ms ease-in 0s, filter 150ms ease-in 0s;
}

body[class*=" layer-"]:not(.hide\:curtain)
{
  .application > div:not(.layer)
  {
    filter: blur(2.5px);
    opacity: 0.65;
  }
}

body.hide\:curtain .layer
{
  background-color: transparent !important;
  pointer-events: none;

  .container
  {
    pointer-events: initial;
  }
}

.layer
{
  left: 0; top: 0;
  position: fixed;
  z-index: 1000;

  &:not(.tooltip)
  {
    margin: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100vh;
    display: flex;

    background-color: rgba(119, 140, 162, 0);

    &.show:not(.popover)
    {
      background-color: rgba(119, 140, 162, 0.6);
    }
  }

  transition: background-color 300ms ease-in 0s;


  .container
  {
    background-color: white;
    box-sizing: border-box;
    position: relative;
    transition: all 450ms cubic-bezier(0.23, 1, 0.32, 1) 0ms;
    // transform-origin: left top 0px; // kill mobile fullscreen fix position
    // transform: scale(1, 1) translate(0px, 0px);
    border-radius: 4px;

    -webkit-tap-highlight-color: rgba(0, 0, 0, 0);

    &:not(.no-padding)
    {
      padding: $layer-padding;
    }

    .close
    {
      z-index: 1;
      position: absolute;
      top: $layer-padding;
      right: $layer-padding;
      cursor: pointer;

      width: $layer-padding * 2;
      height: $layer-padding * 2;

      svg path
      {
        fill: black;
      }

      @include respond-to(desktop)
      {
        border-radius: 100%;
        background-color: rgba(0,0,0,0.2);

        svg
        {
          transform: scale(.8);

          path
          {
            fill: white;
          }
        }
      }

    }
  }


  &.no-padding .container
  {
    padding: 0;
  }

  &:not(.active)
  {
    display: none;
  }

  &:not(.closeable),
  &.no-close,
  {
    .close
    {
      display: none;
    }
  }

  &.bordered
  {
    .container
    {
      box-shadow: 0 2px 6px rgba(0,0,0,0.15), 0 0 0 1px rgba(0,0,0,0.07);
      border-radius: 3px;
    }
  }

  // Methods

  @include respond-to(desktop)
  {
    &.dialog
    {
      justify-content: center;
      align-items: center;

      .container
      {
        background: white;
        // width: 75%;
        min-width: 20%;
        // max-width: 768px;
        max-width: fit-content;
        max-height: 90vh;
        overflow-y: scroll;
        overflow-x: hidden;

        -ms-overflow-style: none;  // IE 10+
        overflow: -moz-scrollbars-none;  // Firefox

        &::-webkit-scrollbar
        {
          display: none;
        }
      }

      &.narrow
      {
        .container
        {
          width: 450px;
        }
      }

      &.window
      {
        .container
        {
          padding: 0;
          background-color: $gray-light;
        }

        .title
        {
          margin: 0;
          text-align: left;
          padding: $layer-padding;
          text-transform: uppercase;
          font-size: calc($layer-padding / 3) * 2;
          background: $yellow;

          svg
          {
            height: 1.2rem;
            margin-right: 0.5rem;
          }

        }

        .close
        {
          background-color: white;

          svg path
          {
            fill: $yellow;
          }
        }
      }

      &:not(.active)
      {
        .container
        {
          transform: translate(0px, -30%);
        }
      }
    }
  }

  @include respond-to(mobile)
  {
    &.dialog
    {
      background: white;

      .container
      {
        position: inherit;
        width: 100%;

        overflow-y: auto;
        height: 100%;

        .content
        {
          width: 100%;
        }
      }

      &.centered
      {
        .container
        {
          height: 100vh;
          display: flex;
          justify-content: center;
          align-items: center;
        }
      }
    }
  }

  &.fullscreen
  {
    background: white;

    .container
    {
      position: inherit;
      width: 100%;

      overflow-y: auto;
      height: 100%;
      border-radius: 0;

      .content
      {
        width: 100%;
      }
    }

    &.centered
    {
      .container
      {
        height: 100vh;
        display: flex;
        justify-content: center;
        align-items: center;
      }
    }
  }

  &.popover
  {
    justify-content: center;
    align-items: center;

    background-color: rgba(0, 0, 0, 0);
    position: absolute;

    .container
    {
      background: white;
      position: absolute;
      border-radius: 4px;
      box-shadow: 0px 2px 16px 0px $gray-light;

      overflow-y: auto;
      max-height: 80vh;
      height: fit-content;
      // left: 0px;

    }
  }

  &.tooltip
  {
    .container .content
    {
      width: max-content;
    }

    &:not(.closeable) .close
    {
      display: none;
    }
  }

  &.dialog
  {
    .container
    {
      border-radius: 4px;
      box-shadow: 0px 2px 16px 0px $gray-dark;

      @include respond-to(mobile)
      {
        border-radius: 0;
        box-shadow: none;
        border: 0;
      }

      display: flex;
      flex-grow: 1;

      .content
      {
        display: flex;
        flex-grow: 1;
      }
    }
  }

  &.sidebar
  {
    .container
    {
      border-radius: 0;
      height: 100vh;
      max-height: 100vh;
      min-width: auto;
      transform: translateX(0%);
      transition: transform 300ms ease-in 0s;
      left: 100%;

      .content
      {
        max-height: 100%;
        overflow-y: scroll;
      }
    }

    &.show .container
    {
      transform: translateX(-100%);
    }

    &.left
    {
      .container
      {
        left: 0%;
        transform: translateX(-100%);
      }

      &.show .container
      {
        transform: translateX(0%);
      }
    }
  }

  &.preload
  {
    background: none;
    cursor: progress;

    .container
    {
      background: none;
      width: auto;
      position: absolute;
      transition: none;
      padding: 0;

      top: 50vh;
      left: 50vw;
      transform: translate(-50%, -50%);
    }
  }
}

body.layer-fullscreen
{
  padding: 0;
  margin: 0;
  overflow: visible;
  height: auto;
  background-color: white;

  .application
  {
    padding: 0;
    margin: 0;

    > *:not(.layer)
    {
      display: none !important;
    }

    .layer
    {
      position: static;
      overflow: visible;
      // height: 100%;
    }
  }
}

@include respond-to(mobile)
{
  body.layer-dialog
  {
    padding: 0;
    margin: 0;
    overflow: visible;
    height: auto;
    background-color: white;

    .application
    {
      padding: 0;
      margin: 0;

      > *:not(.layer)
      {
        display: none !important;
      }

      .layer
      {
        position: static;
        overflow: visible;
        height: auto;
      }
    }
  }
}
