// -------------------------
//  Personal menu.
// -------------------------

/* stylelint-disable declaration-no-important*/

#snap-pm {
    background-color: #eee;
    overflow-x: hidden; // Prevent scrollbars.
    display: none;

    @include media-breakpoint-up(md) {
        min-height: 100vh;
    }
}

#primary-nav {
    display: none;
}

body.snap-pm-open {
    background-color: #eee;
}

// -------------------------
//  Personal open and close.
// -------------------------
.snap-pm-open {

    #snap-pm {
        display: block;
    }

    #page,
    #moodle-footer,
    #mr-nav,
    #newmessageoverlay,
    .skiplinks {
        display: none;
    }

    // Animate opening the pm.
    #snap-pm-inner {
        /* stylelint-disable no-unknown-animations*/
        animation-name: snap-drop;
        /* stylelint-enable no-unknown-animations*/
        animation-iteration-count: once;
        animation-timing-function: ease-in-out;
        animation-duration: 0.3s;
    }
}

// -------------------------
//  Personal menu header.
// -------------------------
#snap-pm-header {
    padding: 2%;
    color: white;

    .userpicture {
        float: left;
        width: 5em;
        margin-right: 2%;
    }

    h1,
    a {
        color: white !important;
        padding-top: 0; // No top padding on close icon and links.
    }

    #snap-pm-header-quicklinks {
        a:after {
            content: '-';
            display: inline-block;
            margin: 0 .5em;
        }
        a:last-of-type:after {
            content: '';
        }
    }
}

// -------------------------
// Personal Menu as login form.
// -------------------------
.snap-pm-login-form {
    #snap-pm-content {
        width: 23em;
        margin: 2em auto;
    }
    label {
        font-weight: 300;
        letter-spacing: 0.03rem;
    }

    #snap-pm-login-help {
        position: fixed;
        bottom: 0;
        right: 2%;
    }
}

// -------------------------
//  Navigation to previous years courses.
// -------------------------
#snap-pm-courses-nav {
    border: none;
    // Reset bs styles.
    .nav-item {
        float: left;
    }
    .nav-link {
        background-color: transparent;
        border: none;
        padding: .5em;
    }
}


// -------------------------
//  Personal menu content.
// -------------------------
#snap-pm-content {
    padding: 2%;
    position: relative;

    // Headings for sections including updates.
    h2 {
        clear: both;
        font-size: 1rem;
        font-weight: 500;
        line-height: 1;
        padding: 0.5em 0;
        margin: 0.5em 0;
    }

    #snap-pm-courses {
        overflow: hidden;
    }

    // Tablet and mobile display.
    @include media-breakpoint-down(md) {
        width: 700vw;

        section {
            width: 100vw !important;
            float: left;
            padding: 0 2em;
            margin-bottom: 60px; // For the menu.
            border-color: transparent !important;

        }
    }
}

// -------------------------
//  Tab content for current and previous courses.
// -------------------------
#snap-pm-courses-content {
    .tab-pane {
        display: none;
        &.active {
            display: block;
            animation-name: slideFromRight;
            animation-iteration-count: once;
            animation-timing-function: ease-in-out;
            animation-duration: .7s;
        }
    }

    #snap-pm-courses-current.tab-pane.active {
        animation-name: slideFromLeft;
    }
}

@keyframes slideFromLeft {
    0% {
        opacity: 0;
        transform: translate3d(-1000px, 0, 0);
    }

    100% {
        opacity: 1;
        transform: translate3d(0, 0, 0);
    }
}

@keyframes slideFromRight {
    0% {
        opacity: 0;
        transform: translate3d(1000px, 0, 0);
    }

    100% {
        opacity: 1;
        transform: translate3d(0, 0, 0);
    }
}

// -------------------------
//  Personal menu tablet & mobile navigation.
// -------------------------
#snap-pm-mobilemenu {
    display: none;

    @include media-breakpoint-down(md) {
        position: fixed;
        bottom: 0;
        left: 0;
        z-index: 1;
        width: 100%;
        height: 60px;
        padding: .5em 0;
        display: flex;
        background-color: white;
        border-top: 1px solid $gray-lighter;

        a {
            flex: 1;
            margin: 0 4%;
            text-align: center;
            outline: none;
            @include alakazam();

            .svg-icon {
                border-radius: 50%;
                height: 40px;
                width: 40px;
                background-color: white;
                border: 1px solid $gray-light;
            }

            &.state-active {
                transform: scale(1.5);
                margin-top: -.5em;
            }
        }
    }
}

// -------------------------
//  Personal menu current courses.
// -------------------------
#snap-pm-courses-current {
    #snap-pm-courses-current-cards {
        margin-top: 2em;
    }
    // Hidden courses - always output for js, but hidden unless populated.
    #snap-pm-courses-hidden {
        display: none;
        &.state-visible {
            display: block; // Toggled in template and js.
        }
    }
}

// -------------------------
//  Course cards - a card for each course.
// -------------------------
.coursecard {

    @include media-breakpoint-up(md) {
        width: 30%;
        float: left;
        height: 250px;

        &:hover {
            transform: scale(1.05);
            box-shadow:
                0 8px 17px 0 $gray-light,
                0 6px 20px 0 rgba(0, 0, 0, 0.19);
        }
    }

    height: 150px;
    margin: .5em 3% .5em 0;
    border-radius: .3em;
    box-shadow: 0 1px 2px 0 #eceeef;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    @include bg-cover;
    @include alakazam();

    // Course card data - below the image.
    .coursecard-body {
        background-color: white;
        position: absolute;
        bottom: 0;
        width: 100%;
        padding: 1.5em .5em 1em .5em;
        min-height: 50%;

        // Course name.
        h3 {
            font-size: 1em;
            margin: 0;
            // Link to course, limited to 2 lines.
            a {
                overflow: hidden;
                line-height: 1.25;
                width: 100%;
                max-height: 2.5em; // 1em font-size * 1.25 line height * 2 lines to show.
                white-space: normal !important;
                display: -webkit-box;
                text-overflow: ellipsis;
                -webkit-line-clamp: 2;
                -webkit-box-orient: vertical;
            }
        }
    }

    .coursecard-contacts {
        position: absolute;
        top: -1em;
        left: -1%;
        width: 100%;
        overflow: hidden;
        text-align: center;

        .userpicture,
        .coursecard-contacts-more {
            margin: 0 1%;
            width: 2rem;
            height: 2rem;
            background-color: white;
            padding: 2px;
        }
        .coursecard-contacts-more {
            display: inline-block;
            border-radius: 50%;
            padding: 0;
            border: 3px solid $gray-lighter;
        }
    }

    .completionstatus,
    .coursegrade {
        font-size: $font-size-sm;
    }

    .coursegrade {
        display: block;
        line-height: 2.5em;
    }

    .published-status {
        clear: both;
        float: left;
        margin-bottom: -1em;
    }

    .completionstatus {
        border-bottom: .5em solid $gray-lighter;
    }

    .completion-line {
        background-color: $brand-success;
        height: .3em;
        margin-top: -.4em;
    }

    /* Course favoriting */
    .favoritetoggle {
        display: block;
        width: 2em;
        height: 2em;
        padding: 0;
        position: absolute;
        top: 0;
        right: 0;
        margin: 0.25em;
        z-index: 1;
    }

    .favoritetoggle:after {
        background: url("[[pix:theme|fav_unchecked]]");
        background-repeat: none;
        content: ' ';
        width: 80%;
        height: 80%;
        display: block;
        margin: 0 10% 5%;
    }

    &.favorited .favoritetoggle:after {
        background: url("[[pix:theme|fav_checked]]");
    }
}

// -------------------------
//  Personal menu updates.
// -------------------------
#snap-pm-updates {
    width: unset;

    section {
        position: relative;
        border-bottom: 1px solid $gray-light;
        padding-bottom: .5em;
        width: 100%;
    }
}

// -------------------------
//  Personal menu links to browse all course, see all messages etc.
// -------------------------
#snap-pm-courses .snap-personal-menu-more {
    position: absolute;
    top: 0;
    right: 0;
}
.snap-personal-menu-more {
    display: block;
    text-align: right;
}
