/* Charles K. Henry — typography-first stylesheet.
   Hand-written rather than a third-party theme: a theme is unreviewed code on
   every page, and this site's whole premise is a minimal attack surface. */

/* ── Equity (Matthew Butterick) ───────────────────────────────────────────────
   The same family used on Charles's letterhead. Equity Text A carries the body
   and the section headings; Equity Caps A sets the document title, matching how
   the letterhead treats a title. Converted to woff2 at image build time.
   font-display: swap so text is readable immediately rather than invisible
   while ~200 KB of fonts load. */
@font-face {
  font-family: 'Equity Text A';
  src: url('/fonts/equity_text_a_regular.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Equity Text A';
  src: url('/fonts/equity_text_a_italic.woff2') format('woff2');
  font-weight: 400; font-style: italic; font-display: swap;
}
@font-face {
  font-family: 'Equity Text A';
  src: url('/fonts/equity_text_a_bold.woff2') format('woff2');
  font-weight: 700; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Equity Text A';
  src: url('/fonts/equity_text_a_bold_italic.woff2') format('woff2');
  font-weight: 700; font-style: italic; font-display: swap;
}
@font-face {
  font-family: 'Equity Caps A';
  src: url('/fonts/equity_caps_a_regular.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Equity Caps A';
  src: url('/fonts/equity_caps_a_bold.woff2') format('woff2');
  font-weight: 700; font-style: normal; font-display: swap;
}

:root {
  --bg:        #fdfdfb;
  --surface:   #f4f3ee;
  --text:      #1c1b19;
  --muted:     #5f5c56;
  --accent:    #7a2f2f;
  --border:    #e0ded7;
  --measure:   38rem;      /* ~68 characters — the comfortable reading width */

  --font-text: 'Equity Text A', Georgia, 'Iowan Old Style', 'Times New Roman', serif;
  --font-caps: 'Equity Caps A', 'Equity Text A', Georgia, serif;
  --font-ui:   system-ui, -apple-system, 'Segoe UI', sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:      #16151a;
    --surface: #1e1d23;
    --text:    #e8e6e1;
    --muted:   #a5a19a;
    --accent:  #d98c8c;
    --border:  #2e2c34;
  }
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-text);
  font-size: 19px;
  line-height: 1.7;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.wrap { width: 100%; max-width: var(--measure); margin: 0 auto; padding: 0 1.25rem; }

/* ── Header ────────────────────────────────────────────────────────────── */
.site-header { border-bottom: 1px solid var(--border); padding: 1.25rem 0; }
.header-inner { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.brand { text-decoration: none; color: var(--text); }
.brand-name {
  font-family: var(--font-caps);
  font-size: 1.05rem; font-weight: 700; letter-spacing: 0.05em;
}
.site-nav { display: flex; gap: 1.1rem; }
.site-nav a,
.brand:hover .brand-name { color: var(--accent); }
.site-nav a {
  font-family: var(--font-ui);
  font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.08em;
  text-decoration: none;
}
.site-nav a:hover { text-decoration: underline; text-underline-offset: 4px; }

/* ── Layout ────────────────────────────────────────────────────────────── */
main.wrap { flex: 1; padding-top: 3rem; padding-bottom: 4rem; }

.intro { margin-bottom: 3.5rem; }
.lede { color: var(--muted); font-size: 1.15rem; margin-top: 0.75rem; }

.section-label {
  font-family: var(--font-ui);
  font-size: 0.75rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.12em; color: var(--muted);
  padding-bottom: 0.6rem; border-bottom: 1px solid var(--border);
  margin-bottom: 1.75rem;
}

/* ── Post list ─────────────────────────────────────────────────────────── */
.post-item { margin-bottom: 2.5rem; }
.post-item h3 { font-size: 1.4rem; line-height: 1.3; letter-spacing: -0.01em; }
.post-item h3 a { color: var(--text); text-decoration: none; }
.post-item h3 a:hover { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.post-summary { color: var(--muted); margin-top: 0.5rem; }

.post-meta {
  font-family: var(--font-ui);
  font-size: 0.8rem; color: var(--muted); margin-top: 0.35rem;
}
.dot { margin: 0 0.4rem; }

/* ── Single post ───────────────────────────────────────────────────────── */
.post-header { margin-bottom: 2.5rem; }

/* The document title gets Equity Caps A, the way the letterhead sets a title.
   Caps faces need positive tracking to breathe, and no synthetic bolding — the
   caps family has its own bold. */
h1 {
  font-family: var(--font-caps);
  font-weight: 700;
  letter-spacing: 0.03em;
  font-size: 2rem;
  line-height: 1.22;
  /* Equity Caps A is already a caps design; leave the source text alone so a
     title typed in mixed case renders as the designer intended. */
  text-transform: none;
}

/* Section headings inside a post stay in Equity Text A, as requested. */
.prose h2, .prose h3, .prose h4,
.post-item h3 {
  font-family: var(--font-text);
}

.tags { margin-top: 0.75rem; display: flex; flex-wrap: wrap; gap: 0.4rem; }
.tag {
  font-family: var(--font-ui);
  font-size: 0.72rem; letter-spacing: 0.06em; text-transform: uppercase;
  background: var(--surface); border: 1px solid var(--border);
  padding: 0.2rem 0.55rem; border-radius: 999px; color: var(--muted);
}

.toc {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 6px; padding: 1rem 1.25rem; margin-bottom: 2.5rem;
}
.toc-label {
  font-family: var(--font-ui);
  font-size: 0.72rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.1em; color: var(--muted); margin-bottom: 0.5rem;
}
.toc ul { list-style: none; padding-left: 0; }
.toc ul ul { padding-left: 1rem; }
.toc li { margin: 0.25rem 0; font-size: 0.95rem; }
.toc a { color: var(--text); text-decoration: none; }
.toc a:hover { color: var(--accent); text-decoration: underline; }

/* ── Prose ─────────────────────────────────────────────────────────────── */
.prose > * + * { margin-top: 1.4rem; }
.prose h2 { font-size: 1.55rem; line-height: 1.3; margin-top: 2.75rem; letter-spacing: -0.01em; }
.prose h3 { font-size: 1.25rem; line-height: 1.35; margin-top: 2.25rem; }
.prose a { color: var(--accent); text-underline-offset: 3px; }
.prose ul, .prose ol { padding-left: 1.4rem; }
.prose li + li { margin-top: 0.5rem; }
.prose blockquote {
  border-left: 3px solid var(--accent);
  padding: 0.25rem 0 0.25rem 1.25rem;
  color: var(--muted); font-style: italic;
}
.prose img { max-width: 100%; height: auto; border-radius: 4px; }
.prose hr { border: none; border-top: 1px solid var(--border); margin: 2.5rem 0; }
.prose code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.85em; background: var(--surface);
  border: 1px solid var(--border); border-radius: 3px; padding: 0.1em 0.35em;
}
.prose pre {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 6px; padding: 1rem; overflow-x: auto;
}
.prose pre code { background: none; border: none; padding: 0; font-size: 0.85rem; }
.prose table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
.prose th, .prose td { border: 1px solid var(--border); padding: 0.5rem 0.7rem; text-align: left; }
.prose th { background: var(--surface); }

/* Footnotes — long-form legal and policy writing leans on these. */
.footnotes { font-size: 0.9rem; color: var(--muted); border-top: 1px solid var(--border); margin-top: 3rem; padding-top: 1rem; }

/* ── Comments ──────────────────────────────────────────────────────────── */
.comments { margin-top: 4rem; padding-top: 1rem; border-top: 1px solid var(--border); }

/* ── Footer ────────────────────────────────────────────────────────────── */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 2rem 0; margin-top: auto;
  font-family: var(--font-ui);
  font-size: 0.85rem; color: var(--muted);
}
.muted { color: var(--muted); }

@media (max-width: 640px) {
  body { font-size: 18px; }
  .intro h1 { font-size: 1.9rem; }
  .post-header h1 { font-size: 1.75rem; }
}
