@charset "UTF-8";

/* The breakpoints below match PHONE_MAX_WIDTH in inc/assets.php (phones are
   767px and narrower, the tablet band starts at 768px). CSS cannot read PHP
   constants, so keep them in sync. */
/* Menu items only for phones (see inc/min_eskak.php). */
.user-menu .phone-only {
    display: none;
}

/* The small colour icon must keep its width; otherwise a long opponent name
   squeezes the cell and the icon wraps, doubling the row height. */
.oversigt .color-cell {
    min-width: 22px;
    white-space: nowrap;
}

/* Open-tournaments password search: keep the field a usable width at every
   screen size, not just the tiny size=5 default. */
.open-turns-search-box {
    width: 300px;
    max-width: 100%;
}

.open-turns-search {
    display: flex;
    align-items: center;
    gap: 4px;
}

.open-turns-search input[type="text"] {
    flex: 1 1 0;
    width: auto !important;
    min-width: 0;
    box-sizing: border-box;
}

/* Profil ekstraoplysninger: make the free-text area elastic at every width so
   its normal-size sans-serif text fits the table. */
.profile-extra-form {
    width: 100% !important;
    max-width: 100% !important;
}

.profile-extra-form textarea {
    width: 100% !important;
    box-sizing: border-box;
    font-size: 1rem;
}

@media (max-width: 767px) {
    body {
        padding: 8px;
        overflow-x: hidden;
    }

    .site-header,
    .site-header > tbody,
    .site-header > tbody > tr,
    .site-header > tbody > tr > td {
        display: block;
        box-sizing: border-box;
        width: 100% !important;
        max-width: 100%;
    }

    .site-header td[width="10"],
    .site-header td[height="50"],
    .site-header tr:last-child {
        display: none !important;
    }

    .site-header td {
        min-width: 0;
        overflow-wrap: anywhere;
    }

    .site-header td[height="25"] {
        font-size: 0.8em;
    }

    .site-header img {
        max-width: 100%;
        height: auto;
    }

    .page-layout,
    .page-layout > tbody {
        display: block;
        width: 100%;
    }

    .page-layout > tbody > tr {
        display: flex;
        flex-direction: column;
        width: 100%;
    }

    .page-layout > tbody > tr > td {
        display: block;
        box-sizing: border-box;
        width: 100% !important;
        max-width: 100%;
        min-width: 0;
        padding-left: 0;
        padding-right: 0;
    }

    .page-layout > tbody > tr > td.page-spacer,
    .page-layout > tbody > tr > td[width="10"] {
        display: none !important;
    }

    .page-sidebar {
        margin-bottom: 12px;
    }

    .page-content,
    .page-aside,
    .pgn-column {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .site-menu,
    .user-menu {
        display: flex;
        flex-wrap: wrap;
        width: 100%;
    }

    .site-menu > div:first-child,
    .user-menu > div:first-child {
        flex: 0 0 100%;
        width: 100%;
    }

    .site-menu .menuItem,
    .user-menu .menuItem {
        box-sizing: border-box;
        flex: 0 0 50%;
        width: 50%;
        min-height: 44px;
        align-items: center;
        padding: 5px 6px;
    }

    .user-menu .login-menu-item,
    .site-menu .menubottomLeft,
    .user-menu .menubottomLeft {
        flex-basis: 100%;
        width: 100%;
    }

    .site-menu .menubullet,
    .user-menu .menubullet {
        flex: 0 0 18px;
        width: 18px;
        padding-right: 4px;
    }

    .site-menu .menuitemLeft,
    .user-menu .menuitemLeft {
        flex: 1 1 auto;
        width: auto;
        min-width: 0;
        padding-right: 0;
    }

    .site-menu a.menu,
    .user-menu a.menu {
        display: block;
        padding: 7px 0;
        line-height: 1.25;
    }

    .site-menu .menuheaderLeft,
    .user-menu .menuheaderLeft,
    .submenu .menuheaderLeft {
        cursor: pointer;
    }

    .site-menu .menuheaderLeft::after,
    .user-menu .menuheaderLeft::after,
    .submenu .menuheaderLeft::after {
        content: "\25BE";
        float: right;
        padding-right: 12px;
    }

    .site-menu.expanded .menuheaderLeft::after,
    .user-menu.expanded .menuheaderLeft::after,
    .submenu.expanded .menuheaderLeft::after {
        content: "\25B4";
    }

    /* Collapsed by default below the breakpoint; .expanded is the user's choice. */
    .site-menu:not(.expanded) .menuItem,
    .site-menu:not(.expanded) .menubottomLeft,
    .user-menu:not(.expanded) .menuItem,
    .user-menu:not(.expanded) .menubottomLeft,
    .submenu:not(.expanded) tr:not(:first-child) {
        display: none;
    }

    .user-menu:not(.expanded) .login-menu-item {
        display: flex;
    }

    .user-menu.expanded .phone-only {
        display: flex;
    }

    input:not([type="hidden"]):not([type="checkbox"]):not([type="radio"]),
    select,
    textarea,
    button,
    .button,
    .button2 {
        box-sizing: border-box;
        max-width: 100%;
        min-height: 40px;
        font-size: 16px;
    }

    textarea {
        width: 100%;
    }

    img {
        max-width: 100%;
        height: auto;
    }

    .analyse-layout,
    .analyse-layout > tbody,
    .analyse-layout > tbody > tr {
        display: block;
        width: 100%;
    }

    .analyse-layout > tbody > tr > td {
        display: block;
        box-sizing: border-box;
        width: 100% !important;
        max-width: 100%;
        min-width: 0;
        padding-left: 0;
        padding-right: 0;
    }

    .analyse-controls {
        display: flex;
        flex-wrap: wrap;
        width: 100%;
    }

    #board1 {
        max-width: 100%;
    }

    /* The board fitting shrinks the board on phones, but the PGN box keeps
       the desktop height from the preferred board width. Let it size to a
       viewport cap instead of mismatching the board. */
    .pgn-scroll {
        height: auto !important;
        max-height: 60vh;
    }

    .board-controls-table {
        display: flex;
        flex-wrap: wrap;
        width: 100%;
    }

    .board-controls-table > tbody,
    .board-controls-table > tbody > tr {
        display: contents;
    }

    .board-controls-table td {
        display: block;
        padding: 2px;
    }

    .board-controls-table form {
        margin: 0;
    }

    /* Oversigtstabeller: hold rækkehøjden ens ved at lade alle kolonner
       undtagen turneringskolonnen blive på én linje. */
    .oversigt td {
        white-space: nowrap;
    }

    .oversigt .tournament-cell {
        white-space: normal;
    }

    /* Visitkort: the player information needs the full width on phones. Let
       the info block wrap its stat groups and the shelf table fit instead of
       forcing a horizontal scroll. */
    .visitkort-layout {
        table-layout: fixed;
    }

    .visitkort-info {
        font-size: 95%;
    }

    .visitkort-info > table,
    .visitkort-shelf > table {
        width: 100% !important;
        max-width: 100%;
    }

    .visitkort-info td[width="20"] {
        width: 0 !important;
        padding: 0;
    }

    /* Visitkort: put the two short stat groups side by side and the rating
       group below them, instead of three cramped columns. */
    .visitkort-stats,
    .visitkort-stats > tbody {
        display: block;
        width: 100%;
    }

    .visitkort-stats > tbody > tr {
        display: flex;
        flex-wrap: wrap;
        gap: 6px 12px;
    }

    .visitkort-stat-wlt {
        order: 1;
    }

    .visitkort-stat-games {
        order: 2;
    }

    .visitkort-stat-rating {
        order: 3;
        flex-basis: 100%;
    }

    .visitkort-stat-gap {
        display: none;
    }

    /* Game page comment box: the fixed cols/size widths overflow narrow
       phones, so make the table and its fields elastic. */
    .game-comment-table {
        width: 100% !important;
        max-width: 100%;
        table-layout: fixed;
    }

    .game-comment-table textarea {
        width: 100% !important;
        max-width: 100%;
        box-sizing: border-box;
    }

    /* The new-comment input takes the remaining width beside the button. */
    .game-comment-post {
        display: flex;
        align-items: center;
        gap: 4px;
    }

    .game-comment-post input[type="text"] {
        flex: 1 1 0;
        width: auto !important;
        min-width: 0;
        box-sizing: border-box;
    }

    /* Open tournaments: put the create button and the password search on
       separate lines instead of cramped side by side. */
    .open-turns-toolbar {
        flex-direction: column !important;
        align-items: stretch;
        gap: 8px;
    }

    .open-turns-search-box {
        width: 100%;
    }

    /* Postkasse: stack the folder menu above the contact finder and paging on
       phones instead of squeezing them side by side. */
    .post-mail-menu {
        table-layout: auto !important;
    }

    .post-mail-menu > tbody > tr:first-child {
        display: block;
    }

    .post-mail-menu > tbody > tr:first-child > td {
        display: block;
        width: auto !important;
    }

    .post-mail-menu > tbody > tr:first-child > td:last-child {
        text-align: left;
        margin-top: 6px;
    }

    /* Postkasse reply: let the flash view and its form use the width, and let
       the action buttons below the form wrap if needed. */
    .post-flash-view {
        width: 100% !important;
        max-width: 100%;
    }

    .post-reply-form textarea {
        width: 100% !important;
        box-sizing: border-box;
    }

    .post-reply-actions,
    .post-reply-actions > tbody,
    .post-reply-actions > tbody > tr {
        display: block;
    }

    .post-reply-actions > tbody > tr > td {
        display: inline-block;
        margin: 0 6px 6px 0;
        vertical-align: top;
    }

    /* Profil ekstraoplysninger: stack each label above its field on phones
       instead of squeezing the two columns. */
    .profile-extra-form,
    .profile-extra-form > tbody,
    .profile-extra-form > tbody > tr {
        display: block;
        width: 100%;
    }

    .profile-extra-form > tbody > tr > td {
        display: block;
        width: auto !important;
        text-align: left;
        padding: 2px 0;
    }

    /* Let lone text/select fields use the row width; the compact date selects
       stay inline. */
    .profile-extra-form input[type="text"],
    .profile-extra-form select {
        width: 100% !important;
        box-sizing: border-box;
    }

    .profile-extra-form .profil-date select {
        width: auto !important;
    }

    /* Profil page: stack each label above its field on phones. */
    .profil-form,
    .profil-form > tbody {
        display: block;
        width: 100%;
    }

    .profil-row {
        display: flex;
        flex-direction: column;
        width: 100%;
    }

    .profil-row > td {
        display: block;
        width: auto !important;
        text-align: left;
        padding: 0;
    }

    .profil-label {
        order: 1;
    }

    .profil-field {
        order: 2;
        padding-top: 4px !important;
    }

    .profil-field input[type="text"] {
        width: 100% !important;
        box-sizing: border-box;
    }

    .profil-gap {
        display: none !important;
    }

    /* Profil: let the top action buttons wrap onto more lines on narrow
       phones instead of forcing the page wider. */
    .profil-buttons,
    .profil-buttons > tbody,
    .profil-buttons > tbody > tr {
        display: block;
    }

    .profil-buttons > tbody > tr > td {
        display: inline-block;
        margin: 0 6px 6px 0;
        vertical-align: top;
    }
}

/* Tablets (and narrow desktop windows) keep the sidebar and content side by
   side, but the aside goes into the content column, directly under the
   content, rather than under the sidebar. A two-row grid lets the tall
   sidebar span both rows without pushing the aside down to the sidebar's
   bottom the way a wrapping flex line would. An optional PGN column
   (implicit third column) stays beside the content. */
@media (min-width: 768px) and (max-width: 1023px) {
    .page-layout,
    .page-layout > tbody {
        width: 100%;
    }

    .page-layout > tbody > tr {
        display: grid;
        grid-template-columns: 200px minmax(0, 1fr);
        grid-template-rows: auto 1fr;
        align-items: start;
        gap: 10px;
        width: 100%;
    }

    .page-layout > tbody > tr > td {
        display: block;
        box-sizing: border-box;
        min-width: 0;
    }

    .page-layout > tbody > tr > td.page-spacer,
    .page-layout > tbody > tr > td[width="10"] {
        display: none !important;
    }

    .page-sidebar {
        grid-column: 1;
        grid-row: 1 / span 2;
        width: 200px !important;
    }

    .page-content {
        grid-column: 2;
        grid-row: 1;
        width: auto !important;
        overflow-x: auto;
    }

    .pgn-column {
        grid-column: 3;
        grid-row: 1;
    }

    .page-aside {
        grid-column: 2;
        grid-row: 2;
        width: auto !important;
    }
}

/* Narrow (phone and tablet) adjustments that span the two breakpoints. */
@media (max-width: 1023px) {
    /* Front page: the SMS input belongs directly under the message board at
       the end of the content, so move it above the statistics widget (and
       the other aside links). Desktop keeps the existing order. */
    .front-page .page-aside {
        display: flex;
        flex-direction: column;
    }

    .front-page .page-aside > br {
        display: none;
    }

    .front-page .page-aside > * {
        order: 2;
        margin-bottom: 10px;
    }

    .front-page .page-aside > #sms-official,
    .front-page .page-aside > #sms-input {
        order: 1;
    }

    /* Postkasse: make the inbox/outbox menu table elastic so it shrinks to
       the content width instead of forcing a horizontal scroll. A fixed
       two-column split stops the contact finder from widening the table. */
    .post-mail-menu {
        width: 100% !important;
        max-width: 100% !important;
        table-layout: fixed;
    }

    .post-mail-menu > tbody > tr > td:first-child {
        width: 62%;
    }

    .post-mail-menu > tbody > tr > td:last-child {
        width: 38%;
    }

    .post-mail-menu select {
        width: 100%;
        max-width: 100%;
    }

    /* Postkasse conversation: shrink the bubbles to the content width so our
       own messages stay visible instead of overflowing to the right. */
    .post-conversation {
        width: 100% !important;
        table-layout: fixed;
    }

    .post-conversation table.whitebordersmallgreen,
    .post-conversation table.whitebordersmallblue {
        width: 100% !important;
        max-width: 100%;
        box-sizing: border-box;
        overflow-wrap: anywhere;
    }

    /* Visitkort: stack the columns so nothing sits beside the photo/info and
       the right-hand menu ends up below the player information. */
    .visitkort-layout {
        width: 100% !important;
    }

    .visitkort-layout > tbody {
        display: flex;
        flex-direction: column;
        gap: 10px;
        width: 100%;
    }

    .visitkort-layout > tbody > tr {
        display: contents;
    }

    .visitkort-layout > tbody > tr > td {
        width: auto !important;
        min-width: 0;
    }

    .visitkort-layout > tbody > tr > td:empty {
        display: none;
    }

    .visitkort-photo {
        order: 1;
    }

    .visitkort-info {
        order: 2;
    }

    .visitkort-shelf {
        order: 3;
    }

    .visitkort-menu {
        order: 4;
    }

    /* The filler table that stretches the right menu on desktop only adds
       empty vertical space once the layout is stacked. */
    .visitkort-menu-spacer {
        display: none !important;
    }
}
