/* Novel Numbers — warm literary stylesheet. No frameworks. */

:root {
  --paper: #faf6ee;
  --card: #fffdf7;
  --soft: #f3ead6;
  --ink: #2b2118;
  --muted: #6f5f4c;
  --accent: #8a4b1f;
  --accent-2: #b9772f;
  --line: #e7dcc4;
  --display: "Playfair Display", Georgia, "Times New Roman", serif;
  --body: "Source Serif 4", Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body);
  line-height: 1.65;
  font-size: 17px;
}

.wrap {
  max-width: 1020px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

h1, h2, h3 {
  font-family: var(--display);
  line-height: 1.2;
  font-weight: 700;
  margin: 0 0 0.6em;
}

h1 { font-size: clamp(2rem, 5vw, 2.9rem); }
h2 { font-size: 1.55rem; margin-top: 2.2rem; }
h3 { font-size: 1.15rem; }

p { margin: 0 0 1em; }

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: #6d3a14; }

/* ---------------- header ---------------- */

.site-header {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-top: 0.7rem;
  padding-bottom: 0.7rem;
  flex-wrap: wrap;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  text-decoration: none;
  color: var(--ink);
}

.brand-mark { font-size: 1.6rem; color: var(--accent); line-height: 1; }
.brand-name { font-family: var(--display); font-weight: 700; font-size: 1.35rem; }

.site-nav { display: flex; flex-wrap: wrap; gap: 0.25rem 1.1rem; }

.site-nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.98rem;
  padding: 0.2rem 0;
  border-bottom: 2px solid transparent;
}

.site-nav a:hover { color: var(--ink); }
.site-nav a.active { color: var(--ink); font-weight: 600; border-bottom-color: var(--accent); }

/* ---------------- hero / page heads ---------------- */

.hero { text-align: center; padding: 3.5rem 0 2.5rem; }

.kicker {
  text-transform: uppercase;
  letter-spacing: 0.22em;
  font-size: 0.78rem;
  color: var(--accent);
  margin-bottom: 0.8rem;
}

.hero h1 { font-size: clamp(2.6rem, 7vw, 4.2rem); margin-bottom: 0.5rem; }

.lede { font-size: 1.18rem; color: var(--muted); max-width: 38rem; margin: 0 auto 1em; }

.page-head { padding: 2.2rem 0 0.5rem; }

.attribution {
  font-style: italic;
  color: var(--muted);
  border-left: 3px solid var(--accent-2);
  padding-left: 0.9rem;
}

.fineprint { font-size: 0.88rem; color: var(--muted); }

.disclaimer {
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.7rem 1rem;
  font-size: 0.92rem;
  color: var(--muted);
}

.placeholder {
  border: 2px dashed var(--line);
  border-radius: 10px;
  padding: 2rem 1.5rem;
  text-align: center;
  color: var(--muted);
  font-style: italic;
  background: var(--card);
}

/* ---------------- cards ---------------- */

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 1.25rem;
  margin: 1rem 0 2.5rem;
}

.card {
  display: block;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1.4rem 1.3rem;
  text-decoration: none;
  color: var(--ink);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.card:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 24px rgba(90, 60, 25, 0.12);
  color: var(--ink);
}

.card h2 { margin: 0 0 0.4rem; font-size: 1.3rem; }
.card p { color: var(--muted); font-size: 0.98rem; margin-bottom: 0.9rem; }
.card-meta { font-size: 0.82rem; color: var(--accent); text-transform: uppercase; letter-spacing: 0.08em; }

.data-status {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1.4rem 1.6rem;
  margin-bottom: 3rem;
}

.data-status h2 { margin-top: 0; font-size: 1.25rem; }
.data-status ul { margin: 0 0 0.8rem; padding-left: 1.2rem; }
.data-status li { margin-bottom: 0.25rem; }

/* ---------------- NYT lists ---------------- */

.nyt-list { margin-bottom: 3rem; }

.nyt-list-head {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  flex-wrap: wrap;
  border-bottom: 2px solid var(--ink);
  padding-bottom: 0.4rem;
  margin-bottom: 1rem;
}

.nyt-list-head h2 { margin: 0; }
.nyt-list-head .fineprint { margin: 0; }

.books { list-style: none; margin: 0; padding: 0; }

.book {
  display: flex;
  gap: 1.1rem;
  align-items: flex-start;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1.1rem 1.2rem;
  margin-bottom: 0.8rem;
}

.rank {
  font-family: var(--display);
  font-size: 1.9rem;
  font-weight: 700;
  color: var(--accent-2);
  min-width: 2.2rem;
  text-align: center;
  line-height: 1.1;
}

.book-cover { width: 64px; height: auto; border-radius: 4px; flex-shrink: 0; }
.book-body { flex: 1; min-width: 0; }
.book-body h3 { margin: 0 0 0.2rem; font-size: 1.2rem; }
.byline { color: var(--muted); font-size: 0.95rem; margin-bottom: 0.25rem; }
.weeks { font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--accent); margin-bottom: 0.4rem; }
.desc { margin-bottom: 0; color: var(--ink); }
.buy-links { margin: 0.6rem 0 0; display: flex; gap: 0.5rem; flex-wrap: wrap; }
.buy-btn {
  display: inline-block;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  text-decoration: none;
  border: 1px solid var(--accent);
}
.buy-primary { background: var(--accent); color: #fff; }
.buy-secondary { background: transparent; color: var(--accent); }
.buy-btn:hover { filter: brightness(0.94); }

/* ---------------- trends ---------------- */

.trend-section { margin-bottom: 3rem; }

.chart-wrap {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1rem;
}

.chart { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis { font-family: var(--body); font-size: 13px; fill: var(--muted); }
.chart .line { stroke: var(--accent); stroke-width: 3; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { fill: var(--accent); opacity: 0.10; }
.chart .dot { fill: var(--card); stroke: var(--accent); stroke-width: 2.5; }
.chart .bar { fill: var(--accent-2); rx: 3; }
.chart .barlabel { font-family: var(--body); font-size: 13px; fill: var(--ink); font-weight: 600; }

.callouts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.9rem;
  margin-top: 1rem;
}

.callout {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.9rem 1rem;
}

.callout p { margin: 0 0 0.2rem; }
.callout-when { font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.callout-when span { text-transform: none; letter-spacing: 0; }
.callout-then { font-family: var(--display); font-size: 1.25rem; font-weight: 700; }
.callout-delta { font-size: 0.9rem; color: var(--accent); }

.note-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 10px;
  padding: 1.2rem 1.4rem;
}

/* ---------------- library ---------------- */

.bigstat {
  text-align: center;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 2.2rem 1.5rem;
  margin: 1.5rem 0 2.5rem;
}

.bigstat-label { color: var(--muted); font-size: 1rem; margin-bottom: 0.4rem; }
.bigstat-value { font-family: var(--display); font-size: clamp(2.6rem, 8vw, 4rem); font-weight: 700; color: var(--accent); margin: 0; }

.map-wrap {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1rem;
}

#us-map { width: 100%; height: auto; display: block; }
#us-map path { stroke: var(--card); stroke-width: 1.2; cursor: default; }
#us-map path:hover { stroke: var(--ink); stroke-width: 2; }

.map-legend { margin-top: 0.8rem; padding: 0 0.4rem; }

.legend-bar {
  position: relative;
  height: 16px;
  border-radius: 8px;
  border: 1px solid var(--line);
}

.legend-marker {
  position: absolute;
  top: -5px;
  bottom: -5px;
  width: 3px;
  background: var(--ink);
  transform: translateX(-50%);
  border-radius: 2px;
}

.legend-labels { position: relative; height: 1.6rem; font-size: 0.78rem; color: var(--muted); }
.legend-labels span { position: absolute; transform: translateX(-50%); white-space: nowrap; }
.legend-labels span:first-child { transform: none; }
.legend-labels span:last-child { transform: translateX(-100%); }

.legend-avg { font-size: 0.9rem; margin: 0.3rem 0 0; }
.legend-avg::before {
  content: "";
  display: inline-block;
  width: 3px;
  height: 0.9em;
  background: var(--ink);
  margin-right: 0.45rem;
  vertical-align: baseline;
}

/* ---------------- tables ---------------- */

.table-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; background: var(--card); }

.data-table { width: 100%; border-collapse: collapse; font-size: 0.97rem; min-width: 560px; }

.data-table th, .data-table td { padding: 0.65rem 0.9rem; text-align: left; }

.data-table thead th {
  font-family: var(--display);
  font-size: 0.88rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: var(--soft);
  border-bottom: 2px solid var(--line);
  white-space: nowrap;
}

.data-table th[data-sort] { cursor: pointer; user-select: none; }
.data-table th[data-sort]:hover { color: var(--accent); }
.data-table th[data-sort]::after { content: " \21C5"; color: var(--muted); font-size: 0.8em; }
.data-table th.sorted::after { content: " \25B2"; color: var(--accent); }
.data-table th.sorted[data-dir="desc"]::after { content: " \25BC"; }

.data-table tbody tr { border-bottom: 1px solid var(--line); }
.data-table tbody tr:last-child { border-bottom: none; }
.data-table tbody tr:nth-child(even) { background: rgba(185, 119, 47, 0.05); }
.data-table tbody tr:hover { background: rgba(185, 119, 47, 0.10); }

.abbr { color: var(--muted); font-size: 0.85em; }

/* ---------------- bookfinder ---------------- */

.field-label { display: block; font-weight: 600; margin: 1rem 0 1.2rem; }

select {
  font-family: var(--body);
  font-size: 1rem;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.5rem 0.8rem;
  margin-left: 0.5rem;
  max-width: 100%;
}

.author-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 2.5rem;
}

.author-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1rem 1.1rem;
}

.author-card h3 { margin: 0 0 0.3rem; font-size: 1.1rem; }
.author-card p { margin: 0; font-size: 0.9rem; color: var(--muted); }
.author-card .born { margin-right: 0.6rem; }

/* ---------------- footer ---------------- */

.site-footer {
  border-top: 1px solid var(--line);
  margin-top: 3rem;
  padding: 2rem 0 2.5rem;
  background: var(--card);
}

.footer-title { font-family: var(--display); font-weight: 700; margin-bottom: 0.4rem; }
.footer-credits, .footer-note { font-size: 0.85rem; color: var(--muted); margin-bottom: 0.4rem; }

/* ---------------- responsive ---------------- */

@media (max-width: 700px) {
  body { font-size: 16px; }

  .header-inner { flex-direction: column; align-items: flex-start; gap: 0.5rem; }
  .site-nav { gap: 0.2rem 0.9rem; }

  .hero { padding: 2.2rem 0 1.5rem; }

  .cards { grid-template-columns: 1fr; }

  .book { gap: 0.8rem; padding: 0.9rem; }
  .rank { font-size: 1.5rem; min-width: 1.8rem; }

  .callouts { grid-template-columns: 1fr 1fr; }

  .data-table { font-size: 0.9rem; min-width: 520px; }
  .data-table th, .data-table td { padding: 0.5rem 0.65rem; }

  .field-label select { margin-left: 0; margin-top: 0.4rem; display: block; width: 100%; }
}
