/* Entire design system, one file. Tokens only — never hardcode a colour in
   a component rule below. Any new colour must be defined in all three theme
   blocks (light root, prefers-color-scheme dark, [data-theme=dark]) or it
   breaks in one theme. */

:root {
  --paper: #f6f1e6;
  --paper-raised: #efe8d8;
  --ink: #2a2620;
  --ink-muted: #6b6255;
  --line: #ddd3bd;
  --brass: #a97d2f;
  --brass-ink: #6e5320;
  --indigo: #3c4a7a;
  --patina: #3f7a5c;
  --alert: #a5352a;
  --font-display: "Chivo", system-ui, sans-serif;
  --font-body: "Newsreader", Georgia, serif;
  --font-mono: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
  --radius: 3px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #1c1a16;
    --paper-raised: #26231d;
    --ink: #ece5d6;
    --ink-muted: #a89d89;
    --line: #3a352b;
    --brass: #d3a752;
    --brass-ink: #e8c988;
    --indigo: #8b9bd6;
    --patina: #6fbf94;
    --alert: #e08579;
  }
}

:root[data-theme="dark"] {
  --paper: #1c1a16;
  --paper-raised: #26231d;
  --ink: #ece5d6;
  --ink-muted: #a89d89;
  --line: #3a352b;
  --brass: #d3a752;
  --brass-ink: #e8c988;
  --indigo: #8b9bd6;
  --patina: #6fbf94;
  --alert: #e08579;
}

* { box-sizing: border-box; }
html { overflow-x: hidden; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1.05rem;
  line-height: 1.6;
  overflow-x: hidden;
}

h1, h2, h3, h4, .brand, button, .button, nav, .card-type, .stat-num {
  font-family: var(--font-display);
}

h1 { font-size: 2.1rem; margin: 0 0 0.4em; }
h2 { font-size: 1.5rem; margin: 1.6em 0 0.6em; border-bottom: 1px solid var(--line); padding-bottom: 0.3em; }
h3 { font-size: 1.15rem; margin: 0 0 0.3em; }

a { color: var(--indigo); text-decoration-thickness: 1px; }
a:hover { color: var(--brass-ink); }

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

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

.site-header { border-bottom: 1px solid var(--line); background: var(--paper-raised); }
.site-header-inner { display: flex; align-items: center; gap: 1.5rem; padding: 0.9rem 1.25rem; max-width: 960px; margin: 0 auto; }
.brand { font-weight: 700; font-size: 1.2rem; color: var(--ink); text-decoration: none; }
.main-nav { display: flex; gap: 1.1rem; flex-wrap: wrap; margin-left: auto; }
.main-nav a { color: var(--ink-muted); text-decoration: none; font-size: 0.92rem; }
.main-nav a:hover { color: var(--brass-ink); }
.theme-toggle {
  background: none; border: 1px solid var(--line); border-radius: var(--radius);
  color: var(--ink); width: 2.1rem; height: 2.1rem; cursor: pointer; font-size: 1rem;
}

/* ---------- hero ---------- */

.hero { padding: 3rem 1.25rem 2rem; text-align: center; }
.hero h1 { font-size: 2.6rem; }
.lede { color: var(--ink-muted); font-size: 1.15rem; max-width: 640px; margin: 0 auto 1.5rem; }
.hero-stats { display: flex; justify-content: center; gap: 2.5rem; margin: 2rem 0; flex-wrap: wrap; }
.stat { display: flex; flex-direction: column; }
.stat-num { font-size: 2rem; font-weight: 700; color: var(--brass-ink); font-variant-numeric: tabular-nums; }
.stat-label { color: var(--ink-muted); font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.04em; }

.button {
  display: inline-block; font-family: var(--font-display); font-weight: 600;
  background: var(--brass); color: #1c1a16; padding: 0.7em 1.4em; border-radius: var(--radius);
  text-decoration: none;
}
.button:hover { background: var(--brass-ink); color: #1c1a16; }

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

.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1.1rem; margin: 1rem 0 2rem; }
.card {
  display: block; background: var(--paper-raised); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; text-decoration: none; color: var(--ink);
}
.card:hover { border-color: var(--brass); }
.card-body { padding: 0.9rem 1rem; }
.device-card img { width: 100%; aspect-ratio: 1 / 1; object-fit: cover; display: block; background: var(--paper); }
.card-type { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--brass-ink); margin: 0 0 0.2em; }
.card h3 { margin: 0 0 0.3em; }
.card-meta { color: var(--ink-muted); font-size: 0.88rem; margin: 0.2em 0; }
.card-price { font-family: var(--font-mono); font-variant-numeric: tabular-nums; margin: 0.3em 0 0; }
.card-measured { font-size: 0.8rem; color: var(--patina); margin: 0.2em 0 0; }

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

.wide { overflow-x: auto; margin: 1rem 0; }
table { border-collapse: collapse; width: 100%; font-size: 0.95rem; }
th, td { text-align: left; padding: 0.55em 0.8em; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-family: var(--font-display); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--ink-muted); }
td.price, .price { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.db-table td:first-child, .db-table th:first-child { white-space: normal; min-width: 200px; }

.pill {
  display: inline-block; font-family: var(--font-mono); font-size: 0.7rem; padding: 0.1em 0.5em;
  border-radius: 2em; margin-left: 0.4em; vertical-align: middle;
}
.pill-ours { background: var(--brass); color: #1c1a16; }

.stock { font-size: 0.85rem; font-family: var(--font-mono); }
.stock.in-stock { color: var(--patina); }
.stock.out-of-stock { color: var(--alert); }

/* ---------- database filters ---------- */

.db-filters { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: center; margin: 1rem 0; }
.db-filters input, .db-filters select {
  font-family: var(--font-body); font-size: 0.95rem; padding: 0.5em 0.7em;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper-raised); color: var(--ink);
}
.db-filters input[type="search"] { flex: 1; min-width: 180px; }
.device-row[hidden] { display: none; }

/* ---------- device page ---------- */

.device-header { display: flex; gap: 1.5rem; flex-wrap: wrap; align-items: flex-start; margin-bottom: 1.5rem; }
.device-header img { width: 220px; height: 220px; object-fit: cover; border: 1px solid var(--line); border-radius: var(--radius); flex-shrink: 0; }
.breadcrumb { color: var(--ink-muted); font-size: 0.85rem; }
.breadcrumb a { color: var(--ink-muted); }

/* ---------- article / prose ---------- */

.article { max-width: 720px; }
.meta { color: var(--ink-muted); font-size: 0.85rem; font-family: var(--font-mono); }
.prose p { margin: 1em 0; }
.prose ul, .prose ol { padding-left: 1.4em; }
.prose blockquote { border-left: 3px solid var(--brass); margin: 1em 0; padding: 0.2em 1em; color: var(--ink-muted); }
.prose img { max-width: 100%; border-radius: var(--radius); }
.prose code { font-family: var(--font-mono); background: var(--paper-raised); padding: 0.1em 0.35em; border-radius: 2px; font-size: 0.9em; }
.prose pre { background: var(--paper-raised); padding: 1em; border-radius: var(--radius); overflow-x: auto; }
.prose pre code { background: none; padding: 0; }
.prose hr { border: none; border-top: 1px solid var(--line); margin: 2em 0; }

.toc { background: var(--paper-raised); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.8em 1.2em; margin: 1.5em 0; }
.toc-title { font-family: var(--font-display); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--ink-muted); margin: 0 0 0.4em; }
.toc ul { margin: 0; padding-left: 1.2em; }

/* ---------- callouts ---------- */

.callout { border-radius: var(--radius); padding: 0.9em 1.2em; margin: 1.4em 0; background: var(--paper-raised); border: 1px solid var(--line); }
.callout-title { font-family: var(--font-display); font-weight: 600; margin: 0 0 0.4em; }
.callout-note { border-left: 3px solid var(--indigo); }
.callout-key { border-left: 3px solid var(--brass); }
.callout-warn { border-left: 3px solid var(--alert); }
.callout-safety { border-left: 3px solid var(--alert); background: color-mix(in srgb, var(--alert) 10%, var(--paper-raised)); }
.callout p:first-child { margin-top: 0; }
.callout p:last-child { margin-bottom: 0; }

/* ---------- forms ---------- */

.subscribe { max-width: 480px; }
.subscribe label { display: block; margin-bottom: 0.5em; font-family: var(--font-display); }
.subscribe-row { display: flex; gap: 0.6rem; }
.subscribe input { flex: 1; padding: 0.6em 0.8em; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper-raised); color: var(--ink); }
.subscribe button { font-family: var(--font-display); background: var(--brass); color: #1c1a16; border: none; padding: 0.6em 1.2em; border-radius: var(--radius); cursor: pointer; }

/* ---------- misc ---------- */

.muted { color: var(--ink-muted); }
.small { font-size: 0.85rem; }
.where-to-buy { margin: 1rem 0; }

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

.site-footer { border-top: 1px solid var(--line); background: var(--paper-raised); margin-top: 3rem; }
.site-footer-inner { padding: 1.5rem 1.25rem; max-width: 960px; margin: 0 auto; font-size: 0.85rem; color: var(--ink-muted); }
.disclosure { max-width: 640px; }
.footer-links { display: flex; gap: 1rem; margin-top: 0.8em; }
.footer-links a { color: var(--ink-muted); }

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

@media (max-width: 600px) {
  .hero h1 { font-size: 2rem; }
  .site-header-inner { flex-wrap: wrap; }
  .main-nav { order: 3; width: 100%; margin-left: 0; gap: 0.8rem; }
  .device-header img { width: 100%; height: auto; aspect-ratio: 1/1; }
}
