/* Storefront styles. Tokens and rules are documented in DESIGN.md. */
:root {
  --bg: #14171b;
  --surface: #1d2127;
  --surface-2: #262b33;
  --line: #333a44;
  --text: #ece9e4;
  --text-dim: #a9b0ba;
  --accent: #4caf63;        /* Download / Free: the one action colour */
  --accent-hover: #5fc277;
  --accent-text: #0d1a10;
  --soon: #8a93a0;
  --focus: #ffd257;         /* Focus ring: keyboard and gamepad */
  --radius: 10px;
  --gap: clamp(16px, 2.5vw, 28px);
  --wrap: 1180px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 var(--font);
}
img { max-width: 100%; display: block; }
a { color: var(--text); }
h1, h2, h3, h4 { line-height: 1.2; margin: 0 0 0.5em; }
p { margin: 0 0 1em; }
.muted { color: var(--text-dim); }
.wrap { width: min(var(--wrap), 100% - 2 * var(--gap)); margin-inline: auto; }

/* Focus: always visible, thick enough to read from the couch. */
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; border-radius: 6px; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--focus); color: #000; padding: 8px 12px; z-index: 10; }
.skip:focus { left: 8px; }

/* Header and footer */
.site-header { background: var(--surface); border-bottom: 1px solid var(--line); }
.header-row { display: flex; align-items: center; justify-content: space-between; min-height: 64px; }
.brand { font-weight: 800; font-size: 1.2rem; letter-spacing: 0.02em; text-decoration: none; }
.site-header nav a { color: var(--text-dim); text-decoration: none; padding: 10px 12px; font-weight: 600; }
.site-header nav a:hover { color: var(--text); }
.site-footer { margin-top: 64px; padding: 28px 0; border-top: 1px solid var(--line); color: var(--text-dim); font-size: 0.9rem; }
.site-footer p { margin: 0.25em 0; }

/* 404 */
.not-found { padding: 40px 0; }
.not-found .btn { display: inline-flex; }

/* Home grid */
.page-title { font-size: 1.6rem; margin: 36px 0 20px; }
.grid { list-style: none; padding: 0; margin: 0; display: grid; gap: var(--gap); grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); }
.card { display: flex; flex-direction: column; height: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; text-decoration: none; transition: transform 120ms ease, border-color 120ms ease; }
.card:hover, .card:focus-visible { transform: translateY(-2px); border-color: var(--text-dim); }
.card-body { padding: 16px 18px 18px; display: flex; flex-direction: column; flex: 1; position: relative; }
.card h2 { font-size: 1.25rem; margin-bottom: 0.35em; }
.card p { color: var(--text-dim); font-size: 0.95rem; flex: 1; }
.card-meta { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 0.85rem; color: var(--text-dim); }
.version { position: absolute; top: 18px; right: 18px; font-size: 0.8rem; color: var(--text-dim); }

/* Price chips */
.price { font-weight: 700; font-size: 0.85rem; padding: 3px 10px; border-radius: 999px; white-space: nowrap; }
.price.free { background: var(--accent); color: var(--accent-text); }
.price.soon { background: var(--surface-2); color: var(--text-dim); border: 1px solid var(--line); }

/* Key art and its labelled placeholder */
.capsule { aspect-ratio: 460 / 215; width: 100%; object-fit: cover; }
.header { aspect-ratio: 1920 / 620; width: 100%; object-fit: cover; }
.art-placeholder {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  background: repeating-linear-gradient(135deg, var(--surface-2) 0 14px, #2a3038 14px 28px);
  color: var(--text-dim); text-align: center;
}
.ph-title { font-size: 1.5rem; font-weight: 800; color: var(--text); }
.ph-note { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.08em; }
.hero .header.art-placeholder { aspect-ratio: auto; height: clamp(90px, 14vw, 200px); }

/* Game page */
.game-head { margin-top: 28px; }
.game-layout { display: grid; gap: var(--gap); grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }
.game-title { font-size: clamp(1.8rem, 4vw, 2.6rem); }
.pitch { font-size: 1.15rem; color: var(--text-dim); max-width: 60ch; }
.tag-list { list-style: none; padding: 0; margin: 0 0 20px; display: flex; flex-wrap: wrap; gap: 8px; }
.tag-list li { background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 3px 12px; font-size: 0.85rem; color: var(--text-dim); }
/* Screenshot carousel (static/gallery.js) */
.gallery { margin: 0 0 var(--gap); }
.gallery-stage { position: relative; }
.gallery-main { display: block; cursor: zoom-in; border-radius: 8px; }
.gallery-main img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); }
.gallery-arrow { position: absolute; top: 50%; transform: translateY(-50%); width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line); background: rgba(20, 23, 27, 0.8); color: var(--text); font-size: 1.8rem; line-height: 1; display: grid; place-items: center; cursor: pointer; opacity: 0; transition: opacity 120ms ease; }
.gallery-arrow[hidden] { display: none; }
.gallery-prev { left: 10px; }
.gallery-next { right: 10px; }
.gallery-stage:hover .gallery-arrow, .gallery-arrow:focus-visible { opacity: 1; }
@media (hover: none) { .gallery-arrow { opacity: 1; } }
.gallery-thumbs { list-style: none; margin: 10px 0 0; padding: 2px 2px 6px; display: flex; gap: 8px; overflow-x: auto; scroll-snap-type: x proximity; }
.gallery-thumbs li { flex: 0 0 clamp(96px, 18%, 150px); scroll-snap-align: start; }
.gallery-thumbs a { display: block; border-radius: 6px; outline-offset: 2px; }
.gallery-thumbs img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 6px; border: 2px solid transparent; opacity: 0.55; transition: opacity 120ms ease, border-color 120ms ease; }
.gallery-thumbs a:hover img { opacity: 0.85; }
.gallery-thumbs a[aria-current="true"] img { opacity: 1; border-color: var(--text); }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; margin-bottom: var(--gap); }
.panel h2 { font-size: 1.1rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-dim); }
.features { padding-left: 1.2em; margin: 0; }
.features li { margin: 0.3em 0; }
.release + .release { border-top: 1px solid var(--line); padding-top: 16px; margin-top: 16px; }
.release h3 { font-size: 1.05rem; }
.release h4 { font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-dim); margin: 12px 0 4px; }
.release ul { margin: 0; padding-left: 1.2em; }
.older { list-style: none; padding: 0; margin: 0; }
.older li { display: flex; flex-wrap: wrap; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.older a { font-weight: 600; }

/* Download box */
.game-side { display: flex; flex-direction: column; gap: var(--gap); }
.buy-box { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.buy-title { font-weight: 700; font-size: 1.1rem; display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 0.3em; }
.downloads { list-style: none; padding: 0; margin: 14px 0 0; display: grid; gap: 10px; }
.btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 52px; padding: 10px 16px; border-radius: 8px; border: 0;
  background: var(--accent); color: var(--accent-text); font-weight: 800; font-size: 1rem; text-decoration: none; text-align: center;
}
.btn:hover { background: var(--accent-hover); }
.btn-sub { font-weight: 600; font-size: 0.8rem; opacity: 0.8; }
.btn-disabled { background: var(--surface); color: var(--soon); border: 1px solid var(--line); cursor: default; }
.btn-disabled:hover { background: var(--surface); }
details { font-size: 0.85rem; color: var(--text-dim); margin-top: 6px; }
summary { cursor: pointer; padding: 4px 0; }
.checksum code { display: block; word-break: break-all; font-size: 0.75rem; background: var(--bg); padding: 6px 8px; border-radius: 6px; }
.launch-help ul { padding-left: 1.1em; margin: 6px 0 0; }
.facts, .requirements dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0; font-size: 0.92rem; }
.facts dt, .requirements dt { color: var(--text-dim); }
.facts dd, .requirements dd { margin: 0; }
.requirements { margin-bottom: 0; }
.bug-link { font-size: 0.9rem; margin: 0; }

/* Phones and narrow windows: one column, download box first after the title. */
@media (max-width: 860px) {
  .game-layout { grid-template-columns: 1fr; }
  .game-side { order: -1; }
}

/* TV / couch: big screens get bigger text so it reads from across the room. */
@media (min-width: 1800px) {
  body { font-size: 19px; }
  :root { --wrap: 1500px; }
}

@media (prefers-reduced-motion: reduce) {
  .card, .gallery-arrow, .gallery-thumbs img { transition: none; }
  .card:hover, .card:focus-visible { transform: none; }
}

/* Full-screen viewer (static/gallery.js) */
.lightbox { padding: 0; border: 0; background: transparent; max-width: 100vw; max-height: 100vh; width: 100vw; height: 100vh; overflow: hidden; }
.lightbox::backdrop { background: rgba(8, 10, 12, 0.92); }
.lightbox figure { margin: 0; width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 56px clamp(12px, 7vw, 96px); }
.lightbox img { max-width: 100%; max-height: calc(100vh - 140px); object-fit: contain; border-radius: 8px; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6); }
.lb-count { white-space: nowrap; }
.lightbox figcaption { display: flex; gap: 16px; color: var(--text-dim); font-size: 0.95rem; text-align: center; }
.lb-btn { position: absolute; display: grid; place-items: center; width: 52px; height: 52px; border-radius: 50%; border: 1px solid var(--line); background: rgba(29, 33, 39, 0.85); color: var(--text); font-size: 2rem; line-height: 1; cursor: pointer; }
.lb-btn:hover { background: var(--surface-2); }
.lb-prev { left: clamp(8px, 2vw, 24px); top: 50%; transform: translateY(-50%); }
.lb-next { right: clamp(8px, 2vw, 24px); top: 50%; transform: translateY(-50%); }
.lb-close { right: clamp(8px, 2vw, 24px); top: clamp(8px, 2vw, 24px); font-size: 1.6rem; }
.lightbox.single .lb-prev, .lightbox.single .lb-next { display: none; }
