:root {
  --bg: #f5f5ee;
  --bg-translucent: rgba(245, 245, 238, 0.92);
  --ink: #000000;
  --ink-muted: #6b6b6b;
  --link: #16140f;
  --link-underline: #7e8590;
  --link-underline-hover: #4b5158;
  --rule: #e2e2dc;

  --orange: #FF6600;
  --orange-hover: #E65C00;

  --footer-bg: #000000;
  --footer-ink: #f5f5ee;
  --footer-ink-muted: #888;
  --footer-rule: #2a2a2a;

  --font-sans: "Avenir Next", Avenir, "Nunito Sans", -apple-system,
               BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-serif: "Source Serif 4", "Source Serif Pro", Georgia, "Times New Roman", serif;

  --article-max: 640px;
  --shell-max: 1120px;
  --nav-height: 56px;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  font-size: 16px;
  font-weight: 500;
  line-height: 1.7;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

@media (min-width: 768px) {
  body { font-size: 17px; }
}

strong, b {
  font-weight: 900;
}

a {
  color: var(--link);
  text-decoration: underline;
  text-decoration-color: var(--link-underline);
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
  transition: text-decoration-color 0.15s ease;
}

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

/* ---------- Top nav ---------- */

.nav {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--nav-height);
  display: flex;
  align-items: center; /* vertically center the HStack inside the 56px bar */
  border-bottom: 1px solid var(--rule);
  background: var(--bg-translucent);
  backdrop-filter: saturate(180%) blur(10px);
  -webkit-backdrop-filter: saturate(180%) blur(10px);
}

.nav-inner {
  width: 100%;
  max-width: var(--shell-max);
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center; /* vertically center button + nav-start group */
  gap: 24px;
}

/* inner group: logo + nav links share a baseline (= bottom of caps) */
.nav-start {
  display: flex;
  align-items: baseline;
  gap: 24px;
}

.btn {
  margin-left: auto;
}

.nav-logo {
  font-size: 20px;
  font-weight: 700;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: -0.01em;
  line-height: 1;
  display: inline-flex;
  align-items: center;
}

.nav-logo:hover {
  color: var(--ink);
  text-decoration: none;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 22px;
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 14px;
  font-weight: 500;
  line-height: 1;
  letter-spacing: 0.025rem;
}

.nav-links a {
  text-decoration: none;
  color: var(--ink);
  line-height: 1;
}

.nav-links a:hover {
  color: var(--orange);
  text-decoration: none;
}

.nav-spacer {
  flex: 1;
}

.btn {
  display: inline-flex;
  align-items: center;
  background: var(--ink);
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  font-size: 14px;
  padding: 9px 16px;
  border-radius: 8px;
  border: 0;
  cursor: pointer;
  line-height: 1;
}

.btn:hover {
  background: #333;
  color: #fff;
  text-decoration: none;
}

@media (max-width: 720px) {
  .nav-links { display: none; }
}

/* ---------- Page shell ---------- */

main {
  max-width: var(--article-max);
  margin: 0 auto;
  padding: 32px 24px 64px;
}

@media (min-width: 768px) {
  main { padding: 56px 24px 96px; }
}

/* ---------- Page title block (centered on long-form pages) ---------- */

.page-title {
  text-align: center;
  margin-bottom: 2.5em;
}

@media (min-width: 768px) {
  .page-title { margin-bottom: 3em; }
}

/* ---------- Typography ---------- */

h1, h2 {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 600;
  letter-spacing: -0.005em;
  color: var(--ink);
  margin: 0;
}

h1 {
  font-size: clamp(2.25rem, 4vw, 3rem);
  line-height: 1.15;
  margin-bottom: 0.5em;
  text-wrap: balance;
}

h2 {
  font-size: 1.75rem;
  line-height: 1.2;
  margin-top: 2em;
  margin-bottom: 0.75em;
}

@media (min-width: 768px) {
  h2 { font-size: 2rem; }
}

h3, h4 {
  font-family: var(--font-sans);
  font-style: normal;
  color: var(--ink);
  margin: 0;
}

h3 {
  font-size: 1em;
  font-weight: 700;
  line-height: 1.7;
  margin-top: 2.5em;
  margin-bottom: 1em;
}

h4 {
  font-size: 1em;
  font-weight: 400;
  color: var(--ink-muted);
  line-height: 1.5;
  margin-top: 1.5em;
  margin-bottom: 0.5em;
}

p {
  margin: 1.25em 0;
}

p:first-child {
  margin-top: 0;
}

.lede {
  font-size: 1.15em;
  font-weight: 500;
  line-height: 1.6;
  color: var(--ink);
  margin-bottom: 2em;
}

ul, ol {
  margin: 1.25em 0;
  padding-left: 1.625em;
}

li {
  margin-bottom: 0.4em;
}

code {
  font-family: "SF Mono", Menlo, Consolas, Monaco, monospace;
  font-size: 0.9em;
  background: rgba(0, 0, 0, 0.05);
  padding: 0.1em 0.35em;
  border-radius: 4px;
}

/* ---------- About-page two-column with sticky TOC ---------- */

.with-sidebar {
  display: block;
}

.toc-sidebar {
  display: none;
}

@media (min-width: 1024px) {
  .with-sidebar {
    display: grid;
    grid-template-columns: 160px var(--article-max);
    column-gap: 48px;
    align-items: start;
    max-width: calc(160px + 48px + var(--article-max));
    margin: 0 auto;
  }

  main:has(.with-sidebar) {
    max-width: none;
    padding-left: 24px;
    padding-right: 24px;
  }

  .toc-sidebar {
    display: block;
    position: sticky;
    top: calc(var(--nav-height) + 24px);
    width: 160px;
    font-size: 14px;
  }

  .toc-sidebar ul {
    list-style: none;
    padding: 0;
    margin: 0;
  }

  .toc-sidebar li {
    margin-bottom: 0.6em;
  }

  .toc-sidebar a {
    text-decoration: none;
    color: var(--ink-muted);
    font-weight: 500;
    line-height: 1.4;
    display: block;
    transition: color 0.15s ease;
  }

  .toc-sidebar a:hover {
    color: var(--ink);
    text-decoration: none;
  }
}

/* fallback inline TOC for narrow viewports / pages without sidebar */
.toc {
  list-style: none;
  padding: 0;
  margin: 0 0 2em 0;
}

.toc li { margin-bottom: 0.25em; }

.toc a {
  text-decoration: none;
  color: var(--ink);
  font-weight: 500;
}

.toc a:hover {
  color: var(--orange);
  text-decoration: none;
}

@media (min-width: 1024px) {
  /* hide inline TOC when sidebar is visible */
  .with-sidebar .toc { display: none; }
}

/* ---------- Blog index ---------- */

.post-list {
  list-style: none;
  padding: 0;
  margin: 2em 0 0 0;
}

.post-list li {
  padding: 1.75em 0;
  border-bottom: 1px solid var(--rule);
  margin: 0;
}

.post-list li:first-child {
  border-top: 1px solid var(--rule);
}

.post-meta {
  font-size: 0.85em;
  font-weight: 500;
  color: var(--ink-muted);
  margin-bottom: 0.4em;
  letter-spacing: 0.02em;
}

.post-list h3 {
  font-family: var(--font-serif);
  font-style: italic;
  margin: 0 0 0.4em 0;
  font-size: 1.5em;
  font-weight: 600;
  line-height: 1.25;
}

.post-list h3 a {
  text-decoration: none;
  color: var(--ink);
}

.post-list h3 a:hover {
  text-decoration: underline;
  text-decoration-color: var(--link-underline);
}

.post-excerpt {
  color: var(--ink);
  font-weight: 500;
  margin: 0;
}

/* ---------- Post page ---------- */

.post-header {
  margin-bottom: 2em;
  text-align: center;
}

.post-header .post-meta {
  margin-bottom: 0.75em;
}

.post-header h1 {
  margin-bottom: 0.5em;
}

.post-header .lede {
  text-align: left;
  margin-top: 1em;
}

article p {
  margin-bottom: 1.25em;
}

/* ---------- Footer ---------- */

footer {
  background: var(--footer-bg);
  color: var(--footer-ink);
}

.footer-inner {
  max-width: var(--shell-max);
  margin: 0 auto;
  padding: 64px 24px 32px;
}

.footer-tagline {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 1.75em;
  font-weight: 600;
  color: var(--footer-ink);
  margin: 0 0 2em 0;
  line-height: 1.2;
}

.footer-cols {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 32px;
  margin-bottom: 48px;
}

.footer-col h4 {
  font-size: 0.8em;
  font-weight: 700;
  color: var(--footer-ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 0 0 1em 0;
}

.footer-col ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.footer-col li {
  margin-bottom: 0.6em;
  font-size: 0.95em;
}

.footer-col a {
  text-decoration: none;
  color: var(--footer-ink);
  font-weight: 500;
}

.footer-col a:hover {
  color: var(--orange);
  text-decoration: none;
}

.footer-bottom {
  border-top: 1px solid var(--footer-rule);
  padding-top: 24px;
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  font-size: 0.85em;
  font-weight: 500;
  color: var(--footer-ink-muted);
}

.footer-bottom a {
  color: var(--footer-ink);
  text-decoration: none;
  font-weight: 700;
}

.footer-bottom a:hover {
  text-decoration: underline;
  text-decoration-color: var(--footer-ink);
  text-underline-offset: 3px;
}

.footer-bottom .spacer {
  flex: 1;
}
