/* Panda's Room (room.html): scene with hotspots, a command bar, and Panda talking in the dialog box */

#room-frame {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #000;
}

#room-stage {
    position: relative;
    flex: none;
    margin: 0 auto;
    isolation: isolate;     /* its own stacking context: a layer under the art stays inside the stage */
    overflow: hidden;       /* layers that run past the picture (the train coming on) stay inside it */
}

/* the art is a nearest-neighbour 4x copy scaled down smoothly ("sharp bilinear"): at the window's
   non-integer 1.65x, plain nearest-neighbour gives uneven 1px/2px columns that break the dithers */
#room-art {
    display: block;
    width: 100%;
    height: 100%;
}

/* the city twinkle sits over the art at a native-pixel rect (set in % by scene.js) */
#room-twinkle {
    position: absolute;
    display: block;
    pointer-events: none;
}

/* its night lights are the room's own night view: by day the glass shows the day's view, nothing over it */
#room-twinkle[hidden] {
    display: none;
}


#room-twinkle {
    background-repeat: no-repeat;
    background-position: 0% 0%;
    animation-name: room-twinkle;
    animation-iteration-count: infinite;
}

/* duration and steps() come from room-data.js (frames / fps) */
@keyframes room-twinkle {
    from { background-position: 0% 0%; }
    to { background-position: 100% 0%; }
}

#room-hotspots {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}


.room-hotspot {
    fill: transparent;
    stroke: transparent;
    stroke-width: 2px;
    vector-effect: non-scaling-stroke;
    shape-rendering: crispEdges;
    cursor: url("/img/cursors/magnifier.png") 12 12, pointer;
    outline: none;
}

/* exact object outlines: invisible except while LOOK flashes them */
.room-outline {
    fill: none;
    stroke: transparent;
    stroke-width: 2px;
    vector-effect: non-scaling-stroke;
    shape-rendering: crispEdges;
    pointer-events: none;
}

/* LOOK: flash every object's outline, pink if you haven't looked at it yet, blue if you have */
#room-hotspots.reveal .room-outline {
    stroke: #ffaaba;
    animation: room-reveal 1.6s steps(1) forwards;
}

#room-hotspots.reveal .room-outline.seen {
    stroke: #8799ff;
    animation-name: room-reveal-seen;
}

@keyframes room-reveal {
    0%, 25%, 50%, 75% { stroke: #ffaaba; }
    12%, 37%, 62% { stroke: #ef0060; }
    100% { stroke: transparent; }
}

@keyframes room-reveal-seen {
    0%, 75% { stroke: #8799ff; }
    100% { stroke: transparent; }
}

.room-glint {
    fill: #fff;
    pointer-events: none;
    transform-box: fill-box;
    transform-origin: center;
    animation: room-glint 1.2s steps(6) forwards;
}

@keyframes room-glint {
    0% { transform: scale(0); opacity: 1; }
    40% { transform: scale(1); opacity: 1; }
    100% { transform: scale(0.2); opacity: 0; }
}

/* BACK and LOOK sit in the dialog box's top-right corner, like PC-98 command buttons */
#room-cmds {
    position: absolute;
    top: 8px;
    right: 14px;
    z-index: 1;
    display: flex;
    gap: 10px;
}

#room-cmds button {
    font-family: 'pc-98';
    font-size: 22px;
    color: #fff;
    background-color: #2a2a66;
    border: 3px outset #8799ff;
    padding: 2px 12px;
    cursor: pointer;
}

#room-cmds button:hover,
#room-cmds button:focus-visible {
    background-color: #ffaaba;
    color: #000;
    outline: none;
}

/* the music's speaker: the explore pages' corner button (style.css #mute), over the scene */
#main-image #mute {
    z-index: 1;
    cursor: pointer;
}

/* dialog box */
#room-text {
    font-size: 26px;
    white-space: pre-line; /* the PC's login answers span lines */
    min-height: 1.3em;
    margin-top: 0;
    margin-bottom: 10px;
}

#room-choices {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    margin-left: 18px;
}

/* the LOOK list: every object plus "Never mind" has to fit the 252px box, so four tight columns */
#room-choices.room-choices-grid {
    display: grid;
    grid-template-columns: repeat(4, max-content);
    column-gap: 14px;
    row-gap: 0;
}

#room-choices.room-choices-grid3 { grid-template-columns: repeat(3, max-content); }

/* #room-choices for specificity: style.css's `.subwindow a` would stretch link choices to 80% */
#room-choices .room-choice {
    font-family: 'pc-98';
    font-size: 26px;
    line-height: 1.25;
    color: #fff;
    background: none;
    border: none;
    padding: 0 8px;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
    width: auto; /* .subwindow a sets 80% */
    margin: 0;
}

#room-choices.room-choices-grid .room-choice {
    font-size: 20px;
    line-height: 1.15;
}

#room-choices .room-choice.dim {
    color: #8799ff;
}

/* the selected choice is an inverted bar, PC-98 menu style */
#room-choices .room-choice:hover,
#room-choices .room-choice:focus-visible,
#room-choices .room-choice:focus {
    background-color: #ffaaba;
    color: #000;
    outline: none;
}

#text-arrow {
    position: absolute;
    right: 18px;
    bottom: 10px;
    width: 25px;
    height: 25px;
    image-rendering: pixelated;
}

#text-arrow.bounce {
    animation: room-bounce 1.5s steps(15) infinite;
}

@keyframes room-bounce {
    0%, 100% { transform: translateY(0%); }
    50% { transform: translateY(-30%); }
}

@media (prefers-reduced-motion: reduce) {
    #text-arrow.bounce,
    #room-hotspots.reveal .room-outline {
        animation: none;
    }
    #room-hotspots.reveal .room-outline {
        stroke: #ffaaba;
    }
    #room-hotspots.reveal .room-outline.seen {
        stroke: #8799ff;
    }
    #room-twinkle {
        display: none;
    }
}

/* phones: the scene and the dialog box stack, full width */
@media (max-width: 768px) {
    #main-image,
    #text-box {
        position: relative;
        left: 0;
        top: 0;
        width: 100%;
    }

    #main-image {
        height: auto;
    }

    /* the scene's space held before the room is built, so the dialog box doesn't jump down when it is */
    #room-frame {
        aspect-ratio: 500 / 357;
    }

    #main-image #mute {
        width: 56px;
        height: 56px;
    }

    #room-cmds {
        top: 6px;
        right: 8px;
        gap: 6px;
    }

    #room-cmds button {
        font-size: 18px;
        padding: 2px 8px;
    }

    #text-box {
        height: auto;
        min-height: 230px;
        background-color: #000;
        border-top: 2px solid #8799ff;
    }

    #text-box .text-container {
        position: relative;
        padding: 8px 6px 40px 6px;
    }

    #room-text,
    #room-choices .room-choice {
        font-size: 19px;
    }

    #room-choices.room-choices-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        column-gap: 8px;
    }

    #room-choices.room-choices-grid .room-choice {
        font-size: 17px;
    }
}

/* a slow connection: NOW LOADING blinks in the empty frame until the room is drawn (after a moment, so a quick load
   never shows it) */
#room-frame:has(#room-art:not([src])) {
    position: relative;
}

#room-frame:has(#room-art:not([src]))::after {
    content: "NOW LOADING";
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    white-space: nowrap;
    font-family: 'pc-98';
    font-size: 22px;
    color: #8799ff;
    opacity: 0;
    animation: room-loading 1.2s step-end 0.5s infinite;
}

@keyframes room-loading {
    0% { opacity: 1; }
    50% { opacity: 0; }
    100% { opacity: 0; }
}

/* Explore (R.illegible): its hotspots are plain links, a pointer and nothing more (no magnifier, no outlines) */
.scene-illegible .room-hotspot {
    cursor: pointer;
}

/* a scene's extra pictures (layers under or over the art) and visible buttons: placed by native rect */
.scene-layer {
    position: absolute;
    pointer-events: none;
    image-rendering: auto;
}

/* a typed answer (the PC's PASSWORD:), in the menu's place */
#room-choices .room-input {
    font-family: 'pc-98';
    font-size: 26px;
    color: #fff;
    background: #000;
    border: none;
    border-bottom: 3px solid #8799ff;
    padding: 0 8px;
    margin-left: 8px;
    width: 80%;
    caret-color: #ffaaba;
    outline: none;
}

/* what you're carrying (js/house-key.js): the house key's slot and the hunt's items, by the ▼ */
#hk-inventory {
    position: absolute;
    right: 52px;
    bottom: 8px;
    max-width: calc(100% - 70px);
    display: flex;
    flex-wrap: wrap-reverse;     /* a full pocket grows upward, never off the box */
    justify-content: flex-end;
    gap: 6px;
    z-index: 1;
}

@media (max-width: 768px) {
    #hk-inventory button, #hk-inventory img { width: 24px; height: 24px; }
    #hk-inventory { gap: 4px; }
}

#hk-inventory button {
    width: 32px;
    height: 32px;
    padding: 0;
    border: none;
    background: none;
    cursor: pointer;
}

#hk-inventory img {
    display: block;
    width: 32px;
    height: 32px;
    image-rendering: pixelated;
}

#hk-inventory button:hover img,
#hk-inventory button:focus-visible img {
    filter: drop-shadow(0 0 2px #ffaaba);
}

#hk-inventory button:focus-visible {
    outline: none;
}

/* layers drawn on the picture's own pixel grid, and their animations */
.scene-layer.scene-pixel { image-rendering: pixelated; }
.scene-anim-flicker { animation: scene-flicker 4.3s steps(1) infinite; }
@keyframes scene-flicker {
    0%, 100% { opacity: 1; } 31% { opacity: .82; } 33% { opacity: 1; } 64% { opacity: .9; } 67% { opacity: 1; }
}
/* a failing neon tube: mostly on, dropping out in stutters */
.scene-anim-buzz { animation: scene-buzz 5s steps(1) infinite; }
@keyframes scene-buzz {
    0%, 100% { opacity: 1; } 20% { opacity: 0; } 22% { opacity: 1; } 24% { opacity: 0; } 27% { opacity: 1; }
    61% { opacity: 0; } 70% { opacity: 1; }
}

/* a crossing's walk signal: red most of the time, then walk, blinking before it turns back */
.scene-anim-signal { animation: scene-signal 12s steps(1) infinite; }
@keyframes scene-signal {
    0% { opacity: 0; } 58% { opacity: 1; } 88% { opacity: 0; } 90% { opacity: 1; } 92% { opacity: 0; }
    94% { opacity: 1; } 96% { opacity: 0; } 98% { opacity: 1; } 100% { opacity: 0; }
}

/* the train crossing the bridge: in from the right, off to the left, a pause, again */
.scene-anim-train { animation: scene-train 24s linear infinite; }
@keyframes scene-train {
    0% { transform: translateX(100%); } 55% { transform: translateX(-175%); } 100% { transform: translateX(-175%); }
}

/* a sleeping cat breathing: the breath-in frame over the breath-out one, now and then */
.scene-anim-breathe { animation: scene-breathe 3.6s steps(1) infinite; }
@keyframes scene-breathe { 0% { opacity: 0; } 40% { opacity: 1; } 75% { opacity: 0; } }

/* the lake's ferry, crossing slowly and coming back */
.scene-anim-ferry { animation: scene-ferry 70s steps(140) infinite alternate; }
@keyframes scene-ferry { from { transform: translateX(-10%); } to { transform: translateX(280%); } }

/* the night train's window lights, sliding past (the strip is twice as wide as the picture and tiles) */
.scene-anim-lights { animation: scene-lights 14s linear infinite; }
@keyframes scene-lights { from { transform: translateX(0); } to { transform: translateX(-50%); } }

/* a lighthouse lens turning past: a flash every six seconds */
.scene-anim-flash { animation: scene-flash 6s steps(1) infinite; }
@keyframes scene-flash { 0% { opacity: 0; } 85% { opacity: .5; } 88% { opacity: 1; } 92% { opacity: .5; } 95% { opacity: 0; } }

/* two layers of glints on water, in turn */
.scene-anim-twinkle-a { animation: scene-twinkle 1.4s steps(1) infinite; }
.scene-anim-twinkle-b { animation: scene-twinkle 1.4s steps(1) -.7s infinite; }
@keyframes scene-twinkle { 0% { opacity: 1; } 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
    .scene-anim-flicker, .scene-anim-twinkle-a, .scene-anim-twinkle-b, .scene-anim-buzz,
    .scene-anim-signal, .scene-anim-breathe, .scene-anim-ferry, .scene-anim-lights,
    .scene-anim-flash { animation: none; }
    .scene-anim-train { animation: none; transform: translateX(0); }
}

/* a minigame over the picture (js/explore-games.js) */
.play-overlay {
    position: absolute;
    inset: 0;
    z-index: 3;
    background: #000;
}

.play-overlay canvas {
    display: block;
    width: 100%;
    height: 100%;
    image-rendering: pixelated;
    cursor: crosshair;
    touch-action: none;
}

/* the stray cat (js/explore-town.js) */
.play-cat {
    position: absolute;
    z-index: 2;
    background: url(/img/explore/layers/cat.png) 0 0 / 600% 100% no-repeat;
    image-rendering: pixelated;
    cursor: pointer;
}

.play-catbox {
    position: absolute;
    z-index: 2;
    overflow: hidden;
}

.play-catbox .play-cat {
    inset: 0;
    transition: transform .5s steps(4);
}

.play-hit {
    position: absolute;
    z-index: 2;
    cursor: pointer;
}

/* the roulette ball (js/explore-games.js) */
.play-ball {
    position: absolute;
    z-index: 2;
    background: #fff;
    box-shadow: inset -3px -3px 0 #aab;
    pointer-events: none;
}

/* ambient life over a scene: fireflies, steam (js/explore-ambient.js) */
.play-ambient {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    image-rendering: pixelated;
    pointer-events: none;
}

/* a pocket with something new in it (the stamp card after a new stamp) */
#hk-inventory .hk-new img { animation: hk-pulse 1s steps(2) infinite; }
@keyframes hk-pulse { 50% { filter: drop-shadow(0 0 3px #ffee88) brightness(1.3); } }

/* a camera flash (the game centre's photo booth) */
.play-flash {
    position: absolute;
    inset: 0;
    z-index: 3;
    background: #fff;
    animation: play-flash .45s steps(3) forwards;
    pointer-events: none;
}
@keyframes play-flash { to { opacity: 0; } }

/* the penthouse telescope: a round view of somewhere else */
.play-telescope {
    position: absolute;
    inset: 0;
    z-index: 3;
    background-color: #000;
    background-size: cover;
    image-rendering: pixelated;
    clip-path: circle(34% at 50% 48%);
    cursor: pointer;
}

/* the camera's album: photos like prints on a table */
.play-album {
    position: absolute;
    inset: 0;
    z-index: 3;
    background: rgba(20, 12, 8, .88);
    display: flex;
    flex-wrap: wrap;
    align-content: center;
    justify-content: center;
    gap: 3%;
    padding: 4%;
    box-sizing: border-box;
    cursor: pointer;
}

.play-photo {
    width: 21%;
    aspect-ratio: 4 / 3;
    background-size: cover;
    background-position: center;
    border: solid #f4efe4;
    border-width: 6px 6px 18px;
    box-shadow: 3px 4px 0 rgba(0, 0, 0, .5);
    image-rendering: pixelated;
}

/* the net cafe's screen at three in the morning */
.play-glitch {
    position: absolute;
    inset: 0;
    z-index: 3;
    pointer-events: none;
    background: repeating-linear-gradient(0deg, rgba(0, 0, 0, .35) 0 2px, rgba(120, 160, 255, .12) 2px 4px);
    animation: play-glitch 1.4s steps(7) forwards;
}
@keyframes play-glitch {
    0% { opacity: 1; transform: translateX(0); } 20% { transform: translateX(-6px); } 40% { transform: translateX(4px); opacity: .7; }
    60% { transform: translateX(-2px); } 100% { opacity: 0; transform: translateX(0); }
}

/* a train going over the izakaya under the tracks */
.play-rumble { animation: play-rumble .16s steps(2) 10; }
@keyframes play-rumble { 0% { transform: translate(0, 0); } 50% { transform: translate(1px, 2px); } }
