/*
 * Fixes for narrow screens, added by hand on top of the built stylesheet (the build cannot be repeated).
 * Loaded after index-*.min.css from index.html. Only applies below 768px; wider screens are untouched.
 *
 * The built stylesheet gives every list row a fixed height of 41px. On a phone the names wrap, and the wrapped
 * text spills over the rows below.
 */
@media (max-width: 767px) {
    /* Rows are as tall as their content. */
    .list .list-item {
        height: auto;
        min-height: 41px;
    }

    /* Categories: icon and name on the left, file count on the right, abbreviation on a line of its own. */
    .home .categories .category .category-link {
        display: -ms-flexbox;
        display: flex;
        -ms-flex-wrap: wrap;
        flex-wrap: wrap;
        -ms-flex-align: baseline;
        align-items: baseline;
        min-width: 0;
        padding: 10px 15px;
    }

    .home .categories .category .category-link > img,
    .home .categories .category .category-link > span:first-child {
        -ms-flex: 0 0 auto;
        flex: 0 0 auto;
        width: 26px;
        margin-right: 4px;
    }

    .home .categories .category .name {
        -ms-flex: 1 1 0px;
        flex: 1 1 0;
        min-width: 0;
        overflow-wrap: break-word;
        word-wrap: break-word;
    }

    .home .categories .category .info-1 {
        float: none;
        -ms-flex: 0 0 auto;
        flex: 0 0 auto;
        -ms-flex-order: 2;
        order: 2;
        margin-left: 10px;
        white-space: nowrap;
    }

    .home .categories .category .info-2 {
        -ms-flex: 0 0 100%;
        flex: 0 0 100%;
        -ms-flex-order: 3;
        order: 3;
        padding-left: 30px;
        font-size: 12px;
        line-height: 1.3;
    }

    /* Files: the name wraps, downloads and date go on a line below it, the rating stays compact on the left. */
    .home .files .file .rating {
        -ms-flex: 0 0 auto;
        flex: 0 0 auto;
        -ms-flex-align: center;
        align-items: center;
    }

    .home .files .file .rating .rating-button {
        padding: 11px 8px 10px;
    }

    .home .files .file .rating .score {
        width: 24px;
    }

    .home .files .file .file-infos {
        display: -ms-flexbox;
        display: flex;
        -ms-flex-wrap: wrap;
        flex-wrap: wrap;
        -ms-flex-align: baseline;
        align-items: baseline;
        -ms-flex: 1 1 0px;
        flex: 1 1 0;
        min-width: 0;
        padding: 10px 12px;
    }

    .home .files .file .file-infos > img {
        -ms-flex: 0 0 auto;
        flex: 0 0 auto;
        margin-right: 6px;
    }

    .home .files .file .name {
        -ms-flex: 1 1 0px;
        flex: 1 1 0;
        min-width: 0;
        overflow-wrap: break-word;
        word-wrap: break-word;
        word-break: break-word;
    }

    .home .files .file .info-1 {
        float: none;
        -ms-flex: 0 0 100%;
        flex: 0 0 100%;
        -ms-flex-order: 3;
        order: 3;
        padding-left: 22px;
        font-size: 12px;
        line-height: 1.6;
    }

    /*
     * The menu button of a row (administrators, and uploaders on their own files): a column over the whole height
     * of the row, wide enough for a finger, with the arrow in its middle.
     */
    .home .categories .category .action-container,
    .home .files .file .action-container,
    .list .list-item .action-container {
        display: -ms-flexbox;
        display: flex;
        -ms-flex: 0 0 40px;
        flex: 0 0 40px;
        max-width: none;
        -ms-flex-item-align: stretch;
        align-self: stretch;
    }

    .list .list-item .action-container > * {
        display: -ms-flexbox;
        display: flex;
        -ms-flex: 1 1 auto;
        flex: 1 1 auto;
    }

    .list .list-item .action-container .action-dropdown {
        position: relative;
        display: -ms-flexbox;
        display: flex;
        -ms-flex: 1 1 auto;
        flex: 1 1 auto;
        -ms-flex-align: center;
        align-items: center;
        -ms-flex-pack: center;
        justify-content: center;
        width: auto;
        margin: 0;
        line-height: 1;
        font-size: 18px;
    }

    /* The menu opens towards the left, inside the screen, instead of beyond its right edge. */
    .list .list-item .action-container .dropdown-menu {
        left: auto;
        right: 0;
        top: 50%;
        margin-top: 14px;
        font-size: 15px;
    }

    .list .list-item .action-container .dropdown-menu > li > a {
        padding: 10px 16px;
    }
}
