/* Ms. Pac-man - Perfected! — docked instructions panel + fluid-scaling stage.
   The cabinet art is a 1019x997 image with a transparent screen cut-out at
   (179,133) 650x816; the canvas is centred in that cut-out at the game's
   490:670 proportions, all in percentages so the cabinet scales as one unit. */

:root {
    /* Mirrors the semantic tier in assets/site.css. This page deliberately
       loads no shared stylesheet — it is a standalone full-screen stage — so
       the values are restated here, but under the same names. */
    --surface: #14141f;
    --surface-2: #1d1d2c;
    --text: #f2f2f7;
    --border: #2b2b40;
    --accent: #ffd400;
    --accent-alt: #29d8ff;
    --scroll-thumb: #2b2b40;
    --scroll-thumb-hover: #3a3a55;
    --font-display: 'Press Start 2P', 'Courier New', monospace;

    /* CRT overlay tuning (scoped to the game screen, not the cabinet) */
    --scanline-gap: 2.5px;    /* pitch of the horizontal lines */
    --scanline-dark: .50;   /* how black the gaps go */
    --grille: .04;          /* aperture-grill tint strength */
}

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    background: #000;
}

body {
    display: flex;
    gap: 20px;
    padding: 20px;
    box-sizing: border-box;
    overflow: hidden;
}

/* Overlay-style scrollbar: transparent track, inset thumb. */
::-webkit-scrollbar {
    width: 14px;
    height: 14px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--scroll-thumb);
    border: 4px solid transparent;
    background-clip: content-box;
    border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--scroll-thumb-hover);
    background-clip: content-box;
}

* {
    scrollbar-width: thin;
    scrollbar-color: var(--scroll-thumb) transparent;
}

/* Press Start 2P - SIL Open Font License 1.1 */
@font-face {
    font-family: 'Press Start 2P';
    src: url('../fonts/press-start/press-start-2p-latin.woff2') format('woff2');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

/* ---------- Instructions panel (docked left) ---------- */

#instructions {
    position: relative;
    flex: 0 0 390px;
    overflow-y: auto;
    background: var(--surface);
    border: 2px solid var(--border);
    padding: 1.4rem 1.6rem;
    color: var(--text);
    font: 12.5px/1.75 ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", "Courier New", monospace;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .45);
    transition: flex-basis .22s ease, padding .22s ease;
}

#btnToggle {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 30px;
    height: 30px;
    /* flex centring: glyph metrics don't centre reliably on their own */
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 2px solid var(--border);
    background: var(--surface-2);
    color: var(--text);
    font: 16px/1 system-ui, sans-serif;
    cursor: pointer;
}

#btnToggle:hover { border-color: var(--accent-alt); color: var(--accent-alt); }

#btnToggle svg { display: block; }
#btnToggle .ico-open { display: none; }
body.instructions-collapsed #btnToggle .ico-close { display: none; }
body.instructions-collapsed #btnToggle .ico-open { display: block; }

/* Collapsed: the panel chrome disappears, leaving only the toggle button. */
body.instructions-collapsed #instructions {
    flex-basis: 32px;
    align-self: flex-start;
    padding: 0;
    background: none;
    border: 0;
    box-shadow: none;
    overflow: visible;
}

body.instructions-collapsed #insText { display: none; }

body.instructions-collapsed #btnToggle {
    position: static;
    font-size: 15px;
}

#instructions h1 {
    font-family: var(--font-display);
    font-weight: normal;
    text-transform: uppercase;
    letter-spacing: .02em;
    font-size: .78rem;
    line-height: 1.5;
    color: var(--accent);
    margin: .2rem 0 1.1rem;
    padding-right: 2.6rem;
}

#instructions p { margin: 0 0 .8rem; }
#instructions p:last-child { margin-bottom: 0; }

#instructions .lede {
    font-weight: 700;
    color: #fff;
}

#instructions a {
    color: var(--accent-alt);
    text-decoration: none;
}

#instructions a:hover { text-decoration: underline; }

a.sup { text-decoration: none; }
a.sup:hover { text-decoration: underline; }

/* ---------- Stage (cabinet + emulator canvas) ---------- */

#stageWrap {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: flex-start;
    justify-content: center;
}

#stage {
    position: relative;
    aspect-ratio: 1019 / 997;
    width: min(100%, calc((100vh - 40px) * 1.0221));
    background: url('../mspacman/background.png') no-repeat;
    background-size: 100% 100%;
}

/* Screen cut-out within the 1019x997 cabinet: (179,133) 650x816 */
#content {
    position: absolute;
    left: 17.566%;
    top: 13.34%;
    width: 63.788%;
    height: 81.846%;
    display: flex;
    align-items: center;
    justify-content: center;
}

#content canvas {
    display: block;
    height: 100% !important;
    width: auto !important;
    aspect-ratio: 490 / 670;
    image-rendering: pixelated;
}

/* CRT overlay: scanlines, an aperture-grill triad and a faint vignette, on one
   pseudo-element sized to match the canvas exactly (height-filling at the game
   ratio, centred) so it sits on the screen and not the black bezel gaps. It is
   absolutely positioned, so it paints above the in-flow canvas. */
#content::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    aspect-ratio: 490 / 670;
    pointer-events: none;
    background:
        radial-gradient(ellipse 78% 78% at 50% 50%,
            transparent 55%,
            rgba(0, 0, 0, .35) 100%),
        repeating-linear-gradient(to right,
            rgba(255, 0, 0, var(--grille)) 0 1px,
            rgba(0, 255, 0, var(--grille)) 1px 2px,
            rgba(0, 0, 255, var(--grille)) 2px 3px),
        repeating-linear-gradient(to bottom,
            transparent 0 calc(var(--scanline-gap) - 1px),
            rgba(0, 0, 0, var(--scanline-dark)) calc(var(--scanline-gap) - 1px) var(--scanline-gap));
}

#tilesets {
    display: none;
}

/* ---------- Small screens: stack, instructions first ---------- */

@media (max-width: 860px) {
    body {
        flex-direction: column;
        overflow: auto;
        height: auto;
        min-height: 100%;
    }

    #stage { width: 100%; }

    #instructions {
        flex: none;
        overflow-y: visible;
    }

    body.instructions-collapsed #instructions { flex-basis: auto; }
}
