$standard: 400px;
$wide: 50vw;
$tall: 50vh;
$ease: cubic-bezier(.3, 0, 0, 1);

.hk-slide-panel-overlay {
  z-index: 100;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  overflow: hidden;
  opacity: 0;
  background: transparent;
  transition: .4s $ease;

  &.is-visible {
    opacity: 1;
    background: rgba(#596981, 0.20);
  }
}

.hk-slide-panel-container {
  overflow-y: hidden;

  /* Smartphones (portrait and landscape) ----------- */
  @media only screen and (min-device-width : 320px) and (max-device-width : 480px) {
    width: calc(100% - 20px);
  }

  /* iPads/Desktop (portrait and landscape) ----------- */
  @media only screen and (min-device-width : 768px) {
    min-width: $standard;
  }

  min-height: 200px;
  transition-delay: .2s;
  transition: transform .4s $ease;

  &.from-left,
  &.from-right {
    top: 0;
    height: calc(100% - 20px);
    /* Smartphones (portrait and landscape) ----------- */
    @media only screen and (min-device-width : 320px) and (max-device-width : 480px) {
      width: calc(100% - 20px);
    }
    /* iPads/Desktop (portrait and landscape) ----------- */
    @media only screen and (min-device-width : 768px) {
      width: $standard;
    }
    /* iPads/Desktop (portrait only) ----------- */
    @media only screen and (min-device-width : 768px) and (orientation:portrait) {
      max-height: 1050px;
    }

    &.large {
      /* iPads/Desktop (portrait and landscape) ----------- */
      @media only screen and (min-device-width : 768px) {
        width: $wide;
      }
    }
  }

  &.from-left {
    left: 0;
    transform: translateX(-$standard);

    &.large {
      transform: translateX(-$wide);
    }

    .is-visible & {
      transform: translateX(0);

      .large {
        transform: translateX(0);
      }
    }
  }

  &.from-right {
    right: 0;
    transform: translateX($standard);

    &.large {
      transform: translateX($wide);
    }

    .is-visible & {
      transform: translateX(0);

      .large {
        transform: translateX(0);
      }
    }
  }

  &.from-bottom,
  &.from-top {
    left: 0;
    right: 0;
    /* Smartphones (portrait and landscape) ----------- */
    @media only screen and (min-device-width : 320px) and (max-device-width : 480px) {
      height: 100%;
    }
    /* iPads/Desktop (portrait and landscape) ----------- */
    @media only screen and (min-device-width : 768px) {
      height: $standard;
    }

    &.large {
      /* iPads/Desktop (portrait and landscape) ----------- */
      @media only screen and (min-device-width : 768px) {
        height: $tall;
        min-height: $standard;
      }
    }
  }

  &.from-bottom {
    bottom: 0;
    transform: translateY($standard);

    &.large {
      transform: translateY($tall);
    }

    .is-visible & {
      transform: translateY(0);

      .large {
        transform: translateY(0);
      }
    }
  }

  &.from-top {
    top: 0;
    transform: translateY(-$standard);

    &.large {
      transform: translateY(-$tall);
    }

    .is-visible & {
      transform: translateY(0);

      .large {
        transform: translateY(0);
      }
    }
  }
}

.hk-slide-panel-header,
.hk-slide-panel-footer {
  overflow: hidden;
  min-height: 51px;
  flex: 0 0 auto;
}

.hk-slide-panel-content {
  flex: 1;
  // Effect taken from
  // http://lea.verou.me/2012/04/background-attachment-local/
  background:
		/* Shadow covers */
		linear-gradient(white 30%, rgba(255,255,255,0)),
		linear-gradient(rgba(255,255,255,0), white 70%) 0 100%,
		
		/* Shadows */
		radial-gradient(50% 0, farthest-side, rgba(0,0,0,.1), rgba(0,0,0,0)),
		radial-gradient(50% 100%,farthest-side, rgba(0,0,0,.1), rgba(0,0,0,0)) 0 100%;
	background:
		/* Shadow covers */
		linear-gradient(white 30%, rgba(255,255,255,0)),
		linear-gradient(rgba(255,255,255,0), white 70%) 0 100%,
		
		/* Shadows */
		radial-gradient(farthest-side at 50% 0, rgba(0,0,0,.1), rgba(0,0,0,0)),
		radial-gradient(farthest-side at 50% 100%, rgba(0,0,0,.1), rgba(0,0,0,0)) 0 100%;
	background-repeat: no-repeat;
	background-color: white;
	background-size: 100% 40px, 100% 40px, 100% 14px, 100% 14px;
	
	/* Opera doesn't support this in the shorthand */
	background-attachment: local, local, scroll, scroll;
}

.slide-panel-shadow-cover-top {
  flex-basis: 10px;
  flex-shrink: 0;
  flex-grow: 0;
  height: 10px;
  width: 100%;
  background: linear-gradient(#FFFFFF 30%, rgba(255, 255, 255, 0)) 100% 0;
  background-size: 100% 12px;
  background-repeat: no-repeat;
  pointer-events: none;
}

.slide-panel-shadow-cover-bottom {
  flex-basis: 10px;
  flex-shrink: 0;
  flex-grow: 0;
  height: 10px;
  width: 100%;
  background: linear-gradient(rgba(255, 255, 255, 0), #FFFFFF 70%) 0 100%;
  background-size: 100% 12px;
  background-repeat: no-repeat;
  pointer-events: none;
}

body.panel-is-visible {
  // allows iOS to keep momentum scrolling even when you touch an input inside
  // a slide panel.
  -webkit-overflow-scrolling: touch;
  overflow: hidden;
}

.hk-slide-panel-container.from-bottom,
.hk-slide-panel-container.from-top {

  .hk-slide-panel-content {
    height: calc(100% - 40px);
  }

  .hk-slide-panel-header,
  .hk-slide-panel-footer {
    min-height: 40px;
  }
}

@keyframes hk-fade-in {
  from { opacity: 0 }
  to { opacity: 1 }
}

@keyframes hk-fade-out {
  from { opacity: 1 }
  to { opacity: 0 }
}

@keyframes hk-slide-up {
  from { transform: translateY(calc(100% + 8px)) }
  to { transform: translateY(0%) }
}

@keyframes hk-slide-down {
  from { transform: translateY(0%) }
  to { transform: translateY(calc(100% + 8px)) }
}

.hk-slide-panel-breakout-overlay {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 100;
  background: rgba(#596981, 0.15);
  animation: .3s $ease both hk-fade-in;
}

.hk-slide-panel-breakout-content {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 100;
  background: white;
  animation: .3s $ease .1s both hk-slide-up;
}

.hk-slide-panel-breakout[hidden] {
  display: block;

  .hk-slide-panel-breakout-overlay {
    animation: .3s $ease both hk-fade-out;
  }
  .hk-slide-panel-breakout-content {
    animation: .3s $ease both hk-slide-down;
  }
}
