/* The Dungeon Generator's walk mode (walk.js): its bar above the map, the fog and tokens over it, the pad and the prompt
   for touch. It speaks the page's language (the Dungeon Generator's dark panels, gold outlined pill buttons) and takes
   the page's variables when it has them, with the same colours as a fallback. */
.dwalk-bar {
    --dwalk-gold: #e7bf8f;
    --dwalk-panel: var(--dungeon-surface, #0e171c);
    --dwalk-line: var(--dungeon-surface-line, rgba(242, 192, 128, 0.16));
    position: relative;
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 8px;
    min-height: 48px;
    padding: 4px 10px;
    border: 1px solid var(--dwalk-line);
    border-radius: 8px;
    background: var(--dwalk-panel);
    color: var(--dungeon-text, #f2c080);
    font-family: inherit;
    font-size: 0.85rem;
}

.dwalk-bar[hidden],
.dwalk-bar [hidden],
.dwalk-pad[hidden],
.dwalk-prompt[hidden],
.dwalk-screen-exit[hidden] {
    display: none;
}

.dwalk-title {
    flex: 1 1 auto;
    min-width: 4.5rem;
    overflow: hidden;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dwalk-inline,
.dwalk-menu-pickers {
    display: flex;
    flex: 0 1 auto;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.dwalk-pick {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 6px;
    margin: 0;
    color: var(--dungeon-muted, #b6cbd0);
    white-space: nowrap;
}

/* A picker keeps the width of its words (the bar moves the pickers into the menu when they do not fit). */
.dwalk-bar select {
    flex: 0 0 auto;
    max-width: 16rem;
    min-height: 36px;
    padding: 2px 26px 2px 10px;
    border: 1px solid var(--dwalk-line);
    border-radius: 18px;
    background-color: #151f25;
    color: var(--dwalk-gold);
    font: inherit;
}

/* The page's secondary buttons: a dark pill with a gold outline that fills with gold on hover. */
.dwalk-bar button,
.dwalk-prompt button {
    min-width: 40px;
    min-height: 36px;
    padding: 4px 14px;
    border: 1px solid var(--dwalk-gold, #e7bf8f);
    border-radius: 25px;
    background: #151f25;
    color: var(--dwalk-gold, #e7bf8f);
    font: inherit;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    white-space: nowrap;
    cursor: pointer;
}

.dwalk-bar button:hover,
.dwalk-prompt button:hover,
.dwalk-bar button[aria-pressed="true"] {
    background: var(--dwalk-gold, #e7bf8f);
    color: #151f25;
}

.dwalk-bar button:focus-visible,
.dwalk-prompt button:focus-visible,
.dwalk-pad button:focus-visible {
    outline: 2px solid var(--dungeon-link, #80ead5);
    outline-offset: 2px;
}

.dwalk-bar .dwalk-more {
    padding: 4px 12px;
    font-size: 1.2rem;
    line-height: 1;
}

.dwalk-bar .dwalk-exit {
    border-color: #d85f5f;
    color: #f0a0a0;
}

.dwalk-bar .dwalk-exit:hover {
    background: #d85f5f;
    color: #151f25;
}

/* What the walker is told, floating under the bar over the map (it never changes the bar's height). */
.dwalk-status {
    position: absolute;
    top: calc(100% + 6px);
    left: 8px;
    z-index: 70;
    max-width: calc(100% - 16px);
    margin: 0;
    padding: 4px 12px;
    border-radius: 14px;
    background: rgba(14, 23, 28, 0.88);
    color: var(--dungeon-text, #f2c080);
    pointer-events: none;
}

.dwalk-status:empty {
    display: none;
}

/* The menu of the "..." button: a panel under the bar; on a small screen a sheet from the bottom of it. */
.dwalk-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    z-index: 70;
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: min(300px, calc(100vw - 24px));
    padding: 14px;
    border: 1px solid var(--dwalk-line);
    border-radius: 10px;
    background: var(--dwalk-panel);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.5);
}

.dwalk-menu-pickers {
    display: none;
    flex-direction: column;
    align-items: stretch;
}

.dwalk-menu-pickers:not(:empty) {
    display: flex;
}

.dwalk-menu-pickers .dwalk-pick {
    flex: 0 1 auto;
    justify-content: space-between;
}

.dwalk-menu-pickers select {
    flex: 0 1 auto;
    min-width: 0;
    max-width: 60%;
    min-height: 44px;
}

.dwalk-bar .dwalk-check {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 40px;
    margin: 0;
    color: var(--dungeon-text, #f2c080);
    white-space: nowrap;
}

.dwalk-bar .dwalk-check input {
    width: 20px;
    height: 20px;
    margin: 0;
    accent-color: var(--dwalk-gold, #e7bf8f);
}

.dwalk-menu button {
    width: 100%;
    min-height: 44px;
}

.dwalk-overlay {
    position: absolute;
    z-index: 3;
    touch-action: none;
    cursor: pointer;
}

/* The pad and the prompt sit over the map's corner (fixed, so they stay put while the map scrolls, and inside the map's
   frame, so they stay in view when it is made full screen). A page with a bar along the bottom of the screen sets
   --dwalk-inset-bottom on the map's frame to the bar's height. */
.dwalk-pad {
    position: fixed;
    right: 12px;
    bottom: var(--dwalk-inset-bottom, 12px);
    z-index: 60;
    display: grid;
    grid-template-columns: repeat(3, 52px);
    grid-auto-rows: 52px;
    gap: 6px;
}

.dwalk-pad button {
    padding: 0;
    border: 1px solid rgba(231, 191, 143, 0.55);
    border-radius: 14px;
    background: rgba(14, 23, 28, 0.55);
    color: rgba(255, 255, 255, 0.92);
    font-size: 1.3rem;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.dwalk-pad .dwalk-pad-gap {
    visibility: hidden;
}

.dwalk-pad button:active {
    background: rgba(231, 191, 143, 0.55);
}

@media (pointer: coarse) {
    .dwalk-pad {
        grid-template-columns: repeat(3, 60px);
        grid-auto-rows: 60px;
    }
}

.dwalk-prompt {
    position: fixed;
    left: 12px;
    bottom: var(--dwalk-inset-bottom, 12px);
    z-index: 60;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    max-width: calc(100vw - 24px - 3 * 66px);
    padding: 8px;
    border-radius: 12px;
    background: rgba(14, 23, 28, 0.9);
}

.dwalk-prompt button {
    min-height: 44px;
}

.dwalk-frame:fullscreen {
    background: #000;
}

/* The players' screen where the browser has no full screen to give: the map's frame fills the window (its position is set
   by the script), with a button to come back above it. */
.dwalk-frame.dwalk-player-screen {
    inset: 0;
    z-index: 1060;
    width: 100%;
    height: 100%;
    max-height: none;
    background: #000;
}

.dwalk-screen-exit {
    position: fixed;
    top: 12px;
    right: 12px;
    z-index: 61;
    min-height: 40px;
    padding: 4px 14px;
    border: 1px solid var(--dwalk-gold, #e7bf8f);
    border-radius: 25px;
    background: rgba(21, 31, 37, 0.85);
    color: var(--dwalk-gold, #e7bf8f);
    font: inherit;
    font-weight: 600;
    text-transform: uppercase;
    cursor: pointer;
}

/* A phone, or a landscape phone (the page's own phone layout): one 48 px row, Search and the DM view as icons of words
   short enough to fit, the pickers in the menu, which opens as a sheet over the bottom of the screen. */
@media (max-width: 767px), (pointer: coarse) and (max-height: 500px) {
    .dwalk-bar {
        gap: 6px;
        height: 48px;
        padding: 3px 6px;
        border-radius: 0;
        border-left: 0;
        border-right: 0;
    }

    .dwalk-bar button {
        min-height: 42px;
        padding: 4px 10px;
        font-size: 0.75rem;
    }

    .dwalk-bar .dwalk-more {
        min-width: 42px;
        padding: 4px 8px;
    }

    .dwalk-title {
        font-size: 0.8rem;
    }

    .dwalk-menu {
        position: fixed;
        top: auto;
        right: 0;
        bottom: 0;
        left: 0;
        z-index: 1070;
        width: auto;
        max-height: 70vh;
        padding: 16px 16px max(16px, env(safe-area-inset-bottom));
        overflow-y: auto;
        border-width: 1px 0 0;
        border-radius: 16px 16px 0 0;
    }

    /* The prompt of the stairs goes over the pad, not under it (as high as the pad while the pad is shown). */
    .dwalk-prompt {
        right: 12px;
        bottom: calc(var(--dwalk-inset-bottom, 12px) + 3 * 60px + 24px);
        max-width: none;
    }

    .dwalk-frame:has(.dwalk-pad[hidden]) .dwalk-prompt {
        bottom: var(--dwalk-inset-bottom, 12px);
    }
}
