/* ============================================
   THE DIRECTORATE — LOBBY SKIN
   Restyles the shared lobby (prototypes/shared/proto-lobby.*) for this game:
   menu art behind, navy panels, the name/menu panel kept left of the art's
   scene, and a room screen that fits without scrolling.
   Load after proto-lobby.css. Colours and art come from spy-theme.css.
   ============================================ */

/* --- Text sizes --- */

.proto-lobby__title {
    font-size: clamp(2rem, 7vw, 3.1rem);
    letter-spacing: 1px;
    line-height: 1.1;
}

.proto-lobby__label {
    font-size: 1.05rem;
    letter-spacing: 1.5px;
    line-height: 1.1;
}

.proto-lobby__code {
    font-size: 2.6rem;
    line-height: 1;
}

.proto-lobby__code-input {
    font-size: 1.5rem;
    padding-block: 0.35rem;
}

/* --- Layout and panels --- */

/* Lobby: menu art, with the panel (title + buttons) on the left over the dark sky */
.proto-lobby {
    /* Where the art's scene starts on screen. The art is drawn "cover" at
       --menu-focus-x, so: its width is the larger of the window width and
       height × aspect, and its left edge is (100vw − width) × focus. */
    --art-w: max(100vw, 100dvh * var(--menu-bg-aspect));
    --art-edge-x: calc(100vw * var(--menu-focus-x) - var(--art-w) * (var(--menu-focus-x) - var(--menu-art-edge)));
    --menu-card-w: clamp(300px, calc(var(--art-edge-x) - 48px), 420px);

    background:
        var(--menu-shade),
        var(--menu-bg-image) var(--menu-bg-focus) / cover no-repeat,
        var(--color-bg-deep);
    justify-content: flex-start;
    padding-left: clamp(16px, 5vw, 96px);
    padding-right: 16px;
}

/* Name / menu: centred in the dark sky, left of where the scene starts */
.proto-lobby[data-panel="name"],
.proto-lobby[data-panel="menu"],
.proto-lobby[data-panel="busy"] {
    align-items: center;
    padding-left: 0;
}

.proto-lobby__card {
    background: var(--panel-solid);
    border: 1px solid var(--panel-line);
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35), 0 14px 40px rgba(0, 0, 0, 0.55);
    -webkit-backdrop-filter: blur(5px);
    backdrop-filter: blur(5px);
}

.proto-lobby[data-panel="name"] .proto-lobby__card,
.proto-lobby[data-panel="menu"] .proto-lobby__card,
.proto-lobby[data-panel="busy"] .proto-lobby__card {
    max-width: none;
    width: var(--menu-card-w);
    margin-left: max(16px, calc((var(--art-edge-x) - var(--menu-card-w)) / 2));
}

/* The room has more to read: a little more solid */
.proto-lobby[data-panel="room"] .proto-lobby__card {
    background: rgba(9, 20, 32, 0.92);
}

.proto-lobby .btn--secondary { border-color: var(--panel-line); }
.proto-lobby .btn--secondary:hover { border-color: var(--color-gold); }
.proto-lobby__seat,
.proto-lobby__input,
.proto-lobby__select,
.proto-lobby__chat-log { border-color: rgba(201, 170, 110, 0.18); }
.proto-options { background: var(--scrim); }

/* Room, wide screens: everything fits without scrolling.
   Title, room code and invite link share one header row; settings sit two
   to a row; chat takes whatever height is left. */
@media (min-width: 761px) {
    .proto-lobby[data-panel="room"] .proto-lobby__card {
        display: grid;
        grid-template-columns: auto minmax(0, 1fr);
        grid-template-rows: auto auto minmax(0, 1fr) auto;
        column-gap: var(--spacing-md);
        /* a definite height so the chat row can take what's left */
        height: min(700px, calc(100dvh - 2 * var(--spacing-lg)));
        padding: var(--spacing-md) var(--spacing-md) 0.9rem;
    }
    .proto-lobby[data-panel="room"] .proto-lobby__title {
        grid-row: 1;
        grid-column: 1;
        align-self: center;
        margin: 0;
        font-size: clamp(2rem, 3.4vw, 2.6rem);
        text-align: left;
    }
    /* The panel's children join the card's grid */
    .proto-lobby[data-panel="room"] .proto-lobby__panel[data-panel="room"] {
        display: contents;
    }
    .proto-lobby[data-panel="room"] .proto-lobby__code-row {
        grid-row: 1;
        grid-column: 2;
        justify-content: flex-end;
        flex-wrap: nowrap;
        gap: var(--spacing-md);
    }
    .proto-lobby[data-panel="room"] .proto-lobby__code-row > div {
        display: flex;
        align-items: baseline;
        gap: 0.6rem;
    }
    .proto-lobby[data-panel="room"] .proto-lobby__error {
        grid-row: 2;
        grid-column: 1 / -1;
        margin: var(--spacing-xs) 0 0;
    }
    .proto-lobby[data-panel="room"] .proto-lobby__room-body {
        grid-row: 3;
        grid-column: 1 / -1;
        margin-top: var(--spacing-sm);
        overflow-y: auto;
        overflow-x: hidden;    /* never a sideways scrollbar */
    }
    .proto-lobby[data-panel="room"] .proto-lobby__actions {
        grid-row: 4;
        grid-column: 1 / -1;
        margin-top: var(--spacing-sm);
    }
    /* Each setting: name | dropdown. A narrow column shortens the name, never pushes the dropdown out. */
    .proto-lobby[data-panel="room"] .proto-lobby__setting {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        column-gap: 0.5rem;
    }
    .proto-lobby[data-panel="room"] .proto-lobby__setting > span {
        overflow: hidden;
        text-overflow: ellipsis;
    }
    /* An odd one out (5 settings) takes the whole last row */
    .proto-lobby[data-panel="room"] .proto-lobby__setting:last-child:nth-child(odd) {
        grid-column: 1 / -1;
    }
    .proto-lobby[data-panel="room"] .proto-lobby__settings {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.4rem var(--spacing-md);
    }
}

/* The title shrinks with a narrow panel so "Directorate" stays inside it */
.proto-lobby[data-panel="name"] .proto-lobby__title,
.proto-lobby[data-panel="menu"] .proto-lobby__title,
.proto-lobby[data-panel="busy"] .proto-lobby__title {
    font-size: min(3.1rem, calc((var(--menu-card-w) - 48px) / 7.3));
}

.proto-lobby__settings .proto-lobby__select {
    flex: none;            /* never squeeze "Normal" to "Norm" */
    min-width: auto;
}

/* Phones: settings two to a row, name above its dropdown, so the room fits */
@media (max-width: 760px) {
    .proto-lobby[data-panel="room"] .proto-lobby__settings {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 0.45rem var(--spacing-xs);
    }
    .proto-lobby[data-panel="room"] .proto-lobby__setting {
        flex-direction: column;
        align-items: stretch;
        gap: 2px;
        min-width: 0;
    }
    .proto-lobby[data-panel="room"] .proto-lobby__setting > span {
        font-size: 0.95rem;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .proto-lobby[data-panel="room"] .proto-lobby__settings .proto-lobby__select {
        min-width: 0;
        padding-inline: 0.4rem;
    }
    .proto-lobby[data-panel="room"] .proto-lobby__room-col--chat .proto-lobby__chat-log {
        height: 70px;
        min-height: 70px;
    }
}

.proto-lobby__setting > span {
    font-family: var(--font-ui);
    font-size: 1.05rem;
    letter-spacing: 1px;
    line-height: 1.1;
    color: var(--color-text-dim);
    text-transform: uppercase;
    white-space: nowrap;
}

@media (max-width: 600px) {
    .proto-lobby { justify-content: center; padding-left: 16px; }
    .proto-lobby[data-panel="name"] .proto-lobby__card,
    .proto-lobby[data-panel="menu"] .proto-lobby__card,
    .proto-lobby[data-panel="busy"] .proto-lobby__card { width: 100%; margin-left: 0; }
    /* Phones: panel at the bottom so the art's faces stay in view */
    .proto-lobby[data-panel="name"],
    .proto-lobby[data-panel="menu"],
    .proto-lobby[data-panel="busy"] { align-items: flex-end; padding-bottom: 24px; padding-left: 16px; }
}

/* Room buttons: Leave and Start Game together on the left; the guests'
   "waiting for the host" note on the right. */
.proto-lobby[data-panel="room"] .proto-lobby__actions { justify-content: flex-start; }
.proto-lobby[data-panel="room"] [data-action="leave"] { order: 0; }
.proto-lobby[data-panel="room"] [data-action="start"] { order: 1; }
.proto-lobby[data-panel="room"] .proto-lobby__waiting { order: 2; margin-left: auto; }
