// Name:            Transition
// Description:     Utilities for transitions
//
// Component:       `uk-transition-*`
//
// Modifiers:       `uk-transition-fade`
//                  `uk-transition-scale-up`
//                  `uk-transition-scale-down`
//                  `uk-transition-slide-top-*`
//                  `uk-transition-slide-bottom-*`
//                  `uk-transition-slide-left-*`
//                  `uk-transition-slide-right-*`
//                  `uk-transition-opaque`
//                  `uk-transition-slow`
//
// Sub-objects:     `uk-transition-toggle`,
//                  `uk-transition-active`
//
// States:          `uk-active`
//
// ========================================================================


// Variables
// ========================================================================

$transition-duration:                            0.3s !default;

$transition-scale:                               1.1 !default;

$transition-slide-small-translate:               10px !default;
$transition-slide-medium-translate:              50px !default;

$transition-slow-duration:                       0.7s !default;


/* ========================================================================
   Component: Transition
 ========================================================================== */


/* Toggle (Hover + Focus)
 ========================================================================== */

/*
 * 1. Prevent tab highlighting on iOS.
 */

.uk-transition-toggle {
    /* 1 */
    -webkit-tap-highlight-color: transparent;
}

/*
 * Remove outline for `tabindex`
 */

.uk-transition-toggle:focus { outline: none; }


/* Transitions
 ========================================================================== */

/*
 * The toggle is triggered on touch devices by two methods:
 * 1. Using `:focus` and tabindex
 * 2. Using `:hover` and a `touchstart` event listener registered on the document
 *    (Doesn't work on Surface touch devices)
 *
 * Note: Transitions don't work with `uk-postion-center-*` classes because they also use `transform`,
 *       therefore it's recommended to use an extra `div` for the transition.
 */

.uk-transition-fade,
[class*='uk-transition-scale'],
[class*='uk-transition-slide'] {
    transition: $transition-duration ease-out;
    transition-property: opacity, transform, filter;
    opacity: 0;
}

/*
 * Fade
 */

.uk-transition-toggle:hover .uk-transition-fade,
.uk-transition-toggle:focus .uk-transition-fade,
.uk-transition-active.uk-active .uk-transition-fade { opacity: 1; }

/*
 * Scale
 */

.uk-transition-scale-up { transform: scale(1,1); }
.uk-transition-scale-down { transform: scale($transition-scale,$transition-scale); }

/* Show */
.uk-transition-toggle:hover .uk-transition-scale-up,
.uk-transition-toggle:focus .uk-transition-scale-up,
.uk-transition-active.uk-active .uk-transition-scale-up {
    opacity: 1;
    transform: scale($transition-scale,$transition-scale);
}

.uk-transition-toggle:hover .uk-transition-scale-down,
.uk-transition-toggle:focus .uk-transition-scale-down,
.uk-transition-active.uk-active .uk-transition-scale-down {
    opacity: 1;
    transform: scale(1,1);
}

/*
 * Slide
 */

.uk-transition-slide-top { transform: translateY(-100%); }
.uk-transition-slide-bottom { transform: translateY(100%); }
.uk-transition-slide-left { transform: translateX(-100%); }
.uk-transition-slide-right { transform: translateX(100%); }

.uk-transition-slide-top-small { transform: translateY(-$transition-slide-small-translate); }
.uk-transition-slide-bottom-small { transform: translateY($transition-slide-small-translate); }
.uk-transition-slide-left-small { transform: translateX(-$transition-slide-small-translate); }
.uk-transition-slide-right-small { transform: translateX($transition-slide-small-translate); }

.uk-transition-slide-top-medium { transform: translateY(-$transition-slide-medium-translate); }
.uk-transition-slide-bottom-medium { transform: translateY($transition-slide-medium-translate); }
.uk-transition-slide-left-medium { transform: translateX(-$transition-slide-medium-translate); }
.uk-transition-slide-right-medium { transform: translateX($transition-slide-medium-translate); }

/* Show */
.uk-transition-toggle:hover [class*='uk-transition-slide'],
.uk-transition-toggle:focus [class*='uk-transition-slide'],
.uk-transition-active.uk-active [class*='uk-transition-slide'] {
    opacity: 1;
    transform: translate(0,0);
}


/* Opacity modifier
 ========================================================================== */

.uk-transition-opaque { opacity: 1; }


/* Duration modifiers
 ========================================================================== */

.uk-transition-slow { transition-duration: $transition-slow-duration; }


// Hooks
// ========================================================================

@if(mixin-exists(hook-transition-misc)) {@include hook-transition-misc();}

// @mixin hook-transition-misc(){}
