//
// Imports
//

// Project Variables
@import "fc-variables";

// Project Mixins
@import "mixins";

// Flipclock Base Styles
// @import "fc-base";

// Theme Styles
@import "theme-default";

.flip-clock {
    font-family: $fc-font-family;
    font-size: 16px;
    -webkit-user-select: none;
    text-align: center;
    position: relative;
    width: 100%;
    display: inline-flex;
    font-size: 1vw;
    font-family: "Helvetica Neue", Helvetica, sans-serif;
    box-sizing: border-box;
    align-items: flex-end;
    animation-duration: 500ms;

    .flip-clock-group {
        display: flex;

        .flip-clock-label {
            font-size: .875em;
            height: 2em;
            line-height: 2em;
        }

        .flip-clock-list {
            width: $fc-face-width;
            height: $fc-face-height;
            background: $fc-face-background;
            position: relative;
            border-radius: .75rem;
            margin: 0 .125em;
            @include material-shadow(1);
            font-weight: bold;
            color: $fc-face-color;

            &:not(.flip) {
                .flip-clock-list-item-inner {
                    &.active {
                        z-index: 4;
                    }

                    .top,
                    .bottom {
                        &:after {
                            display: none;
                        }
                    }
                }
            }

            &.flip {
                animation-delay: 500ms;
                animation-duration: 500ms;

                .before {
                    animation-delay: 0s;
                }


                .before {
                    .top {
                        animation: flip-top .5s linear both;

                        &:after {
                            animation: show-shadow .5s linear both;
                        }
                    }

                    .bottom {
                        &:after {
                            animation: show-shadow .5s linear both;
                        }
                    }
                }

                .top,
                .bottom,
                .active,
                & > div {
                    animation-delay: inherit;
                    animation-duration: inherit;
                    animation-fill-mode: both;
                    animation-timing-function: linear;

                    &:after {
                        animation-duration: inherit;
                        animation-fill-mode: inherit;
                        animation-timing-function: inherit;
                    }
                }

                /*
                .top,
                .top:after,
                .bottom,
                .bottom:after,
                .active {
                    animation-duration: 500ms;
                    animation-fill-mode: both;
                    animation-timing-function: linear;
                }
                */

                .before {
                    .top {
                        animation-name: flip-top;
                    }

                    .top:after,
                    .bottom:after {
                        animation-name: show-shadow;
                    }
                }

                .active {
                    animation-name: indexing;

                    .top:after,
                    .bottom:after {
                        animation-delay: calc(inherit * .15);
                        animation-name: hide-shadow;
                    }

                    .bottom {
                        animation-name: flip-bottom;
                    }
                }

                /*
                .before {
                    .top {
                        animation: flip-top .5s linear both;

                        &:after {
                            animation: show-shadow .5s linear both;
                        }
                    }

                    .bottom {
                        &:after {
                            animation: show-shadow .5s linear both;
                        }
                    }
                }
                .active {
                    //animation: indexing .5s .5s linear both;

                    .top {
                        &:after {
                            //animation: hide-shadow .5s (.5s * .15) linear both;
                        }
                    }

                    .bottom {
                        //animation: flip-bottom .5s .5s linear both;

                        &:after {
                            //animation: hide-shadow .5s (.5s * .15) linear both;
                        }
                    }
                }
                */
            }

            .flip-clock-list-item-inner {
                position: absolute;
                width: 100%;
                height: 100%;
                perspective: 15em;

                &:first-child {
                    z-index: 2;
                }

                &.before {
                    z-index: 3;

                    .top {
                        z-index: 2;
                        transform-origin: bottom center;

                        &:after {
                            background: linear-gradient(to bottom, rgba($fc-flip-shadow-color,.1) 0%, rgba($fc-flip-shadow-color,1) 100%);
                        }
                    }

                    .bottom {
                        &:after {
                            background: linear-gradient(to bottom, rgba($fc-flip-shadow-color,1) 0%, rgba($fc-flip-shadow-color,.1) 100%);
                        }
                    }
                }

                &.active {
                    z-index: 2;

                    .top {
                        &:after {
                            background: linear-gradient(to bottom, rgba($fc-flip-shadow-color,.1) 0%, rgba($fc-flip-shadow-color,1) 100%);
                        }
                    }

                    .bottom {
                        z-index: 2;
                        transform-origin: top center;

                        &:after {
                            background: linear-gradient(to bottom, rgba($fc-flip-shadow-color,1) 0%, rgba($fc-flip-shadow-color,.1) 100%);
                        }
                    }
                }

                > .top,
                > .bottom {
                    width: 100%;
                    height: 50%;
                    overflow: hidden;
                    position: relative;
                    backface-visibility: hidden;
                    font-size: $fc-face-font-size;
                    background: $fc-face-background;
                    box-shadow: inset 0 0 .2em rgba(#000,.5);

                    &:after {
                        content: " ";
                        display: block;
                        position: absolute;
                        top: 0;
                        right: 0;
                        bottom: 0;
                        left: 0;
                        overflow: hidden;
                    }

                    &:before {
                        content: " ";
                        display: block;
                        width: 100%;
                        height: 1px;
                        position: absolute;
                    }
                }

                .top {
                    border-radius: .75rem .75rem 0 0;
                    line-height: $fc-face-height/$fc-face-font-size;

                    &:after {
                        border-radius: .75rem .75rem 0 0;
                    }

                    &:before {
                        background: $fc-face-background;
                        opacity: .4;
                        bottom: 0;
                    }
                }

                .bottom {
                    border-radius: 0 0 .75rem .75rem;
                    line-height: 0;

                    &:after {
                        border-radius: 0 0 .75rem .75rem;
                    }

                    &:before {
                        background: $fc-face-color;
                        opacity: .1;
                    }
                }
            }
        }
    }

    .flip-clock-divider {
        position: relative;
        width: 1.5em;
        height: $fc-face-height;

        &:before,
        &:after {
            content: " ";
            display: block;
            width: .75em;
            height: .75em;
            background: $fc-face-background;
            border-radius: 50%;
            position: absolute;
            top: 50%;
            left: 50%;
        }

        &:before {
            transform: translate(-50%, 75%);
        }

        &:after {
            transform: translate(-50%, -175%);
        }

    }

}

@keyframes indexing {
    0% {
        z-index: 2;
    }
    1% {
        z-index: 4;
    }
    100% {
        z-index: 4;
    }
}

@keyframes flip-bottom {
    0% {
        transform: rotateX(90deg);
    }
    100% {
        transform: rotateX(0deg);
    }
}

@keyframes flip-top {
    0% {
        transform: rotateX(0deg);
    }
    100% {
        transform: rotateX(-90deg);
    }
}

@keyframes show-shadow {
    0% {
        opacity: 0;
    }
    100% {
        opacity: 1;
    }
}

@keyframes hide-shadow {
    0% {
        opacity: 1;
    }
    100% {
        opacity: 0;
    }
}
