/*
 * Small screens for the content pages (head.jsp loads this after the theme). Desktop stays as it is: everything is
 * inside the media query. Some pages bring their own <style> after this file, hence the "html body" selectors.
 */

@media (max-width: 799px) {

    html {
        -webkit-text-size-adjust: 100%;
        text-size-adjust: 100%;
    }

    html body.mainframe {
        padding: 12px 12px 24px;
        margin: 0;
        overflow-wrap: anywhere;
    }

    html body.mainframe img,
    html body.mainframe input,
    html body.mainframe select,
    html body.mainframe textarea {
        max-width: 100%;
    }

    /* Headings and the tab rows of home and settings may wrap. */
    h1,
    h2,
    .dense {
        white-space: normal;
    }

    h1 {
        font-size: 1.4em;
        line-height: 1.3;
    }

    h2 {
        line-height: 2;
    }

    span.header a,
    .headerSelected {
        display: inline-block;
        padding: 6px 0;
    }

    .albumComment,
    #mediaFilePath {
        width: auto;
        max-width: 100%;
    }

    #mediaFilePath,
    #mediaFilePath code {
        white-space: normal;
    }

    /* Home: flexible tiles, two per row ---------------------------------------------------- */

    html body .albumGrid {
        float: none !important;
        width: 100%;
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 4px 12px;
        clear: both;
    }

    html body .albumThumb {
        display: block;
        min-width: 0;
        padding: 0 0 12px;
    }

    html body .albumThumb .coverart {
        display: block;
    }

    html body .albumThumb .coverart > div:first-child {
        width: 100% !important;
        max-width: 100% !important;
        height: auto !important;
        max-height: none !important;
        aspect-ratio: 1 / 1;
    }

    html body .albumThumb .coverart img[id] {
        width: 100%;
        height: auto;
    }

    html body .albumThumb .caption1,
    html body .albumThumb .caption2,
    html body .albumThumb .caption3 {
        width: auto !important;
        max-width: 100%;
    }

    .welcomeMessage,
    .upgradeMessage {
        float: none !important;
        width: auto !important;
        margin: 0 0 16px;
        padding: 8px 12px !important;
        border-left-width: 3px !important;
    }

    /* Book page (albumMain): cover and buttons above the details -------------------------- */

    html body #left {
        float: none;
        width: auto;
        display: grid;
        grid-template-columns: 136px 1fr;
        grid-template-areas: "back back" "cover actions" "search search";
        column-gap: 16px;
        align-items: center;
    }

    html body #left > .bookUp {
        grid-area: back;
    }

    html body #left > .coverart {
        grid-area: cover;
        margin: 0 !important;
        width: 136px !important;
    }

    html body #left > .bookActions {
        grid-area: actions;
    }

    html body #left .coverart > div:first-child {
        width: 136px !important;
        max-width: 136px !important;
        height: 136px !important;
        max-height: 136px !important;
    }

    html body #left .coverart img[id] {
        width: 136px;
        height: 136px;
    }

    html body #left .linkBtn {
        width: auto;
        margin: 0 0 10px;
        line-height: 24px;
    }

    html body #left br {
        display: none;
    }

    html body #left #search {
        grid-area: search;
        margin-top: 8px;
        font-size: 0.9em;
    }

    html body #left #search a {
        padding: 6px 12px 6px 0;
    }

    html body #left #search br {
        display: none;
    }

    html body #right {
        display: block;
        width: auto;
        max-width: 100%;
        margin: 12px 0 0;
    }

    /* Track and folder tables: titles are cut, the icons get a finger-sized target -------- */

    table.music {
        width: 100%;
        line-height: 1.4;
    }

    table.music tr {
        height: 44px;
    }

    table.music td.truncate {
        max-width: 0;
        width: 100%;
        padding-left: 6px;
        padding-right: 6px;
    }

    table.music td.truncate + td.truncate {
        display: none;
    }

    table.music td.fit {
        padding-left: 0;
        padding-right: 0;
    }

    table.music td.fit:empty {
        display: none;
    }

    table.music td.fit > img[onclick] {
        box-sizing: content-box;
        padding: 11px;
        height: 18px;
    }

    /* Adding to the queue is a desktop thing, the row has no room for it. */
    table.music img[id^="add"] {
        display: none;
    }

    table.music td.rightalign {
        padding-right: 6px;
    }

    /* Settings and other wide forms scroll inside the table instead of the page. */
    table.indent:not(.music),
    table.ruleTable,
    body.mainframe > table:not(.music),
    body.mainframe form > table,
    table.music[style*="width:inherit"] {
        display: block;
        max-width: 100%;
        overflow-x: auto;
    }

    p.detail {
        white-space: normal;
    }

    p.detail a {
        display: inline;
    }

    /* Artist info box */
    html body #artistInfoTable {
        display: block;
        padding: 1em !important;
    }

    html body #artistImage {
        max-width: 100% !important;
        margin: 0 0 1em !important;
    }

    /* Authors (left.jsp) */
    .leftframe a {
        display: inline-block;
        min-height: 32px;
        line-height: 32px;
    }
}
