:root {
    --vh: 100%
}

body {
    height: 100%;
    margin: 0;
}

a {
    cursor: pointer;
}

#world {
    height: calc(var(--vh, 1vh) * 100);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

ul li {
    list-style: none;
}

#edit-button {
    margin-bottom: 0;
    box-shadow: none;
}

#backlog {
    width: 100%;
    flex: 1 1 0;
    overflow-y: auto;
    flex-direction: column-reverse;
    display: flex;
    padding: 1rem;
    min-height: 0;
    margin: .5rem;
    scroll-behavior: smooth;
    white-space: pre-wrap;
}

#backlog li {
    list-style: none;
    padding: 0.5rem 0;
    margin: 0;
    animation: highlight 2.5s ease-out;
}


#backlog .your-speech {
    animation: none;
}

@keyframes highlight {
    0% {
        background-color: var(--pico-primary-focus);
    }

    100% {
        background-color: transparent;
    }
}

#backlog li a {
    text-decoration: underline;
}

#backlog .your-movement~li a {
    color: gray;
    cursor: default;
    pointer-events: none;
    text-decoration: none;
}

a[disabled="true"],
a.disabled-link {
    color: var(--pico-h3-color);
    cursor: default;
    pointer-events: none;
    text-decoration: none !important;
}

#backlog .your-arrival {
    border-top: 1px solid var(--pico-contrast-border);
    padding-top: 1.5rem;
}


#backlog .scenery a {
    padding-left: 0.5rem;
}

#backlog .look {
    border-left: .15rem;
    border-left-style: solid;
    padding-left: 1.5rem;
}

#backlog .emote {
    border-left: .15rem;
    border-left-style: solid;
    padding-left: 1.5rem;
}

header .title {
    flex: 1;
    margin: 0;
    min-width: 0;
    /* Allows text truncation if needed */
}

/* Busy container stays compact */
header .busy-container {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    width: auto;
}

[data-loading] {
    display: none;
}

/* Loading spinner sizing */
header .busy-container [data-loading-aria-busy] {
    width: 20px;
    height: 20px;
    min-width: 20px;
}

/* Close button stays compact */
header button[rel="prev"] {
    flex-shrink: 0;
    margin: 0;
}

.room-detail {
    width: 100%;
}

.room-detail li,
button {
    width: 100%;
}

.speak {
    display: flex;
    align-items: center;
    bottom: 0;
    margin-left: 0.5rem;
}

#emote-button {
    margin-right: 0.75rem;
    margin-bottom: var(--pico-spacing);
    width: auto;
}

#speak-button {
    --button-padding-horiz: 0.75rem;
    --button-padding-vert: 0rem;
    --icon-size: 1.25rem;
    padding-left: var(--button-padding-horiz);
    padding-right: var(--button-padding-horiz);
    padding-top: var(--button-padding-vert);
    padding-bottom: var(--button-padding-vert);
}

.default-svg {
    --icon-size: 1.65rem;
    height: var(--icon-size);
    width: var(--icon-size);
}

.default-svg image {
    height: var(--icon-size);
    width: var(--icon-size);
}

.nav-button {
    --button-padding-horiz: 0.5rem;
    --button-padding-vert: 0.5rem;
    --icon-size: 1.25rem;
    padding-left: var(--button-padding-horiz);
    padding-right: var(--button-padding-horiz);
    padding-top: var(--button-padding-vert);
    padding-bottom: var(--button-padding-vert);
}

.nav-button svg,
image {
    height: var(--icon-size);
    width: var(--icon-size);
}

#dialog[open] {
    height: 80%;
    max-height: none;
}

#dialog header {
    display: flex;
    justify-content: space-between;
}

.dialog-body {
    overflow-y: scroll;
    flex: 1;
    display: flex;
    flex-direction: column;
}

#dialog .htmx-indicator {
    flex-grow: 0;
}

.bottom {
    margin-top: auto;
}

#dialog>article:first-child {
    width: 90%;
    display: flex;
    flex-grow: 1;
    flex-direction: column;
}

.htmx-indicator {
    display: none;
    width: 1.5rem;
    height: 1.5rem;
}

.htmx-request .htmx-indicator {
    display: inline;
}

.htmx-request.htmx-indicator {
    display: inline;
}

.flash-container {
    position: relative;
    min-height: 1.5rem;
    display: flex;
    flex-direction: column;
}

#main-menu {
    background-color: var(--pico-background-color);
    padding: 1.5em;
}

#main-menu header {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
}

#main-menu li {
    cursor: pointer;
}

/* Desktop/Pad layout: side-by-side */
@media (min-width: 768px) {
    main {
        margin: 0;
    }

    .desktop-layout {
        display: flex;
        flex-direction: row;
        flex: 1;
        overflow: visible;
        width: 100%;
        align-items: stretch;
        min-height: 0;
    }

    #main-menu {
        width: 280px;
        flex-shrink: 0;
        overflow-y: auto;
        transition: width var(--pico-transition), padding var(--pico-transition);
        align-self: stretch;
    }

    #main-menu.is-collapsed {
        width: 0;
        margin: 0;
        padding-left: 0;
        padding-right: 0;
        overflow: hidden;
    }

    /* Pull resizer to left edge when menu is collapsed */
    #main-menu.is-collapsed~.resizer {
        margin-left: calc(-0.5rem);
    }

    /* Hide close button in menu header on desktop */
    #main-menu button[rel="close"] {
        display: none;
    }

    .resizer {
        width: 0.5rem;
        flex-shrink: 0;
        align-self: stretch;
        background-color: var(--pico-muted-border-color);
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        position: relative;
        z-index: 1;
    }

    .resizer:hover {
        background-color: var(--pico-primary);
    }

    .resizer-toggle {
        width: 1.5rem;
        height: 3rem;
        padding: 0;
        margin: 0;
        border: none;
        background-color: var(--pico-muted-border-color);
        border-radius: 0.25rem 0 0 0.25rem;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        position: absolute;
        right: 0;
        top: 50%;
        transform: translateY(-50%);
    }

    .resizer-toggle:hover {
        background-color: var(--pico-primary);
    }

    .resizer-toggle svg {
        width: 1.25rem;
        height: 1.25rem;
    }

    .resizer-toggle svg image {
        width: 100%;
        height: 100%;
    }

    .main-content {
        flex: 1;
        min-width: 0;
        min-height: 0;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        align-self: stretch;
    }

    .main-content>nav {
        padding-left: 0.5rem;
    }
}

/* Mobile: overlay menu */
@media (max-width: 767px) {
    .desktop-layout {
        display: flex;
        flex-direction: column;
        flex: 1;
    }

    #main-menu {
        z-index: 4;
        inset: 0;
        position: fixed;
        transform: translate(calc(-100% - var(--pico-spacing)));
        transition: transform var(--pico-transition);
    }

    #main-menu.is-open {
        transform: translate(0);
    }

    .resizer {
        display: none;
    }

    .main-content {
        display: flex;
        flex-direction: column;
        flex: 1;
        overflow: hidden;
    }
}

.flex-col {
    display: flex;
    flex-direction: column;
}

.flex-grow {
    flex: 1;
}

.flexy {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.overflow-auto {
    overflow: auto;
    overflow-x: hidden;
    max-width: 100%;
    width: 100%;
}

/* Table cell text wrapping */
table {
    max-width: 100%;
    width: 100%;
}

td {
    white-space: normal;
    word-wrap: break-word;
}

/* Table icon column - sized to fit icons */
.exits-table td.icon-cell,
.exits-table th.icon-cell {
    width: 3rem;
    max-width: 3rem;
    white-space: nowrap;
    padding: var(--pico-spacing) 0.5rem;
    min-width: 2.5rem;
}


#sse-connection-status {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    display: flex;
    justify-content: flex-start;
    align-items: flex-start;
    padding-top: 50px;
    transition: opacity 0.3s ease;
    pointer-events: all;
}

#sse-connection-status h1 {
    color: #ff3333;
    text-align: center;
    width: 100%;
    font-size: 2rem;
    opacity: 1;
    animation: pulse 1.5s infinite;
}

#sse-connection-status.sse-connected {
    opacity: 0;
    pointer-events: none;
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }
}

.validation-message {
    min-height: 1.5em;
    /* Reserve space for one line of text */
}

.landing-title {
    font-family: serif;
    font-size: x-large;
}
textarea.auto-grow {
    field-sizing: content;
}

.clickable:active {
    outline: 2px solid var(--pico-contrast-border);
    outline-offset: 2px;
}

/* fade out deleted rows */
tr.htmx-swapping td {
    opacity: 0;
    transition: opacity 1s ease-out;
}

.room-edit.description {
    min-height: 15rem;
}

/* exit editor */
#destination-inputs>div {
    display: none;
    margin-top: var(--pico-spacing);
}

#destination-inputs[data-which="create"]>#new-exit-name-input {
    display: block;
}

#destination-inputs[data-which="existing"]>#new-exit-existing-input {
    display: block;
}

#destination-inputs[data-which="same"]>#same-space-indicator {
    display: flex;
}

#same-space-indicator {
    height: 2.5rem;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--pico-muted-border-color);
    border-radius: var(--pico-border-radius, 0.375rem);
    background-color: var(--pico-background-color);
    color: var(--pico-muted-color);
    display: flex;
    align-items: center;
    box-sizing: border-box;
}

#same-space-indicator>h6 {
    margin: 0;
    padding: 0;
    font-size: 1rem;
    font-weight: inherit;
    display: inline-flex;
    align-items: center;
    width: 100%;
}