/* Esteban Sancho redesign — tokens */
:root {
  --bg: #f7f4ee;
  --bg-alt: #f0ece2;
  --ink: #1c1a16;
  --body-muted: #4a453c;
  --muted: #6f695e;
  --border: #ddd6c8;
  --border-soft: #e4ded1;
  --accent: #a4442f;
  --accent-hover: #7d3323; /* hover goes darker in light, lighter in dark */
  --on-accent: #fff;       /* text on an accent-filled surface */
  --serif: 'Newsreader', Georgia, serif;
  --sans: 'Instrument Sans', -apple-system, sans-serif;
  color-scheme: light dark;
}
/* Dark mode — system setting only, no toggle (site stays JS-free).
   Warm near-black: same paper character, not neutral charcoal.
   Palette from the design handoff; contrast re-verified AA at all sizes. */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171512;
    --bg-alt: #211e19;
    --ink: #ece7dd;
    --body-muted: #bfb6a7;
    --muted: #988e7e;
    --border: #38322a;
    --border-soft: #2a2620;
    --accent: #cf7a60;
    --accent-hover: #e0937a;
    --on-accent: #171512; /* white on the lighter dark accent is only 3.18:1 */
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--serif); min-height: 100vh; display: flex; flex-direction: column; }
main { flex: 1 0 auto; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }
.kicker { font-family: var(--sans); font-size: 12px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; margin-bottom: 16px; }
.kicker.accent { color: var(--accent); }
.kicker.muted { color: var(--muted); }
.meta, .post-meta { font-family: var(--sans); font-size: 13px; color: var(--muted); }

/* Header */
.site-header { border-bottom: 1px solid var(--border); }
.site-header-inner { max-width: 1100px; margin: 0 auto; padding: 28px 40px; display: flex; align-items: baseline; justify-content: space-between; gap: 24px; flex-wrap: wrap; }
.masthead { display: flex; align-items: baseline; gap: 16px; }
.masthead-heading { margin: 0; font-size: inherit; font-weight: inherit; line-height: inherit; }
.site-name { font-size: 23px; font-weight: 600; letter-spacing: -0.01em; color: var(--ink); }
.site-tagline { font-family: var(--sans); font-size: 13px; color: var(--muted); }
.site-nav { display: flex; flex-wrap: wrap; gap: 12px 28px; font-family: var(--sans); font-size: 14px; font-weight: 500; }
.site-nav a { color: var(--ink); }
.site-nav a.accent, .site-nav a:hover { color: var(--accent); }

/* Homepage hero */
.hero { max-width: 1100px; margin: 0 auto; padding: 64px 40px 48px; display: grid; grid-template-columns: 1fr 300px; gap: 64px; }
.hero-title { font-size: clamp(32px, 4vw, 46px); line-height: 1.1; font-weight: 500; letter-spacing: -0.015em; margin: 0 0 20px; text-wrap: pretty; }
.hero-title a { color: var(--ink); }
.hero-summary { font-size: 20px; line-height: 1.5; color: var(--body-muted); margin: 0 0 24px; max-width: 56ch; }
.hero-bio { display: flex; flex-direction: column; gap: 16px; padding-top: 6px; }
.portrait { width: 132px; height: 132px; border-radius: 50%; object-fit: cover; }
.hero-bio p { font-size: 16px; line-height: 1.5; color: var(--body-muted); margin: 0; }
.bio-links { display: flex; gap: 16px; font-family: var(--sans); font-size: 13px; font-weight: 500; }

/* Start here */
.start-here { background: var(--bg-alt); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.start-here > * { max-width: 1100px; margin-left: auto; margin-right: auto; }
.start-here-head { display: flex; align-items: baseline; gap: 14px; padding: 40px 40px 0; }
.start-here-head .kicker { margin: 0; }
.start-here-sub { font-family: var(--sans); font-size: 13px; color: var(--muted); }
.start-here-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; padding: 20px 40px 40px; }
.start-card { display: block; background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 22px 24px; color: var(--ink); }
.start-card:hover { border-color: var(--accent); color: var(--ink); }
.start-card-theme { font-family: var(--sans); font-size: 11px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent); margin-bottom: 10px; }
.start-card-title { font-size: 21px; font-weight: 500; letter-spacing: -0.01em; line-height: 1.25; margin-bottom: 8px; }
.start-card-why { font-size: 15px; line-height: 1.45; color: var(--muted); }

/* Recent list */
.recent { max-width: 1100px; margin: 0 auto; padding: 40px 40px 72px; }
.post-row { display: grid; grid-template-columns: 150px 1fr; gap: 32px; padding: 26px 0; border-bottom: 1px solid var(--border-soft); align-items: baseline; }
.post-row-date { font-family: var(--sans); font-size: 13px; color: var(--muted); }
.post-row-title { font-size: 24px; font-weight: 500; letter-spacing: -0.01em; line-height: 1.25; margin: 0 0 6px; }
.post-row-title a { color: var(--ink); }
.post-row-title a:hover { color: var(--accent); }
.post-row-summary { font-size: 16px; line-height: 1.5; color: var(--muted); margin: 0; max-width: 64ch; }
.all-link { padding-top: 28px; font-family: var(--sans); font-size: 14px; font-weight: 500; }

/* Post page */
.post { max-width: 800px; margin: 0 auto; padding: 64px 40px 96px; } /* 800 - 2x40 padding = 720px text column */
.post-title { font-size: clamp(32px, 4vw, 44px); line-height: 1.12; font-weight: 500; letter-spacing: -0.015em; margin: 0 0 18px; text-wrap: pretty; }
.post-subtitle { font-size: 21px; line-height: 1.45; color: var(--body-muted); font-style: italic; margin: 0 0 20px; }
.post-meta { padding-bottom: 28px; border-bottom: 1px solid var(--border); margin-bottom: 40px; }
.toc { background: var(--bg-alt); border-radius: 6px; padding: 20px 24px; margin-bottom: 40px; }
.toc .kicker { margin-bottom: 10px; }
.toc ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; font-family: var(--sans); font-size: 14px; }
.post-body { font-size: 19px; line-height: 1.65; }
.post-body p { margin: 0 0 24px; }
.post-body h2 { font-size: 29px; font-weight: 500; letter-spacing: -0.01em; margin: 48px 0 16px; }
.post-body h3 { font-size: 23px; font-weight: 500; margin: 36px 0 12px; }
.post-body blockquote { margin: 40px 0; padding: 0 0 0 28px; border-left: 3px solid var(--accent); font-size: 26px; line-height: 1.35; font-weight: 500; letter-spacing: -0.01em; }
.post-body blockquote p { margin: 0; }
.post-body figure { margin: 0 0 28px; }
.post-body img { max-width: 100%; border-radius: 6px; }
.post-body figcaption { font-family: var(--sans); font-size: 13px; color: var(--muted); margin-top: 10px; }
.post-body code { font-size: 0.85em; background: var(--bg-alt); padding: 2px 6px; border-radius: 4px; }
.post-body pre { background: var(--bg-alt); border: 1px solid var(--border); border-radius: 6px; padding: 18px 20px; overflow-x: auto; font-size: 15px; line-height: 1.5; }
.post-body pre code { background: none; padding: 0; }
.post-body ul, .post-body ol { margin: 0 0 24px; padding-left: 28px; }
.post-body li { margin-bottom: 8px; }
.post-pager { margin-top: 56px; padding-top: 28px; border-top: 1px solid var(--border); display: flex; justify-content: space-between; gap: 32px; font-family: var(--sans); font-size: 14px; }
.pager-label { color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.pager-next { text-align: right; }

/* Footer */
/* The band is full-bleed like the header and the start-here band; the inner
   div carries the 1100px measure. The handoff put both on .site-footer, which
   inset the tint and left its top rule aligned to nothing. */
.site-footer { background: var(--bg-alt); border-top: 1px solid var(--border); font-family: var(--sans); font-size: 13px; color: var(--muted); }
.site-footer-inner { display: flex; justify-content: space-between; gap: 24px; max-width: 1100px; margin: 0 auto; padding: 28px 40px; }
.footer-links { display: inline-flex; gap: 20px; }

/* Responsive */
@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; gap: 40px; }
  .start-here-grid { grid-template-columns: 1fr; }
  .post-row { grid-template-columns: 1fr; gap: 6px; }
}

/* ---------------------------------------------------------------------------
   Spike additions — not in the mockup.
   Screens the handoff did not design (about, /posts/ archive, /tags/, /ama/)
   plus markup the essays actually use (tables). Kept in one block so it is
   easy to review or drop during real integration.
   --------------------------------------------------------------------------- */

/* Generic prose page + archive shells */
.page, .archive { max-width: 800px; margin: 0 auto; padding: 64px 40px 96px; } /* 720px text column, same measure as .post */
.archive { max-width: 900px; }
.page-title { font-size: clamp(30px, 4vw, 40px); line-height: 1.15; font-weight: 500; letter-spacing: -0.015em; margin: 0 0 28px; }
.page-lead { font-size: 19px; line-height: 1.55; color: var(--body-muted); margin: 0 0 32px; }
.archive .post-row:first-of-type { border-top: 1px solid var(--border-soft); }

/* TOC links inherit accent from `a`, but keep hover explicit for clarity */
.toc a { color: var(--accent); }
.toc a:hover { color: var(--accent-hover); }

/* Tables (one essay uses them; the mockup has none) */
.post-body table { display: block; width: 100%; overflow-x: auto; border-collapse: collapse; margin: 0 0 28px; font-family: var(--sans); font-size: 15px; line-height: 1.45; }
.post-body th, .post-body td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--border-soft); vertical-align: top; }
.post-body th { font-weight: 600; color: var(--ink); border-bottom: 1px solid var(--border); }
.post-body td { color: var(--body-muted); }

/* Footnotes (kramdown) */
.post-body .footnotes { margin-top: 48px; padding-top: 20px; border-top: 1px solid var(--border-soft); font-size: 16px; color: var(--muted); }

/* Taxonomy index, shared by /topics/ and /tags/ */
.taxonomy-index { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 48px; font-family: var(--sans); font-size: 14px; }
.taxonomy-index a { border: 1px solid var(--border); border-radius: 6px; padding: 5px 12px; color: var(--ink); background: var(--bg-alt); }
.taxonomy-index a:hover { border-color: var(--accent); color: var(--accent); }
.taxonomy-count { color: var(--muted); font-size: 12px; }
.taxonomy-group { margin-bottom: 40px; }
.taxonomy-heading { font-size: 23px; font-weight: 500; margin: 0 0 8px; scroll-margin-top: 24px; text-transform: capitalize; }
.taxonomy-group .post-row { padding: 16px 0; }
.taxonomy-group .post-row-title { font-size: 20px; }

/* The article kicker links to its topic; keep it looking like a kicker */
.kicker a { color: inherit; }
.kicker a:hover { color: var(--accent-hover); }

/* AMA page */
.ama-note { font-family: var(--sans); font-size: 13px; line-height: 1.6; color: var(--muted); margin-top: 20px; }

@media (max-width: 900px) {
  .post, .page, .archive { padding: 40px 24px 64px; }
}

/* End-of-essay author card (spike addition, not in the mockup).
   Mirrors the TOC box so the essay is bookended by the same surface. */
.author-card { display: flex; gap: 20px; align-items: flex-start; background: var(--bg-alt); border-radius: 6px; padding: 24px; margin-top: 56px; }
.author-card-portrait { width: 72px; height: 72px; border-radius: 50%; object-fit: cover; flex: 0 0 auto; }
.author-card-body { min-width: 0; }
.author-card-name { font-family: var(--sans); font-size: 12px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); margin-bottom: 10px; }
.author-card-bio { font-size: 17px; line-height: 1.5; color: var(--body-muted); margin: 0 0 14px; max-width: 52ch; }
.author-card-links { display: flex; flex-wrap: wrap; gap: 18px; font-family: var(--sans); font-size: 14px; font-weight: 500; }

/* The card already provides the closing rule, so the pager drops its own. */
.author-card + .post-pager { margin-top: 32px; border-top: 0; padding-top: 0; }

@media (max-width: 900px) {
  .author-card { flex-direction: column; gap: 16px; }
}

/* ── AMA widget: layout only ─────────────────────────────────────────────────
   Colours now live in ama-widget.css against the shared tokens, so the widget
   follows light and dark on its own. What remains here is the panel sizing the
   design needs; the original `height: calc(100dvh - 280px)` rendered an empty
   chat as a full-screen void. */
#ama-full-chat {
  height: auto;
  min-height: 360px;
  max-height: min(620px, calc(100vh - 240px));
  margin-top: 24px;
}

/* About-page portrait anchor (spike addition, optional: `portrait: true`) */
.page-portrait { float: right; width: 120px; height: 120px; border-radius: 50%; object-fit: cover; margin: 4px 0 24px 36px; shape-outside: circle(); }
@media (max-width: 640px) {
  .page-portrait { float: none; display: block; margin: 0 0 24px; width: 96px; height: 96px; }
}

/* Dark-mode elevation. Must live at the end of the file: media queries add no
   specificity, so declaring these next to the palette put them BEFORE the base
   .start-here / .start-card rules and they never applied. Cards and the TOC box
   stay raised on --bg-alt; the band drops to --bg and its borders separate it. */
@media (prefers-color-scheme: dark) {
  .start-here { background: var(--bg); }
  .start-card { background: var(--bg-alt); }
}
