/* AI Arcade design system.
   Dark first: this is a games platform and most play happens on a phone at night.
   Light mode is supported but is not the design target. */

:root {
  /* Surface ramp, darkest to lightest. Three levels is enough; a fourth
     always ends up indistinguishable from its neighbour on a phone screen. */
  --bg: #0a0c12;
  --surface: #12151f;
  --surface-2: #1a1f2e;
  --line: #262d40;
  --line-strong: #39425c;

  --ink: #e9edf7;
  --ink-dim: #a4afc7;
  --ink-faint: #6d7893;

  --accent: #7c5cff;
  --accent-ink: #ffffff;
  --accent-soft: #241d49;
  --ok: #3ddc97;
  --warn: #f5c451;
  --bad: #ff6b6b;

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 18px;
  --r-pill: 999px;

  --gutter: 16px;
  --measure: 1100px;

  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.28);

  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f4f6fb;
    --surface: #ffffff;
    --surface-2: #eef1f8;
    --line: #dfe4ef;
    --line-strong: #c3cbdd;
    --ink: #10131b;
    --ink-dim: #4d566c;
    --ink-faint: #7b8499;
    --accent-soft: #ece8ff;
    --shadow: 0 1px 2px rgba(16, 19, 27, 0.06), 0 8px 24px rgba(16, 19, 27, 0.08);
    color-scheme: light;
  }
}

:root[data-theme="dark"] { color-scheme: dark; }

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a { color: inherit; }

/* ---------- Layout ---------- */

.wrap {
  width: 100%;
  max-width: var(--measure);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

main { flex: 1 0 auto; padding: 28px 0 64px; }

/* ---------- Masthead ---------- */

.masthead {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
}

.masthead .wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 58px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-weight: 700;
  letter-spacing: -0.02em;
  text-decoration: none;
  font-size: 17px;
  flex: 0 0 auto;
}

.brand .glyph {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  background: linear-gradient(145deg, var(--accent), #4aa8ff);
  font-size: 14px;
}

/* Primary nav collapses to a scrollable strip under the masthead on phones,
   rather than into a hamburger: three links do not earn a menu. */
.nav {
  display: flex;
  gap: 2px;
  margin-left: auto;
  align-items: center;
}

.nav a {
  padding: 7px 11px;
  border-radius: var(--r-sm);
  text-decoration: none;
  color: var(--ink-dim);
  font-size: 14.5px;
  font-weight: 500;
  white-space: nowrap;
}

.nav a:hover { color: var(--ink); background: var(--surface-2); }
.nav a[aria-current="page"] { color: var(--ink); background: var(--surface-2); }

.subnav {
  display: none;
  gap: 2px;
  overflow-x: auto;
  scrollbar-width: none;
  border-bottom: 1px solid var(--line);
  padding: 6px var(--gutter);
  background: var(--bg);
  position: sticky;
  top: 52px;
  z-index: 19;
}
.subnav::-webkit-scrollbar { display: none; }
.subnav a {
  padding: 6px 11px;
  border-radius: var(--r-pill);
  text-decoration: none;
  color: var(--ink-dim);
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
}
.subnav a[aria-current="page"] { color: var(--ink); background: var(--surface-2); }

/* Phone layout. This block must stay after both nav definitions above: it flips
   which of the two strips is visible, and an equal-specificity rule declared
   later would silently win and leave the phone with no navigation at all. */
@media (max-width: 620px) {
  .masthead .wrap { height: 52px; }
  .nav { display: none; }
  .subnav { display: flex; }
}

/* ---------- Buttons ---------- */

.btn {
  font: inherit;
  font-size: 14.5px;
  font-weight: 600;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 15px;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  background: var(--accent);
  color: var(--accent-ink);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}

.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; filter: none; }

.btn.ghost { background: transparent; border-color: var(--line-strong); color: var(--ink); }
.btn.ghost:hover { background: var(--surface-2); filter: none; }
.btn.sm { padding: 7px 11px; font-size: 13.5px; }

/* ---------- Account control ---------- */

.account { flex: 0 0 auto; display: flex; align-items: center; gap: 8px; }

.avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  object-fit: cover;
  display: block;
}

.menu { position: relative; }

.menu-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 210px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow);
  padding: 6px;
}

.menu-panel[hidden] { display: none; }

.menu-panel .who {
  padding: 9px 10px 11px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 6px;
}
.menu-panel .who strong { display: block; font-size: 14.5px; }
.menu-panel .who span { display: block; font-size: 12.5px; color: var(--ink-faint); word-break: break-all; }

.menu-panel button, .menu-panel a {
  display: block;
  width: 100%;
  text-align: left;
  font: inherit;
  font-size: 14px;
  padding: 8px 10px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
}
.menu-panel button:hover, .menu-panel a:hover { background: var(--surface-2); }

/* ---------- Page furniture ---------- */

.page-head { margin: 0 0 22px; }
.page-head h1 { font-size: clamp(24px, 5vw, 32px); letter-spacing: -0.025em; margin: 0 0 6px; }
.page-head p { margin: 0; color: var(--ink-dim); max-width: 62ch; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 20px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border-radius: var(--r-pill);
  background: var(--accent-soft);
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

/* Empty states carry weight here: for the first weeks most routes are empty,
   and an empty page has to read as deliberate rather than broken. */
.empty {
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-lg);
  padding: 44px 24px;
  text-align: center;
  color: var(--ink-dim);
  background: color-mix(in srgb, var(--surface) 55%, transparent);
}
.empty .mark { font-size: 30px; line-height: 1; margin-bottom: 12px; }
.empty h2 { margin: 0 0 6px; font-size: 17px; color: var(--ink); }
.empty p { margin: 0 auto; max-width: 46ch; font-size: 14.5px; }
.empty .btn { margin-top: 18px; }

code { font-family: var(--mono); font-size: 0.9em; background: var(--surface-2); border-radius: 5px; padding: 1px 5px; }

/* ---------- Footer ---------- */

footer {
  border-top: 1px solid var(--line);
  padding: 22px 0 34px;
  color: var(--ink-faint);
  font-size: 13.5px;
}
footer .wrap { display: flex; flex-wrap: wrap; gap: 10px 20px; align-items: center; }
footer a { color: var(--ink-dim); text-decoration: none; }
footer a:hover { color: var(--ink); }
footer .spacer { margin-left: auto; }

/* ---------- Route transition ---------- */

#view[data-busy="true"] { opacity: 0.45; }
#view { transition: opacity 120ms ease; }

@media (prefers-reduced-motion: reduce) {
  #view { transition: none; }
}

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  color: var(--ink);
  padding: 11px 16px;
  border-radius: var(--r-pill);
  font-size: 14px;
  box-shadow: var(--shadow);
  z-index: 40;
  max-width: calc(100vw - 32px);
}
.toast[hidden] { display: none; }
.toast.bad { border-color: var(--bad); }

/* ---------- Catalog grid ---------- */

.grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(232px, 1fr));
}

.game-card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  transition: transform 140ms ease, border-color 140ms ease;
}

.game-card:hover { transform: translateY(-2px); border-color: var(--line-strong); }

.game-card .body { padding: 14px 15px 16px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.game-card h3 { margin: 0; font-size: 16.5px; letter-spacing: -0.015em; }
.game-card p { margin: 0; font-size: 14px; color: var(--ink-dim); line-height: 1.45; }

/* Cover art is generated from two colours and a glyph in catalog.json. Real art
   would cost bytes against a 360 MB/day transfer ceiling, and these stay sharp
   at any size for nothing. */
.cover {
  position: relative;
  aspect-ratio: 16 / 10;
  display: grid;
  place-items: center;
  overflow: hidden;
  isolation: isolate;
}

.cover::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(120% 90% at 22% 12%, rgba(255, 255, 255, 0.22), transparent 60%);
}

.cover .glyph {
  font-size: clamp(38px, 9vw, 54px);
  line-height: 1;
  filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.42));
}

.cover.lg { aspect-ratio: 21 / 9; border-radius: var(--r-lg); }
.cover.lg .glyph { font-size: clamp(52px, 12vw, 86px); }

/* Gameplay shot on the card: lazily fetched, sits over the gradient, which
   stays the instant base layer and the fallback for games without one. The
   sheen is suppressed there: a 22% white radial wash over a photo just fogs it. */
.cover .shot {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 1;
}
.cover.has-shot::after { display: none; }
.cover.has-shot .glyph { opacity: 0; transition: opacity .2s; }

.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; padding-top: 10px; }
.tag {
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--ink-dim);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  padding: 3px 8px;
  white-space: nowrap;
}

/* ---------- Store page ---------- */

.store-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 14px 20px;
  margin: 18px 0 22px;
}
.store-head h1 { margin: 0 0 4px; font-size: clamp(25px, 5.5vw, 34px); letter-spacing: -0.028em; }
.store-head .hook { margin: 0; color: var(--ink-dim); max-width: 54ch; }
.store-head .actions { margin-left: auto; display: flex; gap: 9px; align-items: center; }

@media (max-width: 620px) {
  .store-head .actions { margin-left: 0; width: 100%; }
  .store-head .actions .btn { flex: 1; }
}

.store-body {
  display: grid;
  gap: 26px;
  grid-template-columns: minmax(0, 1.65fr) minmax(210px, 0.9fr);
  align-items: start;
}

@media (max-width: 760px) {
  .store-body { grid-template-columns: 1fr; gap: 22px; }
}

.prose p { margin: 0 0 13px; line-height: 1.62; }
.prose p:last-child { margin-bottom: 0; }

.facts { display: grid; gap: 0; }
.facts h2 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-faint); margin: 0 0 10px; }
.facts .row { display: flex; gap: 12px; padding: 9px 0; border-top: 1px solid var(--line); font-size: 14px; }
.facts .row:first-of-type { border-top: 0; }
.facts .row dt { flex: 0 0 42%; color: var(--ink-dim); margin: 0; }
.facts .row dd { margin: 0; flex: 1; }

.note-line { font-size: 13px; color: var(--ink-faint); margin: 10px 0 0; }
