/* Loaded after ../styles.css: the same colours and parts, laid out for a phone held in one hand. Everything is under body.m, which also puts it
   ahead of the narrow-screen rules of the desktop style sheet. */

body.m {
    --nav-height: calc(60px + env(safe-area-inset-bottom, 0px));
    font-size: 15px;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body.m main {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
    width: min(640px, 100%);
    margin: 0 auto;
    padding: 12px max(12px, env(safe-area-inset-right, 0px)) 16px max(12px, env(safe-area-inset-left, 0px));
}

body.m-monitor,
body.m-bots,
body.m-settings,
body.m-waypoints,
body.m-profile { padding-bottom: var(--nav-height); }

body.m h1 { font-size: 20px; }
body.m h2 { font-size: 16px; font-weight: 700; overflow-wrap: anywhere; }
body.m p { margin: 0; }

body.m .panel {
    padding: 14px;
    border-radius: 10px;
    min-width: 0;
}

body.m .panel-head {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

body.m .panel-head .badge { align-self: center; }
body.m .panel-head a { padding: 8px 0 8px 12px; }

/* 16px keeps the phone from zooming in when a field is touched */
body.m input:not([type="checkbox"]),
body.m select,
body.m textarea {
    min-height: 44px;
    font-size: 16px;
}

body.m button,
body.m .button-link { min-height: 44px; touch-action: manipulation; }

body.m button:disabled { background: #a9b0b8; }

body.m .inline-check { min-height: 44px; font-size: 15px; font-weight: 700; color: #34404a; }
body.m .inline-check input,
body.m .client-select-box { width: 22px; height: 22px; min-height: 22px; margin: 0; }

body.m .m-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
body.m .report-who { flex: 1 1 100%; min-width: 0; margin: 0; }
body.m .report-who select { flex: 1; width: auto; min-width: 0; }
body.m [data-panel="reports"] .m-row { margin-bottom: 10px; }
body.m #reportsRefresh { flex: 1; }
body.m .m-note { margin: 6px 0 10px; font-size: 13px; }
body.m .m-note:empty { display: none; }
body.m .m-since { font-size: 13px; }
body.m .m-since:empty { display: none; }
body.m .m-switch { padding: 6px 0; text-align: center; }
body.m .m-switch a { display: inline-block; padding: 10px 16px; color: #1568b7; }

/* ---- top bar ---------------------------------------------------------------------------------------------------- */

body.m .m-top {
    position: sticky;
    z-index: 20;
    top: 0;
    padding: env(safe-area-inset-top, 0px) max(12px, env(safe-area-inset-right, 0px)) 0 max(12px, env(safe-area-inset-left, 0px));
    color: #ffffff;
    background: linear-gradient(90deg, #06183a 0%, #15256f 60%, #3a003f 100%);
}

body.m .m-top-row {
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: 616px;
    min-height: 60px;
    margin: 0 auto;
}

body.m .m-top h1 { flex: 1; min-width: 0; }
body.m .m-top select { flex: 1; min-width: 0; }
body.m .m-top-link { padding: 12px 0 12px 12px; color: #ffffff; font-weight: 700; }

body.m .link-pill {
    flex: none;
    max-width: 46%;
    padding: 6px 10px;
    border-radius: 999px;
    color: #ffffff;
    font-size: 12px;
    font-weight: 700;
    text-align: center;
}

body.m .link-good { background: #16a34a; }
body.m .link-warn { background: #b45309; }
body.m .link-bad { background: #dc3650; }
body.m .link-wait { background: #6b7280; }

body.m .tabs {
    display: flex;
    justify-content: space-between;
    gap: 0;
    max-width: 616px;
    margin: 0 auto;
    overflow-x: auto;
    scrollbar-width: none;
    border: 0;
}

body.m .tabs button {
    padding: 0 4px;
    border-bottom: 3px solid transparent;
    border-radius: 0;
    color: #b9c4e4;
    background: transparent;
    font-size: 13px;
}

/* seven tabs on a narrow phone */
@media (max-width: 370px) {
    body.m .tabs button { padding: 0 1px; font-size: 12px; }
}

body.m .tabs button.on { border-bottom-color: #38bdf8; color: #ffffff; background: transparent; }

/* ---- bottom bar ------------------------------------------------------------------------------------------------- */

body.m .m-nav {
    position: fixed;
    z-index: 20;
    right: 0;
    bottom: 0;
    left: 0;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    height: var(--nav-height);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    border-top: 1px solid #d8e0e7;
    background: #ffffff;
}

body.m .m-nav a {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    color: #66717d;
    font-size: 12px;
    font-weight: 700;
    text-decoration: none;
}

body.m .m-nav a.active { color: #1568b7; box-shadow: inset 0 3px 0 #1568b7; }
body.m .m-nav svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
body.m .m-nav .nav-badge { padding: 0 5px; font-size: 10px; }

/* ---- monitor ---------------------------------------------------------------------------------------------------- */

body.m .column { gap: 12px; }
body.m .state-line { margin-top: 6px; }
body.m .bars { margin-top: 10px; }
body.m .bar-line { grid-template-columns: 64px minmax(0, 1fr); gap: 8px; }

body.m .fact-row {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin: 12px 0 0;
    overflow-wrap: anywhere;
}

body.m .command-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    margin: 0;
    padding: 12px;
    border-radius: 10px;
}

body.m .command-who { font-size: 13px; }
body.m #selectedClientName { display: none; }
body.m #commandStatus:empty { display: none; }

body.m .command-buttons {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    width: 100%;
}

body.m .command-buttons button { width: 100%; min-height: 52px; padding: 6px; font-size: 14px; line-height: 1.2; }
body.m .command-buttons .button-link { grid-column: 1 / -1; }

body.m .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 10px; }
body.m .tile span { font-size: 18px; overflow-wrap: anywhere; }

body.m .log-list { font-size: 12px; }
body.m .log-list li { gap: 8px; }
body.m .log-list.short { height: 240px; }
body.m .log-list.tall { height: calc(100vh - 340px); height: calc(100dvh - 340px); min-height: 280px; }

body.m .stat-cards { columns: 1; }
body.m .stat-card { margin-bottom: 12px; }
body.m .stat-cards:empty { display: none; }
body.m [data-panel="statistics"] > p { margin-bottom: 10px; font-size: 13px; }

body.m .map-head-actions { justify-content: space-between; margin-top: 4px; }
body.m .map-zoom-controls button { min-width: 52px; height: 44px; font-size: 16px; }

/* width stays "auto" so that the picture keeps its shape when the height is what limits it */
body.m #bigMap {
    width: auto;
    max-width: 100%;
    max-height: calc(100vh - 290px);
    max-height: calc(100dvh - 290px);
    min-height: 300px;
    object-fit: contain;
    margin-top: 8px;
}

body.m .filter-chips { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
body.m .filter-chips button { min-height: 38px; font-size: 14px; }
body.m .filter-chips + .m-row { margin-top: 6px; }

body.m .narrow-input { width: 100%; }
body.m #inventoryNote:empty { display: none; }
body.m .inventory-groups { grid-template-columns: minmax(0, 1fr); margin-top: 12px; }
body.m .data-table th, body.m .data-table td { padding: 8px 6px; }
body.m .report-title { margin: 14px 0 10px; }

body.m .storage-grid { grid-template-columns: minmax(0, 1fr); gap: 12px; }
body.m #storageNote:empty { display: none; }
body.m .storage-table th, body.m .storage-table td { padding: 8px 4px; }
body.m .moves-list.tall { height: auto; max-height: 420px; min-height: 0; }
body.m #movesOlder { width: 100%; }

/* reports: one card per period instead of nine columns */
body.m #reportTable,
body.m #reportTable tbody { display: block; }
body.m #reportTable tr { display: block; }
body.m #reportTable tr.head { display: none; }

body.m #reportTable tr.clickable {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px 12px;
    margin-top: 10px;
    padding: 12px;
    border: 1px solid #d8e0e7;
    border-radius: 8px;
}

body.m #reportTable tr.clickable.on { border-color: #1568b7; box-shadow: inset 0 0 0 1px #1568b7; }
body.m #reportTable td { display: block; padding: 0; border: 0; text-align: left; white-space: normal; }
body.m #reportTable td[data-label]::before { content: attr(data-label); display: block; color: #66717d; font-size: 11px; font-weight: 700; }

/* ---- bots ------------------------------------------------------------------------------------------------------- */

body.m .top-stats { width: 100%; }
body.m .top-stats span { font-size: 13px; }

body.m #fleetTable,
body.m #fleetTable tbody { display: block; margin: 0; }
body.m #fleetTable tr { display: block; }
body.m #fleetTable tr.head { display: none; }

body.m #fleetTable tr.fleet-bot,
body.m #fleetTable tr.empty {
    margin-bottom: 10px;
    padding: 12px;
    border: 1px solid #d8e0e7;
    border-radius: 10px;
    background: #ffffff;
}

body.m #fleetTable tr.fleet-bot {
    display: grid;
    grid-template-columns: 30px 12px repeat(3, minmax(0, 1fr));
    align-items: center;
    gap: 6px 8px;
}

body.m #fleetTable td { display: block; min-width: 0; padding: 0; border: 0; text-align: left; white-space: normal; overflow-wrap: anywhere; }
body.m #fleetTable td[data-label]::before { content: attr(data-label) " "; color: #66717d; font-size: 11px; font-weight: 700; }

body.m #fleetTable .f-pick { grid-column: 1; grid-row: 1 / span 6; align-self: start; padding-top: 2px; }
body.m #fleetTable .f-dot { grid-column: 2; grid-row: 1; }
body.m #fleetTable .f-name { grid-column: 3 / -1; grid-row: 1; font-size: 16px; }
body.m #fleetTable .f-name a { display: block; padding: 4px 0; color: #1568b7; }
body.m #fleetTable .f-state { grid-column: 3 / -1; grid-row: 2; }
body.m #fleetTable .f-map { grid-column: 3 / span 2; grid-row: 3; }
body.m #fleetTable .f-level { grid-column: 5; grid-row: 3; }
body.m #fleetTable .f-hp { grid-column: 3 / -1; grid-row: 4; }
body.m #fleetTable .f-mp { grid-column: 3 / -1; grid-row: 5; }
body.m #fleetTable .f-kills { grid-column: 3; grid-row: 6; }
body.m #fleetTable .f-deaths { grid-column: 4; grid-row: 6; }
body.m #fleetTable .f-seen { grid-column: 5; grid-row: 6; font-size: 13px; }

body.m #fleetTable .f-hp,
body.m #fleetTable .f-mp { display: grid; grid-template-columns: 24px minmax(0, 1fr); align-items: center; }
body.m #fleetTable .bar.small { width: 100%; }

/* ---- profile and admin ------------------------------------------------------------------------------------------ */

body.m .profile-facts { gap: 0; margin-top: 8px; }
body.m .profile-facts div { grid-template-columns: 120px minmax(0, 1fr); gap: 10px; }
body.m .profile-form { margin-top: 12px; }

body.m details.panel > summary {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 32px;
    cursor: pointer;
    list-style: none;
}

body.m details.panel > summary::-webkit-details-marker { display: none; }
body.m details.panel > summary h2 { flex: 1; min-width: 0; }
body.m details.panel > summary::after { content: "+"; width: 16px; color: #66717d; font-size: 22px; text-align: center; }
body.m details.panel[open] > summary::after { content: "\2212"; }
body.m details.panel > p { margin-top: 10px; }

body.m .button-link.danger-link { background: #dc3650; }

body.m .admin-activate { margin-top: 12px; }
body.m .admin-activate button { width: 100%; }
body.m .admin-actions { grid-template-columns: minmax(0, 1fr); margin-top: 12px; }
body.m .admin-actions form { grid-template-columns: minmax(0, 1fr) minmax(110px, auto); }
body.m .admin-actions .m-wide { grid-column: 1 / -1; }

body.m .m-admin-client {
    display: grid;
    grid-template-columns: 12px minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    padding: 10px;
    border: 1px solid #d8e0e7;
    border-radius: 8px;
    background: #f9fbfd;
    overflow-wrap: anywhere;
}

body.m .m-admin-client span.muted { display: block; font-size: 13px; }

/* ---- sign in ---------------------------------------------------------------------------------------------------- */

body.m-auth main { align-content: center; min-height: 100vh; min-height: 100dvh; }
body.m-auth .auth-panel h1 { margin-bottom: 16px; font-size: 26px; }
body.m-auth .auth-panel .alert { margin-bottom: 16px; }

/* ---- a phone held sideways: little height ----------------------------------------------------------------------- */

@media (max-height: 520px) {
    body.m .m-top { position: static; }
}
