/* On a phone: one column, the menu behind a button, the page scrolling as a
   whole. Loaded last; what is above stays as it was for a wide window. */

#menutoggle,
#menubutton {
    display: none;
}

@media (max-width: 48rem) {

    /* THE FRAME */

    #general {
        width: 100%;
        height: auto;
        min-height: 100vh;
        min-height: 100dvh;
    }

    .scroll {
        overflow-y: visible;
    }

    #topbar {
        flex-basis: auto;
        height: 3.5rem;
        position: sticky;
        top: 0;
        z-index: 20;
        align-items: center;
    }

    #logo {
        flex-basis: auto;
        font-size: 1.7rem;
        align-self: center;
        padding: 0 0.3rem 0.15rem 1rem;
    }

    #sublogo {
        flex-basis: auto;
        align-self: center;
        font-size: 1rem;
        padding: 0.45rem 0 0 0;
    }

    #path {
        display: none;
    }

    #user {
        flex: 1 1 0;
        min-width: 0;
        font-size: 0.9rem;
        padding: 0 0.5rem;
    }

    #user div {
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    #user div:has(> span) {
        display: none;
    }

    #user a {
        color: #012169;
    }

    #menubutton {
        display: flex;
        flex-direction: column;
        justify-content: center;
        gap: 0.3rem;
        flex: 0 0 3.5rem;
        height: 3.5rem;
        padding: 0 1rem;
        cursor: pointer;
    }

    #menubutton span {
        display: block;
        height: 0.16rem;
        background-color: #012169;
    }

    #bulk {
        flex-direction: column;
        max-height: none;
    }

    #nav {
        display: none;
        position: fixed;
        top: 3.5rem;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 10;
        min-width: 0;
        overflow-y: auto;
        background-color: white;
        padding: 0 0.7rem 1rem 0.7rem;
    }

    #menutoggle:checked ~ #bulk #nav {
        display: flex;
    }

    /* The first page has nothing of its own: on a phone it is the menu. */

    #general.home #nav {
        display: flex;
        position: static;
        overflow-y: visible;
    }

    #general.home #menubutton {
        display: none;
    }

    #general.home #user {
        padding-right: 1rem;
    }

    #general.home #center {
        order: -1;
        flex: 0 0 auto;
        padding: 0 1rem;
    }

    #nav .explore,
    #nav .venture {
        padding: 0.6rem 1rem;
    }

    #nav ul li {
        padding: 0;
    }

    #nav ul li a {
        display: block;
        padding: 0.65rem 0 0.65rem 0.6rem;
    }

    #center {
        margin: 0;
        padding: 1rem;
        min-width: 0;
    }

    /* The panel a page of one thing has on its right goes under it. */

    #center:has(+ #right) {
        flex: 0 0 auto;
    }

    #right {
        flex: 1 0 auto;
        min-width: 0;
        overflow-y: visible;
        padding: 0.5rem 1rem 2rem 1rem;
    }

    #right:not(:has(*)) {
        display: none;
    }

    #right .openform {
        width: 100%;
        max-width: 20rem;
        min-height: 2.75rem;
    }

    #right .submit,
    .submit,
    .modalsubmit {
        min-height: 2.75rem;
        min-width: 5rem;
        padding: 0.5rem 1rem;
    }

    /* LISTS OF THINGS */

    #center div.plurals .headers,
    #center div.indexed .headers {
        font-size: 1.8em;
    }

    #center div.plurals .objectinfos .item,
    #drafts .box,
    div.collectiveitem {
        width: 100%;
        height: auto;
        margin-right: 0;
        padding: 1.2em;
    }

    /* The rows of a card shared its fixed height; now each takes its own. */
    #center div.plurals div.objectinfos div.item > [class] {
        flex: 0 0 auto;
    }

    #center div.plurals .headers a.headers {
        font-size: inherit;
        padding-bottom: 0;
    }

    #center div.plurals .infos {
        grid-template-columns: 1fr;
        grid-auto-rows: auto;
    }

    #center div.plurals div.infos div.item .status {
        height: auto;
    }

    #center .votecheck {
        margin-right: 0;
    }

    /* ONE THING */

    #center div.singular {
        max-width: 100%;
        flex-direction: column;
    }

    #center div.singular div.center {
        padding-right: 0;
    }

    #center div.singular div.center .headers,
    #center div.singular div.center .headerdetails,
    #center div.singular div.center div.headerdraft .title,
    #center div.singular div.center div.headerevent .title {
        font-size: 1.8rem;
        overflow-wrap: anywhere;
    }

    #center div.singular div.center .infos {
        flex-direction: column;
    }

    #center div.singular div.center div.infos .item {
        margin: 0 0 1rem 0;
    }

    #center div.singular div.infos div.item div.boxes .item {
        max-height: none;
    }

    #center div.singular div.center .headerdraft,
    #center div.singular div.center .headerevent {
        flex-wrap: wrap;
        column-gap: 1.25rem;
    }

    #center div.singular div.center div.headerdraft .title,
    #center div.singular div.center div.headerevent .title {
        flex-basis: 100%;
    }

    #center div.singular div.center div.headerdraft .released,
    #center div.singular div.center div.headerevent .status {
        min-width: 0;
        margin-left: 0;
    }

    #center div.singular div.center .draftpreview {
        width: 100%;
        height: 70vh;
    }

    #center div.center div.boardgrid .item {
        width: 100%;
    }

    #center div.center div.eventgrid {
        height: auto;
    }

    #center div.center div.eventgrid .infos {
        grid-template-columns: 1fr;
    }

    .memberdraft ul {
        white-space: normal;
    }

    /* FORMS */

    .formentry {
        width: calc(100% - 0.626rem);
        font-size: 1.05rem;
        min-height: 2.75rem;
    }

    #center .policyentry {
        flex-wrap: wrap;
        row-gap: 0.6rem;
    }

    #center .policyentry div.policy,
    #center .policyentry div.datetime {
        flex: 1 1 9rem;
        margin-right: 0.6rem;
    }

    #center .policyentry div.check .word {
        margin-right: 1.5rem;
    }

    .modalshow {
        left: 1rem;
        right: 1rem;
        top: 15%;
        width: auto;
        max-width: none;
    }

    /* NEWS */

    #center div.indexed .headers {
        display: flex;
        flex-wrap: wrap;
        align-items: baseline;
        column-gap: 1rem;
    }

    #center div.indexed .maintoggle {
        padding-left: 0;
    }

    #center div.indexed .actionpanel {
        flex-direction: column-reverse;
    }

    #center div.indexed .actionpanel .right {
        margin-top: 0;
        height: auto;
        padding: 0 0 1rem 0;
        flex-direction: row;
        flex-wrap: wrap;
        align-items: baseline;
        gap: 0.3rem 1rem;
    }

    #center div.indexed .actionpanel .right .first,
    #center div.indexed .actionpanel .right .notfirst {
        flex: 0 0 auto;
    }

    #center div.indexed .screen {
        margin: 1em 0 0.7em 0;
    }

    #center div.indexed div.screen .item {
        flex-direction: column;
        padding-top: 0.8em;
    }

    #center div.indexed div.screen .item .duration {
        flex-basis: auto;
    }

    #center div.indexed div.screen .item .hideduration {
        display: none;
    }

    #center div.indexed div.screen div.item .description {
        padding-left: 0;
    }

    /* MINE: connections, updates, media, events, proposed actions, votes */

    .cards {
        flex-direction: column;
        margin-top: 1rem;
    }

    .cards .type {
        margin: 0 0 1rem 0;
    }

    .mediacard,
    #updates {
        width: 100%;
    }

    .mediaheader,
    #myevents .eventheader,
    #pendingactions .headerline,
    #detailedvote .header {
        flex-wrap: wrap;
        gap: 0.3rem 1rem;
    }

    .mediaheader .headers,
    .mediaheader .mediatabs,
    #myevents .eventheader .headers,
    #myevents .eventheader .toggle {
        flex-basis: auto;
    }

    .mediaheader .headers,
    #myevents .eventheader .headers {
        font-size: 1.8em;
    }

    .mediadetails {
        flex-direction: column;
    }

    .mediadetails div {
        margin-right: 0;
    }

    .mediadetails .object {
        display: inline-block;
        margin-bottom: 0.4rem;
    }

    #updates .card .actioninfo {
        flex-wrap: wrap;
        column-gap: 1rem;
        padding-bottom: 0.6rem;
        border-bottom: 0.063rem solid #d7e3ff;
    }

    #updates .card .actioninfo .description {
        flex-basis: 100%;
    }

    #updates .card .actioninfo .vote,
    #updates .card .actioninfo .duration {
        flex: 0 1 auto;
        justify-content: flex-start;
    }

    #updates .card .actioninfo .duration {
        font-weight: 300;
    }

    #updates .card .actioninfo .vote:empty {
        display: none;
    }

    #attending .eventcard .firstrow,
    #managing .eventcard .firstrow,
    #attending .eventcard .secondrow,
    #managing .eventcard .secondrow {
        flex-wrap: wrap;
        gap: 0.5rem 1rem;
    }

    #attending .eventcard .secondrow div,
    #managing .eventcard .secondrow div {
        flex: 1 1 9rem;
    }

    #pendingactions .pendingcard {
        width: 100%;
        height: auto;
        min-height: 8em;
        margin-right: 0;
    }

    #detailedvote .header .detailed {
        margin-left: 0;
    }

    #detailedvote .header .right {
        flex-basis: auto;
        padding-right: 0;
        float: none;
    }
}
