@import url("https://cdn.jsdelivr.net/npm/beercss@5.0.3/dist/cdn/beer.min.css") layer(material);

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #1a2230;
  --muted: #64748b;
  --border: #e2e8f0;
  --primary: #2563eb;
  --primary-soft: #eff6ff;
  --accent: #f59e0b;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(16,24,40,.08), 0 4px 16px rgba(16,24,40,.06);
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  display: block; /* BeerCSS `:has(>main)` turns body into a 3-column grid */
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
.container { max-width: 1100px; margin: 0 auto; padding: 0 20px; }
@media (min-width: 1400px) {
  .container { max-width: 1440px; }
}

/* Hero */
.hero {
  display: block; /* BeerCSS styles `header` as a grid, which shrink-wraps .container */
  background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 60%, #2563eb 100%);
  color: #fff;
  padding: 56px 0 64px;
  margin-bottom: -56px;
}
.eyebrow { text-transform: uppercase; letter-spacing: .12em; font-size: 12px; font-weight: 600; opacity: .8; margin: 0 0 8px; }
.hero h1 { font-size: clamp(2.2rem, 5vw, 3.2rem); margin: 0 0 12px; font-weight: 800; letter-spacing: -.02em; }
.hero-link { display: inline-block; color: #fff; font-size: 14px; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }

/* Controls */
.controls { position: relative; z-index: 2; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin: 0 0 24px; }
.search-wrap { position: relative; margin-bottom: 14px; }
.search-wrap .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--muted); }
#global-search {
  width: 100%; padding: 11px 14px 11px 40px;
  border: 1px solid var(--border); border-radius: 10px;
  font-size: 15px; font-family: inherit; background: var(--bg);
  transition: border-color .15s, box-shadow .15s;
}
#global-search:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.15); background: #fff; }
.filter-row { display: flex; gap: 12px; align-items: end; flex-wrap: wrap; }
.filter { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.filter select {
  min-width: 180px; padding: 9px 12px; font: inherit; font-size: 14px; color: var(--text);
  border: 1px solid var(--border); border-radius: 10px; background: #fff; cursor: pointer;
}
.filter select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.15); }
.result-count { margin-left: auto; font-size: 13px; color: var(--muted); align-self: center; }
.btn-ghost {
  border: 1px solid var(--border); background: #fff; color: var(--muted);
  padding: 9px 14px; border-radius: 10px; font: inherit; font-size: 13px; font-weight: 500; cursor: pointer;
  transition: all .15s;
}
.btn-ghost:hover { border-color: #fca5a5; color: #dc2626; background: #fef2f2; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.chips:empty { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--primary-soft); color: var(--primary);
  font-size: 12.5px; font-weight: 600; padding: 4px 10px; border-radius: 999px;
}
.chip button { background: none; border: 0; color: inherit; cursor: pointer; font-size: 14px; line-height: 1; padding: 0; opacity: .7; }
.chip button:hover { opacity: 1; }

/* Table */
.table-card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
thead { position: sticky; top: 0; z-index: 1; }
thead th { background: #f8fafc; border-bottom: 1px solid var(--border); }
.th-btn {
  all: unset; display: flex; align-items: center; gap: 6px;
  box-sizing: border-box; width: 100%; padding: 12px 14px; cursor: pointer;
  font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted);
  user-select: none;
}
.th-btn:hover { color: var(--primary); }
.sort-ind { font-size: 10px; opacity: .35; transition: opacity .15s; }
th.sorted .sort-ind { opacity: 1; color: var(--primary); }
.column-filters th { padding: 0 8px 10px; }
.column-filters input {
  width: 100%; padding: 7px 10px; font: inherit; font-size: 13px;
  border: 1px solid var(--border); border-radius: 8px; background: #fff;
}
.column-filters input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
tbody td { padding: 13px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
tbody tr { transition: background .12s; }
tbody tr:hover { background: var(--primary-soft); }
tbody tr:last-child td { border-bottom: 0; }
td.title a { color: var(--text); font-weight: 600; text-decoration: none; display: inline; }
td.title a .subtitle { font-weight: 400; color: var(--muted); }
td.title a:hover { color: var(--primary); text-decoration: underline; }
td.title .goodreads-link, td.title .buy-link { display: inline-flex; align-items: center; color: var(--muted); margin-left: 4px; }
td.title .goodreads-link .link-icon, td.title .buy-link .link-icon { width: 15px; height: 15px; }
td.title .goodreads-link:hover, td.title .buy-link:hover { color: var(--primary); }
td.year { white-space: normal; color: var(--muted); font-variant-numeric: tabular-nums; }
td.authors { color: var(--muted); font-size: 13px; }
th.own-col { width: 56px; text-align: center; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
th[data-col="year"] { width: 112px; }
th[data-col="authors"] { width: 15%; }
td.own-cell { text-align: center; }
.own-toggle {
  width: 30px; height: 30px; line-height: 1;
  border: 1px solid var(--border); border-radius: 8px; background: #fff;
  color: var(--muted); font-size: 15px; cursor: pointer; padding: 0;
  transition: border-color .15s, color .15s, background .15s;
}
.own-toggle:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
.own-toggle.owned { background: var(--primary); border-color: var(--primary); color: #fff; }
.own-toggle.owned:hover { background: #1d4ed8; }
.own-toggle.want { background: var(--accent); border-color: var(--accent); color: #fff; }
.own-toggle.want:hover { background: #d97706; }
.topic-tag {
  display: inline-block; background: #f1f5f9; color: #334155;
  font-size: 12px; font-weight: 500; padding: 3px 10px; border-radius: 999px; white-space: normal;
}
.format-tag { font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.rating { display: inline-flex; align-items: center; gap: 5px; font-weight: 600; font-variant-numeric: tabular-nums; }
.rating .star { color: var(--accent); }
.rating .count { color: var(--muted); font-weight: 400; font-size: 12.5px; }
.rating.na { color: var(--muted); font-weight: 400; }
#empty-state { text-align: center; color: var(--muted); padding: 32px 20px; margin: 0; }
td.load-error { text-align: center; color: var(--muted); padding: 32px 20px; }

/* Footer */
.site-footer { text-align: center; color: var(--muted); font-size: 13px; padding: 32px 0 40px; }
.site-footer .disclaimer { font-size: 15px; line-height: 1.6; max-width: 68ch; margin: 0 auto 1em; }

@media (max-width: 640px) {
  .hero { padding: 40px 0 64px; }
  .controls { padding: 14px; }
  .filter select { min-width: 0; width: 100%; }
  .filter { width: calc(50% - 6px); }
  .result-count { width: 100%; margin: 0; }
}

/* About page */
.page-about .hero { margin-bottom: 0; }
.page-about main { padding-top: 48px; padding-bottom: 56px; }
.page-about .about-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px;
}
.page-about .bio { font-size: 17px; line-height: 1.7; max-width: 53ch; color: var(--text); margin: 0 0 1.1em; }
.page-about .bio:last-child { margin-bottom: 0; }
.page-about .back-link { margin: 24px 0 0; }
.page-about .back-link a { color: var(--primary); font-weight: 600; text-decoration: none; }
.page-about .back-link a:hover { text-decoration: underline; }

@media (max-width: 640px) {
  .page-about .about-card { padding: 20px; }
}

/* About this page */
.page-about-this-page .about-card ul { margin: 0 0 1.1em; padding-inline-start: 1.25em; }
.page-about-this-page .about-card li { margin: 0 0 .4em; color: var(--text); }
.page-about-this-page .about-card li:last-child { margin-bottom: 0; }
.page-about-this-page .about-card a { color: var(--primary); font-weight: 600; text-decoration: none; }
.page-about-this-page .about-card a:hover { text-decoration: underline; }

/* Site menu */
.site-nav { display: block; background: var(--surface); border-bottom: 1px solid var(--border); }
.site-nav .tabs { flex-wrap: wrap; }
.site-nav .tabs > a { flex: 1 1 auto; inline-size: auto; min-inline-size: max-content; }
.site-nav .tabs > a:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
