//
// Imports
//

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

// Project Mixins
@import "mixins";

.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;

    .flip-clock-group {
        display: flex;
        position: relative;

        .flip-clock-label {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            font-size: 1em;
            height: 2em;
            line-height: 2em;
            font-weight: 400;
            text-transform: capitalize;
            transform: translateY(-100%);

            &.flip-clock-meridium {
                font-size: 1.75em;
                line-height: 1.75em;
                top: 50%;
                left: 100%;
                flex: 0;
                width: auto;
                text-transform: uppercase;
                font-weight: 200;
                transform: translate(.5em, -50%);
            }
        }

        .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) {
                .active .flip-clock-list-item-inner {
                    z-index: 4;
                }

                .flip-clock-list-item-inner {
                    .top,
                    .bottom {
                        &:after {
                            display: none;
                        }
                    }
                }
            }

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

                .top,
                .bottom,
                .active,
                .active > div,
                .before,
                .before > 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;
                    }
                }

                .before {
                    animation-delay: 0s;

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

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

                .active {
                    & > div {
                        animation-name: indexing;
                    }

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

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


            .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%);
                    }
                }
            }

            .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%);
                    }
                }
            }

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

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

                > .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;
    }
}
