/* ── Phone and tablet layer (C12) ──────────────────────────────────────────
 * Loaded on every page after the KATANA stylesheets, before the page stylesheet. Desktop stays as
 * it was: every rule sits under "screen and (max-width...)", so print pages are not touched either.
 * 1024px covers tablets and a phone in landscape; 600px covers a phone in portrait.
 *
 * The header height is not fixed here: common.js measures the header and writes --header-height on
 * the body, because the header wraps to a number of rows that depends on the page and the screen.
 */

/* ── Header with filters, and the travel table as cards: shared by TRAVELS and PRINTS ─────────── */
.FiltersToggle,
.NarrowOnly
{
    display: none;
}

.FilterField
{
    margin-left: .25rem;
}

.FilterField>b
{
    position: relative;
    top: .125rem;
}

.FilterRefresh
{
    margin-left: .25rem;
}

.TableScroller
{
    margin: 1rem;
    overflow-x: auto;
}

.TableScroller>table
{
    margin: 0 !important;
    width: 100% !important;
}

/* Under this width the centred title runs into the filters. */
@media screen and (max-width: 1700px)
{
    header.WithFilters>.Title
    {
        display: none;
    }
}

@media screen and (max-width: 1024px)
{
    header
    {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        justify-content: space-between;
        gap: .5rem;
        left: .5rem;
        width: calc(100% - 1rem);
        height: auto;
        min-height: var(--header-height);
        padding: .5rem;
    }

    header>left_container,
    header>right_container,
    header>center_container,
    header>.Title
    {
        position: static;
        transform: none;
        min-width: 0;
    }

    header>.Title
    {
        font-size: 125%;
    }

    /* Touch targets: 44 px, and 16 px text in the fields so iOS does not zoom on focus. */
    button,
    ki-button
    {
        min-height: 44px;
        min-width: 44px;
        padding: .25rem .625rem;
    }

    input:not([type=checkbox]):not([type=radio]):not([type=file]),
    select,
    textarea
    {
        min-height: 44px;
        font-size: 16px;
    }

    input[type=checkbox],
    input[type=radio]
    {
        width: 22px;
        height: 22px;
    }
}

@media screen and (max-width: 600px)
{
    header>.Title
    {
        font-size: 110%;
    }

    /* A hidden modal waits just off the left edge: its shadow must not fall on the page. */
    modal_screen:not([show])>modal_container,
    .ModalScreen:not([show])>modal_container
    {
        box-shadow: none;
    }

    /* A modal with its own close button takes the whole screen; a short message stays a box. */
    modal_screen>modal_container,
    .ModalScreen>modal_container
    {
        top: var(--env-banner-height, 0px);
        left: 0;
        transform: none;
        width: 100% !important;
        height: calc(100% - var(--env-banner-height, 0px)) !important;
        max-width: none !important;
        max-height: none !important;
        border-radius: 0;
        padding-bottom: max(1rem, env(safe-area-inset-bottom));
    }
}

@media screen and (max-width: 1024px)
{
    .FiltersToggle
    {
        display: inline-block;
    }

    .NarrowOnly
    {
        display: block;
        font-size: 75%;
    }

    header.WithFilters>left_container
    {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: .25rem;
        flex: 1 1 100%;
    }

    header.WithFilters>left_container>br,
    header.WithFilters>right_container br
    {
        display: none;
    }

    header.WithFilters>.Title
    {
        display: none;
    }

    .UpperPercs
    {
        flex: 1 1 100%;
        font-size: 85%;
        text-align: center;
    }

    header.WithFilters>right_container
    {
        flex: 1 1 100%;
        text-align: left;
    }

    header.WithFilters #userInfo
    {
        float: none;
        top: 0;
        display: block;
        text-align: center;
        font-size: 85%;
    }

    .HeaderFilters
    {
        display: none;
    }

    body.FILTERS_OPEN .HeaderFilters
    {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: .5rem;
        margin-top: .5rem;
    }

    .HeaderFilters>select,
    .HeaderFilters>.FilterRefresh
    {
        grid-column: 1 / -1;
        width: 100%;
        margin-left: 0;
    }

    .FilterField
    {
        margin-left: 0;
        min-width: 0;
    }

    .FilterField>b
    {
        display: block;
        top: 0;
        font-size: 75%;
    }

    .FilterField>input
    {
        width: 100%;
    }

    /* the table as cards */
    .TableScroller
    {
        margin: .5rem;
        overflow: visible;
    }

    #travels_table
    {
        display: block;
        width: calc(100% - 1rem);
        margin: .5rem;
        background: none;
        box-shadow: none;
    }

    #travels_table>thead
    {
        display: none;
    }

    #travels_table>tbody
    {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: .5rem;
    }

    #travels_table tr.TravelRow:not(.FILTERED_OUT)
    {
        display: grid;
        grid-template-columns: repeat(12, minmax(0, 1fr));
        gap: .25rem .5rem;
        align-content: start;
        padding: .5rem;
        border-radius: .25rem;
        background-color: white;
        box-shadow: var(--shadow2);
    }

    #travels_table tr.TravelRow:hover
    {
        color: inherit;
        background-color: white;
    }

    #travels_table tr.TravelRow>td
    {
        display: block;
        grid-column: span 12;
        width: auto;
        min-width: 0;
        max-width: none;
        padding: 0;
        border: none;
        text-align: left;
        white-space: normal;
        overflow-wrap: anywhere;
    }

    #travels_table tr.TravelRow>td.Load,
    #travels_table tr.TravelRow>td.WarehouseAndGate
    {
        display: none;
    }

    #travels_table tr.TravelRow>td::before
    {
        display: block;
        font-size: 70%;
        font-weight: bold;
        color: dimgray;
    }
}

@media screen and (max-width: 600px)
{
    #travels_table>tbody
    {
        grid-template-columns: minmax(0, 1fr);
    }

    /* INFO PERFORMANCE: four columns fit a phone once the labels may wrap. */
    #evaluationStats_table
    {
        width: 100%;
        table-layout: fixed;
        font-size: 80%;
    }

    #evaluationStats_table th,
    #evaluationStats_table td
    {
        padding: .25rem;
        white-space: normal;
        overflow-wrap: anywhere;
    }

    #evaluationStats_table th
    {
        font-size: 80%;
    }
}
