/* latin-ext */
@font-face {
  font-family: 'IBM Plex Sans';
  font-style: normal;
  font-weight: 400 600;
  font-stretch: 100%;
  font-display: swap;
  src: url(/fonts/ibm-plex-sans-normal-400-600-latin-ext.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* latin */
@font-face {
  font-family: 'IBM Plex Sans';
  font-style: normal;
  font-weight: 400 600;
  font-stretch: 100%;
  font-display: swap;
  src: url(/fonts/ibm-plex-sans-normal-400-600-latin.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* latin-ext */
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url(/fonts/jetbrains-mono-normal-400-600-latin-ext.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* latin */
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url(/fonts/jetbrains-mono-normal-400-600-latin.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* latin-ext */
@font-face {
  font-family: 'Source Serif 4';
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url(/fonts/source-serif-4-italic-400-latin-ext.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* latin */
@font-face {
  font-family: 'Source Serif 4';
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url(/fonts/source-serif-4-italic-400-latin.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* latin-ext */
@font-face {
  font-family: 'Source Serif 4';
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url(/fonts/source-serif-4-normal-400-600-latin-ext.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* latin */
@font-face {
  font-family: 'Source Serif 4';
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url(/fonts/source-serif-4-normal-400-600-latin.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* Adapted from the supplied davidrhp.com design artifact. */
/* ───────── design tokens ───────── */
  :root {
    color-scheme: light dark;
    --maxw: 680px;
    --font-serif: "Source Serif 4", Georgia, "Times New Roman", serif;
    --font-sans: "IBM Plex Sans", system-ui, -apple-system, sans-serif;
    --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
    --font-body: var(--font-serif);
    --font-head: var(--font-serif);

    --accent: #7d2935;

    --bg: oklch(0.992 0.003 85);
    --surface: oklch(0.972 0.004 85);
    --text: oklch(0.28 0.012 75);
    --muted: oklch(0.505 0.012 75);
    --faint: oklch(0.55 0.01 75);
    --border: oklch(0.9 0.006 80);
    --hairline: oklch(0.93 0.004 80);
    --code-bg: oklch(0.967 0.005 85);
    --code-text: oklch(0.33 0.012 75);
    --link: var(--accent);

    --tok-com: oklch(0.62 0.012 75);
    --tok-kw: oklch(0.5 0.13 300);
    --tok-str: oklch(0.5 0.1 150);
    --tok-fn: oklch(0.5 0.12 250);
    --tok-type: oklch(0.52 0.1 205);
    --tok-num: oklch(0.55 0.11 62);
  }
  @media (prefers-color-scheme: dark) {
  :root {
    --bg: oklch(0.179 0.006 80);
    --surface: oklch(0.214 0.007 80);
    --text: oklch(0.91 0.006 85);
    --muted: oklch(0.645 0.012 80);
    --faint: oklch(0.62 0.01 80);
    --border: oklch(0.3 0.008 80);
    --hairline: oklch(0.255 0.007 80);
    --code-bg: oklch(0.224 0.008 80);
    --code-text: oklch(0.86 0.008 85);
    --link: color-mix(in oklab, var(--accent) 55%, white);

    --tok-com: oklch(0.52 0.012 80);
    --tok-kw: oklch(0.74 0.12 300);
    --tok-str: oklch(0.76 0.1 150);
    --tok-fn: oklch(0.74 0.12 250);
    --tok-type: oklch(0.76 0.1 205);
    --tok-num: oklch(0.78 0.11 62);
  }
  }

  /* ───────── reset / base ───────── */
  * { box-sizing: border-box; }
  html { -webkit-text-size-adjust: 100%; scroll-padding-top: 84px; }
  body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 18px;
    line-height: 1.65;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    transition: background-color .3s ease, color .3s ease;
  }
  ::selection { background: color-mix(in oklab, var(--accent) 22%, transparent); }
  a { color: var(--link); text-decoration: none; }
  a:hover { text-decoration: underline; text-underline-offset: 2px; }

  .wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 28px; }

  /* ───────── header ───────── */
  .site-head {
    position: sticky; top: 0; z-index: 20;
    background: color-mix(in oklab, var(--bg) 80%, transparent);
    -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
    border-bottom: 1px solid transparent;
    transition: border-color .3s ease, background-color .3s ease;
  }
  .site-head[data-scrolled="1"] { border-bottom-color: var(--hairline); }
  .site-head .wrap {
    display: flex; align-items: center; justify-content: space-between;
    height: 64px;
  }
  .brand {
    display: inline-flex; align-items: center; gap: 9px;
    font-family: var(--font-mono); font-weight: 600; font-size: 15px;
    letter-spacing: -.01em; color: var(--text); cursor: pointer;
    background: none; border: 0; padding: 0;
  }
  .brand:hover { text-decoration: none; }
  .brand .mark {
    width: 11px; height: 11px; border-radius: 2.5px;
    background: var(--accent);
    transition: transform .25s cubic-bezier(.3,.7,.4,1);
  }
  .brand:hover .mark { transform: rotate(45deg); }

  /* ───────── homepage intro ───────── */
  main { min-height: 70vh; }
  .intro { padding: 80px 0 24px; }
  .intro .lead {
    margin: 0; max-width: 24em;
    font-family: var(--font-head); font-weight: 500; font-size: 25px;
    line-height: 1.45; letter-spacing: -.012em; color: var(--text);
    text-wrap: pretty;
  }
  .intro .links {
    display: flex; flex-wrap: wrap; gap: 18px; margin-top: 22px;
    font-family: var(--font-mono); font-size: 13px;
  }
  .intro .links a {
    display: inline-flex; align-items: center; gap: 5px;
    color: var(--muted); border-bottom: 1px solid var(--border); padding-bottom: 1px;
  }
  .intro .links a:hover { color: var(--text); border-color: var(--text); text-decoration: none; }
  .intro .links a .arr { font-size: 11px; opacity: .7; }

  /* ───────── writing list ───────── */
  .section-label {
    margin: 0;
    font-family: var(--font-mono); font-size: 11px; font-weight: 600;
    letter-spacing: .14em; text-transform: uppercase; color: var(--faint);
    padding: 40px 0 8px;
  }
  .post-list { list-style: none; margin: 0; padding: 0; }
  .post-item { border-top: 1px solid var(--hairline); }
  .post-item:last-child { border-bottom: 1px solid var(--hairline); }
  .post-link {
    display: block; padding: 26px 0; cursor: pointer; color: inherit;
    position: relative;
  }
  .post-link:hover { text-decoration: none; }
  .post-meta-top {
    display: flex; align-items: center; gap: 10px;
    font-family: var(--font-mono); font-size: 12px; color: var(--faint);
    margin-bottom: 8px;
  }
  .post-meta-top .dot { width: 3px; height: 3px; border-radius: 50%; background: currentColor; opacity: .6; }
  .post-title {
    font-family: var(--font-head); font-weight: 600; font-size: 23px;
    line-height: 1.28; letter-spacing: -.012em; margin: 0 0 7px;
    transition: color .15s ease;
  }
  .post-link:hover .post-title { color: var(--link); }
  .post-excerpt { margin: 0; color: var(--muted); font-size: 16.5px; line-height: 1.55; text-wrap: pretty; }
  .tags { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 13px; }
  .tag {
    font-family: var(--font-mono); font-size: 11px; color: var(--faint);
    background: var(--surface); border: 1px solid var(--hairline);
    padding: 2px 8px; border-radius: 999px; letter-spacing: .01em;
  }

  /* ───────── post / article ───────── */
  .reading-progress {
    position: fixed; top: 0; left: 0; height: 2px; width: 0;
    background: var(--accent); z-index: 30; pointer-events: none;
  }
  .back-link {
    display: inline-flex; align-items: center; gap: 7px; margin: 40px 0 0;
    font-family: var(--font-mono); font-size: 13px; color: var(--muted);
  }
  .back-link:hover { color: var(--text); text-decoration: none; }
  .article-head { padding: 22px 0 6px; }
  .article-head h1 {
    font-family: var(--font-head); font-weight: 600; font-size: 34px;
    line-height: 1.18; letter-spacing: -.02em; margin: 0 0 16px; text-wrap: balance;
  }
  .article-meta {
    display: flex; align-items: center; flex-wrap: wrap; gap: 10px;
    font-family: var(--font-mono); font-size: 12.5px; color: var(--faint);
  }
  .article-meta .dot { width: 3px; height: 3px; border-radius: 50%; background: currentColor; opacity: .6; }

  .prose { padding: 8px 0 8px; font-size: 18.5px; line-height: 1.72; }
  .prose > *:first-child { margin-top: 0; }
  .prose p { margin: 0 0 22px; text-wrap: pretty; }
  .prose h2 {
    font-family: var(--font-head); font-weight: 600; font-size: 23px;
    letter-spacing: -.012em; line-height: 1.3; margin: 44px 0 14px;
  }
  .prose h3 {
    font-family: var(--font-head); font-weight: 600; font-size: 19px;
    margin: 32px 0 10px;
  }
  .prose a { border-bottom: 1px solid color-mix(in oklab, var(--link) 35%, transparent); }
  .prose a:hover { text-decoration: none; border-bottom-color: var(--link); }
  .prose blockquote {
    margin: 26px 0; padding: 2px 0 2px 22px;
    border-left: 2px solid var(--accent);
    color: var(--muted); font-style: italic;
  }
  .prose blockquote p { margin: 0; }
  .prose ul, .prose ol { margin: 0 0 22px; padding-left: 1.3em; }
  .prose li { margin: 0 0 8px; }
  .prose code {
    font-family: var(--font-mono); font-size: .82em;
    background: var(--code-bg); border: 1px solid var(--hairline);
    padding: 1.5px 5px; border-radius: 5px; color: var(--code-text);
  }
  .prose pre {
    margin: 26px 0; padding: 20px 22px; overflow-x: auto;
    background: var(--code-bg); border: 1px solid var(--hairline);
    border-radius: 12px; line-height: 1.6;
  }
  .prose pre code {
    font-family: var(--font-mono); font-size: 13.5px;
    background: none; border: 0; padding: 0; color: var(--code-text);
    white-space: pre;
  }
  .tok-com { color: var(--tok-com); font-style: italic; }
  .tok-kw  { color: var(--tok-kw); }
  .tok-str { color: var(--tok-str); }
  .tok-fn  { color: var(--tok-fn); }
  .tok-type{ color: var(--tok-type); }
  .tok-num { color: var(--tok-num); }

  .substack-note {
    margin: 36px 0 0; padding: 16px 18px; border: 1px solid var(--hairline);
    border-radius: 12px; background: var(--surface);
    display: flex; align-items: center; justify-content: space-between; gap: 14px;
    font-family: var(--font-mono); font-size: 12.5px; color: var(--muted);
  }
  .substack-note a { color: var(--link); white-space: nowrap; }

  /* prev / next */
  .post-nav {
    display: grid; grid-template-columns: 1fr 1fr; gap: 14px;
    margin: 48px 0 0; padding-top: 28px; border-top: 1px solid var(--hairline);
  }
  .post-nav a {
    display: block; color: inherit; padding: 16px 18px; border-radius: 12px;
    border: 1px solid var(--hairline); background: var(--surface);
    transition: border-color .15s, transform .15s;
  }
  .post-nav a:hover { text-decoration: none; border-color: var(--border); transform: translateY(-1px); }
  .post-nav .pn-label { font-family: var(--font-mono); font-size: 11px; color: var(--faint); letter-spacing: .04em; }
  .post-nav .pn-title { font-family: var(--font-head); font-size: 16px; font-weight: 600; margin-top: 5px; line-height: 1.3; }
  .post-nav .next { text-align: right; }
  .post-nav .next.empty, .post-nav .prev.empty { visibility: hidden; }

  /* ───────── footer ───────── */
  footer {
    margin-top: 80px; border-top: 1px solid var(--hairline);
    padding: 28px 0 56px;
  }
  footer .wrap {
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
    flex-wrap: wrap;
    font-family: var(--font-mono); font-size: 12px; color: var(--faint);
  }
  footer .f-links { display: flex; gap: 16px; }
  footer .f-links a { color: var(--muted); }
  footer .f-links a:hover { color: var(--text); text-decoration: none; }

  /* fade-in for view changes */
  @media (prefers-reduced-motion: no-preference) {
    .view-anim { animation: fade .35s ease both; }
    @keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
  }

  @media (max-width: 560px) {
    body { font-size: 17px; }
    .intro { padding: 52px 0 16px; }
    .intro .lead { font-size: 22px; }
    .article-head h1 { font-size: 27px; }
    .post-nav { grid-template-columns: 1fr; }
    .post-nav .next { text-align: left; }
  }

/* Production additions: keyboard access, Markdown media, and overflow safety.
   Metadata and dark-mode links use stronger contrast than the design mockup. */
:focus-visible { outline: 2px solid var(--link); outline-offset: 5px; border-radius: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.skip-link { position: fixed; top: 8px; left: 16px; z-index: 100; padding: 8px 14px; background: var(--bg); color: var(--link); border: 1px solid var(--border); transform: translateY(-160%); font-family: var(--font-mono); font-size: 13px; }
.skip-link:focus { transform: translateY(0); }
.intro .lead p { margin: 0; }
.intro .lead p + p { margin-top: 1em; }
.intro .links a::after { content: "↗"; font-size: 11px; opacity: .7; }
.wrap.intro { padding-right: 28px; padding-left: 28px; }
.brand .mark { flex-shrink: 0; }
.back-link svg { width: 18px; height: 18px; }
.post-meta-top { flex-wrap: wrap; }
.post-title, .post-excerpt, .article-head h1, .pn-title { overflow-wrap: anywhere; }
.prose { overflow-wrap: anywhere; }
.prose pre { overflow-wrap: normal; }
.prose img, .prose video { max-width: 100%; height: auto; border-radius: 8px; }
.prose figure { margin: 26px 0; }
.prose figcaption { color: var(--muted); font-size: 14px; }
.prose hr { border: 0; border-top: 1px solid var(--hairline); margin: 32px 0; }
.prose table { display: block; max-width: 100%; overflow-x: auto; border-collapse: collapse; margin: 26px 0; font-size: 16px; }
.prose th, .prose td { padding: 8px 12px; border: 1px solid var(--border); text-align: left; }
.prose th { background: var(--surface); font-weight: 600; }
.prose input[type="checkbox"] { accent-color: var(--accent); }
.empty-state, .error-state { padding: 28px 0; color: var(--muted); }
.section-label { margin: 0; }
@supports (animation-timeline: scroll()) {
  .reading-progress { width: 100%; transform: scaleX(0); transform-origin: left; animation: reading-progress linear both; animation-timeline: scroll(root block); }
  @keyframes reading-progress { to { transform: scaleX(1); } }
}
@media (max-width: 560px) {
  .post-nav .empty, .post-nav > span:empty { display: none; }
  .substack-note { align-items: flex-start; flex-direction: column; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
  .brand:hover .mark, .post-nav a:hover { transform: none; }
  .reading-progress { display: none; }
}

