// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
/**
 * Moodle blocks.
 *
 * @package   theme_snap
 * @copyright Copyright (c) 2015 Blackboard Inc. (http://www.blackboard.com)
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */

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

@include media-breakpoint-up(md) {
    #moodle-blocks > aside {
        column-count: 2;
        column-gap: 5%;
        column-width: 45%;
    }

    #moodle-blocks .block:not(.block_settings) {
        display: inline-block;
        width: 100%;
        // Added for yui overlays which use position absolute, so parent needs to be relative.
        position: relative;
    }
}

.block .header .title h2 {
    font-size: $h5-font-size;
}

.block h3 {
    font-size: $h6-font-size;
}

/* remove block actions, always display blocks when displayed */
.block_action {
    display: none;
}

.block.hidden .content {
    display: block;
}

/* hide blocks by default */
/* workaround for participant list pretending to be course view MDL-50492 */
#moodle-blocks,
.path-user.path-course.path-course-view.editing #moodle-blocks {
    visibility: hidden;
    height: 0;
    overflow: hidden;
}

/* show blocks on front page, quiz, book, cal etc and when clicked */
#page-admin-index #moodle-blocks,
#page-mod-quiz-attempt #moodle-blocks,
#page-mod-quiz-review #moodle-blocks,
#page-mod-book-view #moodle-blocks,
#page-mod-lesson-view #moodle-blocks,
#page-site-index #moodle-blocks,
#page-user-profile #moodle-blocks,
#page-my-index #moodle-blocks,
#page-calendar-view #moodle-blocks,
#moodle-blocks.state-visible,
.format-weeks.path-course-view.editing #moodle-blocks,
.format-topics.path-course-view.editing #moodle-blocks {
    visibility: visible;
    height: auto;
    overflow: visible;
}

/* Some mods have faux blocks - but we want to hide all the other blocks */
#page-mod-lesson-view,
#page-mod-book-view,
#page-mod-quiz-review,
#page-mod-quiz-attempt {
    #moodle-blocks > aside {
        -webkit-column-count: 1;
        -moz-column-count: 1;
        column-count: 1;

        .block {
            display: none;
        }

        .block__fake,
        .block_fake,
        .block_settings {
            display: block;
        }

        .block__fake,
        .block_fake {
            margin-top: 1rem;
        }
    }
}

.block,
.block-region .block {
    margin: 0 auto 1em;
    padding: 0 2%;
    border: 0;
    box-shadow: none;
    background-color: transparent;
    max-width: 50.5em;
}

body.path-site .block-region .block {
    margin: 2em auto;
}

.block.block_settings,
body.path-site .block.block_settings {
    margin-top: 0;
    margin-bottom: 1em;
}

/* Reset margin on setting block. */
.block_settings {
    > .card-body {
        padding-left: 0;
        padding-right: 0;
        @media (max-width: 996px) {
            padding-top: 3rem;
        }
        @media (max-width: 762px) {
            padding-top: 3.5rem;
        }
        @media (max-width: 560px) {
            padding-top: 6.3rem;
        }


        // This is inside card-body for specificity resasons.
        .block_tree [aria-expanded="false"].loading {
            background: none;

            :after {
                content: '';
                margin-left: 0.5em;
                @include ajaxing(inline-block, relative, 16px, 4px);
            }
        }
    }
    .footer {
        padding: 0 1em;
    }
    .block_tree {
        ul {
            margin-left: 0;
            padding-left: 20px;
        }
    }
}

/* icons in blocks */
.block_navigation .block_tree .tree_item.branch,
.block_settings .block_tree .tree_item.branch {
    background-position: 0 0.4em;
    margin-left: 0;
}

.block_navigation .block_tree li.item_with_icon > p img,
.block_settings .block_tree li.item_with_icon > p img {
    top: 0.15em;
    position: relative;
}

.block .icon.column {
    width: 21px;

    img {
        vertical-align: baseline;
    }
}

.eventcontent .smallicon {
    width: 50px;
    margin-right: 2%;
}

/* Calandar */
.eventtitle {
    font-size: 1em;
}

.calendar-event-panel .eventcontent {
    text-align: left;
    padding: 0.5em;
}

.block .minicalendar {
    max-width: 100%;
}

// hide this stuff from blocks when not viewing full page cal
.eventskey,
.block_calendar_month .calendar_filters {
    display: none;
}

/* ADMIN BLOCK */
#page-content .block_settings {
    width: 320px;
    height: 0;
    visibility: hidden;
    position: fixed;
    background-color: #fff !important;
    top: 0;
    right: -100%;
    padding: 0;

    .moodle-core-dragdrop-draghandle {
        display: none;
    }

    & > .card-block {
        padding-left: 2%;
        padding-right: 2%;
    }

    .card-title {
        visibility: hidden;
    }
}

#page-content .block_settings.state-visible,
.block_settings:target {
    visibility: visible;
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 13;
    right: 0;
    border-left: 1px solid #eee;
    transition: right 0.4s ease-in-out;
}

.block .header .title .commands {
    width: 100%;
    font-size: $font-size-sm;
}

.block_rss_client ul.list li {
    border: 0;
    margin: 1em 0;

    .description {
        font-size: small;
    }
}

/* BLOCKS EDITING */
.block .moodle-actionmenu[data-enhanced].show .menu,
.block .moodle-actionmenu[data-enhanced].show .menu[style] {
    left: 0 !important; // overwrite moodle js
}

.block .commands.show .moodle-core-dragdrop-draghandle {
    display: none;
}

/* Hide header when editing front page block. */
#page-site-index.pagelayout-admin {
    #page-header {
        display: none;
    }
    #region-main {
        padding-top: 2em;
    }
}
