/* ═══════════════════════════════════════════════════════════════
   ARCADIA — arcade.css
   Shared chrome for the /games/ PWA scope. Standalone by design:
   dark-only neon identity, self-hosted pixel font, zero references
   outside /games/.

   --accent is the per-game personality hook: each game page sets it
   inline on <html> (and via Arcade.init({accent})); everything here
   that should carry the game's color reads var(--accent).
   ═══════════════════════════════════════════════════════════════ */

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

:root {
    --bg:            #000;
    --bg-soft:       #12162A;
    --bg-card:       #1B2038;
    --headers:       #EAF2FF;
    --text:          #C5C7D0;
    --text-muted:    rgba(197, 199, 208, 0.62);
    --border:        rgba(255, 255, 255, 0.08);
    --border-strong: rgba(255, 255, 255, 0.16);
    --grid-line:     rgba(255, 255, 255, 0.04);
    --overlay:       rgba(8, 8, 19, 0.9);

    --neon-blue:   #19C6FF;
    --neon-pink:   #FF2DAA;
    --neon-lime:   #8EFF2A;
    --neon-yellow: #FFD533;
    --neon-purple: #8B5CFF;
    --neon-orange: #FF9B21;
    --neon-red:    #FF4B5C;

    /* per-game personality; games override on <html> */
    --accent:      var(--neon-yellow);
    --accent-glow: rgba(255, 213, 51, 0.3);

    /* legacy aliases — pre-neon games consume these */
    --highlight:   var(--neon-red);
    --yellow:      var(--neon-yellow);

    --bezel:      #0B0E1E;
    --bezel-text: #EAF2FF;
    --font-mono:  ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
    --font-pixel: 'Press Start 2P', ui-monospace, monospace;
    --bar-h:      52px;
    --ease-snap:  cubic-bezier(0.22, 0.9, 0.32, 1);
    --dur-fast:   180ms;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
    -webkit-text-size-adjust: 100%;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-mono);
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
    -webkit-font-smoothing: antialiased;
}

/* Game pages lock the viewport; the hub scrolls normally. */
body.arc-playing {
    position: fixed;
    inset: 0;
    overflow: hidden;
    overscroll-behavior: none;
    display: flex;
    flex-direction: column;
}

button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
a { color: inherit; text-decoration: none; }
button, a { touch-action: manipulation; }
canvas, .arc-surface { touch-action: none; display: block; }

/* ── Top bar — the cabinet bezel; accent trim = game color ────── */
.arc-bar {
    --bar-ink-size: 0.62rem;
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    min-height: calc(var(--bar-h) + env(safe-area-inset-top));
    padding: calc(0.35rem + env(safe-area-inset-top)) calc(0.5rem + env(safe-area-inset-right)) 0.35rem calc(0.5rem + env(safe-area-inset-left));
    background: var(--bezel);
    color: var(--bezel-text);
    border-bottom: 1px solid var(--accent);
    font: var(--bar-ink-size)/1 var(--font-pixel);
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

/* iOS standalone (Add to Home Screen): the status bar's blur overhangs the
   top of the viewport, so drop the bar an extra 40px to keep the controls clear */
html.ios-standalone .arc-bar {
    min-height: calc(var(--bar-h) + env(safe-area-inset-top) + 40px);
    padding-top: calc(0.35rem + env(safe-area-inset-top) + 40px);
}

.arc-bar .arc-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 42px;
    min-height: 42px;
    color: var(--bezel-text);
    opacity: 0.85;
    transition: opacity var(--dur-fast) ease;
}

.arc-bar .arc-btn::before {
    content: "";
    width: var(--bar-ink-size);
    height: var(--bar-ink-size);
}

.arc-bar .arc-pause-btn::before {
    border-inline: calc(var(--bar-ink-size) * 0.3) solid currentColor;
}

.arc-bar .arc-gear::before {
    background: radial-gradient(circle, transparent 24%, currentColor 25%);
    clip-path: polygon(
        35% 0, 65% 0, 65% 15%, 85% 15%, 85% 35%, 100% 35%, 100% 65%,
        85% 65%, 85% 85%, 65% 85%, 65% 100%, 35% 100%, 35% 85%, 15% 85%,
        15% 65%, 0 65%, 0 35%, 15% 35%, 15% 15%, 35% 15%
    );
}

/* back link: plain pixel-font text, same height as the game title,
   a bit fainter so the title still leads */
.arc-bar .arc-back {
    margin-right: 0.45rem;
    color: var(--bezel-text);
    opacity: 0.62;
    white-space: nowrap;
    transition: opacity var(--dur-fast) ease;
}

.arc-bar .arc-back:active { opacity: 0.4; }

.arc-title {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.arc-score-slot {
    color: var(--accent);
    padding: 0 0.4rem;
    white-space: nowrap;
}

/* ── Stage — the area a game owns below the bar ───────────────── */
.arc-stage {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem;
    padding-bottom: calc(0.75rem + env(safe-area-inset-bottom));
    position: relative;
    overflow: hidden;
}

html.arc-game-background .arc-playing .arc-stage {
    --stage-art: url('./art/skatepark-day.webp');
    background-image: linear-gradient(rgba(0, 0, 0, 0.44), rgba(0, 0, 0, 0.52)), var(--stage-art);
    background-position: center;
    background-size: cover;
}

@media (prefers-color-scheme: dark) {
    html.arc-game-background .arc-playing .arc-stage {
        --stage-art: url('./art/skatepark-night.webp');
    }
}

/* ── Overlays (settings / pause / game over) ──────────────────── */
.arc-overlay {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background: var(--overlay);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
}

.arc-panel {
    width: min(360px, 100%);
    background: var(--bg-soft);
    border: 1px solid var(--border-strong);
    border-radius: 6px;
    box-shadow: 0 0 24px var(--accent-glow);
    padding: 1.5rem;
}

.arc-settings-panel {
    max-height: 100%;
    overflow: auto;
}

.arc-panel-title {
    font-family: var(--font-pixel);
    font-size: 0.72rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 1.25rem;
}

.arc-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.7rem 0;
    border-top: 1px solid var(--border);
    font-size: 0.78rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

/* Toggle pill */
.arc-toggle {
    min-width: 58px;
    padding: 0.4rem 0.7rem;
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    color: var(--text-muted);
}

.arc-toggle[aria-pressed="true"] {
    background: var(--accent);
    border-color: var(--accent);
    color: #080813;
    box-shadow: 0 0 12px var(--accent-glow);
}

/* Primary / secondary action buttons */
.arc-actions { display: flex; gap: 0.6rem; margin-top: 1.4rem; }

.arc-action {
    flex: 1;
    padding: 0.8rem 1rem;
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    font-size: 0.74rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    text-align: center;
    transition: transform var(--dur-fast) var(--ease-snap);
}

.arc-action:active { transform: translateY(2px); }

.arc-action--primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #080813;
    box-shadow: 0 0 16px var(--accent-glow);
}

/* ── Game over panel bits ─────────────────────────────────────── */
.arc-over-title {
    font-family: var(--font-pixel);
    font-size: 0.95rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--headers);
    margin-bottom: 1.1rem;
}

.arc-over-score {
    font-family: var(--font-pixel);
    font-size: 1.8rem;
    color: var(--headers);
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
    text-shadow: 0 0 18px var(--accent-glow);
}

.arc-over-label {
    font-size: 0.68rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.arc-best-chip {
    display: inline-block;
    margin-top: 0.8rem;
    padding: 0.35rem 0.65rem;
    background: var(--accent);
    border-radius: 3px;
    color: #080813;
    font-family: var(--font-pixel);
    font-size: 0.55rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    font-variant-numeric: tabular-nums;
}

.arc-newbest {
    display: inline-block;
    margin-top: 0.8rem;
    margin-left: 0.4rem;
    padding: 0.35rem 0.65rem;
    background: var(--neon-pink);
    border-radius: 3px;
    color: #080813;
    font-family: var(--font-pixel);
    font-size: 0.55rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    animation: arc-blink 0.9s steps(2, start) infinite;
}

@keyframes arc-blink { 50% { opacity: 0.35; } }

/* Pause overlay is just a tappable message */
.arc-pause-msg {
    font-family: var(--font-pixel);
    font-size: 0.85rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--headers);
    text-align: center;
}

.arc-pause-sub {
    display: block;
    margin-top: 0.9rem;
    font-family: var(--font-mono);
    font-size: 0.68rem;
    letter-spacing: 0.12em;
    color: var(--text-muted);
}

/* ── Coming-soon prototype chip ───────────────────────────────── */
.arc-proto {
    position: absolute;
    top: 0.6rem;
    right: 0.6rem;
    z-index: 5;
    padding: 0.32rem 0.55rem;
    font-family: var(--font-pixel);
    font-size: 0.5rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
    border: 1px dashed var(--border-strong);
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.45);
}

/* ── Toast ────────────────────────────────────────────────────── */
.arc-toast {
    position: fixed;
    left: 50%;
    bottom: calc(1.25rem + env(safe-area-inset-bottom));
    transform: translateX(-50%) translateY(8px);
    z-index: 80;
    max-width: min(90vw, 420px);
    padding: 0.7rem 1.1rem;
    background: var(--bezel);
    color: var(--bezel-text);
    border: 1px solid var(--accent);
    border-radius: 4px;
    box-shadow: 0 0 16px var(--accent-glow);
    font-size: 0.72rem;
    letter-spacing: 0.06em;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--dur-fast) ease, transform var(--dur-fast) var(--ease-snap);
}

.arc-toast.arc-toast--show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── Install hint banner (hub) ────────────────────────────────── */
.arc-hint {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    margin-top: 1rem;
    padding: 0.85rem 1rem;
    border: 1px dashed var(--border-strong);
    border-radius: 6px;
    font-size: 0.72rem;
    line-height: 1.6;
    letter-spacing: 0.03em;
    color: var(--text-muted);
}

.arc-hint strong { color: var(--headers); font-weight: 600; }

.arc-hint .arc-hint-close {
    margin-left: auto;
    min-width: 36px;
    min-height: 36px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.arc-hint .arc-action { flex: 0 0 auto; padding: 0.5rem 0.9rem; }

/* ── CRT mode (on by default): static scanlines, no flicker ────
   The old steps(2) flicker strobed the whole screen at ~8 Hz,
   which made fast-moving sprites look like they left trails. */
html.arc-crt::after {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 95;
    pointer-events: none;
    background: repeating-linear-gradient(
        to bottom,
        transparent 0 2px,
        rgba(0, 0, 0, 0.16) 2px 4px
    );
}

/* ── INSERT COIN launch flourish ──────────────────────────────── */
.arc-coin { z-index: 85; background: rgba(8, 8, 19, 0.72); }

.arc-coin-text {
    font-family: var(--font-pixel);
    font-size: clamp(1rem, 5vw, 1.6rem);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--neon-yellow);
    text-shadow: 0 0 18px rgba(255, 213, 51, 0.55);
    animation: arc-blink 0.32s steps(2, start) infinite;
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
