/* Silicon Wizardry: one stylesheet, three styles.
   Theme b (Cartridge Shelf) is the default on :root. Themes a and c override the tokens only,
   chosen either by the Style <select> (CSS :has, works without JS) or by data-theme on <html> (set by JS).
   Components below read var(--token) only: no colours or fonts outside the token blocks. */

/* ---------- Fonts (self-hosted, latin subset, SIL Open Font Licence: see assets/fonts/OFL-*.txt) ---------- */

@font-face { font-family: "Press Start 2P"; src: url("../fonts/press-start-2p-400-latin.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "VT323"; src: url("../fonts/vt323-400-latin.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Pixelify Sans"; src: url("../fonts/pixelify-sans-latin.woff2") format("woff2"); font-weight: 400 700; font-display: swap; }
@font-face { font-family: "IBM Plex Sans"; src: url("../fonts/ibm-plex-sans-latin.woff2") format("woff2"); font-weight: 100 700; font-display: swap; }
@font-face { font-family: "IBM Plex Mono"; src: url("../fonts/ibm-plex-mono-400-latin.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "IBM Plex Mono"; src: url("../fonts/ibm-plex-mono-500-latin.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "IBM Plex Mono"; src: url("../fonts/ibm-plex-mono-600-latin.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Silkscreen"; src: url("../fonts/silkscreen-400-latin.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Silkscreen"; src: url("../fonts/silkscreen-700-latin.woff2") format("woff2"); font-weight: 700; font-display: swap; }

/* ---------- Tokens ---------- */

/* Shared by all three styles */
:root {
  --fam-commodore: #d43a3a;
  --fam-sega: #29adff;
  --fam-nintendo: #8b6fe0;
  --fam-sony: #7a8899;
  --fam-mobile: #2f9e5b;
  --fam-other: #6b6574;
  --wip-in-development: #29adff;
  --wip-prototype: #ffcd3c;
  --wip-concept: #c9c4dc;
  --wip-released: #7ee787;
  --wipInk: #0b0a14;
  --gutter: 24px;
}

/* b · Cartridge Shelf (default) */
:root {
  --bg: #f1ece1;
  --panel: #e4ddcd;
  --card: #ffffff;
  --ink: #1d1a24;
  --muted: #57515f;
  --head: #1d1a24;
  --num: #b02a33;
  --line: #1d1a24;
  --bw: 3px;
  --link: #b02a33;
  --on: #1d1a24;
  --onInk: #f1ece1;
  --primary: #b02a33;
  --primaryInk: #ffffff;
  --shadow: 4px 4px 0 #1d1a24;
  --cardShadow: 6px 6px 0 #1d1a24;
  --fD: "Pixelify Sans", sans-serif;
  --fB: "IBM Plex Sans", sans-serif;
  --fM: "IBM Plex Mono", monospace;
  --h1: 60px;
  --h1lh: 1.05;
  --h2: 36px;
  --h3: 23px;
  --h3lh: 1.15;
  --body: 17px;
  --small: 15px;
  --mono: 13px;
  --band: #b02a33;
  --bandH: 8px;
  --tickerBg: #1d1a24;
  --tickerInk: #f1ece1;
  --pub: #1f7a3a;
  --unrel: #a3461e;
  --chk1: #e4ddcd;
  --chk2: #ece6d8;
  --upper: none;
  --inputBg: #ffffff;
}

/* a · Copper Bars */
html:is([data-theme="a"], :has(#style-select option[value="a"]:checked)) {
  --bg: #0b0a14;
  --panel: #14102a;
  --card: #14102a;
  --ink: #e9e6f5;
  --muted: #c9c4dc;
  --head: #ffffff;
  --num: #ffcd3c;
  --line: #29489a;
  --bw: 4px;
  --link: #ffcd3c;
  --on: #ffcd3c;
  --onInk: #0b0a14;
  --primary: #d43a3a;
  --primaryInk: #ffffff;
  --shadow: 4px 4px 0 #ffcd3c;
  --cardShadow: none;
  --fD: "Press Start 2P", monospace;
  --fB: "VT323", monospace;
  --fM: "VT323", monospace;
  --h1: 34px;
  --h1lh: 1.45;
  --h2: 20px;
  --h3: 13px;
  --h3lh: 1.6;
  --body: 22px;
  --small: 19px;
  --mono: 19px;
  /* Copper bars: 18 hard-edged 4px stripes, blue→white→blue then red→gold→red */
  --band: linear-gradient(#1d2b53 0 4px, #29489a 4px 8px, #29adff 8px 12px, #b8e8ff 12px 16px, #ffffff 16px 20px, #b8e8ff 20px 24px, #29adff 24px 28px, #29489a 28px 32px, #1d2b53 32px 36px, #5a1020 36px 40px, #8a1c2b 40px 44px, #d43a3a 44px 48px, #ff8070 48px 52px, #ffcd3c 52px 56px, #ff8070 56px 60px, #d43a3a 60px 64px, #8a1c2b 64px 68px, #5a1020 68px 72px);
  --bandH: 72px;
  --tickerBg: #ffcd3c;
  --tickerInk: #14102a;
  --pub: #7ee787;
  --unrel: #ff9e7a;
  --chk1: #1d2b53;
  --chk2: #172246;
  --upper: uppercase;
  --inputBg: #0b0a14;
}

/* c · ROM Listing */
html:is([data-theme="c"], :has(#style-select option[value="c"]:checked)) {
  --bg: #0f1210;
  --panel: #151a16;
  --card: #151a16;
  --ink: #d9e4d6;
  --muted: #9fb2a4;
  --head: #ffb000;
  --num: #ffb000;
  --line: #3b4a40;
  --bw: 1px;
  --link: #ffb000;
  --on: #ffb000;
  --onInk: #0f1210;
  --primary: #ffb000;
  --primaryInk: #0f1210;
  --shadow: none;
  --cardShadow: none;
  --fD: "Silkscreen", monospace;
  --fB: "IBM Plex Mono", monospace;
  --fM: "IBM Plex Mono", monospace;
  --h1: 50px;
  --h1lh: 1.05;
  --h2: 26px;
  --h3: 18px;
  --h3lh: 1.3;
  --body: 16px;
  --small: 14px;
  --mono: 13px;
  /* 2px amber scanlines */
  --band: repeating-linear-gradient(#ffb000 0 2px, #0f1210 2px 4px);
  --bandH: 8px;
  --tickerBg: #151a16;
  --tickerInk: #ffb000;
  --pub: #7ee0a0;
  --unrel: #ff9e7a;
  --chk1: #151a16;
  --chk2: #1b211c;
  --upper: none;
  --inputBg: #0f1210;
}

/* ---------- Base ---------- */

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--fB);
  font-size: var(--body);
  line-height: 1.5;
  overflow-wrap: break-word;
}

img { display: block; max-width: 100%; height: auto; image-rendering: pixelated; }

a { color: var(--link); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }

:focus-visible { outline: 3px solid var(--link); outline-offset: 3px; }

h1, h2, h3 { margin: 0; font-family: var(--fD); color: var(--head); font-weight: 700; }
h1 { font-size: var(--h1); line-height: var(--h1lh); }
h2 { font-size: var(--h2); line-height: 1.2; text-transform: var(--upper); }
h3 { font-size: var(--h3); line-height: var(--h3lh); }

p, ul, ol, dl { margin: 0; }

.muted { color: var(--muted); }
.measure { max-width: 760px; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute; left: 8px; top: -100px; z-index: 10;
  padding: 10px 14px;
  background: var(--primary); color: var(--primaryInk);
  font-family: var(--fM); font-size: var(--mono);
}
.skip-link:focus { top: 8px; }

.wrap { max-width: 1200px; margin: 0 auto; padding: 0 var(--gutter); }

/* ---------- Header ---------- */

.site-header { border-bottom: var(--bw) solid var(--line); }
.band { height: var(--bandH); background: var(--band); }

/* Logo on the left; nav and Style picker stacked on the right, so wide display fonts never push the picker under the logo. */
.header-inner {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-areas: "logo nav" "logo style";
  align-items: center;
  gap: 8px 28px;
  padding-top: 16px; padding-bottom: 16px;
}
.logo { grid-area: logo; }
.site-nav { grid-area: nav; justify-self: end; }
.site-nav ul { justify-content: flex-end; }
.style-picker { grid-area: style; justify-self: end; }

@media (max-width: 900px) {
  .header-inner { grid-template-columns: 1fr; grid-template-areas: "logo" "nav" "style"; }
  .site-nav, .style-picker { justify-self: start; }
  .site-nav ul { justify-content: flex-start; margin-left: -12px; }
}
.logo img { width: 292px; height: 108px; }

.site-nav ul {
  display: flex; flex-wrap: wrap; gap: 4px;
  list-style: none; padding: 0;
  font-family: var(--fD); font-size: var(--small);
  text-transform: var(--upper);
}
.site-nav a {
  display: block;
  min-height: 44px; padding: 10px 12px;
  color: var(--ink); text-decoration: none;
}
.site-nav a:hover { text-decoration: underline; }
.site-nav a[aria-current="page"] { color: var(--link); text-decoration: underline; text-decoration-thickness: 2px; }

.style-picker {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--fM); font-size: var(--mono); color: var(--muted);
}
.style-picker select {
  min-height: 44px; padding: 0 10px;
  font-family: var(--fM); font-size: var(--mono);
  background: var(--inputBg); color: var(--ink);
  border: var(--bw) solid var(--line); border-radius: 0;
}

/* ---------- Buttons ---------- */

.buttons { display: flex; flex-wrap: wrap; gap: 14px; list-style: none; padding: 0; }

.btn {
  display: inline-flex; align-items: center;
  min-height: 44px; padding: 12px 18px;
  font-family: var(--fD); font-size: var(--small); line-height: 1.3;
  text-transform: var(--upper); text-decoration: none;
  cursor: pointer;
}
.btn-primary { background: var(--primary); color: var(--primaryInk); box-shadow: var(--shadow); border: 0; padding: 14px 20px; }
.btn-ghost { background: var(--card); color: var(--ink); border: var(--bw) solid var(--line); }
.btn:hover { text-decoration: underline; }

/* ---------- Home ---------- */

.hero {
  display: flex; flex-wrap: wrap; align-items: center;
  gap: 48px;
  padding-top: 64px;
}
.hero-text { flex: 1 1 560px; display: flex; flex-direction: column; gap: 22px; }

.eyebrow {
  font-family: var(--fM); font-size: var(--mono);
  color: var(--link); letter-spacing: 1px; text-transform: uppercase;
}
.lede { max-width: 600px; color: var(--muted); }

.stats {
  flex: 1 1 320px;
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--bw);
  background: var(--line); border: var(--bw) solid var(--line);
  align-self: center;
}
.stats > div { display: flex; flex-direction: column-reverse; justify-content: flex-end; gap: 6px; background: var(--panel); padding: 20px; }
.stats dt { color: var(--muted); }
.stats dd { margin: 0; font-family: var(--fD); font-size: var(--h2); line-height: 1.1; color: var(--num); }

.ticker {
  margin-top: 64px; padding: 14px var(--gutter);
  background: var(--tickerBg); color: var(--tickerInk);
  font-family: var(--fM); font-size: var(--mono);
  text-transform: var(--upper); text-align: center;
}

.sections { display: flex; flex-direction: column; gap: 88px; padding-top: 80px; }

.section { display: flex; flex-direction: column; gap: 26px; }
.section-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 12px; }
.section-head.stacked { flex-direction: column; align-items: flex-start; gap: 10px; }

.more-link {
  align-self: center; padding: 10px;
  font-family: var(--fD); font-size: var(--small); text-transform: var(--upper);
}

.split {
  display: flex; flex-direction: row; flex-wrap: wrap; gap: 32px 48px;
  border-top: var(--bw) solid var(--line); padding-top: 48px;
}
.split > :first-child { flex: 0 0 260px; }
.split > :last-child { flex: 1 1 520px; }
.page .split { border-top: 0; padding-top: 0; }
.page .split > .prose { flex: 1 1 520px; }
.page .split > .stats { flex: 0 1 360px; align-self: flex-start; }
.page .sections { padding-top: 24px; gap: 56px; }
.page .sections .split { border-top: var(--bw) solid var(--line); padding-top: 40px; }

/* ---------- Cards ---------- */

.grid {
  display: grid; gap: 22px;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr));
}
.grid-wide { grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); gap: 24px; }

.card {
  display: flex; flex-direction: column;
  background: var(--card); color: var(--ink);
  border: var(--bw) solid var(--line);
  box-shadow: var(--cardShadow);
  scroll-margin-top: 24px;
}
.card:target { outline: 3px solid var(--link); outline-offset: 4px; }

.stripe { height: 8px; }
.fam-commodore { background: var(--fam-commodore); }
.fam-sega { background: var(--fam-sega); }
.fam-nintendo { background: var(--fam-nintendo); }
.fam-sony { background: var(--fam-sony); }
.fam-mobile { background: var(--fam-mobile); }
.fam-other { background: var(--fam-other); }

.card-body { display: flex; flex-direction: column; gap: 8px; flex: 1; padding: 16px 18px 18px; }
.indie-card .card-body { gap: 10px; padding: 20px; }

.card-meta { font-family: var(--fM); font-size: var(--mono); color: var(--muted); text-transform: uppercase; }
.card-title { font-size: var(--h3); line-height: var(--h3lh); text-transform: none; }
.card-title a { color: inherit; text-decoration: none; }
.card-title a:hover { text-decoration: underline; }
.card-summary { flex: 1; font-size: var(--small); color: var(--muted); }
.indie-card .card-summary { font-size: var(--body); }
.card-platforms { font-family: var(--fM); font-size: var(--mono); color: var(--link); }

.facts {
  display: grid; grid-template-columns: 84px 1fr; gap: 1px 8px;
  font-size: var(--small);
}
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }

.badge {
  align-self: flex-start;
  padding: 1px 8px;
  font-family: var(--fM); font-size: var(--mono);
  text-transform: uppercase;
  border: 2px solid;
}
.badge-published { color: var(--pub); border-style: solid; }
.badge-unreleased { color: var(--unrel); border-style: dashed; }

.tag {
  align-self: flex-start;
  padding: 1px 8px;
  font-family: var(--fM); font-size: var(--mono);
  color: var(--wipInk);
}
.tag-in-development { background: var(--wip-in-development); }
.tag-prototype { background: var(--wip-prototype); }
.tag-concept { background: var(--wip-concept); }
.tag-released { background: var(--wip-released); }

/* Screenshot placeholder: 16px checker */
.shot, .shot-large { width: 100%; border-bottom: var(--bw) solid var(--line); }
.placeholder {
  display: flex; align-items: center; justify-content: center;
  height: 180px;
  background: repeating-conic-gradient(var(--chk1) 0 25%, var(--chk2) 0 50%) 0 0 / 16px 16px;
  color: var(--muted); font-family: var(--fM); font-size: var(--mono);
}
.shot-large.placeholder { height: 320px; border: var(--bw) solid var(--line); }

/* Full write-up inside a credit card */
.story { margin-top: 4px; font-size: var(--small); }
.story summary {
  display: inline-flex; align-items: center;
  min-height: 44px;
  color: var(--link); cursor: pointer;
  font-family: var(--fM); font-size: var(--mono); text-transform: var(--upper);
}
.story p { margin-top: 8px; }

/* ---------- Pedigree filters ---------- */

.filters {
  display: flex; flex-direction: column; gap: 14px;
  padding: 18px;
  background: var(--panel); border: var(--bw) solid var(--line);
  font-size: var(--small);
}

.facet { margin: 0; padding: 0; border: 0; min-width: 0; }
.facet legend {
  float: left; width: 110px; padding: 12px 0 0;
  font-family: var(--fM); font-size: var(--mono); color: var(--muted);
  text-transform: var(--upper);
}
.facet .chips { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.facet-sort { border-top: var(--bw) solid var(--line); padding-top: 14px; }
.facet-sort legend { padding-top: 26px; }

.chip {
  position: relative;
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 44px; padding: 0 12px;
  background: var(--card); color: var(--ink);
  border: var(--bw) solid var(--line);
  font-family: var(--fB); font-size: var(--small);
  cursor: pointer;
}
.chip input {
  position: absolute; inset: 0;
  margin: 0; opacity: 0; cursor: pointer;
}
.chip .count { opacity: 0.8; }
.chip:has(input:checked) { background: var(--on); color: var(--onInk); }
.chip:has(input:focus-visible) { outline: 3px solid var(--link); outline-offset: 3px; }
.chip:hover { text-decoration: underline; }

.reset {
  margin-left: auto;
  min-height: 44px; padding: 0 12px;
  background: transparent; color: var(--link); border: 0;
  font-family: var(--fB); font-size: var(--small);
  text-decoration: underline; cursor: pointer;
}

.result-count { margin: 24px 0; font-family: var(--fM); font-size: var(--mono); color: var(--muted); }

.no-match {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  margin-bottom: 24px; padding: 40px;
  border: var(--bw) dashed var(--line); text-align: center;
}
.no-match[hidden] { display: none; }
.no-match-title { font-family: var(--fD); font-size: var(--h3); color: var(--head); }

/* ---------- Inner pages ---------- */

.page { padding-top: 56px; display: flex; flex-direction: column; gap: 24px; }
.page-head { display: flex; flex-direction: column; gap: 10px; margin-bottom: 8px; }

.breadcrumb { font-family: var(--fM); font-size: var(--mono); }

.prose { display: flex; flex-direction: column; gap: 14px; max-width: 760px; }
.prose h2 { margin-top: 16px; font-size: var(--h3); }
.prose ul, .prose ol { padding-left: 1.4em; }

.game { display: flex; flex-direction: column; gap: 32px; }
.game-layout { display: flex; flex-wrap: wrap; gap: 24px 40px; align-items: flex-start; }
.game-layout > .shot-large { flex: 1 1 480px; width: auto; }
.game-layout img.shot-large { border: var(--bw) solid var(--line); }
.game-facts { flex: 0 1 280px; grid-template-columns: 90px 1fr; }

.fact-sheet { grid-template-columns: 140px 1fr; gap: 6px 16px; font-size: var(--body); }

.logo-list { display: flex; flex-direction: column; gap: 28px; margin-top: 20px; list-style: none; padding: 0; }
.logo-list li { display: flex; flex-direction: column; gap: 10px; }

.post-list { display: flex; flex-direction: column; gap: 28px; list-style: none; padding: 0; }
.post-item { display: flex; flex-direction: column; gap: 6px; padding-bottom: 28px; border-bottom: var(--bw) solid var(--line); }
.post-item .card-title { font-size: var(--h2); }

/* ---------- Footer ---------- */

.site-footer { margin-top: 88px; border-top: var(--bw) solid var(--line); }
.footer-inner {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 24px;
  padding-top: 32px; padding-bottom: 48px;
}
.footer-inner img { width: 96px; height: 108px; }
.footer-links { display: flex; flex-wrap: wrap; gap: 4px 20px; list-style: none; padding: 0; }
.footer-links a { display: inline-block; padding: 10px 0; }

/* ---------- Small screens ---------- */

@media (max-width: 600px) {
  :root { --gutter: 16px; }
  h1 { font-size: min(var(--h1), 11vw); }
  .hero { padding-top: 40px; gap: 32px; }
  .sections { gap: 64px; padding-top: 56px; }
  .page { padding-top: 40px; }
  .facet legend { width: 100%; padding: 0 0 6px; }
  .facet .chips { clear: both; }
  .facet-sort legend { padding-top: 0; }
  .reset { margin-left: 0; }
  .split > :first-child { flex-basis: 100%; }
  .fact-sheet { grid-template-columns: 1fr; gap: 0; }
  .fact-sheet dd { margin-bottom: 10px; }
}

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}
