@import "settings.breakpoints";
@import "settings.colors";
@import "settings.vars";
@import "settings.z-index";

@import "mixins/tools.mixins";
@import "mixins/components.article-photo-slider";

$c-photo-slider-ease: cubic-bezier(0.215, 0.61, 0.355, 1);

.c-contain-slider {
  display: block;
  position: relative;
  margin: 0 auto;
}

// Used for ratio contained inpage slider
.c-contain-slider--ratio-3-2  {
  @include c-photo-slider-inpage(3, 2); // 3:2 ratio
}

.c-photo-slider {
  background-color: $color-grey-800;

  // this is width similiar to gallery page (but not article page)
  .c-share-tools {
    margin-left: auto;
    margin-right: auto;
    max-width: $break-mobile-wide;
  }
  // this contains the displayed media info
  .c-photo-slider__caption {
    opacity: 0;
  }
  // this media info is hidden from display, but still accessible for screen readers
  .c-article-media--overlay {
    .c-article-media__info {
      display: none;
    }
  }
}

.c-photo-slider--has-info {
  .c-photo-slider__caption {
    opacity: 1;
  }
}

// modal dialog full viewport slider
.c-photo-slider--full {
  position: absolute;
  width: 100%;
  height: 100%;
  z-index: 1;

  .c-photo-slider__nav--left,
  .c-photo-slider__nav--right {
    width: 20%;
  }
  .c-photo-slider__caption {
    position: absolute;
    bottom: 0;
  }
  .c-article-media__info {
    background: rgba($color-stone-100, 0.8);
  }
  .c-article-media__info--dark {
    background: rgba($color-grey-900, 0.8);
  }
  .c-photo-slider__caption {
    z-index: 4;
  }
}

// article in-page contained slider
.c-photo-slider--contain {
  position: relative;
  z-index: 1;

  .c-photo-slider__nav--left {
    width: 20%;
  }
  .c-photo-slider__nav--right {
    width: 20%;
  }
  .c-photo-slider__caption {
    z-index: 4;
  }
}

.c-photo-slider__nav {
  position: absolute;
  display: none;
  margin: 0;
  padding: 0;
  top: 0;
  bottom: 0;
  cursor: pointer;

  &[disabled] {
    cursor: default;
  }
}

.c-photo-slider--has-nav {
  .c-photo-slider__nav {
    display: block;
  }
}

.c-photo-slider__nav--left {
  left: 0;
  text-align: left;
}

.c-photo-slider__nav--right {
  right: 0;
  text-align: right;
}

.c-photo-slider__nav-button {
  @include remove-button-appearance;
  display: block;
  position: absolute;
  top: calc(50% - #{rem($c-photo-slider-button-width / 2)});
  margin: 0;
  width: rem($c-photo-slider-button-width);
  height: rem($c-photo-slider-button-width);
  font-size: inherit;
  cursor: pointer;

  &[disabled] {
    cursor: default;
    opacity: 0.4;
  }
}

.c-photo-slider__nav-button--left {
  left: 0;
  .c-photo-slider__nav-icon {
    left: rem(($c-photo-slider-button-width / 4) - $c-photo-slider-button-offset);
  }
}

.c-photo-slider__nav-button--right {
  right: 0;
  .c-photo-slider__nav-icon {
    left: rem(($c-photo-slider-button-width / 4) + $c-photo-slider-button-offset);
  }
}

.c-photo-slider__nav-icon {
  width: rem($c-photo-slider-button-width / 2);
  height: rem($c-photo-slider-button-width / 2);
  fill: transparent;
  display: inline-block;
  vertical-align: middle;
  position: absolute;
  top: rem(12);
}

.c-photo-slider__canvas {
  width: 100%;
  height: 100%;
}

.c-photo-slider__list {
  pointer-events: none; // allow events to pass through to canvas or buttons
  position: absolute;
  top: 0;
  overflow: hidden;
  list-style: none;
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
}

.c-photo-slider__caption {
  pointer-events: none; // allow events to pass through to canvas or buttons
  width: 100%;
  transition: opacity 0.2s ease-in-out;
}

.c-photo-slider--has-share-tools {
  .c-photo-slider__nav {
    // don't overlay the share tools bar
    bottom: rem($c-share-tools-height);
  }
  .c-photo-slider__list {
    // make room for the share tools (interpolate the value)
    height: calc(100% - #{rem($c-share-tools-height)});
  }
  .c-photo-slider__caption {
    bottom: rem($c-share-tools-height);
  }
}

.c-photo-slider__item {
  position: absolute;
  top: 0;
  left: 0;
  opacity: 1;
  width: 100%;
  height: 100%;
  transition: transform 200ms $c-photo-slider-ease, opacity 200ms ease;
}

.c-photo-slider__share-tools {
  background-color: $c-share-tools-bg-color;
  position: absolute;
  width: 100%;
  bottom: 0;
}

// when a user rotates the viewport, the image and caption resize is less drastic
.c-photo-slider__item {
  .c-article-media__center {
    transition-property: width, opacity;
    transition-duration: 200ms, 400ms;
    transition-timing-function: $c-photo-slider-ease, ease;
  }
  .c-article-media__image--full-fit {
    .c-image {
      backface-visibility: hidden;
    }
  }
}

// show spinner when lazysizes is loading
// spinner will overlay placeholder src image
.c-photo-slider__item {
  .c-spinner-lg {
    position: absolute;
    top: calc(50% - 4rem);
    left: calc(50% - 4rem);
  }
  .js-lazyimage + .c-spinner-lg {
    display: block;
  }
  .js-lazyimage--loaded + .c-spinner-lg {
    display: none;
  }
}

.c-photo-slider__item-content {
  position: relative;
  width: 100%;
  height: 100%;
}

// don't lazysizes load image when hidden!
.c-photo-slider__item--photo.u-invisible {
  .js-lazyimage {
    display: none;
  }
}

// vertical/horizontal advertisement centering
.c-photo-slider__item--ad .c-photo-slider__item-content {
  display: flex;
  align-items: center;
  justify-content: center;
}
