$tb-swiper-slide-image-height: 305px !default;
$tb-swiper-navigation-icon-size: 42px !default;

/**
* Swiper 4.3.3 (Customized)
* Most modern mobile touch slider and framework with hardware accelerated transitions
* http://www.idangero.us/swiper/
*
* Copyright 2014-2018 Vladimir Kharlampidi
*
* Released under the MIT License
*
* Released on: January 13, 2018
*/

/**
 * NOTE
 *
 * This includes modifier styles which should probably be
 * refactored into separate themes and/or applied via configuration.
 */


/*
 * BASE STYLES
 */

.tb-swiper {
    position: relative;
    width: 100%;
}

.tb-swiper__container {
    margin: 0 auto;
    position: relative;
    overflow: hidden;
    list-style: none;
    padding: 0;
    padding-bottom: theme('padding.1');
    z-index: 1;

    &.js-animation--limit-shake {
        animation: .3s ease limitShake;
    }
}

@keyframes limitShake {
    0%,
    100% {
        transform: translateX(0);
    }

    20%,
    60% {
        transform: translateX(8px);
    }

    40%,
    80%  {
        transform: translateX(-8px);
    }
}

.tb-swiper__wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    z-index: 1;
    display: flex;
    transition-property: transform;
    box-sizing: content-box;
    justify-content: space-between;
    min-height: $tb-swiper-slide-image-height;
}

.tb-swiper-android .tb-swiper__slide,
.tb-swiper__wrapper {
    transform: translate3d(0, 0, 0);
}

.tb-swiper__slide {
    flex-shrink: 0;
    width: 100%;
    position: relative;
    transition-property: transform;
}

.tb-swiper__image,
.tb-swiper__slide-img,
.tb-swiper__lazy-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: opacity 300ms ease;
}

.tb-swiper__image,
.tb-swiper__slide-img,
.tb-swiper__lazy-image,
.c-video {
    height: $tb-swiper-slide-image-height;
}

.tb-swiper__slide:hover .tb-swiper__slide-img,
.tb-swiper__slide:hover .tb-swiper__lazy-image {
    opacity: .9;
}

.tb-swiper__video-icon {
    font-size: 4rem;
    color: theme('colors.white');
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    margin: auto;
}

.tb-swiper-android .tb-swiper__slide,
.tb-swiper__wrapper {
    transform: translate3d(0, 0, 0);
}

/*
 * NAVIGATION
 */

.tb-swiper__navigation {
    position: absolute;
    top: calc(#{$tb-swiper-slide-image-height} / 2 - (#{$tb-swiper-navigation-icon-size} / 2));
    left: 0;
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 theme('padding.2');
}

.tb-swiper--circle-nav-buttons .tb-swiper__navigation {
    height: auto;
    top: 35%;
}

.tb-swiper__button {
    z-index: 2;
}

/**
 * Until this is refactored, we need to set this font size using magic numbers.
 * Currently, this is required for always keeping the navigation vertically centered.
 */
.tb-swiper__button-icon {
    font-size: $tb-swiper-navigation-icon-size;
}

// reset c-icon top offset so its vertically centered
.c-icon.tb-swiper__button-icon {
    top: 0;
}

/**
 * Because we use a button we can't use display flex on it,
 * so we wrap the button content inside a span.
 */
.tb-swiper__button span {
    display: flex;
    align-items: center;
    justify-content: center;
    color: theme('colors.white');
    filter: drop-shadow( 0 0 3px rgba(0, 0, 0, .25) );
}

.tb-swiper--circle-nav-buttons .tb-swiper__button span {
    background-color: theme('colors.white');
    border: 1px solid theme('colors.gray.100');
    color: theme('colors.gray.900');
    border-radius: 50%;
    padding: theme('padding.3');
}

// This could be refactored into a swiper theme.
.tb-swiper--circle-nav-buttons .tb-swiper__button {
    position: relative;
}

.tb-swiper--circle-nav-buttons .tb-swiper__button--prev {
    left: -2rem;

    @include mappy-bp(max lg) {
        left: -1rem;
    }
}

.tb-swiper--circle-nav-buttons .tb-swiper__button--next {
    right: -2rem;

    @include mappy-bp(max lg) {
        right: -1rem;
    }
}

// Positional correction to have a visually centered icon
.tb-swiper--circle-nav-buttons .tb-swiper__button--prev .tb-swiper__button-icon {
    left: -2px;
}

.tb-swiper--circle-nav-buttons .tb-swiper__button--next .tb-swiper__button-icon {
    right: -2px;
}

.tb-swiper--circle-nav-buttons .tb-swiper__button-icon {
    font-size: theme('fontSize.xl');
}

.tb-swiper__button.tb-swiper__button--disabled {
    opacity: .35;
    cursor: disabled;
}

.tb-swiper--circle-nav-buttons {
    .tb-swiper__button--prev.tb-swiper__button--disabled,
    .tb-swiper__button--next.tb-swiper__button--disabled {
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
    }
}

/*
 * PAGINATION
 */

.tb-swiper__pagination {
    position: relative;
    z-index: 1;
    text-align: center;
    padding-top: 1em;
}

.swiper-pagination-bullet {
    display: inline-block;
    margin: 0 .3em;
    height: 1em;
    width: 1em;
    background-color: theme('colors.gray.400');
    border-radius: 50%;
}

.swiper-pagination-bullet-active {
    background-color: theme('colors.secondary.500');
}

/*
 * LAZY LOADING
 */

// Lazy-loading slide
.tb-swiper__lazy-image {
    &.tb-swiper__lazy-image--loading {
        opacity: 0;
        transition: 300ms opacity ease;
    }

    &.tb-swiper__lazy-image--loaded {
        opacity: 1;
    }
}

// Load spinner
.tb-swiper__lazy-preloader {
    display: block;
}

.tb-swiper__lazy-preloader .c-icon {
    animation: swiper-preloader-spin 1s linear infinite;
    font-size: 2rem;
    color: theme('colors.black');
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    margin: auto;
}

@keyframes swiper-preloader-spin {
    100% {
        transform: rotate(360deg);
    }
}

/*
 * A11Y
 */

.tb-swiper .tb-swiper__notification {
    position: absolute;
    left: 0;
    top: 0;
    pointer-events: none;
    opacity: 0;
    z-index: -1;
}

/*
 * FIXES
 */

/* IE10 Windows Phone 8 Fixes */
.tb-swiper-wp8-horizontal,
.tb-swiper-wp8-horizontal > .tb-swiper__wrapper {
    touch-action: pan-y;
}

.tb-swiper-wp8-vertical,
.tb-swiper-wp8-vertical > .tb-swiper__wrapper {
    touch-action: pan-x;
}

/* Hide controls and show stacked images when JavaScript is not available */
.no-js {
    .tb-swiper__lazy-preloader,
    .tb-swiper__button--next,
    .tb-swiper__button--prev,
    .tb-swiper__lazy-image,
    .tb-swiper__lazy-preloader {
        display: none;
    }

    .tb-swiper__wrapper {
        @include mappy-bp(xs) {
            @apply .-mx-2; // keep @apply here for now, using negative margins with tailwinds config() function is not working well
            list-style: none;
            display: flex;
            justify-content: flex-start;
            padding: 0;
            overflow-x: scroll;
            flex-wrap: nowrap;
        }
    }

    .tb-swiper__slide {
        flex-shrink: 0;
        margin-bottom: theme('margin.4');
        padding-left: theme('padding.2');
        padding-right: theme('padding.2');
        width: 100%;

        @include mappy-bp(max xs) {
            padding-left: 0;
            padding-right: 0;
        }

        @include mappy-bp(xs) {
            width: 50%;
        }

        @include mappy-bp(md) {
            width: 25%;
        }
    }
}
