/*
 * The homepage adventure game (js/game.js), in the style of the LucasArts SCUMM games.
 * While it's on, the classic page underneath is hidden; it comes back with "Classic site".
 */

.game-on body {
    overflow: hidden;
}

.game-on .skip-link,
.game-on .site-header,
.game-on main,
.game-on .site-footer {
    display: none;
}

.game {
    --px: 4;
    --g-bg: #0a0812;
    --g-panel: #120e1f;
    --g-line: #2a2342;
    --g-verb: #8f7fe6;
    --g-verb-on: #ffffff;
    --g-hot: #f4d34c;
    --g-sentence: #62d6d0;
    --g-choice: #c08ef0;
    /* A pixel crosshair, like the SCUMM games */
    --g-cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='17' height='17' shape-rendering='crispEdges'%3E%3Cpath d='M7 0h3v6H7zM7 11h3v6H7zM0 7h6v3H0zM11 7h6v3h-6z' fill='%23000'/%3E%3Cpath d='M8 1h1v5H8zM8 11h1v5H8zM1 8h5v1H1zM11 8h5v1h-5z' fill='%23fff'/%3E%3C/svg%3E") 8 8, crosshair;
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    flex-direction: column;
    background: var(--g-bg);
    color: #e9e4ff;
    font-family: 'VT323', ui-monospace, Menlo, Consolas, monospace;
    font-size: 22px;
    line-height: 1.1;
    overflow: hidden;
    -webkit-font-smoothing: none;
    -webkit-tap-highlight-color: transparent;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    touch-action: manipulation;
}

.game input {
    -webkit-user-select: text;
    user-select: text;
}

.game[hidden] {
    display: none;
}

.game button {
    font: inherit;
    color: inherit;
    background: none;
    border: 0;
    padding: 0;
    cursor: pointer;
}

.game :focus-visible {
    outline: 2px solid var(--g-hot);
    outline-offset: 1px;
    box-shadow: none;
    border-radius: 0;
}

.game__skip {
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: 5;
    padding: 6px 10px;
    background: var(--g-hot);
    color: #120e1f;
    transform: translateY(-200%);
}

.game__skip:focus {
    transform: none;
}

/* ---------- Top bar ---------- */

.game__bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 6px 16px;
    border-bottom: 2px solid var(--g-line);
    flex: none;
}

.game__brand {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    color: #fff;
    text-decoration: none;
    font-size: 24px;
    white-space: nowrap;
}

.game__brand:hover {
    color: var(--g-hot);
}

.game__mark {
    display: inline-grid;
    place-items: center;
    width: 26px;
    height: 26px;
    flex: none;
    background: #232e54;
    color: #fff;
    font-size: 18px;
    box-shadow: inset 0 0 0 2px #5ab7f2;
}

.game__room {
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--g-sentence);
}

.game__room:empty {
    display: none;
}

.game__room::before {
    content: '·';
    margin-right: 8px;
    color: #5a527a;
}

.game__tools {
    display: flex;
    gap: 6px;
    flex: none;
}

.game .game__tool {
    padding: 2px 10px;
    border: 2px solid var(--g-line);
    color: var(--g-verb);
    font-size: 20px;
}

.game .game__tool:hover {
    color: var(--g-hot);
    border-color: #4a3f70;
}

/* ---------- Stage ---------- */

.game__body {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 0;
    padding-top: 4px;
}

.game__stage {
    position: relative;
    width: 320px;
    height: 144px;
    max-width: 100%;
    flex: none;
    overflow: hidden;
    overflow: clip; /* not a scroll container, so focusing an off-screen hotspot can't shift it */
    cursor: var(--g-cursor);
    transition: opacity 0.22s;
    touch-action: manipulation;
}

.game__stage.is-fading,
.game--leaving .game__stage {
    opacity: 0;
}

/* Using a screen in the gallery: it grows to fill the stage before the case study opens */
.game__zoom {
    position: fixed;
    z-index: 4;
    background: #fff top left / cover no-repeat;
    box-shadow: 0 0 0 3px #14111f;
    pointer-events: none;
    transition: left 0.45s cubic-bezier(0.6, 0, 0.2, 1), top 0.45s cubic-bezier(0.6, 0, 0.2, 1), width 0.45s cubic-bezier(0.6, 0, 0.2, 1), height 0.45s cubic-bezier(0.6, 0, 0.2, 1);
}

.is-busy .game__stage {
    cursor: wait;
}

/* The room; it scrolls inside the stage when the stage is narrower than the room (portrait) */
.game__world {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    will-change: transform;
}

/* Low on the floor, where there are no hotspots to cover */
.game .game__pan {
    position: absolute;
    bottom: 6px;
    z-index: 1;
    display: grid;
    place-items: center;
    width: 44px;
    height: 48px;
    background: rgba(10, 8, 18, 0.45);
    color: var(--g-hot);
}

.game .game__pan[hidden] {
    display: none;
}

.game__pan--left {
    left: 0;
    border-radius: 0 6px 6px 0;
}

.game__pan--right {
    right: 0;
    border-radius: 6px 0 0 6px;
}

.game__pan span {
    display: block;
    animation: game-nudge 1.4s ease-in-out infinite;
}

.game__pan svg {
    display: block;
    filter: drop-shadow(2px 2px 0 #000);
}

.game__pan--left svg {
    transform: scaleX(-1);
}

.game__pan--left span {
    animation-direction: reverse;
}

@keyframes game-nudge {
    50% { transform: translateX(3px); }
}

.game__canvas {
    display: block;
    width: 100%;
    height: 100%;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

.game__hotspots {
    position: absolute;
    inset: 0;
}

.game .game__hotspot {
    position: absolute;
    cursor: var(--g-cursor);
}

.game .game__hotspot:focus-visible {
    outline: 2px dashed var(--g-hot);
    outline-offset: 0;
}

.game__speech {
    position: absolute;
    max-width: min(70%, 460px);
    margin: 0;
    font-size: max(18px, calc(var(--px) * 8px));
    line-height: 1;
    text-align: center;
    text-wrap: balance;
    pointer-events: none;
    text-shadow:
        2px 0 0 #000, -2px 0 0 #000, 0 2px 0 #000, 0 -2px 0 #000,
        2px 2px 0 #000, -2px -2px 0 #000, 2px -2px 0 #000, -2px 2px 0 #000;
}

.game__title {
    margin: 0;
    color: var(--g-hot);
    font-size: max(30px, calc(var(--px) * 16px));
    line-height: 0.9;
    text-shadow: 3px 3px 0 #a8432c, 6px 6px 0 #000;
}

.game__title span {
    display: block;
}

.game__title span:first-child {
    font-size: 0.55em;
    color: #ffe9a8;
}

.game__subtitle {
    margin: 0.4em 0 0;
    color: #fff;
    font-size: max(18px, calc(var(--px) * 7px));
}

/* ---------- The opening: press start, title screen, credits ---------- */

.is-title .game__sentence,
.is-title .game__ui,
.is-cinematic .game__sentence,
.is-cinematic .game__ui {
    visibility: hidden;
}

.is-title .game__hotspots,
.is-cinematic .game__hotspots {
    display: none;
}

.is-title .game__stage,
.is-cinematic .game__stage {
    cursor: default;
}

.game__lockup {
    position: absolute;
    top: 6%;
    left: 0;
    right: 0;
    text-align: center;
    pointer-events: none;
}

.game__lockup[hidden] {
    display: none;
}

.game__lockup .game__subtitle {
    margin-top: 0.3em;
    color: #c8c2ea;
    font-size: max(16px, calc(var(--px) * 6px));
    text-shadow: 2px 2px 0 #000;
}

.game__credits {
    position: absolute;
    top: 8%;
    left: 5%;
    max-width: 34%;
    margin: 0;
    pointer-events: none;
    text-shadow: 2px 2px 0 #000, -1px -1px 0 #000;
}

.game__credits[hidden] {
    display: none;
}

.game__credits span {
    display: block;
}

.game__credits-small {
    color: var(--g-hot);
    font-size: max(16px, calc(var(--px) * 6px));
}

.game__credits-big {
    color: #fff;
    font-size: max(20px, calc(var(--px) * 9px));
    line-height: 0.95;
}

.game .game__skipintro {
    position: absolute;
    right: 8px;
    bottom: 8px;
    z-index: 2;
    padding: 2px 10px;
    background: rgba(10, 8, 18, 0.75);
    box-shadow: inset 0 0 0 2px var(--g-line);
    color: var(--g-verb);
    font-size: 19px;
}

.game .game__skipintro:hover {
    color: var(--g-hot);
}

.game__skipintro[hidden] {
    display: none;
}

.game__menu {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
}

.game__menu[hidden] {
    display: none;
}

/* Menu and Classic portfolio join the top bar once you've entered */
.is-title .game__tool--inside {
    display: none;
}

/* The pause menu */
.game__pause {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    margin: 6px 0 0;
    padding: 0;
    list-style: none;
}

.game__dialog-title + .game__pause {
    margin-top: 10px;
}

.game .game__menu-item {
    padding: 2px 16px;
    color: var(--g-verb);
    font-size: 28px;
}

.game .game__menu-item:hover,
.game .game__menu-item:focus-visible {
    color: var(--g-hot);
    outline: none;
}

.game .game__menu-item::before,
.game .game__menu-item::after {
    visibility: hidden;
}

.game .game__menu-item::before {
    content: '▸ ';
}

.game .game__menu-item::after {
    content: ' ◂';
}

.game .game__menu-item:hover::before,
.game .game__menu-item:hover::after,
.game .game__menu-item:focus-visible::before,
.game .game__menu-item:focus-visible::after {
    visibility: visible;
}

/* ---------- Sentence line, verbs and inventory ---------- */

.game__sentence {
    flex: none;
    width: 100%;
    margin: 0;
    padding: 4px 16px 2px;
    color: var(--g-sentence);
    font-size: 24px;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.game__panel {
    position: relative;
    flex: none;
    width: 100%;
    max-width: 960px;
    height: 124px;
    padding: 4px 16px 10px;
}

.game__ui {
    display: grid;
    grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
    gap: 16px;
    height: 100%;
}

.game__ui.is-hidden {
    visibility: hidden;
}

.game__verbs {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-auto-rows: 1fr;
}

.game .game__verb {
    color: var(--g-verb);
    font-size: 26px;
    text-align: left;
    padding: 0 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.game .game__verb:hover,
.game .game__verb.is-default {
    color: var(--g-hot);
}

.game .game__verb[aria-pressed="true"] {
    color: var(--g-verb-on);
    background: #2a2342;
}

.game__inventory {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    grid-auto-rows: minmax(0, 1fr);
    gap: 4px;
    margin: 0;
    padding: 0;
    list-style: none;
    overflow-y: auto;
}

.game__inventory li {
    min-height: 0;
    background: var(--g-panel);
    box-shadow: inset 0 0 0 2px var(--g-line);
}

.game .game__item {
    display: grid;
    place-items: center;
    width: 100%;
    height: 100%;
    padding: 4px;
}

.game .game__item:hover {
    background: #2a2342;
}

.game__item img {
    width: 100%;
    max-width: 64px;
    height: 100%;
    max-height: 48px;
    object-fit: contain;
    image-rendering: pixelated;
}

.game__choices {
    /* Anchored to the bottom of the panel; grows up over the scene when there are many options */
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 2;
    min-height: 100%;
    max-height: 70vh;
    margin: 0;
    padding: 8px 16px 10px;
    background: var(--g-bg);
    border-top: 2px solid var(--g-line);
    list-style: none;
    overflow-y: auto;
    columns: 2;
    column-gap: 24px;
}

.game__choices[hidden] {
    display: none;
}

.game__choices li {
    break-inside: avoid;
}

.game .game__choice {
    display: block;
    width: 100%;
    padding: 1px 0;
    color: var(--g-choice);
    font-size: 22px;
    text-align: left;
}

.game .game__choice:hover,
.game .game__choice:focus-visible {
    color: var(--g-hot);
}

/* ---------- Modals ---------- */

.game__modal {
    position: absolute;
    inset: 0;
    z-index: 4;
    display: grid;
    place-items: center;
    padding: 16px;
    background: rgba(10, 8, 18, 0.7);
}

.game__modal[hidden] {
    display: none;
}

.game__dialog {
    width: min(100%, 420px);
    max-height: 100%;
    overflow-y: auto;
    padding: 18px 20px;
    background: #1c1630;
    box-shadow: 0 0 0 2px #000, 0 0 0 4px #5a4f8a, 8px 8px 0 4px #000;
    color: #e9e4ff;
    font-size: 21px;
}

.game__dialog p {
    margin: 0 0 10px;
}

.game__dialog a {
    color: var(--g-sentence);
}

.game__dialog a:hover {
    color: var(--g-hot);
}

.game__dialog-title {
    color: var(--g-hot);
    font-size: 28px;
}

.game__label {
    display: block;
    margin-bottom: 4px;
    color: var(--g-sentence);
}

.game__input {
    width: 100%;
    padding: 6px 8px;
    border: 0;
    background: #0a0812;
    box-shadow: inset 0 0 0 2px #5a4f8a;
    color: #fff;
    font: inherit;
    font-size: 22px;
}

.game__error {
    margin-top: 8px !important;
    color: #ff8a7a;
}

.game__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 14px 0 10px;
}

.game .game__button {
    padding: 4px 14px;
    background: #2a2342;
    box-shadow: inset 0 0 0 2px #5a4f8a;
    color: #fff;
}

.game .game__button:hover {
    color: var(--g-hot);
}

.game .game__button--primary {
    background: #232e54;
    box-shadow: inset 0 0 0 2px #5ab7f2;
}

.game .game__button:disabled {
    opacity: 0.7;
    cursor: wait;
}

.game__small {
    color: #a9a0cc;
    font-size: 19px;
}

.game__help {
    margin: 0;
    padding-left: 1.1em;
    list-style: square;
}

.game__help li {
    margin-bottom: 6px;
}

.game__help b {
    color: var(--g-verb);
    font-weight: normal;
}

.game__card {
    padding: 16px 18px;
    background: #f6f1e2;
    box-shadow: inset 0 0 0 2px #232e54;
    color: #232e54;
}

.game__card p {
    margin: 0;
}

.game__card-name {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 30px;
}

.game__card-role {
    margin-top: 6px !important;
    font-size: 21px;
}

.game__card-place {
    color: #61707b;
    font-size: 19px;
}

.game__card-links {
    margin: 12px 0 0;
    padding: 0;
    list-style: none;
    font-size: 21px;
    overflow-wrap: anywhere;
}

.game .game__card a {
    color: #0f74b3;
}

.game .game__card a:hover {
    color: #a8432c;
}

/* ---------- Phones ---------- */

@media (max-width: 699px) {
    .game {
        font-size: 20px;
    }

    .game__bar {
        padding: 6px 12px;
    }

    .game__brand {
        font-size: 21px;
    }

    .game__room {
        display: none;
    }

    .game .game__tool {
        padding: 2px 8px;
        font-size: 18px;
    }

    .game__sentence {
        padding: 6px 12px 4px;
        font-size: 21px;
    }

    .game__body {
        justify-content: flex-start;
        padding-top: 12px;
    }

    .game__panel {
        height: 220px;
        padding: 4px 12px 12px;
    }

    .game__ui {
        grid-template-columns: 1fr;
        grid-template-rows: 3fr 2fr;
        gap: 10px;
    }

    .game .game__verb {
        font-size: 23px;
        text-align: center;
        box-shadow: inset 0 0 0 1px var(--g-line);
    }

    .game__choices {
        columns: 1;
        padding: 6px 12px 12px;
    }

    .game .game__choice {
        padding: 4px 0;
        font-size: 21px;
        border-bottom: 1px solid var(--g-line);
    }
}

/* Narrow phones: keep the PS mark, drop the name so the tools fit */
@media (max-width: 420px) {
    .game__name {
        display: none;
    }
}

/* Landscape phones: verbs beside the inventory, kept short */
@media (max-height: 500px) and (min-width: 600px) {
    .game__panel {
        height: 96px;
    }

    .game .game__verb {
        font-size: 21px;
    }
}

/* Portrait phones: a zoomed, scrolling scene with big thumb-sized controls (sized in js/game.js) */
.is-portrait .game__body {
    justify-content: flex-start;
    padding-top: 0;
}

.is-portrait .game__sentence {
    padding: 8px 12px 6px;
}

.is-portrait .game__ui {
    grid-template-rows: 3fr 2fr;
    gap: 12px;
}

.is-portrait .game__verbs {
    gap: 4px;
}

.game.is-portrait .game__verb {
    font-size: 25px;
    background: var(--g-panel);
}

.game.is-portrait .game__verb[aria-pressed="true"] {
    background: #2a2342;
}

.is-portrait .game__credits {
    max-width: 80%;
}

.is-portrait .game__menu {
    gap: 10px;
}

.game.is-portrait .game__menu-item {
    font-size: 32px;
}

@media (prefers-reduced-motion: reduce) {
    .game__stage {
        transition: none;
    }

    .game__pan span {
        animation: none;
    }
}

/* "Point & click" link in the classic site's header */
.site-nav .nav-game {
    font-weight: 600;
}
