/* THE MOBILE LAYOUT of the site pages: the log in page, the admin portal and the tools off it. Loaded after home.css on each of them, and
   written against `html[data-layout="mobile"]` (see layout.js - the same Auto/Mobile/Desktop choice as the game's) so a player's choice
   holds here too. Unlike the game, these pages work held either way up: nothing here assumes landscape.

   The admin pages are the ones this is mostly for. They get used away from a desk, in a hurry, when something is wrong - so the things that
   matter there (muting and suspending players, restarting the server) must be reachable and hard to get wrong with a thumb. */

/* ---- The layout picker: in the header of every site page ----------------------------------------------------------------------------- */

.layout-switch {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text-2);
    font-size: var(--font-sm);
    white-space: nowrap;
}

.layout-switch-select {
    padding: 4px 6px;
    border: var(--px) solid var(--ink);
    background: var(--fill-sub);
    color: var(--text);
    font-family: inherit;
    font-size: var(--font-sm);
    cursor: pointer;
}

.site-header__nav {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

/* ---- Mobile ---------------------------------------------------------------------------------------------------------------------------- */

html[data-layout="mobile"] {
    -webkit-tap-highlight-color: transparent;
}

/* A page that scrolls sideways is a page whose edge you can't find: nothing may be wider than the screen */
html[data-layout="mobile"] body {
    overflow-x: hidden;
}

/* The header: brand and nav on one compact band, not a tall block - the page below it is what is wanted */
html[data-layout="mobile"] .site-header {
    padding: 8px 12px;
    gap: 6px 12px;
}

html[data-layout="mobile"] .site-header__brand {
    font-size: 26px;
}

html[data-layout="mobile"] .site-header__nav a {
    padding: 8px 10px;
}

/* The layout picker is a small control in the header's corner, not another big button - and its label is the only thing to give up to fit */
html[data-layout="mobile"] .layout-switch-label {
    display: none;
}

html[data-layout="mobile"] .layout-switch-select {
    min-height: 36px;
    padding: 2px 6px;
}

html[data-layout="mobile"] .site-main {
    align-items: flex-start;
    padding: 12px;
}

html[data-layout="mobile"] .panel {
    max-width: none;
    padding: 14px 12px;
}

html[data-layout="mobile"] .admin-layout {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
}

html[data-layout="mobile"] .admin-menu {
    flex: none;
    max-width: none;
}

/* Everything pressed is at least a fingertip tall */
html[data-layout="mobile"] .button,
html[data-layout="mobile"] .tab,
html[data-layout="mobile"] .auth-form button[type="submit"],
html[data-layout="mobile"] .site-header__nav a {
    min-height: 44px;
}

html[data-layout="mobile"] select:not(.layout-switch-select),
html[data-layout="mobile"] input[type="search"],
html[data-layout="mobile"] input[type="number"],
html[data-layout="mobile"] input[type="text"],
html[data-layout="mobile"] input[type="password"],
html[data-layout="mobile"] input[type="email"] {
    min-height: 44px;
    font-size: 16px;
}

html[data-layout="mobile"] input[type="checkbox"] {
    width: 24px;
    height: 24px;
}

/* The two that can take the server down sit apart from the rest, and well clear of Log Out */
html[data-layout="mobile"] #admin-restart-button {
    margin-top: 14px;
}

/* The server actions are a long column of buttons, and the players (what is wanted in a hurry) are below them: a jump to either, always at
   the top. Not shown on a desktop, where both are on screen at once. */
.admin-jump {
    display: none;
}

html[data-layout="mobile"] .admin-jump {
    display: flex;
    gap: 8px;
    width: 100%;
}

html[data-layout="mobile"] .admin-jump .button {
    flex: 1;
    margin-top: 0;
    padding-left: 8px;
    padding-right: 8px;
    text-decoration: none;
}

/* Buttons share a row where there is room (a phone held sideways) instead of one to a line */
html[data-layout="mobile"] .account-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 10px;
}

html[data-layout="mobile"] .account-actions > .button {
    margin: 0;
}

/* ---- The dashboard: tabs, server and refresh ---- */

html[data-layout="mobile"] .admin-dashboard__bar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
}

/* Tabs wrap onto as many lines as they need, each taking an equal share of its line */
html[data-layout="mobile"] .admin-dashboard__tabs {
    flex: none;
}

html[data-layout="mobile"] .admin-dashboard__tabs .tab {
    flex: 1 1 auto;
    padding: 8px 14px;
}

html[data-layout="mobile"] .admin-dashboard__server {
    justify-content: space-between;
}

html[data-layout="mobile"] .admin-dashboard__server select {
    flex: 1;
    min-width: 0;
}

/* Toolbars (the period, the search box, Deleted players) wrap rather than push the page wider */
html[data-layout="mobile"] .admin-activity-toolbar {
    flex-wrap: wrap;
    align-items: stretch;
}

html[data-layout="mobile"] .admin-activity-toolbar label,
html[data-layout="mobile"] .admin-activity-toolbar .admin-search {
    flex: 1 1 100%;
    min-width: 0;
}

html[data-layout="mobile"] .admin-activity-toolbar select {
    flex: 1;
    min-height: 44px;
}

/* ---- Tables become cards ---- */

/* A row of a wide table has to be scrolled sideways to read, and the Manage and Mute buttons are at its far end. As a card, every value is
   in view with its own label (tableLabels.js puts the headings on the cells), and the buttons run along the bottom. The headings stay as a
   row of small buttons above the cards, which is what sorting a column is. */
html[data-layout="mobile"] .admin-table-scroll {
    max-height: none;
    min-height: 0;
    overflow: visible;
    border: none;
    background: none;
}

html[data-layout="mobile"] .card-table,
html[data-layout="mobile"] .card-table tbody,
html[data-layout="mobile"] .card-table tr,
html[data-layout="mobile"] .card-table td {
    display: block;
    width: 100%;
}

html[data-layout="mobile"] .card-table thead {
    display: block;
}

html[data-layout="mobile"] .card-table thead tr {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 10px;
}

html[data-layout="mobile"] .card-table th {
    position: static;
    width: auto;
    padding: 0;
    border: none;
    background: none;
    text-align: left;
}

/* A heading that isn't a sort button (the Actions one) has nothing to press, and nothing to say once the buttons are on the cards */
html[data-layout="mobile"] .card-table th:not(:has(button)) {
    display: none;
}

html[data-layout="mobile"] .admin-sort-button {
    min-height: 36px;
    padding: 4px 10px;
    border: var(--px) solid var(--ink);
    background: var(--fill-ctrl);
}

html[data-layout="mobile"] .card-table tbody tr {
    margin-bottom: 10px;
    padding: 6px 12px 10px;
    background: var(--fill-sub);
    border: var(--px) solid var(--ink);
    box-shadow: var(--bevel-panel);
}

html[data-layout="mobile"] .card-table td {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 14px;
    padding: 5px 0;
    border: none;
    text-align: right;
    white-space: normal;
    overflow-wrap: anywhere;
}

html[data-layout="mobile"] .card-table td::before {
    content: attr(data-label);
    flex: none;
    color: var(--text-3);
    font-size: var(--font-xs);
    text-align: left;
}

/* The first value (who it is) leads the card, larger and with no label */
html[data-layout="mobile"] .card-table td:first-child {
    justify-content: flex-start;
    flex-wrap: wrap;
    padding-bottom: 8px;
    border-bottom: var(--px) solid var(--ink);
    color: var(--text-hi);
    font-size: var(--font-base);
    text-align: left;
    white-space: normal;
}

html[data-layout="mobile"] .card-table td:first-child::before {
    display: none;
}

html[data-layout="mobile"] .card-table td.admin-players-actions {
    display: flex;
    gap: 8px;
    padding-top: 10px;
}

html[data-layout="mobile"] .card-table td.admin-players-actions::before {
    display: none;
}

html[data-layout="mobile"] .card-table td.admin-players-actions .button {
    flex: 1;
    min-height: 44px;
}

/* ---- Windows over the page (Manage a player, a player's history) ---- */

html[data-layout="mobile"] .admin-modal-backdrop {
    padding: 0;
}

html[data-layout="mobile"] .admin-modal {
    width: 100%;
    height: 100%;
    max-height: none;
    border: none;
    box-shadow: none;
}

html[data-layout="mobile"] .admin-modal-close {
    min-width: 44px;
    min-height: 44px;
}

html[data-layout="mobile"] .admin-modal-body {
    padding: 12px;
}

html[data-layout="mobile"] .admin-modal-controls {
    flex-wrap: wrap;
}

html[data-layout="mobile"] .admin-modal-controls > * {
    flex: 1 1 140px;
    min-height: 44px;
}

html[data-layout="mobile"] .home-main {
    gap: 12px;
    padding-top: 12px;
    padding-bottom: 12px;
}

html[data-layout="mobile"] .landing {
    padding: 16px 14px 20px;
}
