@import "bourbon/dist/bourbon";
@import "mixins";

@import "cards/amex";
@import "cards/discover";
@import "cards/visa";
@import "cards/mastercard";

body {
    font-family: $card-font-family;

    & > *, & > *:before, & > *:after {
        -moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box;
        font-family: inherit;
    }
}

.card-container {
    @include perspective(1000px);
    width: $card-width;
    height: $card-height;
    margin: auto;
    z-index: 1;
    position: relative;
}

.card {
    position: relative;
    width: 100%;
    height: 100%;
    border-radius: $card-border-radius;

    @include transform-style(preserve-3d);
    @include transition(all $card-transition-time linear);

    &.flipped {
        @include transform(rotateY(180deg));
    }

    .front, .back {
        @include backface-visibility(hidden);
        @include transform-style(preserve-3d);
        @include transition(all $card-transition-time linear);
        width: 100%;
        height: 100%;
        position: absolute;
        top: 0;
        left: 0;
        overflow: hidden;
        border-radius: $card-border-radius;
        background: #DDD;

        &:before {
            @include shape();
            position: absolute;
            width: 100%;
            height: 100%;
            top: 0;
            left: 0;
            opacity: 0;
            border-radius: 10px;
            @include transition(all $card-transition-time ease);
        }

        &:after {
            @include shape();
        }

        .display {
            color: $card-font-color;
            font-weight: normal;
            opacity: 0.5;
            @include transition(opacity $card-transition-time linear);
            &.focused {
                opacity: 1;
                font-weight: 700;
                &.valid {}
            }
        }

        .cvc {
            font-family: $card-monospace-font-family;
            font-size: 14px;
        }

        .shiny {
            $color: #CCC;
            $radius: 5px;
            width: 50px;
            height: 35px;
            border-radius: $radius;
            background: $color;
            position: relative;
            &:before {
                @include shape();
                $height: 60%;
                width: 70%;
                height: $height;
                border-top-right-radius: $radius;
                border-bottom-right-radius: $radius;                    background: lighten($color, 5%);
                position: absolute;
                top: (100% - $height) / 2
            }
        }
    }

    .front {

        .logo{
            position: absolute;
            opacity: 0;
            right: 5%;
            top: 8%;
            @include transition($card-transition-time);
        }

        .lower {
            $width: 80%;
            width: $width;
            position: absolute;
            left: (100% - $width) / 2;
            bottom: 30px;

            .cvc {
                visibility: hidden;
                float: right;
                position: relative;
                bottom: 5px;
            }

            .number {
                font-family: $card-monospace-font-family;
                font-size: 24px;
                clear: both;
                margin-bottom: 30px;
            }

            .expiry {
                font-family: $card-monospace-font-family;
                $label-padding: 5px;
                letter-spacing: 0em;
                position: relative;
                float: right;
                width: 20%;

                &:before, &:after {
                    font-family: $card-font-family;
                    font-weight: bold;
                    font-size: 7px;
                    white-space: pre;
                    display: block;
                    opacity: .5;
                }

                &:before {
                    content: "month/year";
                    margin-bottom: $label-padding - 3px;
                    font-size: 7px;
                    text-transform: uppercase;
                }

                &:after {
                    position: absolute;
                    content: "valid\Athru";
                    text-align: right;
                    right: 100%;
                    margin-right: $label-padding;
                    margin-top: 2px;
                    bottom: 0;
                }
            }

            .name {
                text-transform: uppercase;
                font-family: $card-monospace-font-family;
                font-size: 20px;
                position: absolute;
                bottom: 0;
                width: 190px;
            }
        }
    }

    .back {
        @include transform(rotateY(180deg));
        $bar-top-offset: 40%;
        $signature-height: 16%;
        $signature-left: 2%;

        .bar {
            @include linear-gradient(#444, #333);
            width: 100%;
            height: 20%;
            position: absolute;
            top: 10%;
        }

        &:after {
            @include shape();
            @include linear-gradient(#FFF, #FFF);
            width: 80%;
            height: $signature-height;
            position: absolute;
            top: $bar-top-offset;
            left: $signature-left;
        }

        .cvc {
            position: absolute;
            top: $bar-top-offset;
            left: 85%;
            @include transition-delay($card-transition-time + 200ms);
        }

        .shiny {
            position: absolute;
            top: $bar-top-offset + $signature-height + 10%;
            left: $signature-left;

            &:after {
                content: "This card has been issued by Jesse Pollak and is licensed for anyone to use anywhere for free.\AIt comes with no warranty.\A For support issues, please visit: github.com/jessepollak/card.";
                position: absolute;
                left: 120%;
                top: 5%;
                color: white;
                font-size: 7px;
                width: 230px;
                opacity: .5;
            }
        }
    }

    &.identified {
        box-shadow: 0 0 20px rgba(0,0,0,0.3);

        .front, .back {
            &:before {
                @include transition(all $card-transition-time ease);
                @include card-texture();
                opacity: 1;
                // box-shadow: inset 0 0 5px rgba(255,255,255,1);
            }

            .logo {
                box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.3);
            }
        }

        &.no-radial-gradient {
            .front, .back {
                &:before {
                    @include card-texture($radial-gradient: false);
                }
            }
        }
    }
}
