/* Rare Books Intel — base styles */

:root {
  --bg: #faf8f3;          /* warm parchment */
  --surface: #ffffff;
  --ink: #1a1816;
  --ink-soft: #5a544c;
  --ink-faint: #a39989;
  --rule: #e8e1d4;
  --accent: #6b3410;      /* leather brown */
  --accent-soft: #f3e7d8;
  --link: #1e4d8c;
  --error: #8b1e1e;
  --ok: #1e6b3a;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Iowan Old Style', Georgia, 'Times New Roman', serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  font-size: 16px;
}

a { color: var(--link); }
a:hover { text-decoration: underline; }

/* ---- Header / nav ---- */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--rule);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.site-header .brand {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--ink);
  text-decoration: none;
}
.site-header nav { display: flex; gap: 18px; }
.site-header nav a {
  color: var(--ink-soft);
  text-decoration: none;
  font-size: 14px;
  font-family: -apple-system, BlinkMacSystemFont, sans-serif;
}
.site-header nav a:hover { color: var(--ink); }
.site-header nav a.active { color: var(--accent); font-weight: 600; }

/* ---- Layout ---- */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
}
.container.narrow { max-width: 720px; }

h1 { font-size: 28px; margin: 0 0 16px; font-weight: 600; }
h2 { font-size: 20px; margin: 24px 0 12px; font-weight: 600; }
h3 { font-size: 16px; margin: 16px 0 8px; font-weight: 600; }

/* ---- Stats grid ---- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 16px;
}
.stat-card .label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
  font-family: -apple-system, sans-serif;
}
.stat-card .value {
  font-size: 28px;
  font-weight: 600;
  margin-top: 4px;
  color: var(--ink);
}
.stat-card .value.loading { color: var(--ink-faint); }

/* ---- Search layout ---- */
.search-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 24px;
}
.filters {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 16px;
  align-self: start;
  position: sticky;
  top: 16px;
}
.filters .filter-group { margin-bottom: 16px; }
.filters label {
  display: block;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-soft);
  font-family: -apple-system, sans-serif;
  margin-bottom: 4px;
}
.filters input, .filters select {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--rule);
  border-radius: 3px;
  font-size: 14px;
  font-family: inherit;
  background: var(--bg);
}
.filters .price-range, .filters .year-range {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

/* ---- Listings ---- */
.search-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}
.search-bar input[type="search"] {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--rule);
  border-radius: 3px;
  font-size: 16px;
  font-family: inherit;
  background: var(--surface);
}
.search-bar button {
  padding: 10px 18px;
  background: var(--accent);
  color: white;
  border: 0;
  border-radius: 3px;
  font-family: -apple-system, sans-serif;
  font-size: 14px;
  cursor: pointer;
}
.search-bar button:hover { background: #4d2509; }

.listing-list { list-style: none; padding: 0; margin: 0; }
.listing-card {
  display: grid;
  grid-template-columns: 100px 1fr auto;
  gap: 16px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 4px;
  margin-bottom: 8px;
}
.listing-card .thumb {
  width: 100px;
  height: 140px;
  object-fit: cover;
  background: var(--accent-soft);
  border: 1px solid var(--rule);
}
.listing-card .meta { min-width: 0; }
.listing-card .title {
  font-size: 17px;
  font-weight: 600;
  color: var(--ink);
  text-decoration: none;
  display: block;
  margin-bottom: 4px;
}
.listing-card .author { color: var(--ink-soft); font-size: 14px; margin-bottom: 6px; }
.listing-card .details {
  font-size: 13px;
  color: var(--ink-soft);
  font-family: -apple-system, sans-serif;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}
.listing-card .price-block {
  text-align: right;
  min-width: 120px;
}
.listing-card .price {
  font-size: 20px;
  font-weight: 600;
  color: var(--accent);
}
.listing-card .source-pill {
  display: inline-block;
  padding: 2px 8px;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 10px;
  font-size: 11px;
  font-family: -apple-system, sans-serif;
  margin-top: 4px;
}

/* ---- Empty / loading states ---- */
.empty, .loading-block {
  padding: 48px 24px;
  text-align: center;
  color: var(--ink-soft);
  font-style: italic;
}

/* ---- Tables ---- */
table { width: 100%; border-collapse: collapse; background: var(--surface); }
table th, table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--rule);
  font-size: 14px;
  font-family: -apple-system, sans-serif;
}
table th {
  background: var(--accent-soft);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
}

/* ---- Forms ---- */
.form-card {
  max-width: 400px;
  margin: 60px auto;
  padding: 32px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 4px;
}
.form-card label { display: block; margin-top: 12px; font-size: 13px; color: var(--ink-soft); font-family: -apple-system, sans-serif; }
.form-card input { width: 100%; padding: 10px; border: 1px solid var(--rule); border-radius: 3px; font-family: inherit; font-size: 15px; margin-top: 4px; }
.form-card button {
  width: 100%;
  margin-top: 20px;
  padding: 12px;
  background: var(--accent);
  color: white;
  border: 0;
  border-radius: 3px;
  font-family: -apple-system, sans-serif;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.form-card .err { color: var(--error); font-size: 13px; margin-top: 12px; }

/* ---- Listing detail ---- */
.detail-grid { display: grid; grid-template-columns: 320px 1fr; gap: 32px; }
.detail-grid .image-col img { width: 100%; border: 1px solid var(--rule); }
.detail-grid dl { margin: 0; }
.detail-grid dt {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-soft);
  font-family: -apple-system, sans-serif;
  margin-top: 12px;
}
.detail-grid dd { margin: 4px 0 0; font-size: 15px; }
.detail-grid .price-large { font-size: 32px; font-weight: 600; color: var(--accent); margin: 8px 0 16px; }

/* ---- Responsive ---- */
@media (max-width: 800px) {
  .search-layout { grid-template-columns: 1fr; }
  .filters { position: static; }
  .listing-card { grid-template-columns: 80px 1fr; }
  .listing-card .price-block { grid-column: 1 / -1; text-align: left; }
  .detail-grid { grid-template-columns: 1fr; }
}
