/*
    Shared rules for tablets and phones.
    Linked last in the <head> of every page (and of Site1.Master), so it wins over the
    page-level <style> blocks and over body.css / master.css / labelMatching.css.
*/

img {
    max-width: 100%;
}

/* GridView preview tables are wide (nowrap cells): scroll them instead of widening the page */
#previewTable {
    overflow-x: auto;
}

/* ---------- Tablets and below ---------- */
@media (max-width: 991px) {
    .col-md-8 {
        width: auto;
    }

    /* Side-by-side blocks on the home page stack on top of each other */
    .ief-flex-wrap-row {
        flex-direction: column;
        gap: 12px !important;
    }

        .ief-flex-wrap-row > [class*="col-md-"] {
            padding-left: 15px !important;
        }

    .ief-search-notes {
        padding-top: 20px !important;
    }

    /* itemSearch: three panels do not fit next to each other */
    .search-panels {
        grid-template-columns: 1fr 1fr !important;
    }

        .search-panels > * {
            min-width: 0;
        }

        .search-panels .panel-results {
            grid-column: 1 / -1;
        }
}

/* ---------- Phones ---------- */
@media (max-width: 767px) {
    html, body {
        overflow-x: hidden;
    }

    /* body.css puts a 10% margin on both sides */
    body {
        margin-left: 0 !important;
        margin-right: 0 !important;
        max-width: 100%;
    }

    h1 {
        font-size: 24px;
    }

    h2 {
        font-size: 21px;
    }

    h3 {
        font-size: 18px;
    }

    h4 {
        font-size: 16px;
    }

    /* 16px keeps iOS from zooming into the field on focus */
    input[type="text"],
    input[type="search"],
    input[type="file"],
    select,
    textarea,
    .form-control {
        font-size: 16px;
        max-width: 100%;
    }

    main {
        padding: 10px;
    }

    /* ----- Header and navigation ----- */
    .ief-header-logo,
    .ief-header-unilogo {
        padding-top: 10px !important;
        padding-bottom: 10px !important;
    }

    .ief-header-title {
        padding: 10px 12px !important;
    }

    .navbar-custom .nav > li > a {
        display: block;
        line-height: 44px;
    }

    /* ----- Footer ----- */
    footer a {
        padding-left: 8px;
        padding-right: 8px;
    }

    /* ----- IEDC_Home ----- */
    .row {
        margin-left: 0;
        margin-right: 0;
    }

    .ief-flex-wrap-row {
        margin-left: 0;
        margin-right: 0;
    }

    /* The search overview table reads top to bottom: question, arrow, answer */
    .iedc-table,
    .iedc-table tbody,
    .iedc-table tr,
    .iedc-table td {
        display: block;
        width: 100% !important;
        box-sizing: border-box;
    }

        .iedc-table td:empty,
        .iedc-table .iedc-arrow-down {
            display: none;
        }

        .iedc-table .iedc-arrow {
            transform: rotate(90deg);
            line-height: 1;
            padding: 0;
        }

        .iedc-table .iedc-logo {
            height: 56px;
        }

        .iedc-table .iedc-right {
            padding: 4px 0 12px;
        }

    .iedc-button {
        white-space: normal;
    }

    /* Buttons with a fixed 400px width */
    .col-md-6 > button.iedc-button {
        width: 100% !important;
        max-width: 100%;
    }

    .ief-search-row {
        flex-direction: column;
        align-items: stretch !important;
        gap: 10px !important;
    }

    .myCheckBoxList td {
        white-space: normal;
    }

    #toDisplay3 .row {
        flex-direction: column;
        justify-content: flex-start !important;
    }

        #toDisplay3 .row > * {
            width: 100% !important;
            max-width: none !important;
        }

    .sankey-wrap {
        padding: 10px;
    }

    .sankey-header {
        flex-direction: column;
    }

    .sankey-brand {
        text-align: left;
    }

    #chart {
        height: 480px;
    }

    /* ----- Table pages (classifications etc.) ----- */
    table.nav-justified,
    table.nav-justified tbody,
    table.nav-justified tr,
    table.nav-justified td {
        display: block;
        width: 100%;
        text-align: left !important;
    }

        table.nav-justified td {
            padding: 4px 0;
        }

        table.nav-justified select {
            width: 100% !important;
        }

    /* ----- dataFilter ----- */
    .main-content {
        padding: 16px 10px 32px;
    }

    .control-card {
        padding: 14px;
    }

    .grid-scroll {
        overflow-x: auto;
    }

    /* ----- itemSearch ----- */
    .search-panels {
        grid-template-columns: 1fr !important;
    }

    .page-intro-card {
        flex-direction: column;
        padding: 14px;
    }

    .dataset-match-body,
    .preview-card-body {
        padding: 10px;
    }

    .action-row .btn-action,
    .action-row .btn-action-outline {
        flex: 1 1 100%;
    }

    /* ----- iedc_author_DOI_search and projects: dataset result lists ----- */
    .search-panel .row {
        flex-direction: column;
        gap: 10px;
    }

        .search-panel .row > [class*="col-md-"] {
            width: 100%;
            padding-top: 0;
        }

    .grid-scroll td[style*="width"] {
        width: auto !important;
    }

    .dataset-row {
        flex-wrap: wrap;
    }

        .dataset-row .dataset-link {
            flex-basis: 100%;
            white-space: normal;
        }

    /* ----- projects ----- */
    .project-logo-container {
        position: static;
        margin: 0 0 10px;
    }

    .project-table td:first-child {
        width: auto;
        min-width: 90px;
    }

    .grid-container {
        overflow-x: auto;
    }

    /* ----- labelMatching: Bootstrap xs columns never stack, and labelMatching.css fixes widths ----- */
    main [class*="col-xs-"],
    .tab-content [class*="col-md-"] {
        float: none;
        width: 100%;
        padding-left: 0;
        padding-right: 0;
    }

    main [class*="col-xs-"] {
        margin-bottom: 8px;
    }

    .tabs {
        flex-wrap: wrap;
    }

    .tab-button {
        flex: 1 1 100%;
        padding: 10px 8px;
        font-size: 14px;
    }

    .tab-content {
        padding-left: 6px;
        padding-right: 6px;
    }

    .modern-gridview {
        width: 100%;
        border-spacing: 6px;
    }

        .modern-gridview tr:not(.gridview-header) td {
            font-size: 15px;
        }

    .tab-content .col-md-6 {
        flex-wrap: wrap;
        justify-content: flex-start;
    }

    #section1Sheet {
        overflow-x: auto;
    }
}
