/* =====================================================================
   ARCADE: a cabinet's game-select screen. PICO-8 palette on navy, Silkscreen
   pixel type for labels and numbers, IBM Plex Mono for reading, square
   corners, notched "pixel" frames and scanlines over everything.
   Yellow is the one accent.
   Spec: docs/themes/arcade.md

   THE FRAME RULE (read docs/themes/arcade.md before changing anything here):
   every framed element, game cards included, has a LIGHT GREY (#c2c3c7)
   notched frame. The frame is never the game's colour: the colour lives only
   in the icon block. The toast is the one yellow frame at rest; a hovered game
   card, button or theme button lights its frame yellow (a danger button red),
   and pressing turns it orange.
   Every --pb below is set with plain specificity, so what you read is what
   renders: never put an id inside the shared :is() frame selector.
   ===================================================================== */
:root[data-theme="arcade"] {
  color-scheme: dark;
  --p-black: #000; --p-navy: #1d2b53; --p-plum: #7e2553; --p-green-d: #008751; --p-brown: #ab5236;
  --p-grey-d: #5f574f; --p-grey: #c2c3c7; --p-white: #fff1e8; --p-red: #ff004d; --p-orange: #ffa300;
  --p-yellow: #ffec27; --p-green: #00e436; --p-blue: #29adff; --p-lav: #83769c; --p-pink: #ff77a8; --p-peach: #ffccaa;
  --bg: var(--p-navy); --surface: var(--p-black); --surface-2: #2a2230;
  --text: var(--p-white); --muted: var(--p-grey); --faint: var(--p-lav); --border: var(--p-grey-d); --rule: var(--p-grey);
  --accent: var(--p-yellow);
  --primary: var(--p-yellow); --primary-strong: var(--p-orange); --primary-contrast: #000; --primary-soft: var(--p-plum);
  --danger: var(--p-red); --danger-soft: var(--p-plum); --success: var(--p-green);
  --radius: 0px; --r-ctl: 0px; --r-ctl-in: 0px; --r-dialog: 0px; --r-menu: 0px; --r-board: 0px; --r-cell: 0px; --r-pill: 0px;
  --content-w: 940px;
  /* a cabinet does not ease: hovers snap. Both tokens sit on :root, so --fade (which
     is built from --t-fast, and resolves where it is declared) picks this up. */
  --t-fast: 0s;
  --shadow: none;
  --dialog-shadow: none;
  --menu-shadow: none;
  --overlay: rgba(0, 0, 0, .6);
  --font: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  --font-display: "Silkscreen", "IBM Plex Mono", monospace;
  --font-mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  --toast-bg: #000; --toast-fg: var(--p-white); --toast-action: var(--p-yellow);
  --record-bg: var(--p-yellow); --record-fg: #000;
  /* the notched frame colour; the frame itself (--frame) is built on each framed element */
  --pb: var(--p-grey);
  --bevel: inset -5px -5px 0 rgba(0, 0, 0, .28), inset 5px 5px 0 rgba(255, 255, 255, .3);
  /* 2048 */
  --g-board: #000; --g-slot: var(--p-navy);
  --t2: var(--p-grey-d); --t4: var(--p-lav); --t8: var(--p-blue); --t16: var(--p-green-d); --t32: var(--p-green); --t64: var(--p-orange);
  --t128: var(--p-pink); --t256: var(--p-red); --t512: var(--p-plum); --t1024: var(--p-brown); --t2048: var(--p-yellow);
  --t-ink: var(--p-white); --t-paper: var(--p-white);
  /* memory grid */
  --flash: var(--p-yellow); --tile: #2a2230;
  /* card table: a navy screen in a thick grey bezel */
  --table-bg: var(--p-navy);
  --table-frame: 0 0 0 4px var(--p-grey-d), 0 0 0 8px #000;
  --slot-line: var(--p-grey-d);
  --card-paper: var(--p-white); --card-r: 0;
  --card-shadow: 0 0 0 2px #000, 3px 3px 0 rgba(0, 0, 0, .45);
  --court-panel: var(--p-peach); --court-rule: inset 0 0 0 2px #000;
  --suit-red: var(--p-red); --suit-black: #000;
  --card-back-art: repeating-conic-gradient(var(--p-plum) 0 25%, var(--p-navy) 0 50%) 0 0 / 8px 8px;
  --back-edge: var(--p-white); --back-edge-w: .07; --back-shadow: 0 0 0 2px #000, 3px 3px 0 rgba(0, 0, 0, .45);
  --font-card: var(--font-display);
}
/* scanlines over the whole page, like a CRT */
[data-theme="arcade"] body::after {
  content: ""; position: fixed; inset: 0; z-index: 100; pointer-events: none;
  background: repeating-linear-gradient(to bottom, transparent 0 2px, rgba(0, 0, 0, .16) 2px 3px);
}
[data-theme="arcade"] ::selection { background: var(--p-yellow); color: #000; }
/* the backdrop: the attract mode: stars, invaders, the ship (js/backdrops/arcade.js); faint over the content column */
[data-theme="arcade"] .backdrop { --veil: .45; }

/* Framed elements. Light grey; the toast is yellow, and everything clickable lights up on hover (below). */
[data-theme="arcade"] :is(.btn, .game-card, .dialog, .theme-menu, .install-banner, .stat, .theme-btn, .box, #toast) {
  /* declared here, not on :root, so each element resolves its own --pb */
  --frame: 0 -4px 0 0 var(--pb), 0 4px 0 0 var(--pb), -4px 0 0 0 var(--pb), 4px 0 0 0 var(--pb);
  border: 0; border-radius: 0;
  box-shadow: var(--frame);
}
[data-theme="arcade"] #toast { --pb: var(--p-yellow); }

/* pixel type for labels, buttons, headings and every number */
[data-theme="arcade"] :is(.brand, .btn, .segmented button, .tool, .stat-label, .stat-value, .dialog h2, .theme-btn, .game-meta h3, .game-status, .offline-badge, .toast-action, .record, .main-nav a, .section-title, .section-count, .box > h3, .settings-title, .field label, .footer-brand, .footer-links, .version, .t-label, .icon-tile span, .keypad button, .g2048-board > div) {
  font-family: var(--font-display); font-weight: 400; text-transform: uppercase; letter-spacing: .02em;
}

/* ---------- chrome ---------- */
[data-theme="arcade"] .topbar { background: #000; -webkit-backdrop-filter: none; backdrop-filter: none; border-bottom: 4px solid var(--p-grey-d); }
[data-theme="arcade"] .brand { font-size: 1.05rem; font-weight: 700; }
[data-theme="arcade"] body[data-route="home"] .brand { visibility: hidden; }
[data-theme="arcade"] .icon-btn:hover { background: var(--p-grey-d); }
[data-theme="arcade"] .main-nav a { color: var(--p-grey); font-size: .72rem; border-radius: 0; }
[data-theme="arcade"] .main-nav a:hover { background: transparent; color: var(--p-white); }
[data-theme="arcade"] .main-nav a[aria-current="true"] { background: transparent; color: var(--p-yellow); }
[data-theme="arcade"] .main-nav a[aria-current="true"]::before { content: "\25B8 "; }
[data-theme="arcade"] .topbar .lang-toggle { height: 34px; }
[data-theme="arcade"] .theme-btn { height: 34px; margin-right: 4px; background: #000; font-size: .75rem; }
[data-theme="arcade"] .theme-btn .theme-swatch { width: 26px; height: 26px; border-radius: 0; }
[data-theme="arcade"] .theme-menu { top: calc(100% + 14px); background: #000; }
[data-theme="arcade"] .theme-opt strong { font-weight: 400; }
[data-theme="arcade"] :is(.theme-opt:hover, .theme-opt:focus-visible) { background: var(--p-navy); box-shadow: none; }
[data-theme="arcade"] .theme-opt .ico { color: var(--p-yellow); }
[data-theme="arcade"] .theme-opt .apps i { border: 2px solid var(--p-grey-d); border-radius: 0; font-family: var(--font-display); }

/* ---------- controls ---------- */
[data-theme="arcade"] .btn { height: 38px; margin: 4px; background: #000; font-size: .8rem; }
/* hover lights the frame yellow (red on a danger button), pressing turns it orange, like the game cards */
[data-theme="arcade"] :is(.btn, .theme-btn):hover:not(:disabled) { --pb: var(--p-yellow); background: #000; }
[data-theme="arcade"] :is(.btn, .theme-btn):active:not(:disabled) { --pb: var(--p-orange); transform: none; }
[data-theme="arcade"] .btn-primary { background: var(--p-yellow); color: #000; }
[data-theme="arcade"] .btn-primary:hover:not(:disabled) { background: var(--p-orange); }
[data-theme="arcade"] .btn-danger { color: var(--p-red); }
[data-theme="arcade"] .btn-danger:hover:not(:disabled) { --pb: var(--p-red); }
[data-theme="arcade"] :is(.dialog-actions, .row) { gap: 10px; }
[data-theme="arcade"] .segmented { padding: 4px; background: #000; }
[data-theme="arcade"] .segmented button { font-size: .72rem; padding: 7px 10px; }
[data-theme="arcade"] .segmented button[aria-pressed="true"] { background: var(--p-yellow); color: #000; box-shadow: none; }
[data-theme="arcade"] .stats { gap: 16px; padding: 0 4px; }
[data-theme="arcade"] .stat { background: #000; }
[data-theme="arcade"] .stat-label { font-size: .56rem; color: var(--p-pink); }
[data-theme="arcade"] .stat-value { color: var(--p-yellow); }
[data-theme="arcade"] .tool { font-size: .66rem; }
[data-theme="arcade"] .tool:hover:not(:disabled) { background: var(--p-grey-d); color: var(--p-white); }
[data-theme="arcade"] .tool[aria-pressed="true"] { background: var(--p-plum); color: var(--p-yellow); }
[data-theme="arcade"] .tool .badge { border-radius: 0; background: var(--p-red); color: var(--p-white); font-family: var(--font-display); }
[data-theme="arcade"] .hint-text { color: var(--p-lav); }
[data-theme="arcade"] .field label { color: var(--p-pink); font-size: .66rem; }
[data-theme="arcade"] .field input { border: 2px solid var(--p-grey-d); background: #000; }
[data-theme="arcade"] .field input:focus-visible { outline: 0; border-color: var(--p-yellow); }
[data-theme="arcade"] .switch { width: 48px; height: 26px; border-radius: 0; background: #000; box-shadow: inset 0 0 0 3px var(--p-grey-d); }
[data-theme="arcade"] .switch::before { top: 6px; left: 6px; width: 14px; height: 14px; border-radius: 0; background: var(--p-grey-d); box-shadow: none; }
[data-theme="arcade"] .switch[aria-checked="true"] { background: #000; box-shadow: inset 0 0 0 3px var(--p-grey); }
[data-theme="arcade"] .switch[aria-checked="true"]::before { transform: translateX(22px); background: var(--p-yellow); box-shadow: inset -3px -3px 0 var(--p-orange); }
[data-theme="arcade"] :is(.check input, .range) { accent-color: var(--p-yellow); }

/* ---------- surfaces, dialog, toast ---------- */
[data-theme="arcade"] .box { margin: 4px; background: #000; }
[data-theme="arcade"] .box > h3 { color: var(--p-yellow); font-size: .95rem; font-weight: 700; }
[data-theme="arcade"] .spec-grid { gap: 26px; }
[data-theme="arcade"] .dialog { margin: 4px; background: #000; }
[data-theme="arcade"] .dialog h2, [data-theme="arcade"] .settings-title { font-size: 1.3rem; font-weight: 700; color: var(--p-yellow); }
[data-theme="arcade"] .rules, [data-theme="arcade"] .dialog p { font-size: .9rem; color: var(--p-grey); }
[data-theme="arcade"] .dialog .stats { gap: 16px; padding: 4px; }
[data-theme="arcade"] #toast { background: #000; color: var(--p-white); }
[data-theme="arcade"] .install-banner { margin: 4px 4px 30px; background: #000; }
[data-theme="arcade"] .offline-badge { font-size: .72rem; }
[data-theme="arcade"] .offline-badge i { border-radius: 0; }
[data-theme="arcade"] .drawer { background: #000; box-shadow: -4px 0 0 var(--p-grey); }
[data-theme="arcade"] .setting { border-top: 2px dashed var(--p-grey-d); }
[data-theme="arcade"] .setting-text strong { font-weight: 600; }
[data-theme="arcade"] .icon-tile { border: 2px solid var(--p-grey-d); background: #000; color: var(--p-grey); }
[data-theme="arcade"] .icon-tile .ico { color: var(--p-white); stroke-width: 2; stroke-linecap: square; stroke-linejoin: miter; }
[data-theme="arcade"] .swatch-item i { border-radius: 0; box-shadow: inset 0 0 0 2px #000; }

/* ---------- home: the cabinet's game-select screen ---------- */
[data-theme="arcade"] .home-hero { display: flex; flex-direction: column; align-items: center; text-align: center; margin: 22px 0 40px; }
[data-theme="arcade"] .hero-meta { display: flex; order: 1; margin-bottom: 18px; color: var(--p-yellow); font: 400 .8rem/1 var(--font-display); text-transform: uppercase; letter-spacing: .08em; }
[data-theme="arcade"] .hero-meta :is(.meta-date, .meta-note) { display: none; }
[data-theme="arcade"] .meta-count::before, [data-theme="arcade"] .meta-count::after { content: "\2605"; margin: 0 .8em; color: var(--p-pink); }
[data-theme="arcade"] .hero-title {
  display: block; order: 2;
  font: 700 clamp(2.5rem, 10.5vw, 5.6rem)/1 var(--font-display);
  text-transform: uppercase;
  color: var(--p-white);
  text-shadow: .06em .06em 0 var(--p-red), .12em .12em 0 var(--p-plum);
}
[data-theme="arcade"] .hero-title span { display: block; }
[data-theme="arcade"] .hero-title span + span { color: var(--p-yellow); }
[data-theme="arcade"] .intro { order: 3; max-width: 46ch; margin: 30px 0 0; color: var(--p-grey); font-size: .9rem; }
[data-theme="arcade"] .home-hero::after {
  content: "\25B8  Select a game"; order: 4;
  margin-top: 26px;
  color: var(--p-blue); font: 400 .9rem/1 var(--font-display); text-transform: uppercase; letter-spacing: .06em;
  white-space: pre;
  animation: arcade-blink 1.1s steps(1) infinite;
}
[data-theme="arcade"]:lang(de) .home-hero::after { content: "\25B8  Spiel wählen"; }
@keyframes arcade-blink { 50% { opacity: 0; } }

/* section heads: a pink star, yellow pixel title, a dotted run of pixels out to a red count */
[data-theme="arcade"] .section-head { align-items: center; gap: 6px 12px; margin: 0 0 22px; }
[data-theme="arcade"] .section-title { color: var(--p-yellow); font-size: .9rem; letter-spacing: .06em; }
[data-theme="arcade"] .section-title::before { content: "\2605\2002"; color: var(--p-pink); }
[data-theme="arcade"] .section-head::after { content: ""; flex: 1; order: 2; height: 4px; background: repeating-linear-gradient(to right, var(--p-grey-d) 0 4px, transparent 4px 8px); }
[data-theme="arcade"] .section-count { display: block; order: 3; padding: 3px 6px 2px; background: var(--p-red); color: var(--p-white); font-size: .72rem; }
[data-theme="arcade"] .section-note { order: 4; flex-basis: 100%; color: var(--p-lav); font-size: .8rem; }
[data-theme="arcade"] .page > .section-head .section-title { font-size: 1.1rem; font-weight: 700; }
[data-theme="arcade"] .home-section + .home-section { margin-top: 42px; }

[data-theme="arcade"] .game-list { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 26px 30px; padding: 4px; }
[data-theme="arcade"] .game-card { gap: 16px; padding: 16px; background: #000; transition: none; }
[data-theme="arcade"] .game-card:nth-child(8n+1) { --c: var(--p-blue); }
[data-theme="arcade"] .game-card:nth-child(8n+2) { --c: var(--p-red); }
[data-theme="arcade"] .game-card:nth-child(8n+3) { --c: var(--p-green); }
[data-theme="arcade"] .game-card:nth-child(8n+4) { --c: var(--p-lav); }
[data-theme="arcade"] .game-card:nth-child(8n+5) { --c: var(--p-orange); }
[data-theme="arcade"] .game-card:nth-child(8n+6) { --c: var(--p-yellow); }
[data-theme="arcade"] .game-card:nth-child(8n+7) { --c: var(--p-pink); }
[data-theme="arcade"] .game-card:nth-child(8n+8) { --c: var(--p-peach); }
/* hover: the frame lights up yellow, the card darkens a touch and the title gets the ▸ cursor;
   pressed, the frame turns orange like the primary button. Silkscreen has no ▸, so the
   cursor comes from a fallback font with taller metrics: line-height 0 keeps it from
   growing the title's line box (the card would grow 2px and jitter at its bottom edge). */
[data-theme="arcade"] :is(.game-card:hover, .game-card:focus-visible) { --pb: var(--p-yellow); transform: none; outline: none; background: #0b0b14; }
[data-theme="arcade"] .game-card:active { --pb: var(--p-orange); transform: none; }
[data-theme="arcade"] :is(.game-card:hover, .game-card:focus-visible) h3::before { content: "\25B8 "; line-height: 0; color: var(--p-yellow); }
[data-theme="arcade"] .game-card .game-icon {
  width: 64px; height: 64px; border-radius: 0;
  background: var(--c); color: var(--c);
  box-shadow: var(--bevel);
}
[data-theme="arcade"] .game-icon svg [fill="#fff"] { fill: #000; }
[data-theme="arcade"] .game-icon svg [stroke="#fff"] { stroke: #000; }
[data-theme="arcade"] .kind-line .game-card .game-icon { color: #000; }
[data-theme="arcade"] .kind-line .game-card .game-icon svg { width: 30px; height: 30px; stroke-width: 2.4; }
[data-theme="arcade"] .game-meta h3 { font-size: 1.05rem; font-weight: 700; color: var(--p-white); }
[data-theme="arcade"] .game-meta p { margin-top: 6px; font-size: .8rem; line-height: 1.45; color: var(--p-grey); }
[data-theme="arcade"] .game-status { margin-top: 8px; color: var(--c); font-size: .66rem; }
/* art panels: a landscape palette block at the left, so the widest layouts fit */
[data-theme="arcade"] .kind-art .game-card { display: grid; grid-template-columns: 150px minmax(0, 1fr); align-items: center; gap: 16px; padding: 16px; }
[data-theme="arcade"] .kind-art .game-card .game-icon { width: 150px; height: 96px; aspect-ratio: auto; background: var(--c); --art-scale: .58; }
[data-theme="arcade"] .kind-art .game-card .game-meta { padding: 0; }
[data-theme="arcade"] .home-footer { margin-top: 36px; }
[data-theme="arcade"] .icon-list { gap: 26px 30px; padding: 4px; }

/* ---------- footer ---------- */
[data-theme="arcade"] .site-footer { background: #000; border-top: 4px solid var(--p-grey-d); color: var(--p-grey); font-size: .8rem; }
[data-theme="arcade"] .footer-brand { color: var(--p-white); font-weight: 700; }
[data-theme="arcade"] .footer-links a { font-size: .7rem; }
[data-theme="arcade"] .footer-links a:hover { color: var(--p-yellow); text-decoration: none; }
[data-theme="arcade"] .version { color: var(--p-yellow); font-size: .7rem; }

/* ---------- game pieces ---------- */
[data-theme="arcade"] .g2048-board > div { text-shadow: 3px 3px 0 #000; box-shadow: inset -4px -4px 0 rgba(0, 0, 0, .3); }
[data-theme="arcade"] .mem-grid i.lit { box-shadow: var(--bevel); }
[data-theme="arcade"] .keypad button { border: 2px solid var(--p-grey-d); background: #000; font-size: 1.05rem; }
[data-theme="arcade"] .keypad button:hover { border-color: var(--p-yellow); color: var(--p-yellow); background: #000; }
[data-theme="arcade"] .keypad button.accent { background: var(--p-yellow); border-color: var(--p-yellow); color: #000; }
[data-theme="arcade"] .table { margin: 8px; }

@media (max-width: 640px) {
  [data-theme="arcade"] .game-list { grid-template-columns: minmax(0, 1fr); gap: 22px; }
  [data-theme="arcade"] .hero-title { text-shadow: 3px 3px 0 var(--p-red), 6px 6px 0 var(--p-plum); }
  [data-theme="arcade"] .kind-art .game-card { grid-template-columns: 112px minmax(0, 1fr); gap: 12px; padding: 12px; }
  [data-theme="arcade"] .kind-art .game-card .game-icon { width: 112px; height: 76px; --art-scale: .44; }
}
@media (prefers-reduced-motion: reduce) {
  [data-theme="arcade"] .home-hero::after { animation: none; }
}

/* ---------- hover: everything clickable has to visibly react ---------- */
[data-theme="arcade"] :is(.main-nav a, .segmented button):hover:not([aria-current="true"], [aria-pressed="true"]) { background: var(--p-grey-d); color: var(--p-white); }
/* no translucency in this theme: the hover halo on the small form controls is solid yellow */
[data-theme="arcade"] :is(.switch, .range):hover, [data-theme="arcade"] .check:hover input { outline-color: var(--p-yellow); }
[data-theme="arcade"] .keypad button.accent:hover:not(:disabled) { background: var(--p-orange); border-color: var(--p-orange); color: #000; }
