/*
  blog.css — shared stylesheet for /blog/ pages.
  Derived from v18 tokens. Portfolio index.html keeps its CSS inline per CLAUDE.md.
*/

:root {
  /* Tufte palette — cream paper, charcoal ink, rust accent */
  --bg:       #fffff8;
  --surface:  #f7f2e8;
  --rule:     #d6d2c8;
  --text:     #2a2a2a;
  --text-sec: #4a4238;
  --muted:    #766f64;
  --accent:   #8b2e19;

  --size-caption: 0.78rem;
  --size-body:    1rem;
  --gap:          1.75rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    /* Tufte dark variant A — warm near-black, bright cream, saturated rust */
    --bg:       #201b14;
    --surface:  #2b2418;
    --rule:     #3a3024;
    --text:     #f5ecd7;
    --text-sec: #d4c7a9;
    --muted:    #b0a48a;
    --accent:   #e06940;
  }
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 21px;
  background: var(--bg);
  color: var(--text);
  scroll-behavior: smooth;
}

body {
  font-family: 'EB Garamond', Georgia, serif;
  font-size: var(--size-body);
  line-height: 1.7;
  background: var(--bg);
}

:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.page {
  max-width: 640px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.15s ease;
}
a:hover { border-bottom-color: var(--accent); }

/* NAV */
nav {
  padding: 1.6rem 0 1.4rem;
  border-bottom: 1px solid var(--rule);
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
}
.nav-name { font-size: var(--size-body); color: var(--text); border-bottom: none; }
.nav-links { display: flex; flex-wrap: wrap; gap: 0.3rem 1.2rem; list-style: none; }
.nav-links a {
  font-size: var(--size-caption);
  font-variant: small-caps;
  letter-spacing: 0.1em;
  color: var(--muted);
  border-bottom: none;
  padding: 0.3rem 0;
  position: relative;
}
.nav-links a::after {
  content: "";
  position: absolute;
  bottom: 0; left: 0;
  width: 0; height: 1px;
  background: var(--accent);
  transition: width 0.2s ease;
}
.nav-links a:hover { color: var(--text); }
.nav-links a:hover::after { width: 100%; }

/* SECTION LABEL */
.section-label {
  font-size: var(--size-caption);
  font-variant: small-caps;
  letter-spacing: 0.12em;
  color: var(--muted);
  display: block;
  margin-bottom: 1rem;
}

/* BLOG INDEX (listing) */
.blog-index { padding: var(--gap) 0 1rem; }
.blog-index-intro {
  font-size: var(--size-body);
  color: var(--text-sec);
  max-width: 34em;
  margin-bottom: 1.5rem;
}

.writing-entry { margin-bottom: 1.25rem; }
.writing-date {
  font-family: 'Courier New', Courier, monospace;
  font-size: calc(var(--size-caption) * 0.88);
  color: var(--muted);
  display: block;
  margin-bottom: 0.1rem;
  letter-spacing: 0.04em;
}
.writing-title { font-size: var(--size-body); color: var(--text); display: block; margin-bottom: 0.08rem; }
.writing-desc  { font-size: var(--size-caption); color: var(--text-sec); }

/* BLOG POST */
.blog-article { padding: 2.5rem 0 var(--gap); }

.back-link {
  font-size: var(--size-caption);
  font-variant: small-caps;
  letter-spacing: 0.1em;
  color: var(--muted);
  border-bottom: none;
  display: inline-block;
  margin-bottom: 2rem;
}
.back-link:hover { color: var(--accent); }

.blog-header { margin-bottom: 2rem; }

.blog-title {
  font-size: clamp(1.6rem, 4vw, 2.1rem);
  font-weight: 500;
  line-height: 1.25;
  color: var(--text);
  margin-bottom: 0.75rem;
  max-width: 22em;
}

.blog-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem 1rem;
  font-size: var(--size-caption);
  color: var(--muted);
}

.blog-date {
  font-family: 'Courier New', Courier, monospace;
  letter-spacing: 0.04em;
}

.blog-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.6rem;
  list-style: none;
}

.blog-tags li {
  font-size: calc(var(--size-caption) * 0.88);
  font-variant: small-caps;
  letter-spacing: 0.06em;
  color: var(--text-sec);
  border: 1px solid var(--rule);
  padding: 0.08rem 0.5rem;
  border-radius: 2px;
}

/* PROSE */
.blog-body { color: var(--text); }

.blog-body p {
  font-size: var(--size-body);
  color: var(--text);
  max-width: 34em;
  margin-bottom: 1.1rem;
}

.blog-body h2,
.blog-body h3,
.blog-body h4 {
  font-weight: 500;
  color: var(--text);
  margin-top: 2rem;
  margin-bottom: 0.75rem;
  line-height: 1.3;
  max-width: 28em;
}
.blog-body h2 { font-size: 1.35rem; }
.blog-body h3 { font-size: 1.15rem; }
.blog-body h4 { font-size: 1rem; font-variant: small-caps; letter-spacing: 0.06em; color: var(--text-sec); }

.blog-body a { color: var(--accent); border-bottom: 1px solid var(--rule); }
.blog-body a:hover { border-bottom-color: var(--accent); }

.blog-body ul,
.blog-body ol { margin: 0 0 1.1rem 1.4rem; max-width: 34em; }
.blog-body li { margin-bottom: 0.35rem; }

.blog-body blockquote {
  border-left: 2px solid var(--accent);
  padding-left: 1rem;
  margin: 1.25rem 0;
  color: var(--text-sec);
  font-style: italic;
  max-width: 32em;
}
.blog-body blockquote p { color: var(--text-sec); margin-bottom: 0.5rem; }

.blog-body hr {
  border: none;
  border-top: 1px solid var(--rule);
  margin: 2rem 0;
}

.blog-body code {
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.88em;
  background: var(--surface);
  padding: 0.08em 0.35em;
  border-radius: 2px;
  color: var(--text);
}

.blog-body pre {
  font-family: 'Courier New', Courier, monospace;
  font-size: calc(var(--size-caption) * 0.95);
  line-height: 1.6;
  background: var(--surface);
  border-left: 2px solid var(--accent);
  padding: 0.85rem 1rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 1.25rem 0;
  max-width: 100%;
}
.blog-body pre code {
  background: transparent;
  padding: 0;
  border-radius: 0;
  font-size: inherit;
}

.blog-body pre.mermaid {
  border-left: none;
  background: var(--bg);
  padding: 1rem;
  text-align: center;
  font-family: inherit;
}

.blog-body img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 1.5rem 0;
  border: 1px solid var(--rule);
  border-radius: 2px;
}

.blog-body figure { margin: 1.5rem 0; }
.blog-body figcaption {
  font-size: var(--size-caption);
  color: var(--muted);
  margin-top: 0.4rem;
  text-align: center;
}

.blog-body table {
  border-collapse: collapse;
  font-size: var(--size-caption);
  margin: 1.25rem 0;
  width: auto;
}
.blog-body thead { border-top: 1px solid var(--text-sec); border-bottom: 1px solid var(--rule); }
.blog-body th {
  font-variant: small-caps;
  letter-spacing: 0.06em;
  color: var(--text-sec);
  font-weight: 400;
  text-align: left;
  padding: 0.25rem 0.75rem 0.25rem 0;
}
.blog-body td {
  padding: 0.2rem 0.75rem 0.2rem 0;
  color: var(--text);
  border-bottom: 1px solid var(--rule);
}
.blog-body tbody tr:last-child td { border-bottom: 1px solid var(--text-sec); }

/* Italic reserved per CLAUDE.md; em/i in blog prose render as weighted emphasis. */
.blog-body em, .blog-body i { font-style: normal; font-weight: 500; }
.blog-body strong, .blog-body b { font-weight: 600; }

.blog-body sup, .blog-body sub { font-size: 0.75em; line-height: 0; }

.blog-body .footnote-ref { font-size: 0.75em; }
.blog-body .footnotes {
  margin-top: 3rem;
  padding-top: 1rem;
  border-top: 1px solid var(--rule);
  font-size: var(--size-caption);
  color: var(--text-sec);
}
.blog-body .footnotes ol { margin-left: 1.2rem; }

/* FOOTER */
footer { border-top: 1px solid var(--rule); padding: 2.5rem 0 2rem; margin-top: 3rem; }
.footer-contact { margin-bottom: 1.5rem; }
.footer-contact p {
  font-size: var(--size-caption);
  color: var(--text-sec);
  line-height: 1.85;
}
.footer-contact a { color: var(--accent); border-bottom: none; }
.footer-contact a:hover { border-bottom-color: var(--accent); }
.footer-contact .contact-label {
  font-variant: small-caps;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-right: 0.35rem;
}
.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1.4rem;
  list-style: none;
  margin-bottom: 1.25rem;
}
.footer-links a {
  font-size: var(--size-caption);
  font-variant: small-caps;
  letter-spacing: 0.08em;
  color: var(--text-sec);
}
.footer-links a:hover { color: var(--accent); }
.footer-copy { font-size: calc(var(--size-caption) * 0.88); color: var(--muted); }
