/*
 * EGGY_POOL_LOBBY_ACTIONS_V2
 *
 * Shared Pool Hall action rail.
 * - Desktop: Challenge AI / Create Table / Exit Pool share one responsive row.
 * - Phone landscape: the same actions stay compact and shallow above Hub navigation.
 * - Button labels are text-only and mathematically centred.
 */

body[data-template="eggy_pool_lobby"]
.epPoolLobbyV2__availableTools > .epPoolAiChallenge,
body[data-template="eggy_pool_lobby"]
.epPoolLobbyV2__availableTools > #epPoolLobbyCreateHeader,
body[data-template="eggy_pool_lobby"]
.epPoolLobbyV2__availableTools > #epPoolLandscapeExit
{
    box-sizing: border-box !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 0 !important;
    text-align: center !important;
    white-space: nowrap !important;
}

/* Hub may decorate Create Table with an icon. The shared action rail is text-only. */
body[data-template="eggy_pool_lobby"]
.epPoolLobbyV2__availableTools > .epPoolAiChallenge svg,
body[data-template="eggy_pool_lobby"]
.epPoolLobbyV2__availableTools > .epPoolAiChallenge i,
body[data-template="eggy_pool_lobby"]
.epPoolLobbyV2__availableTools > #epPoolLobbyCreateHeader svg,
body[data-template="eggy_pool_lobby"]
.epPoolLobbyV2__availableTools > #epPoolLobbyCreateHeader i,
body[data-template="eggy_pool_lobby"]
.epPoolLobbyV2__availableTools > #epPoolLandscapeExit svg,
body[data-template="eggy_pool_lobby"]
.epPoolLobbyV2__availableTools > #epPoolLandscapeExit i
{
    display: none !important;
}

/* Exit Pool is available in the normal desktop Pool Hall as well as landscape. */
body[data-template="eggy_pool_lobby"] #epPoolLandscapeExit
{
    display: inline-flex !important;
}

/* Stable action ordering regardless of add-on template-modification order. */
body[data-template="eggy_pool_lobby"]
.epPoolLobbyV2__availableTools > .epPoolAiChallenge
{
    order: 10;
}

body[data-template="eggy_pool_lobby"]
.epPoolLobbyV2__availableTools > #epPoolLobbyCreateHeader
{
    order: 20;
}

body[data-template="eggy_pool_lobby"]
.epPoolLobbyV2__availableTools > #epPoolLandscapeExit
{
    order: 30;
}

body[data-template="eggy_pool_lobby"]
.epPoolLobbyV2__availableTools > .epPoolHubNav
{
    order: 100;
    flex: 1 0 100% !important;
    width: 100% !important;
    max-width: none !important;
}

/*
 * Desktop / tablet-width Pool Hall.
 * Keep all three actions on the same line when there is normal UI width,
 * with equal responsive widths and genuinely centred labels.
 */
@media (min-width: 651px)
{
    body[data-template="eggy_pool_lobby"]
    .epPoolLobbyV2__available .epPoolLobbyV2__availableTools
    {
        flex-direction: row !important;
        align-items: center !important;
        justify-content: flex-end !important;
        flex-wrap: wrap !important;
        gap: 9px !important;
    }

    body[data-template="eggy_pool_lobby"]
    .epPoolLobbyV2__availableTools > .epPoolAiChallenge,
    body[data-template="eggy_pool_lobby"]
    .epPoolLobbyV2__availableTools > #epPoolLobbyCreateHeader,
    body[data-template="eggy_pool_lobby"]
    .epPoolLobbyV2__availableTools > #epPoolLandscapeExit
    {
        flex: 0 1 clamp(118px, 11vw, 160px) !important;
        width: clamp(118px, 11vw, 160px) !important;
        min-width: 118px !important;
        max-width: 160px !important;
        min-height: 42px !important;
        padding: 8px 14px !important;
        line-height: 1.2 !important;
    }
}

/*
 * Phone landscape fullscreen shell.
 * The base responsive LESS switches the tool column vertical below 900px;
 * force it back to a row here. Without this, flex-basis becomes vertical and
 * turns the 94-100px action widths into tall chunky buttons.
 */
@media
    (pointer: coarse)
    and (orientation: landscape)
    and (max-height: 600px)
{
    body[data-template="eggy_pool_lobby"]
    .epPoolLobbyV2__available .epPoolLobbyV2__sectionBar
    {
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        align-items: center !important;
        justify-content: space-between !important;
        gap: 8px !important;
    }

    body[data-template="eggy_pool_lobby"]
    .epPoolLobbyV2__available .epPoolLobbyV2__sectionHeading
    {
        flex: 0 0 auto !important;
        min-width: 0 !important;
    }

    body[data-template="eggy_pool_lobby"]
    .epPoolLobbyV2__available .epPoolLobbyV2__availableTools
    {
        display: flex !important;
        flex: 1 1 0 !important;
        width: auto !important;
        max-width: none !important;
        min-width: 0 !important;
        flex-direction: row !important;
        align-items: center !important;
        justify-content: flex-end !important;
        flex-wrap: wrap !important;
        gap: 5px !important;
    }

    /* The header count duplicates the hero metric in landscape. */
    body[data-template="eggy_pool_lobby"]
    .epPoolLobbyV2__available #epPoolLobbyAvailableCount
    {
        display: none !important;
    }

    body[data-template="eggy_pool_lobby"]
    .epPoolLobbyV2__availableTools > .epPoolAiChallenge,
    body[data-template="eggy_pool_lobby"]
    .epPoolLobbyV2__availableTools > #epPoolLobbyCreateHeader,
    body[data-template="eggy_pool_lobby"]
    .epPoolLobbyV2__availableTools > #epPoolLandscapeExit
    {
        flex: 0 0 100px !important;
        width: 100px !important;
        min-width: 100px !important;
        max-width: 100px !important;
        height: 28px !important;
        min-height: 28px !important;
        max-height: 28px !important;
        padding: 4px 8px !important;
        font-size: 10px !important;
        line-height: 18px !important;
        font-weight: 800 !important;
        border-radius: 6px !important;
    }

    body[data-template="eggy_pool_lobby"]
    .epPoolLobbyV2__availableTools > .epPoolHubNav
    {
        flex: 1 0 100% !important;
        width: 100% !important;
        max-width: none !important;
    }
}

@media
    (pointer: coarse)
    and (orientation: landscape)
    and (max-height: 600px)
    and (max-width: 740px)
{
    body[data-template="eggy_pool_lobby"]
    .epPoolLobbyV2__availableTools > .epPoolAiChallenge,
    body[data-template="eggy_pool_lobby"]
    .epPoolLobbyV2__availableTools > #epPoolLobbyCreateHeader,
    body[data-template="eggy_pool_lobby"]
    .epPoolLobbyV2__availableTools > #epPoolLandscapeExit
    {
        flex-basis: 94px !important;
        width: 94px !important;
        min-width: 94px !important;
        max-width: 94px !important;
    }
}

/* Keep the old portrait mobile Hall uncluttered. */
@media
    (pointer: coarse)
    and (orientation: portrait)
    and (max-width: 650px)
{
    body[data-template="eggy_pool_lobby"] #epPoolLandscapeExit
    {
        display: none !important;
    }
}
