/* --------------------------------------------------------------- world

   The voxel island (js/world.js). Everything in here only applies while
   <html> carries .world-on; without it the page is the plain grid of
   css/style.css. In the world view the page does not scroll: the canvas
   fills the window, header and footer float above it, and the cards of the
   grid are kept out of sight until the robot visits their booth. */

.world,
.world-labels,
.world-ui {
    display: none;
}

/* ---------------------------------------------------------------- tools */

/* buttons in the header: view and sound */
.site-tools {
    display: flex;
    align-items: center;
    gap: 0.6em;
}

.site-tools > a {
    margin-left: 0.65em;
}

.tool {
    display: flex;
    align-items: center;
    gap: 0.6em;
    appearance: none;
    cursor: pointer;
    font: inherit;
    font-size: 0.75em;
    text-transform: uppercase;
    white-space: nowrap;
    color: #ffffff;
    padding: 0.65em 0.9em;
    border-radius: 0.5em;
    background: hsla(240, 14%, 30%, 0.25);
    backdrop-filter: blur(10px) saturate(1.5);
}

.tool[hidden] {
    display: none;
}

.tool:hover {
    color: #111117;
    background: #ffffff; 
}

.tool svg {
    display: block;
    width: 1.2em;
    height: 1.2em;
}

/* the view button shows where it leads */
.tool .tool-icon-grid,
.world-on .tool .tool-icon-world {
    display: none;
}

.world-on .tool .tool-icon-grid {
    display: block;
}

.tool[aria-pressed="false"] .tool-icon-waves {
    display: none;
}

/* --------------------------------------------------------------- layout */

.world-on,
.world-on body {
    overflow: hidden;
}

.world-on body {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
}

.world-on .world {
    display: block;
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
}

/* the banner slides up and away in this view, and comes down again in the grid view (it is out
   of reach of the tab key once it is gone) */
.world-on .banner {
    flex-shrink: 0;
    grid-template-rows: 0fr;
    border-bottom-width: 0;
    visibility: hidden;
    transition: grid-template-rows 0.55s cubic-bezier(0.4, 0, 0.2, 1), border-bottom-width 0.55s, visibility 0s 0.55s;
}

/* the page column stays where it is, but only its controls take clicks */
.world-on .container {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    pointer-events: none;
}

.world-on .site-header a,
.world-on .site-header button,
.world-on .site-footer a {
    pointer-events: auto;
}

.world-on .grid {
    display: block;
    flex: 1 1 auto;
    min-height: 0;
    margin: 0;
}

.world-on .site-footer {
    margin-top: 0;
}

/* ---------------------------------------------------------------- cards */

/* the card of the booth the robot stands at slides in from the side */
.world-on .box {
    position: fixed;
    z-index: 3;
    top: 50%;
    right: var(--site-padding);
    width: min(320px, calc(100vw - 2 * var(--site-padding)));
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translate(calc(100% + 4em), -50%);
    box-shadow: 0px 18px 60px 0px rgb(0 0 0 / 55%);
    transition: transform 0.45s cubic-bezier(0.5, 0, 0.75, 0.3), opacity 0.3s, visibility 0s 0.45s;
}

.world-on .box.is-active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translate(0, -50%);
    transition: transform 0.55s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s, visibility 0s;
}

/* --------------------------------------------------------------- labels */

/* the name of the game whose card is up, over its board; js moves it with the picture */
.world-on .world-labels {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 0;
    overflow: hidden;
    pointer-events: none;
}

.world-label {
    position: absolute;
    top: 0;
    left: 0;
    display: flex;
    align-items: center;
    gap: 0.6em;
    max-width: 16em;
    appearance: none;
    cursor: pointer;
    font: inherit;
    font-size: 0.7em;
    line-height: 1;
    text-transform: uppercase;
    white-space: nowrap;
    color: hsl(240, 25%, 82%);
    padding: 0.5em 0.75em;
    border-radius: 0.5em;
    background: rgb(17 17 23 / 80%);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    will-change: transform;
    transition: opacity 0.3s, visibility 0s 0.3s;
}

.world-label.is-shown {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transition: opacity 0.3s 0.15s, visibility 0s;
}

.world-label span {
    overflow: hidden;
    text-overflow: ellipsis;
}

.world-label.is-empty {
    cursor: default;
    color: var(--txt-light);
    pointer-events: none;
}

/* ------------------------------------------------------------------ hud */

/* how to get around, on the right, right above the footer */
.world-on .world-ui {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-shrink: 0;
}

.world-hint {
    min-width: 0;
    font-size: 0.75em;
    line-height: 1.2;
    text-transform: uppercase;
    text-align: right;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--txt-light);
    transition: opacity 1.5s 4s;
}

/* fades once the robot has taken its first steps */
.world-ui.is-used .world-hint {
    opacity: 0;
}

/* ---------------------------------------------------------------- small */

@media (max-width: 950px) {
    .world-hint {
        display: none;
    }
}

@media (max-width: 650px) {

    /* no room for words in the header */
    .tool span {
        display: none;
    }

    .site-tools > a {
        margin-left: 0.25em;
    }

    .world-label {
        font-size: 0.6em;
        max-width: 11em;
    }

    /* the card comes up from below, laid out flat: the picture, then icon beside the texts */
    .world-on .box {
        --box-header: 112px;
        top: auto;
        left: 24px;
        right: 24px;
        bottom: 24px;
        width: auto;
        transform: translateY(calc(100% + 48px));
    }

    .world-on .box.is-active {
        transform: none;
    }

    /* One row: the icon, beside it title and description, and the badges at the right, all centred on the icon; the
       button below, across all of it. The badges take the room they need, title and description
       what is left – cut with … where that is not enough. */
    .world-on .box-details {
        display: grid;
        grid-template-columns: 52px minmax(0, 1fr) auto;
        gap: 0 1.1em;
        padding: 1.1em;
    }

    .world-on .box-icon {
        grid-area: 1 / 1 / span 2 / auto;
        width: 52px;
        height: 52px;
    }

    /* Title and description as one block, centred on the icon: the icon is higher than the two,
       the rows share what is over equally, and the title sits at the bottom of the upper row,
       the description at the top of the lower one. */
    .world-on .box-title {
        grid-area: 1 / 2;
        align-self: end;
    }

    /* The margin puts the two exactly as close as they are in the grid view – there it is the gap
       of the card, 1.5em, less the 1.65em the description is pulled up by; the gap is counted in
       the font size of the card, the description is 0.85 of that. */
    .world-on .box-description {
        grid-area: 2 / 2;
        align-self: start;
        margin-top: calc(1.5em / 0.85 - 1.65em);
        text-align: left;
    }

    .world-on .box-badges {
        grid-area: 1 / 3 / span 2 / auto;
        align-self: center;
        flex-wrap: nowrap;
        justify-content: flex-end;
        margin-top: 0;
    }

    .world-on .box-button,
    .world-on .box-button-disabled {
        grid-area: 3 / 1 / auto / -1;
        margin-top: 1.3em;
        padding: 1em 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    .banner,
    .world-on .banner,
    .world-on .box,
    .world-on .box.is-active,
    .world-label {
        transition: none;
    }
}
