/* Genrematic — design tokens & base */
:root {
  --bg: #faf5ec;
  --surface: #fffdf8;
  --surface-2: #f1e9d8;
  --ink: #201a13;
  --ink-muted: #6e6252;
  --line: #e4d8c0;
  --brand: #201a13;
  --shadow: 0 1px 2px rgba(32,26,19,.06), 0 10px 28px -16px rgba(32,26,19,.22);
  --radius: 12px;
  --focus: #1f6f63;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #17130e;
    --surface: #201a13;
    --surface-2: #271f16;
    --ink: #f1e7d6;
    --ink-muted: #b2a48d;
    --line: #392e20;
    --brand: #f1e7d6;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 14px 32px -18px rgba(0,0,0,.6);
  }
}
:root[data-theme="dark"] {
  --bg: #17130e;
  --surface: #201a13;
  --surface-2: #271f16;
  --ink: #f1e7d6;
  --ink-muted: #b2a48d;
  --line: #392e20;
  --brand: #f1e7d6;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 14px 32px -18px rgba(0,0,0,.6);
}

* { box-sizing: border-box; }
html { color-scheme: light dark; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Karla', system-ui, sans-serif;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; }
a { color: inherit; }
[hidden] { display: none !important; }

h1, h2, h3, .display {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 600;
  letter-spacing: -.01em;
  text-wrap: balance;
  margin: 0 0 .4em;
}
.mono {
  font-family: 'IBM Plex Mono', ui-monospace, monospace;
}
.eyebrow {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11.5px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.wrap { max-width: 1080px; margin: 0 auto; padding: 0 24px; }
.prose { max-width: 68ch; }
.prose p { margin: 0 0 1em; }

/* ---- Header / nav ---- */
.site-header {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.site-header .wrap {
  display: flex; align-items: center; gap: 24px;
  height: 64px;
}
.wordmark {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 600;
  font-size: 20px;
  letter-spacing: -.01em;
  text-decoration: none;
  color: var(--ink);
  white-space: nowrap;
}
.wordmark span { color: var(--focus); }
.site-nav {
  display: flex; gap: 4px; align-items: center;
  margin-left: auto;
  font-size: 14.5px;
}
.site-nav a {
  text-decoration: none;
  padding: 8px 12px;
  border-radius: 8px;
  color: var(--ink-muted);
  font-weight: 600;
}
.site-nav a:hover, .site-nav a[aria-current="page"] { color: var(--ink); background: var(--surface-2); }
.nav-search {
  display: flex; align-items: center; gap: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 999px;
  padding: 6px 14px;
  min-width: 220px;
}
.nav-search input {
  border: none; background: none; outline: none;
  font: inherit; color: var(--ink); width: 100%;
  font-size: 14px;
}
.nav-search svg { flex-shrink: 0; color: var(--ink-muted); }

/* ---- Hero ---- */
.hero { padding: 56px 0 40px; }
.hero h1 { font-size: clamp(32px, 5vw, 48px); max-width: 16ch; }
.hero .lede { color: var(--ink-muted); max-width: 56ch; font-size: 17px; margin-bottom: 28px; }
.hero-search {
  display: flex; gap: 10px; max-width: 520px;
}
.hero-search input {
  flex: 1;
  padding: 14px 16px;
  border-radius: 10px;
  border: 1.5px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font: inherit; font-size: 15px;
  outline: none;
}
.hero-search input:focus { border-color: var(--focus); }
.hero-search button, .btn {
  padding: 14px 20px;
  border-radius: 10px;
  border: none;
  background: var(--ink);
  color: var(--bg);
  font-weight: 700;
  font-size: 14.5px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center;
}
.btn.secondary {
  background: transparent;
  color: var(--ink);
  border: 1.5px solid var(--line);
}
#search-results {
  position: relative;
}
#search-results .results-panel {
  position: absolute; top: 8px; left: 0; right: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
  max-height: 360px; overflow-y: auto;
  z-index: 30;
}
.results-panel a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  text-decoration: none;
  font-size: 14px;
  border-bottom: 1px solid var(--line);
}
.results-panel a:last-child { border-bottom: none; }
.results-panel a:hover { background: var(--surface-2); }
.results-panel .none { padding: 14px; color: var(--ink-muted); font-size: 14px; }

/* ---- Family grid (crate dividers) ---- */
.section { padding: 40px 0; border-top: 1px solid var(--line); }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.section-head h2 { font-size: 22px; }
.section-head .link { font-size: 13.5px; font-weight: 700; text-decoration: none; color: var(--focus); }

.family-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 12px;
}
.family-tile {
  display: block;
  text-decoration: none;
  border-radius: var(--radius);
  padding: 16px 16px 14px;
  background: var(--tint);
  border: 1px solid color-mix(in srgb, var(--fam) 35%, transparent);
  min-height: 96px;
}
.family-tile .fam-name {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 600;
  font-size: 16.5px;
  color: var(--fam);
  margin-bottom: 6px;
  text-wrap: balance;
}
.family-tile .fam-count {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11.5px;
  color: var(--ink-muted);
  letter-spacing: .03em;
}

/* ---- Cards / promos ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.book-promo {
  display: grid;
  grid-template-columns: 96px 1fr auto;
  gap: 18px;
  align-items: center;
  padding: 18px 20px;
}
.book-promo img { width: 96px; border-radius: 6px; box-shadow: var(--shadow); }
.book-promo .status {
  display: inline-block;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10.5px;
  letter-spacing: .06em;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: 99px;
  margin-bottom: 6px;
}
.status.coming_soon { background: color-mix(in srgb, var(--focus) 16%, transparent); color: var(--focus); }
.status.live { background: color-mix(in srgb, #2e8b45 20%, transparent); color: #2e8b45; }
.book-promo h3 { font-size: 18px; margin-bottom: 2px; }
.book-promo p { margin: 0; color: var(--ink-muted); font-size: 14px; }
.book-promo .buy-cell { text-align: right; }
.book-promo .buy-cell .ad-disclosure { text-align: right; font-size: 11px; }

.ad-slot {
  border: 1.5px dashed var(--line);
  border-radius: var(--radius);
  padding: 18px;
  text-align: center;
  color: var(--ink-muted);
  font-size: 12.5px;
  font-family: 'IBM Plex Mono', monospace;
  letter-spacing: .03em;
}

/* ---- Genre index ---- */
.filter-bar {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin-bottom: 22px;
}
.filter-chip {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11.5px;
  letter-spacing: .02em;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-muted);
  cursor: pointer;
}
.filter-chip.active { color: var(--bg); background: var(--ink); border-color: var(--ink); }

.genre-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 10px;
}
.genre-card {
  display: block;
  text-decoration: none;
  padding: 13px 15px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
}
.genre-card:hover { border-color: var(--fam, var(--focus)); }
.genre-card .g-name { font-weight: 700; font-size: 14.5px; margin-bottom: 3px; }
.genre-card .g-fam {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10.5px;
  letter-spacing: .03em;
  color: var(--fam);
  text-transform: uppercase;
}
.genre-card .g-tag { font-size: 12.5px; color: var(--ink-muted); margin-top: 4px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.count-line { font-family: 'IBM Plex Mono', monospace; font-size: 12px; color: var(--ink-muted); margin-bottom: 16px; }

/* ---- Genre detail ---- */
.breadcrumb {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11.5px;
  color: var(--ink-muted);
  margin-bottom: 18px;
}
.breadcrumb a { text-decoration: none; color: var(--ink-muted); }
.breadcrumb a:hover { color: var(--ink); }

.genre-header { padding: 36px 0 8px; }
.genre-chip {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px; letter-spacing: .05em; text-transform: uppercase;
  padding: 4px 11px;
  border-radius: 999px;
  background: var(--tint);
  color: var(--fam);
  margin-bottom: 14px;
}
.genre-chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--fam); }
.genre-header h1 { font-size: clamp(30px, 4.5vw, 42px); }
.genre-header .tagline { font-style: italic; color: var(--ink-muted); font-size: 16px; max-width: 60ch; margin-top: 6px; }
.catalog { font-family: 'IBM Plex Mono', monospace; font-size: 11px; color: var(--ink-muted); margin-top: 10px; }

.content-grid {
  display: grid;
  grid-template-columns: 1fr 260px;
  gap: 40px;
  align-items: start;
  padding: 28px 0 56px;
}
@media (max-width: 780px) { .content-grid { grid-template-columns: 1fr; } }

.g-section { margin-bottom: 34px; }
.g-section h2 { font-size: 19px; margin-bottom: 10px; }
.g-section .body-text { white-space: pre-line; color: var(--ink); font-size: 15.5px; }
.g-section .body-text.muted { color: var(--ink-muted); }

.sidebar { display: flex; flex-direction: column; gap: 20px; position: sticky; top: 84px; }
.sidebar h3 {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px; letter-spacing: .06em; text-transform: uppercase;
  color: var(--ink-muted); margin: 0 0 10px; font-weight: 600;
}

.related-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.related-chip {
  text-decoration: none;
  font-size: 13px; font-weight: 600;
  padding: 7px 13px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
}
.related-chip:hover { border-color: var(--focus); color: var(--focus); }
.related-chip.dead { color: var(--ink-muted); border-style: dashed; cursor: default; }

.mini-promo {
  padding: 16px;
}
.mini-promo img { width: 100%; border-radius: 8px; margin-bottom: 10px; box-shadow: var(--shadow); }
.mini-promo h4 { font-size: 15px; margin: 0 0 4px; font-family: 'Fraunces', serif; font-weight: 600; }
.mini-promo p { margin: 0 0 10px; font-size: 13px; color: var(--ink-muted); }

/* ---- Affiliate disclosure (Amazon buy-links) ---- */
.ad-disclosure { font-size: 11px; color: var(--ink-muted); margin: 6px 0 0; }

/* ---- Books page ---- */
.book-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 22px; }
.book-card { padding: 18px; text-align: left; display: flex; flex-direction: column; }
.book-card img { width: 100%; border-radius: 8px; margin-bottom: 12px; box-shadow: var(--shadow); }
.book-card h3 { font-size: 16.5px; margin-bottom: 4px; }
.book-card .meta { font-size: 12.5px; color: var(--ink-muted); margin-bottom: 8px; }
.book-card .btn { margin-top: auto; }

/* ---- Games teaser ---- */
.coming-soon {
  padding: 64px 0;
  text-align: center;
}
.coming-soon h1 { font-size: 32px; }
.coming-soon p { color: var(--ink-muted); max-width: 50ch; margin: 12px auto 0; }

/* ---- Footer ---- */
.site-footer {
  border-top: 1px solid var(--line);
  padding: 36px 0 60px;
  color: var(--ink-muted);
  font-size: 13.5px;
}
.site-footer .wrap { display: flex; flex-wrap: wrap; gap: 24px; justify-content: space-between; align-items: flex-start; }
.site-footer a { text-decoration: none; color: var(--ink-muted); }
.site-footer a:hover { color: var(--ink); }
.footer-links { display: flex; gap: 18px; flex-wrap: wrap; }

::selection { background: color-mix(in srgb, var(--focus) 30%, transparent); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

@media (max-width: 640px) {
  .nav-search { display: none; }
  .book-promo { grid-template-columns: 64px 1fr; }
  .book-promo img { width: 64px; }
  .book-promo .btn, .book-promo .buy-cell { grid-column: 1 / -1; }
  .book-promo .buy-cell { text-align: left; }
  .book-promo .buy-cell .ad-disclosure { text-align: left; }
}
