/*
 * Arcade look for the public pages (layout.php adds body.arcade everywhere except admin).
 * Loaded after main.css and only overrides it, so admin keeps the original look.
 */

@font-face {
    font-family: 'Press Start 2P';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('fonts/press-start-2p.woff2') format('woff2');
}

body.arcade {
    --page: #000;
    --panel: #1c1c1c;
    --text: #f2f2f2;
    --muted: #a3a3a3;
    --bar: #333;
    --line: #333;
    --amber: #f59e0b;
    --edge: 0 5px 0 #333;
    --shadow: none;
    --pixel: 'Press Start 2P', monospace;
    background: #000;
}

.arcade a:hover { color: var(--amber); text-decoration: none; }

/* --- Top bar, menu and footer -------------------------------------------- */

.arcade .topbar { box-shadow: 0 2px 0 #000; }
.arcade .brand-start, .arcade .brand-home { display: block; color: #fff; }
.arcade .brand-start { flex: none; line-height: 0; }
/* Tilts only under a real mouse: phones keep a tapped spot "hovered", so it would stay tilted. */
@media (hover: hover) and (pointer: fine) {
    .arcade .brand-start:hover .brand-logo { transform: rotate(-8deg) scale(1.08); }
}
.arcade .brand-logo { transition: transform 0.15s; }
/* Phones: a quick tilt that springs back when the raccoon is tapped (game.js adds .tapped). */
.arcade .brand-logo.tapped { animation: arcade-tap-tilt 0.25s ease-out; }
@keyframes arcade-tap-tilt { 40% { transform: rotate(-12deg) scale(1.1); } }
.arcade .brand-home:hover { color: var(--amber); }
.arcade .menu { margin-left: 0; }
.arcade .topbar-space { flex: 1; }
.arcade .sound-toggle {
    flex: none;
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    padding: 0;
    font-size: 18px;
    line-height: 1;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 8px;
}
.arcade .sound-toggle:hover { background: rgba(255, 255, 255, 0.16); }

.arcade .menu-panel { background: #1c1c1c; border: 2px solid #333; }
.arcade .menu-panel a { color: var(--text); }
.arcade .menu-panel a:hover { background: #2a2a2a; color: var(--amber); }

.arcade .site-footer { color: #777; background: #000; border-top: 1px solid #222; }

.arcade .subheader h2 {
    font-family: var(--pixel);
    font-size: clamp(14px, 3.2vw, 20px);
    font-weight: normal;
    line-height: 1.5;
    text-shadow: 3px 3px 0 #000, -2px 0 0 var(--accent);
}

/* --- Main panel: no white box, everything sits on black ------------------ */

.arcade .container { background: none; box-shadow: none; }

/* --- Cards, rows and buttons: chunky and pressable ----------------------- */

.arcade .card,
.arcade .engine-card,
.arcade .game-row,
.arcade .tool-card {
    background: var(--panel);
    border: 2px solid #333;
    border-radius: 8px;
    box-shadow: var(--edge);
    transition: transform 0.12s, border-color 0.12s, box-shadow 0.12s;
}
.arcade .card { margin-bottom: 1.2rem; }
.arcade .engine-card { margin-bottom: 1.1rem; }
.arcade .game-row { margin-bottom: 0.9rem; }
.arcade .engine-card:hover,
.arcade .game-row:hover,
.arcade .tool-card:hover { border-color: var(--accent); }
@media (hover: hover) and (pointer: fine) {
    .arcade .game-row:hover { transform: translateX(4px); }
    .arcade .engine-card:hover,
    .arcade .tool-card:hover { transform: translateY(-3px); box-shadow: 0 8px 0 #333; }
}

.arcade .engine-card-main:hover,
.arcade .tool-card:hover { background: none; }
.arcade .engine-card-text strong {
    font-family: var(--pixel);
    font-size: 13px;
    font-weight: normal;
    line-height: 1.6;
}
.arcade .engine-card-main:hover strong,
.arcade .tool-card:hover strong { color: var(--amber); }
.arcade .engine-card-main img,
.arcade .game-row-icon img { transition: transform 0.2s; }
.arcade .engine-card:hover .engine-card-main img,
.arcade .game-row:hover .game-row-icon img { animation: arcade-hop 0.45s ease-out; }
.arcade .game-row-facts { color: var(--amber); }
.arcade .game-row-body h2 a:hover { color: var(--amber); }
.arcade .card-body h2 a { color: var(--text); }

.arcade .btn,
.arcade button,
.arcade .button {
    box-shadow: 0 4px 0 #7a0000;
    transition: transform 0.05s, box-shadow 0.05s;
}
.arcade .btn:active,
.arcade button:active,
.arcade .button:active { transform: translateY(3px); box-shadow: 0 1px 0 #7a0000; }
.arcade .btn-light,
.arcade button.btn-light { color: var(--text); background: #333; box-shadow: 0 4px 0 #1a1a1a; }
.arcade .btn-light:hover,
.arcade button.btn-light:hover { color: var(--text); background: #444; }
.arcade .link-button,
.arcade .viewer button,
.arcade .sound-toggle { box-shadow: none; }
.arcade .link-button:active,
.arcade .viewer button:active { transform: none; }

.arcade .chip { color: var(--text); background: #1c1c1c; border-color: #333; }
.arcade .chip:hover { color: var(--text); border-color: var(--accent); }
.arcade .chip.active { color: #fff; background: var(--accent); border-color: var(--accent); }
.arcade .chip.active .count { background: #000; }
.arcade .count { background: #444; }
.arcade .badge { color: var(--amber); background: #2e2100; }
.arcade .tag { color: var(--muted); }

/* --- Forms ----------------------------------------------------------------- */

.arcade input[type=text],
.arcade input[type=search],
.arcade input[type=password],
.arcade input[type=url],
.arcade input[type=number],
.arcade select,
.arcade textarea { color: var(--text); background: #111; border: 2px solid #444; }
.arcade .form fieldset { border-color: #333; }

.arcade .flash-success { background: #052e16; color: #bbf7d0; }
.arcade .flash-error { background: #450a0a; color: #fecaca; }
.arcade .flash-info { background: #082f49; color: #bae6fd; }

/* --- Art --------------------------------------------------------------------- */

.arcade .art-strip a,
.arcade .art-tile-img { background: #111; }
.arcade .art-tile-img { border: 2px solid #333; border-radius: 8px; transition: border-color 0.12s; }
.arcade .art-tile:hover .art-tile-img { border-color: var(--accent); }
.arcade .art-tile:hover .art-tile-title { color: var(--amber); }
.arcade .art-tile-title { color: var(--text); }
.arcade .art-filter-bar select.picked { border-color: var(--accent); }

/* --- Home page: start screen, then the section tiles ------------------------ */

html.start-open { overflow: hidden; }

.start-screen {
    position: fixed;
    inset: 56px 0 0 0;
    z-index: 9;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    /* If it still doesn't fit, keep the top (the raccoon) in view and let the bottom run off instead. */
    justify-content: safe center;
    padding: 24px 16px 40px;
    overflow: hidden;
    text-align: center;
    background: #000;
    transition: opacity 0.35s;
}
.start-screen[hidden] { display: none; }
.start-screen.leaving { opacity: 0; pointer-events: none; }
.start-screen > * { position: relative; }
.start-bg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

.start-logo {
    width: 148px;
    height: 148px;
    border-radius: 24px;
    box-shadow: 0 0 0 4px #000, 0 0 0 8px var(--accent), 0 12px 0 8px #000;
    animation: arcade-bob 1.6s ease-in-out infinite;
}
.start-title {
    margin: 34px 0 6px;
    font-family: var(--pixel);
    font-size: clamp(20px, 5.2vw, 40px);
    font-weight: normal;
    line-height: 1.35;
    text-shadow: 4px 4px 0 #000, -2px 0 0 var(--accent);
}
.start-tagline { margin: 0 0 34px; color: var(--muted); }
.arcade .start-press {
    padding: 14px 18px;
    font-family: var(--pixel);
    font-size: clamp(13px, 3.4vw, 18px);
    font-weight: normal;
    color: var(--amber);
    background: none;
    box-shadow: none;
    animation: arcade-blink 1s steps(1) infinite;
}
.arcade .start-press:hover,
.arcade .start-press:focus-visible { color: #fff; background: none; outline: 3px solid var(--accent); animation: none; }
.arcade .start-press:active { transform: none; box-shadow: none; }
.start-quick-label { margin-top: 28px; font-size: 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.12em; }
.start-quick { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; max-width: 520px; margin-top: 10px; }
.arcade .start-quick a { padding: 8px 12px; font-size: 0.9rem; color: var(--muted); background: #000; border: 2px solid #444; border-radius: 6px; }
.arcade .start-quick a:hover { color: #fff; border-color: var(--accent); }

/* PRESS START pressed: it stops blinking, flashes red and white and grows a little, then the screen fades. */
.arcade .start-press.pressed {
    color: #fff;
    outline: none;
    animation: arcade-flash 0.11s steps(1) 4, arcade-grow 0.45s ease-out forwards;
}
@keyframes arcade-flash {
    0% { color: #fff; background: var(--accent); }
    50% { color: var(--accent); background: #fff; }
}
@keyframes arcade-grow { to { transform: scale(1.12); } }

/* Short screens (phones especially): the raccoon and gaps shrink with the screen height, only as much as
   needed to fit under the top bar. Very short screens get a smaller raccoon and smaller quick links. */
@media (max-height: 820px) {
    .start-logo, .start-screen .start-logo { border-radius: 20px; }
    .start-screen { padding: clamp(12px, 3vh, 24px) 16px clamp(16px, 5vh, 40px); }
    .start-logo, .start-screen .start-logo { width: clamp(72px, 23vh, 148px); height: clamp(72px, 23vh, 148px); }
    .start-title { margin-top: clamp(18px, 5.5vh, 34px); }
    .start-tagline { margin-bottom: clamp(12px, 5.5vh, 34px); }
    .arcade .start-press { padding: clamp(8px, 2.2vh, 14px) 18px; }
    .start-quick-label { margin-top: clamp(10px, 4.2vh, 28px); }
}
@media (max-height: 560px) {
    .start-screen { padding: clamp(12px, 3vh, 24px) 16px clamp(16px, 5vh, 40px); }
    .start-logo, .start-screen .start-logo { width: clamp(72px, 19vh, 148px); height: clamp(72px, 19vh, 148px); }
    .start-title { margin-top: clamp(18px, 4.5vh, 34px); }
    .start-tagline { margin-bottom: clamp(12px, 4.5vh, 34px); }
    .arcade .start-press { padding: clamp(8px, 2vh, 14px) 18px; }
    .start-quick-label { margin-top: clamp(10px, 3.5vh, 28px); }
    .start-quick { gap: 6px; margin-top: 8px; }
    .arcade .start-quick a { padding: 6px 10px; font-size: 0.85rem; }
}
@supports (height: 1svh) {
    @media (max-height: 820px) {
        .start-screen { padding: clamp(12px, 3svh, 24px) 16px clamp(16px, 5svh, 40px); }
        .start-logo, .start-screen .start-logo { width: clamp(72px, 23svh, 148px); height: clamp(72px, 23svh, 148px); }
        .start-title { margin-top: clamp(18px, 5.5svh, 34px); }
        .start-tagline { margin-bottom: clamp(12px, 5.5svh, 34px); }
        .arcade .start-press { padding: clamp(8px, 2.2svh, 14px) 18px; }
        .start-quick-label { margin-top: clamp(10px, 4.2svh, 28px); }
    }
    @media (max-height: 560px) {
        .start-screen { padding: clamp(12px, 3svh, 24px) 16px clamp(16px, 5svh, 40px); }
        .start-logo, .start-screen .start-logo { width: clamp(72px, 19svh, 148px); height: clamp(72px, 19svh, 148px); }
        .start-title { margin-top: clamp(18px, 4.5svh, 34px); }
        .start-tagline { margin-bottom: clamp(12px, 4.5svh, 34px); }
        .arcade .start-press { padding: clamp(8px, 2svh, 14px) 18px; }
        .start-quick-label { margin-top: clamp(10px, 3.5svh, 28px); }
    }
}

/* Background chooser: one small icon that slides open on hover (or tap) and tucks away again. */
.bg-pick { position: absolute; right: 12px; bottom: 12px; display: flex; align-items: center; }
/* Admins see the floating "Edit this page" button in that corner, so the chooser moves up. */
body:has(.edit-fab) .bg-pick { bottom: 72px; }
.arcade .bg-icon {
    position: relative;
    z-index: 1;
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    padding: 0;
    color: #fff;
    background: rgba(0, 0, 0, 0.8);
    border: 2px solid rgba(255, 255, 255, 0.25);
    border-radius: 50%;
    box-shadow: none;
    transition: border-color 0.2s, transform 0.2s;
}
.arcade .bg-icon:hover { background: rgba(0, 0, 0, 0.8); }
.arcade .bg-icon:active { box-shadow: none; }
.bg-pick:hover .bg-icon, .bg-pick.open .bg-icon { border-color: var(--amber); transform: rotate(-8deg); }
.bg-opts {
    display: flex;
    gap: 4px;
    align-items: center;
    max-width: 0;
    margin-right: -20px;
    padding: 6px 28px 6px 10px;
    overflow: hidden;
    white-space: nowrap;
    font-size: 0.75rem;
    color: #ccc;
    background: rgba(0, 0, 0, 0.8);
    border: 0 solid var(--amber);
    border-radius: 999px;
    opacity: 0;
    pointer-events: none;
    transition: max-width 0.3s ease, opacity 0.2s;
}
.bg-pick.open .bg-opts { max-width: min(420px, calc(100vw - 64px)); border-width: 2px; opacity: 1; pointer-events: auto; }
.arcade .bg-opts button {
    padding: 5px 9px;
    font-size: 0.75rem;
    font-weight: normal;
    color: #fff;
    background: #333;
    border-radius: 999px;
    box-shadow: none;
}
.arcade .bg-opts button:active { transform: none; box-shadow: none; }
.arcade .bg-opts button.on { background: var(--accent); }

/* The section tiles. */
.area-home .container { max-width: 960px; }
.area-home .topbar { padding: 0 max(16px, calc((100% - 960px) / 2)); }
.area-home .menu-panel { right: max(16px, calc((100% - 960px) / 2)); }
.home-heading {
    margin: 6px 0 4px;
    font-family: var(--pixel);
    font-size: clamp(14px, 3vw, 20px);
    font-weight: normal;
    line-height: 1.5;
    text-shadow: 3px 3px 0 #000;
}
.home-about { margin: 0 0 20px; color: var(--muted); }
.home-tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.arcade .home-tile {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    min-width: 0;
    padding: 18px 10px 14px;
    color: var(--text);
    text-align: center;
    background: #222;
    border: 3px solid #333;
    border-radius: 10px;
    box-shadow: 0 6px 0 #333;
    transition: transform 0.12s, box-shadow 0.12s, border-color 0.12s;
}
.home-tile img { width: 72px; height: 72px; object-fit: contain; border-radius: 12px; }
.home-tile-name { font-family: var(--pixel); font-size: 11px; line-height: 1.5; overflow-wrap: anywhere; }
.home-tile-caption { font-size: 0.8rem; color: var(--muted); }
.home-tile.soon { opacity: 0.55; }
.arcade .home-tile:focus-visible,
.arcade .home-tile.sel {
    color: var(--text);
    outline: none;
    border-color: var(--accent);
    transform: translateY(-4px);
    box-shadow: 0 10px 0 #333;
    animation: arcade-pulse 0.9s ease-in-out infinite;
}
.home-tile.sel img { animation: arcade-hop 0.45s ease-out; }
/* Pointing highlights only with a real mouse; on phones a tapped spot would stay lit after scrolling. */
@media (hover: hover) and (pointer: fine) {
    .arcade .home-tile:hover {
        color: var(--text);
        border-color: var(--accent);
        transform: translateY(-4px);
        box-shadow: 0 10px 0 #333;
    }
    .home-tile:hover img { animation: arcade-hop 0.45s ease-out; }
}
.home-tile.sel::before {
    content: '\25B6';
    position: absolute;
    left: -6px;
    top: 50%;
    color: var(--accent);
    font-size: 18px;
    transform: translate(-100%, -50%);
    animation: arcade-nudge 0.6s ease-in-out infinite;
}

/* What the chosen tile is about, with all its buttons. Without JavaScript every section is listed. */
.home-info { margin-top: 26px; display: grid; gap: 12px; }
.home-info-item {
    display: flex;
    gap: 14px;
    align-items: flex-start;
    padding: 14px 16px;
    background: #111;
    border: 3px solid #333;
    border-radius: 10px;
}
.js .home-info-item:not(.on) { display: none; }
.home-info-item > img { flex: none; width: 48px; height: 48px; object-fit: contain; border-radius: 8px; }
.home-info-item h3 { font-size: 1rem; }
.home-info-item .card-text { margin: 0.3rem 0 0.6rem; color: var(--muted); font-size: 0.95rem; }
.home-info-item .card-actions { margin: 0; }
.home-keys { margin-top: 12px; color: #777; font-size: 0.78rem; text-align: center; }

/* Phones show a tile's details in the pop-up instead (game.js), so the box under the tiles goes. */
@media not all and (hover: hover) and (pointer: fine) {
    .js .home-info { display: none; }
}

/* --- Pop-up window (GamePopup in game.js; reuse it anywhere) ------------------- */

html.gp-open { overflow: hidden; }
.gp { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 16px; }
.gp[hidden] { display: none; }
.gp-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.72);
    animation: gp-fade 0.2s ease-out;
}
.gp-window {
    position: relative;
    width: min(440px, 100%);
    max-height: calc(100vh - 32px);
    overflow: auto;
    padding: 26px 20px 20px;
    color: var(--text);
    background: #141414;
    border: 3px solid #f2f2f2;
    border-radius: 12px;
    box-shadow: 0 0 0 3px #000, 0 0 0 6px var(--accent), 0 12px 0 6px #000;
    animation: gp-bounce 0.55s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
.gp-leaving .gp-backdrop { animation: gp-fade 0.2s ease-in reverse forwards; }
.gp-leaving .gp-window { animation: gp-shrink 0.2s ease-in forwards; }
.arcade .gp-close {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 36px;
    height: 36px;
    padding: 0;
    font-size: 1.5rem;
    line-height: 1;
    color: #fff;
    background: #333;
    border-radius: 50%;
    box-shadow: none;
}
.arcade .gp-close:hover { background: var(--accent); }
.arcade .gp-close:active { transform: none; box-shadow: none; }

/* A home page section inside the pop-up: big bouncing icon, pixel title, then the usual text and buttons. */
.gp-body .home-info-item { display: block; padding: 0; text-align: center; background: none; border: 0; }
.gp-body .home-info-item > img {
    width: 80px;
    height: 80px;
    margin: 0 auto 12px;
    animation: gp-icon 0.7s cubic-bezier(0.2, 0.9, 0.3, 1.4) 0.1s backwards;
}
.gp-body .home-info-item h3 {
    font-family: var(--pixel);
    font-size: 14px;
    font-weight: normal;
    line-height: 1.5;
    text-transform: uppercase;
}
.gp-body .home-info-item .card-text { margin: 0.6rem 0 1rem; }
.gp-body .home-info-item .card-actions { justify-content: center; }
.gp-body .mini-list { text-align: left; }

@keyframes gp-bounce {
    0% { opacity: 0; transform: translateY(40px) scale(0.3); }
    55% { opacity: 1; transform: translateY(-6px) scale(1.06); }
    75% { transform: translateY(2px) scale(0.97); }
    100% { transform: none; }
}
@keyframes gp-shrink { to { opacity: 0; transform: scale(0.8); } }
@keyframes gp-fade { from { opacity: 0; } }
@keyframes gp-icon {
    0% { transform: translateY(-30px) scale(0.5); opacity: 0; }
    60% { transform: translateY(4px) scale(1.1); opacity: 1; }
    100% { transform: none; }
}

@keyframes arcade-bob { 50% { transform: translateY(-10px); } }
@keyframes arcade-blink { 50% { opacity: 0; } }
@keyframes arcade-pulse { 50% { box-shadow: 0 10px 0 #333, 0 0 0 4px rgba(255, 0, 0, 0.35); } }
@keyframes arcade-hop { 40% { transform: translateY(-10px) scale(1.06); } }
@keyframes arcade-nudge { 50% { transform: translate(-70%, -50%); } }

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

@media (max-width: 600px) {
    .start-screen { inset: 52px 0 0 0; }
    /* Bigger start screen on phones: it fills more of the screen. A long site name wraps onto two lines. */
    .start-screen { padding: 28px 16px 16px; }
    .start-screen .start-logo { width: clamp(80px, calc(40vh - 112px), 172px); height: clamp(80px, calc(40vh - 112px), 172px); }
    .start-title { margin-top: clamp(18px, 4.5vh, 34px); }
    .start-tagline { margin-bottom: clamp(12px, 4.5vh, 34px); }
    .start-title { font-size: 7.4vw; }
    .start-tagline { font-size: 1.1rem; }
    .arcade .start-press { font-size: 5vw; }
    .start-quick-label { font-size: 0.8rem; }
    .arcade .start-quick a { padding: 9px 14px; font-size: 1rem; }
    .arcade .sound-toggle { width: 38px; height: 38px; }
    .home-tiles { grid-template-columns: repeat(2, 1fr); gap: 12px; }
    .home-tile img { width: 60px; height: 60px; }
    .home-tile.sel::before { display: none; }
    .home-keys { display: none; }
    .bg-opts { flex-wrap: wrap; justify-content: flex-end; white-space: normal; border-radius: 14px; }
    .arcade .engine-card-text strong { font-size: 11px; }
}

/* Phones: the raccoon follows the screen's smallest height (with the browser bars showing). */
@supports (height: 1svh) {
    @media (max-width: 600px) {
        .start-screen .start-logo { width: clamp(80px, calc(40svh - 112px), 172px); height: clamp(80px, calc(40svh - 112px), 172px); }
        .start-title { margin-top: clamp(18px, 4.5svh, 34px); }
        .start-tagline { margin-bottom: clamp(12px, 4.5svh, 34px); }
    }
}
/* Shorter phones: the site name stays on one line, a smaller raccoon and tighter gaps, so it all fits. */
@media (max-width: 600px) and (max-height: 650px) {
    .start-title { font-size: 5.2vw; margin-top: clamp(14px, 3.5vh, 34px); }
    .start-tagline { margin-bottom: clamp(10px, 3.5vh, 34px); }
    .start-quick-label { margin-top: clamp(10px, 3vh, 28px); }
    .start-screen .start-logo { width: clamp(80px, calc(40vh - 112px), 172px); height: clamp(80px, calc(40vh - 112px), 172px); }
}
@supports (height: 1svh) {
    @media (max-width: 600px) and (max-height: 650px) {
        .start-screen .start-logo { width: clamp(80px, calc(40svh - 112px), 172px); height: clamp(80px, calc(40svh - 112px), 172px); }
    }
}
/* Very short phones (sideways): smaller quick links too. */
@media (max-width: 600px) and (max-height: 560px) {
    .arcade .start-quick a { padding: 6px 10px; font-size: 0.85rem; }
}
/* Phones: the background chooser sits in the top corner, clear of the quick links. */
@media (max-width: 600px) {
    .bg-pick, body:has(.edit-fab) .bg-pick { top: 12px; bottom: auto; }
}

@media (hover: none) {
    .home-keys { display: none; }
}

/* Visitors who turn off animations on their device get a still page. */
@media (prefers-reduced-motion: reduce) {
    .arcade *, .arcade *::before { animation: none !important; transition: none !important; }
}
