/* ============================================================
   Personal site — Black & White, Medium-inspired, scroll-animated
   ============================================================ */

:root {
  /* Palette: pure B/W with grayscale tones */
  --bg:        #ffffff;
  --bg-soft:   #fafafa;
  --bg-tint:   #f4f4f3;
  --ink:       #111111;
  --ink-soft:  #555555;
  --ink-mute:  #888888;
  --ink-faint: #c9c9c9;
  --rule:      #ececec;
  --rule-strong: #d4d4d4;
  --accent:    #111111;       /* black accent */
  --accent-on: #ffffff;       /* text on accent */

  /* Type: Charter-like serif + Inter + Mono */
  --serif:   "Source Serif 4", "Source Serif Pro", "Charter", "Iowan Old Style", "Georgia", ui-serif, serif;
  --sans:    "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", ui-sans-serif, system-ui, sans-serif;
  --mono:    "JetBrains Mono", ui-monospace, "SFMono-Regular", "Menlo", "Consolas", monospace;

  /* Layout: Medium-ish reading column */
  --measure: 680px;
  --hero-measure: 760px;
  --gutter:  clamp(1.25rem, 4vw, 2.5rem);
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
img, svg, video { max-width: 100%; height: auto; display: block; }

html {
  font-size: 17px;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-weight: 400;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--ink);
  text-decoration: none;
  background-image: linear-gradient(transparent calc(100% - 1px), var(--ink) 1px);
  background-size: 100% 100%;
  background-repeat: no-repeat;
  transition: background-image 200ms ease;
}
a:hover { background-image: linear-gradient(transparent calc(100% - 1px), var(--ink-soft) 1px); }
.prose a, .about a, .post-meta a, .hero-meta a {
  background-image: linear-gradient(transparent calc(100% - 1px), var(--ink) 1px);
}

.skip-link {
  position: absolute; top: -100px; left: 8px; z-index: 1000;
  background: var(--ink); color: var(--bg); padding: 8px 14px; border-radius: 4px;
  text-decoration: none; font-weight: 500;
  transition: top .15s ease;
}
.skip-link:focus { top: 8px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }

/* ----- Layout shell ----- */

.site {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 0 var(--gutter);
}
.site--wide { max-width: var(--hero-measure); }

/* ----- Site header / nav (minimal) ----- */
.site-header {
  padding: clamp(1.5rem, 4vw, 2rem) 0 0;
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap;
}
.site-header__brand {
  background: none;
}
.site-header__logo {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}
.site-header__brand:hover { background: none; opacity: 0.7; }
.site-header__nav {
  display: flex; gap: 1.5rem; flex-wrap: wrap;
  font-family: var(--sans);
  font-size: 0.86rem;
  color: var(--ink-soft);
}
.site-header__nav a {
  color: var(--ink-soft);
  background: none;
}
.site-header__nav a:hover, .site-header__nav a[aria-current="page"] {
  color: var(--ink);
  background: none;
}

.site-footer {
  margin-top: clamp(5rem, 12vw, 8rem);
  padding: 2.5rem 0 3rem;
  border-top: 1px solid var(--rule);
  font-size: 0.85rem;
  color: var(--ink-mute);
  display: flex; flex-wrap: wrap; gap: 1rem 2rem; justify-content: space-between;
}
.site-footer a { color: var(--ink-soft); background: none; }
.site-footer a:hover { color: var(--ink); }

/* ----- Nav RSS icon ----- */
.nav-rss {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 4px;
  color: var(--ink-soft);
  transition: color 0.2s ease, background 0.2s ease;
  margin-left: 0.25rem;
}
.nav-rss:hover {
  color: var(--ink);
  background: var(--bg-tint);
}
.nav-rss svg {
  width: 16px;
  height: 16px;
}

/* ----- Subscribe section (index page) ----- */
.subscribe-index {
  margin: clamp(2.5rem, 5vw, 4rem) 0 0;
  padding: clamp(1.5rem, 3vw, 2.5rem);
  border: 1px solid var(--rule);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem 2rem;
  background: var(--bg-tint);
}
.subscribe-index__title {
  font-family: var(--serif);
  font-size: clamp(1.1rem, 2vw, 1.4rem);
  font-weight: 600;
  margin: 0 0 0.3rem;
  color: var(--ink);
}
.subscribe-index__copy {
  font-family: var(--sans);
  font-size: 0.88rem;
  color: var(--ink-soft);
  margin: 0;
  max-width: 42ch;
}
.subscribe-index__actions {
  flex-shrink: 0;
}

/* ----- Site banner (stock image) ----- */
.site-banner {
  position: relative;
  margin: 0 calc(-1 * var(--gutter)) clamp(1.5rem, 3vw, 2rem);
  height: clamp(180px, 24vw, 260px);
  background: var(--bg);
  overflow: hidden;
}
.site-banner__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  filter: grayscale(1) brightness(1.15) contrast(0.75);
  opacity: 0.5;
  -webkit-mask-image: linear-gradient(180deg, transparent 0%, #000 20%, #000 80%, transparent 100%);
  mask-image: linear-gradient(180deg, transparent 0%, #000 20%, #000 80%, transparent 100%);
  transition: opacity 0.5s ease;
}
.site-banner:hover .site-banner__img {
  opacity: 0.72;
}

/* ----- Blog filter bar ----- */
.blog-filters {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: clamp(1.5rem, 3vw, 2.5rem);
  padding-bottom: clamp(1rem, 2vw, 1.5rem);
  border-bottom: 1px solid var(--rule);
}
.blog-filters__cats {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}
.filter-pill {
  font-family: var(--sans);
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  padding: 0.35em 0.85em;
  border: 1px solid var(--rule-strong);
  border-radius: 100px;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  transition: all 0.2s ease;
}
.filter-pill:hover {
  border-color: var(--ink);
  color: var(--ink);
}
.filter-pill.is-active {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--bg);
}
.sort-select {
  font-family: var(--sans);
  font-size: 0.78rem;
  font-weight: 500;
  padding: 0.35em 1.8em 0.35em 0.7em;
  border: 1px solid var(--rule-strong);
  border-radius: 6px;
  background: var(--bg);
  color: var(--ink-soft);
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23999'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.6em center;
  transition: border-color 0.2s ease;
}
.sort-select:hover, .sort-select:focus {
  border-color: var(--ink);
  outline: none;
}
/* Hidden posts during filter */
.posts li[hidden] { display: none; }

/* ----- Hero (Medium-style) ----- */
.hero {
  padding: clamp(3rem, 8vw, 5rem) 0 clamp(2.5rem, 6vw, 4rem);
  margin-bottom: clamp(2.5rem, 5vw, 4rem);
  border-bottom: 1px solid var(--rule);
}
.hero__eyebrow {
  font-family: var(--sans);
  font-size: 0.82rem;
  color: var(--ink-soft);
  margin: 0 0 1.5rem;
  letter-spacing: 0.01em;
}
.hero__title {
  font-family: var(--serif);
  font-weight: 700;
  font-size: clamp(2.2rem, 6vw, 3.6rem);
  line-height: 1.05;
  letter-spacing: -0.025em;
  margin: 0 0 1.5rem;
  color: var(--ink);
}
.hero__lede {
  font-family: var(--serif);
  font-size: clamp(1.15rem, 2.4vw, 1.4rem);
  line-height: 1.55;
  color: var(--ink-soft);
  max-width: 36rem;
  margin: 0 0 1.5rem;
}
.hero__meta {
  font-family: var(--sans);
  font-size: 0.85rem;
  color: var(--ink-mute);
  display: flex; flex-wrap: wrap; gap: 0.4rem 1.2rem;
}

/* Scroll-down hint */
.scroll-hint {
  position: absolute; bottom: 1.5rem;
  left: 50%; transform: translateX(-50%);
  font-family: var(--mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--ink-mute);
  text-decoration: none;
  background: none;
  display: inline-flex; align-items: center; gap: 0.4rem;
  opacity: 0.7;
  transition: opacity 200ms ease, transform 200ms ease;
}
.scroll-hint::after {
  content: "↓";
  display: inline-block;
  animation: scrollBounce 2.2s ease-in-out infinite;
}
.scroll-hint:hover { opacity: 1; }
@keyframes scrollBounce {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(4px); }
}

/* Hero parallax target */
.hero-parallax { will-change: transform; }

/* ----- Post list ----- */
.section-title {
  font-family: var(--sans);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-mute);
  margin: clamp(3rem, 7vw, 4.5rem) 0 1.5rem;
  font-weight: 500;
}
.section-title:first-of-type { margin-top: 0; }

.posts { list-style: none; margin: 0; padding: 0; }
.posts > li { padding: 0; }

.post-card {
  display: block;
  padding: clamp(1.75rem, 4vw, 2.5rem) 0;
  border-bottom: 1px solid var(--rule);
  text-decoration: none;
  background: none;
  color: var(--ink);
}
.posts > li:last-child .post-card { border-bottom: none; }
.posts > li:first-child .post-card { padding-top: 0; }

.post-card__topline {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.5rem;
}
.post-card__category {
  display: inline-block;
  font-family: var(--sans);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink);
  background: #e8e8e6;
  padding: 0.15rem 0.5rem;
  border-radius: 3px;
}
.post-card__date {
  font-family: var(--sans);
  font-size: 0.82rem;
  color: var(--ink-mute);
  letter-spacing: 0.01em;
}
.post-card__title {
  font-family: var(--serif);
  font-weight: 700;
  font-size: clamp(1.5rem, 3.6vw, 1.9rem);
  line-height: 1.18;
  letter-spacing: -0.02em;
  margin: 0 0 0.6rem;
  color: var(--ink);
  background: none;
  transition: color 200ms ease;
}
.post-card:hover .post-card__title { color: var(--ink-soft); }
.post-card__deck {
  font-family: var(--serif);
  font-size: 1.05rem;
  line-height: 1.5;
  color: var(--ink-soft);
  margin: 0 0 0.6rem;
  max-width: 36rem;
}
.post-card__meta {
  display: flex; gap: 0.4rem 1rem; align-items: baseline;
  font-family: var(--sans);
  font-size: 0.8rem;
  color: var(--ink-mute);
}
.post-card__meta .dot { color: var(--ink-faint); }
.post-card__meta .tag {
  color: var(--ink-soft);
  font-size: 0.72rem;
  font-weight: 500;
  background: #f2f2f0;
  padding: 0.1rem 0.45rem;
  border-radius: 3px;
  line-height: 1.6;
}

/* ----- About page ----- */
.about { padding: clamp(2rem, 5vw, 3rem) 0; }
.about h1 {
  font-family: var(--serif);
  font-weight: 700;
  font-size: clamp(2.2rem, 5.5vw, 3rem);
  letter-spacing: -0.025em;
  line-height: 1.1;
  margin: 0 0 1.5rem;
}
.about p { margin: 0 0 1.1rem; line-height: 1.7; }
.about p.lede {
  font-family: var(--serif);
  font-size: 1.3rem;
  line-height: 1.55;
  color: var(--ink);
  font-weight: 400;
}
.about h2 {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 1.4rem;
  letter-spacing: -0.015em;
  margin: 2.5rem 0 0.6rem;
}
.about ul { padding-left: 1.2rem; margin: 0 0 1.2rem; }
.about li { margin-bottom: 0.4rem; }
.about .contact {
  font-family: var(--mono);
  font-size: 0.85rem;
  margin-top: 0.5rem;
  color: var(--ink-soft);
}
.about .contact a { background: none; color: var(--ink); }
.about .contact a:hover { color: var(--ink-soft); }

/* ----- Single post ----- */
.post { padding: clamp(1.5rem, 4vw, 2.5rem) 0 0; }
.post__back {
  display: inline-block;
  font-family: var(--sans);
  font-size: 0.85rem;
  color: var(--ink-mute);
  text-decoration: none;
  background: none;
  margin-bottom: 2.5rem;
}
.post__back:hover { color: var(--ink); }
.post__back::before { content: "← "; }

.post__header {
  margin-bottom: clamp(2.5rem, 5vw, 3.5rem);
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--rule);
}
.post__eyebrow {
  font-family: var(--sans);
  font-size: 0.85rem;
  color: var(--ink-mute);
  margin: 0 0 1rem;
  letter-spacing: 0.01em;
}
.post__title {
  font-family: var(--serif);
  font-weight: 700;
  font-size: clamp(2rem, 5.2vw, 3rem);
  line-height: 1.1;
  letter-spacing: -0.025em;
  margin: 0 0 1rem;
}
.post__deck {
  font-family: var(--serif);
  font-size: clamp(1.15rem, 2.4vw, 1.35rem);
  line-height: 1.5;
  color: var(--ink-soft);
  margin: 0 0 1.5rem;
  max-width: 34rem;
  font-style: italic;
}
.post__meta {
  display: flex; flex-wrap: wrap; gap: 0.4rem 1rem;
  font-family: var(--sans);
  font-size: 0.85rem;
  color: var(--ink-mute);
}
.post__meta .dot { color: var(--ink-faint); }
.post__meta .tag {
  color: var(--ink-soft);
  font-size: 0.78rem;
  font-weight: 500;
  background: #f2f2f0;
  padding: 0.12rem 0.5rem;
  border-radius: 3px;
  line-height: 1.5;
}

/* ----- Post hero banner ----- */
.post__banner {
  margin: 0 calc(-1 * var(--gutter)) clamp(2.5rem, 5vw, 3.5rem);
  overflow: hidden;
  background: var(--bg-tint);
}
.post__banner img {
  display: block;
  width: 100%;
  height: clamp(260px, 42vw, 460px);
  object-fit: cover;
  filter: grayscale(1) contrast(1.05);
  transition: filter 0.6s ease;
  background: var(--bg-tint);
}
.post__banner:hover img {
  filter: grayscale(0.25) contrast(1);
}
@media (min-width: 900px) {
  .post__banner {
    margin-left: calc(-1 * clamp(2rem, 6vw, 5rem));
    margin-right: calc(-1 * clamp(2rem, 6vw, 5rem));
  }
}

/* ----- Long-form prose ----- */
.prose {
  font-family: var(--serif);
  font-size: 1.125rem;
  line-height: 1.75;
  color: var(--ink);
}
.prose p { margin: 0 0 1.4rem; }
.prose h2 {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 1.55rem;
  letter-spacing: -0.015em;
  line-height: 1.25;
  margin: 2.8rem 0 0.9rem;
  scroll-margin-top: 5rem;
}
.prose h3 {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: -0.005em;
  margin: 2rem 0 0.5rem;
}
.prose blockquote {
  border-left: 2px solid var(--ink);
  margin: 1.8rem 0 1.8rem -0.5rem;
  padding: 0.25rem 0 0.25rem 1.5rem;
  font-family: var(--serif);
  font-style: italic;
  color: var(--ink);
  font-size: 1.15rem;
  line-height: 1.55;
}
.prose strong { font-weight: 600; color: var(--ink); }
.prose em { font-style: italic; }
.prose code {
  font-family: var(--mono);
  font-size: 0.88em;
  background: var(--bg-tint);
  padding: 0.1em 0.4em;
  border-radius: 3px;
  color: var(--ink);
}
.prose pre {
  font-family: var(--mono);
  font-size: 0.88rem;
  background: var(--bg-tint);
  padding: 1.1rem 1.3rem;
  border-radius: 6px;
  overflow-x: auto;
  line-height: 1.55;
  margin: 1.8rem 0;
}
.prose pre code { background: none; padding: 0; font-size: inherit; }
.prose ul, .prose ol { margin: 0 0 1.4rem; padding-left: 1.5rem; }
.prose li { margin-bottom: 0.4rem; }
.prose hr {
  border: none;
  border-top: 1px solid var(--rule);
  margin: 3rem auto;
  width: 5rem;
}
.prose img { margin: 1.8rem auto; border-radius: 4px; }
.prose a {
  color: var(--ink);
  background-image: linear-gradient(transparent calc(100% - 1px), var(--ink) 1px);
}
.prose a:hover {
  background-image: linear-gradient(transparent calc(100% - 1px), var(--ink-soft) 1px);
}

/* Pull quote */
.prose .pull {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.35rem;
  line-height: 1.4;
  border-top: 1px solid var(--ink);
  border-bottom: 1px solid var(--ink);
  padding: 1.3rem 0;
  margin: 2.2rem 0;
}

/* Sources */
.prose .sources {
  margin-top: 3.5rem;
  padding-top: 1.8rem;
  border-top: 1px solid var(--rule);
  font-size: 0.95rem;
  font-family: var(--sans);
}
.prose .sources h2 {
  font-family: var(--sans);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-mute);
  margin: 0 0 1rem;
  font-weight: 500;
}
.prose .sources ol { padding-left: 1.2rem; margin: 0; }
.prose .sources li { margin-bottom: 0.6rem; line-height: 1.5; }
.prose .sources a { word-break: break-word; }

.figure { margin: 1.8rem 0; background: var(--bg-tint); border-radius: 4px; }
.figure img, .figure svg { width: 100%; display: block; object-fit: cover; border: 1px solid var(--rule); border-radius: 4px; background: var(--bg-tint); }
.figure figcaption {
  font-family: var(--sans);
  font-size: 0.78rem;
  color: var(--ink-mute);
  text-align: center;
  margin-top: 0.6rem;
}

/* ----- Archive list ----- */
.archive { padding: clamp(1.5rem, 4vw, 2.5rem) 0 0; }
.archive h1 {
  font-family: var(--serif);
  font-weight: 700;
  font-size: clamp(2rem, 5vw, 2.8rem);
  margin: 0 0 0.5rem;
  letter-spacing: -0.025em;
}
.archive__lede {
  font-family: var(--serif);
  font-style: italic;
  color: var(--ink-soft);
  margin: 0 0 2.5rem;
  font-size: 1.15rem;
}
.archive__year {
  font-family: var(--sans);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-mute);
  margin: 2.5rem 0 0.5rem;
  font-weight: 500;
}
.archive ul { list-style: none; margin: 0; padding: 0; }
.archive li {
  display: grid;
  grid-template-columns: 5rem 1fr;
  gap: 1rem;
  padding: 1rem 0;
  border-bottom: 1px solid var(--rule);
  align-items: baseline;
}
.archive li:last-child { border-bottom: none; }
.archive time {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--ink-mute);
  letter-spacing: 0.02em;
}
.archive a {
  font-family: var(--serif);
  font-size: 1.1rem;
  font-weight: 600;
  text-decoration: none;
  background: none;
  color: var(--ink);
  line-height: 1.3;
  letter-spacing: -0.005em;
}
.archive a:hover { color: var(--ink-soft); }

@media (max-width: 480px) {
  .archive li { grid-template-columns: 1fr; gap: 0.2rem; }
}

/* ============================================================
   SCROLL ANIMATIONS
   ============================================================ */

/* Reading progress bar (top) */
.progress {
  position: fixed; top: 0; left: 0; right: 0;
  height: 1px; z-index: 200;
  background: var(--ink);
  width: 0%;
  transition: width 80ms linear;
  pointer-events: none;
}

/* Fade-in on scroll (most elements use this) */
.fade-in {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 700ms cubic-bezier(0.2, 0.7, 0.2, 1),
              transform 700ms cubic-bezier(0.2, 0.7, 0.2, 1);
}
.fade-in.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* Staggered children (post list, archive list) */
.stagger > * {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 600ms cubic-bezier(0.2, 0.7, 0.2, 1),
              transform 600ms cubic-bezier(0.2, 0.7, 0.2, 1);
}
.stagger.is-visible > * {
  opacity: 1;
  transform: translateY(0);
}
.stagger.is-visible > *:nth-child(1)  { transition-delay: 0ms; }
.stagger.is-visible > *:nth-child(2)  { transition-delay: 80ms; }
.stagger.is-visible > *:nth-child(3)  { transition-delay: 160ms; }
.stagger.is-visible > *:nth-child(4)  { transition-delay: 240ms; }
.stagger.is-visible > *:nth-child(5)  { transition-delay: 320ms; }
.stagger.is-visible > *:nth-child(6)  { transition-delay: 400ms; }
.stagger.is-visible > *:nth-child(7)  { transition-delay: 480ms; }
.stagger.is-visible > *:nth-child(8)  { transition-delay: 560ms; }
.stagger.is-visible > *:nth-child(9)  { transition-delay: 640ms; }
.stagger.is-visible > *:nth-child(10) { transition-delay: 720ms; }

/* Word-by-word reveal for hero title */
.word-reveal > .word {
  display: inline-block;
  opacity: 0;
  transform: translateY(0.35em);
  transition: opacity 450ms ease-out,
              transform 550ms cubic-bezier(0.2, 0.7, 0.2, 1);
}
.word-reveal.is-visible > .word { opacity: 1; transform: translateY(0); }

/* Subtle pull-quote scale-in (for .pull elements when scrolled into view) */
.pull {
  opacity: 0;
  transform: scale(0.98);
  transition: opacity 700ms ease-out,
              transform 800ms cubic-bezier(0.2, 0.7, 0.2, 1);
}
.pull.is-visible {
  opacity: 1;
  transform: scale(1);
}

/* Section H2 reveal (inside .prose) */
.prose h2 {
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 500ms ease-out,
              transform 600ms cubic-bezier(0.2, 0.7, 0.2, 1);
}
.prose h2.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* Sticky TOC (right rail) — minimal progress-rail design */
.toc {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  right: max(24px, calc(50vw - 22rem - 180px));
  width: 32px;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0;
}
.toc__label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
}
.toc ol {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.toc li { margin: 0; position: relative; }
.toc li::before { display: none; }
.toc a {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 4px 0;
  text-decoration: none;
  background: none;
  border: none;
  position: relative;
  cursor: pointer;
}
/* The line indicator */
.toc a::before {
  content: '';
  display: block;
  width: 12px;
  height: 2px;
  background: var(--ink-faint, #c8c8c8);
  border-radius: 1px;
  transition: width 280ms cubic-bezier(0.2, 0.7, 0.2, 1),
              background 280ms ease,
              height 280ms ease;
  flex-shrink: 0;
}
/* Hover popup card — appears to the LEFT of the rail */
.toc a .toc__popup {
  position: absolute;
  right: calc(100% + 14px);
  top: 50%;
  transform: translateY(-50%) translateX(6px);
  width: 220px;
  padding: 0.6rem 0.75rem;
  background: var(--bg, #fff);
  border: 1px solid var(--rule);
  border-radius: 6px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.08);
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms ease, transform 220ms cubic-bezier(0.2,0.7,0.2,1);
  z-index: 60;
}
.toc a .toc__popup-title {
  display: block;
  font-family: var(--sans);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.3;
  margin-bottom: 0.25rem;
}
.toc a .toc__popup-summary {
  display: block;
  font-family: var(--sans);
  font-size: 0.68rem;
  font-weight: 400;
  color: var(--ink-mute);
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.toc a:hover .toc__popup {
  opacity: 1;
  transform: translateY(-50%) translateX(0);
  pointer-events: auto;
}
.toc a:hover::before {
  width: 18px;
  background: var(--ink-soft);
}
/* Active state — longer, bolder line */
.toc a.is-active::before {
  width: 28px;
  height: 3px;
  background: var(--ink);
}
@media (prefers-reduced-motion: reduce) {
  .toc a::before,
  .toc a .toc__popup {
    transition: none;
  }
}
@media (max-width: 1180px) { .toc { display: none; } }

/* Scroll depth indicator (small bar on right side, 1px) */
.scroll-depth {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 1px;
  background: var(--ink-faint);
  z-index: 100;
  pointer-events: none;
}
.scroll-depth__fill {
  position: absolute;
  top: 0; left: 0; right: 0;
  background: var(--ink);
  height: 0;
  transition: height 80ms linear;
}
@media (max-width: 720px) { .scroll-depth { display: none; } }

/* Back-to-top button */
.to-top {
  position: fixed;
  bottom: 2rem; right: 2rem;
  width: 40px; height: 40px;
  background: var(--ink); color: var(--bg);
  border: none; border-radius: 50%;
  font-family: var(--sans);
  font-size: 1.1rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transform: translateY(10px);
  transition: opacity 300ms ease, transform 300ms ease, background 200ms ease;
  z-index: 150;
  text-decoration: none;
}
.to-top.is-visible { opacity: 1; transform: translateY(0); }
.to-top:hover { background: var(--ink-soft); }
.to-top::before { content: "↑"; }
@media (max-width: 720px) { .to-top { display: none; } }

/* Keyboard help modal */
.kbd-help {
  position: fixed; inset: 0; z-index: 300;
  display: none; align-items: center; justify-content: center;
  background: rgba(17,17,17,0.55);
  backdrop-filter: blur(4px);
}
.kbd-help.is-open { display: flex; }
.kbd-help__panel {
  background: var(--bg);
  border: 1px solid var(--ink);
  border-radius: 6px;
  padding: 1.5rem 1.8rem;
  max-width: 380px;
  font-family: var(--sans);
  font-size: 0.88rem;
  line-height: 1.7;
  color: var(--ink);
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.kbd-help__panel h3 {
  font-family: var(--sans);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-mute);
  margin: 0 0 0.8rem;
  font-weight: 500;
}
.kbd-help__panel kbd {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.78rem;
  background: var(--bg-tint);
  border: 1px solid var(--rule-strong);
  border-bottom-width: 2px;
  border-radius: 3px;
  padding: 0 0.4rem;
  min-width: 1.4em; text-align: center;
  color: var(--ink);
}
.kbd-help__panel .row {
  display: grid; grid-template-columns: 6rem 1fr;
  gap: 0.6rem; margin: 0.3rem 0;
}
.kbd-help__panel .row span:last-child { color: var(--ink-soft); }
.kbd-help__close {
  display: block; margin-top: 1rem;
  font-size: 0.72rem; color: var(--ink-mute);
  text-align: right;
}

::selection { background: var(--ink); color: var(--bg); }

a:focus-visible, button:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
  border-radius: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .fade-in, .stagger > *, .word-reveal > .word, .pull, .prose h2,
  .scroll-hint::after, .post-card__title {
    transition: none !important;
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
  }
}

@media print {
  body { background: white; color: black; }
  .site-header__nav, .site-footer, .post__back,
  .progress, .scroll-depth, .toc, .to-top { display: none; }
}

/* ============================================================
   Chart-specific scroll animations
   ============================================================ */
.figure {
  margin: 2.5rem 0;
  padding: 0;
}
.figure svg {
  width: 100%;
  height: auto;
  display: block;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: #fff;
}
.figure figcaption {
  font-family: var(--sans);
  font-size: 0.78rem;
  color: var(--ink-mute);
  text-align: left;
  margin-top: 0.7rem;
  letter-spacing: 0.01em;
  line-height: 1.5;
}
.figure figcaption em { color: var(--ink-soft); }

/* Bar growth animation — bars scale from 0 to 1 on horizontal axis */
.figure svg .bar {
  transform: scaleX(0);
  transform-origin: left center;
  transform-box: fill-box;
  transition: transform 900ms cubic-bezier(0.2, 0.7, 0.2, 1);
}
.figure.is-visible svg .bar { transform: scaleX(1); }
.figure.is-visible svg .bar:nth-of-type(1) { transition-delay: 200ms; }
.figure.is-visible svg .bar:nth-of-type(2) { transition-delay: 350ms; }
.figure.is-visible svg .bar:nth-of-type(3) { transition-delay: 500ms; }
.figure.is-visible svg .bar:nth-of-type(4) { transition-delay: 650ms; }
.figure.is-visible svg .bar:nth-of-type(5) { transition-delay: 800ms; }
.figure.is-visible svg .bar:nth-of-type(6) { transition-delay: 950ms; }
.figure.is-visible svg .bar:nth-of-type(7) { transition-delay: 1100ms; }
.figure.is-visible svg .bar:nth-of-type(8) { transition-delay: 1250ms; }
.figure.is-visible svg .bar:nth-of-type(9) { transition-delay: 1400ms; }
.figure.is-visible svg .bar:nth-of-type(10) { transition-delay: 1550ms; }

/* Number tick-up: optional data-animate on text */
.figure svg text.fade-num { opacity: 0; transition: opacity 600ms ease-out; }
.figure.is-visible svg text.fade-num { opacity: 1; }
.figure.is-visible svg text.fade-num:nth-of-type(1) { transition-delay: 400ms; }
.figure.is-visible svg text.fade-num:nth-of-type(2) { transition-delay: 550ms; }
.figure.is-visible svg text.fade-num:nth-of-type(3) { transition-delay: 700ms; }
.figure.is-visible svg text.fade-num:nth-of-type(4) { transition-delay: 850ms; }

@media (prefers-reduced-motion: reduce) {
  .figure svg .bar { transform: scaleX(1) !important; transition: none !important; }
  .figure svg text.fade-num { opacity: 1 !important; transition: none !important; }
}

/* Inline SVG charts (from blog agent) — use SMIL animations, not CSS bar transform */
.figure--chart svg .bar {
  transform: none !important;
  transition: none !important;
}
.figure--chart svg {
  border: 1px solid var(--rule);
  border-radius: 4px;
  overflow: hidden;
}

/* Separator between consecutive figures (prevents visual clutter) */
.figure-sep { margin: 0; padding: 0; line-height: 0; }

/* Chart takeaway line */
.figure__takeaway {
  font-family: var(--sans);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink);
  margin-top: 0.5rem;
  padding-left: 0.25rem;
}

/* ============================================================
   Additional components
   ============================================================ */

/* Chart tooltip */
.chart-tooltip {
  position: fixed;
  z-index: 1000;
  background: #111;
  color: #fff;
  padding: 7px 11px;
  font-family: var(--sans);
  font-size: 0.82rem;
  line-height: 1.4;
  border-radius: 4px;
  pointer-events: none;
  opacity: 0;
  transform: translateY(-2px);
  transition: opacity 120ms ease, transform 120ms ease;
  max-width: 260px;
  white-space: normal;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
}
.chart-tooltip.is-visible { opacity: 1; transform: translateY(0); }

/* Per-section reading time */
.section-time {
  display: inline-block;
  margin-left: 0.6rem;
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 400;
  color: var(--ink-mute);
  letter-spacing: 0.04em;
  vertical-align: 0.15em;
  text-transform: lowercase;
  font-style: normal;
  background: none;
  border: none;
  padding: 0;
  opacity: 0;
  transition: opacity 400ms ease-out;
}
.prose h2.is-visible .section-time { opacity: 1; }

/* Bar hover state */
.figure svg [data-detail]:hover {
  filter: brightness(0.65);
  transition: filter 150ms ease;
}

/* ----- Related posts ----- */
.related {
  margin: 4rem 0 0;
  padding: 2rem 0 0;
  border-top: 1px solid var(--rule);
}
.related__title {
  font-family: var(--sans);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-mute);
  margin: 0 0 1.2rem;
  font-weight: 500;
}
.related__list {
  list-style: none;
  margin: 0; padding: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}
@media (max-width: 640px) {
  .related__list { grid-template-columns: 1fr; gap: 1rem; }
}
.related__card {
  display: block;
  padding: 1.2rem 0;
  border-top: 1px solid var(--rule);
  text-decoration: none;
  background: none;
}
.related__card:first-child { border-top: none; padding-top: 0; }
.related__date {
  display: block;
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--ink-mute);
  margin-bottom: 0.3rem;
  letter-spacing: 0.02em;
}
.related__heading {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 1.1rem;
  line-height: 1.25;
  letter-spacing: -0.01em;
  margin: 0 0 0.3rem;
  color: var(--ink);
  background: none;
}
.related__card:hover .related__heading { color: var(--ink-soft); }
.related__deck {
  font-family: var(--serif);
  font-size: 0.95rem;
  line-height: 1.45;
  color: var(--ink-soft);
  margin: 0;
}

/* ----- End-of-post actions ----- */
.post-end {
  margin: 3rem 0 0;
  padding: 1.5rem 0 0.5rem;
  border-top: 1px solid var(--rule);
  display: flex; flex-wrap: wrap; gap: 0.6rem 1.2rem;
  align-items: center;
  justify-content: space-between;
}
.post-end__actions {
  display: flex; gap: 0.5rem; flex-wrap: wrap;
}
.btn {
  display: inline-flex; align-items: center; gap: 0.4rem;
  font-family: var(--sans);
  font-size: 0.85rem;
  color: var(--ink-soft);
  background: none;
  border: 1px solid var(--rule-strong);
  border-radius: 4px;
  padding: 0.5rem 0.9rem;
  cursor: pointer;
  text-decoration: none;
  transition: background 200ms ease, color 200ms ease, border-color 200ms ease;
}
.btn:hover {
  color: var(--ink);
  border-color: var(--ink);
  background: none;
}
.btn.is-copied {
  color: var(--bg);
  background: var(--ink);
  border-color: var(--ink);
}
.btn::before {
  content: "";
  display: inline-block;
  width: 0.7em; height: 0.7em;
  background: currentColor;
  -webkit-mask-image: var(--icon);
  mask-image: var(--icon);
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
}
.btn--rss { --icon: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'><path fill='black' d='M3 3a10 10 0 0 1 10 10h-2A8 8 0 0 0 3 5V3zm0 4a6 6 0 0 1 6 6H7a4 4 0 0 0-4-4V7zm1.5 4a1.5 1.5 0 1 1 0 3 1.5 1.5 0 0 1 0-3z'/></svg>"); }
.btn--share { --icon: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'><path fill='black' d='M11 2.5a1.5 1.5 0 1 1 0 3 1.5 1.5 0 0 1 0-3zM11 10.5a1.5 1.5 0 1 1 0 3 1.5 1.5 0 0 1 0-3zM4 7.5a1.5 1.5 0 1 1 0 3 1.5 1.5 0 0 1 0-3zm6.5.7L6 6.1m0 3.8l4.5-2.1'/></svg>"); }
.btn--like  { --icon: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'><path fill='black' d='M5.5 6.5 8 2.5l1 1v3h4a1 1 0 0 1 1 1.2l-1 5A1 1 0 0 1 12 13H7a1 1 0 0 1-1-1V8H5a1 1 0 0 1-1-1zM2 8h2.5v6H2z'/></svg>"); }
.btn--coffee{ --icon: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'><path fill='black' d='M3 5h9v5a3 3 0 0 1-3 3H6a3 3 0 0 1-3-3V5zm9 1h1.5a1.5 1.5 0 0 1 0 3H12V6zM5 1.5l.6.7M8 1.5l.6.7M11 1.5l.6.7' stroke='black' stroke-width='1' fill='none' stroke-linecap='round'/></svg>"); }

/* Like button: filled state when this device has liked the post */
.btn--like[aria-pressed="true"] {
  color: var(--bg);
  background: var(--ink);
  border-color: var(--ink);
}
.btn--like[aria-pressed="true"]::before {
  background: var(--bg);
}
.btn--like.is-pulse {
  animation: like-pulse 0.22s ease;
}
@keyframes like-pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.12); }
  100% { transform: scale(1); }
}

/* Like count badge */
.like-count {
  font-family: var(--sans);
  font-size: 0.78rem;
  font-weight: 600;
  margin-left: 0.35rem;
  padding: 0.1rem 0.45rem;
  border-radius: 99px;
  background: var(--bg-tint);
  border: 1px solid var(--rule);
  line-height: 1.3;
  min-width: 1.6em;
  text-align: center;
}
.btn--like[aria-pressed="true"] .like-count {
  background: rgba(255,255,255,0.15);
  border-color: rgba(255,255,255,0.3);
}

/* Index card like count */
.card-likes {
  font-family: var(--sans);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--ink-mute);
  letter-spacing: 0.01em;
  transition: color 0.2s ease;
}
.card-likes.is-liked {
  color: var(--ink);
  font-weight: 600;
}

.post-end__note {
  font-family: var(--sans);
  font-size: 0.85rem;
  color: var(--ink-mute);
}
.post-end__note a { background: none; }

/* ----- Share popup panel ----- */
.share-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.45);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}
.share-overlay.is-open {
  opacity: 1;
  visibility: visible;
}
.share-panel {
  background: var(--bg);
  border: 1px solid var(--rule-strong);
  border-radius: 6px;
  width: min(320px, calc(100vw - 2rem));
  padding: 1.25rem 1.4rem 1.4rem;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
  transform: translateY(10px) scale(0.97);
  transition: transform 0.2s ease;
}
.share-overlay.is-open .share-panel {
  transform: translateY(0) scale(1);
}
.share-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--rule);
}
.share-panel__title {
  font-family: var(--serif);
  font-size: 1rem;
  font-weight: 700;
  color: var(--ink);
}
.share-panel__close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border: none;
  background: none;
  font-size: 1.2rem;
  line-height: 1;
  color: var(--ink-soft);
  cursor: pointer;
  border-radius: 4px;
  transition: background 0.15s ease, color 0.15s ease;
}
.share-panel__close:hover {
  background: var(--bg-tint);
  color: var(--ink);
}
.share-panel__links {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.share-panel__link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--rule);
  border-radius: 4px;
  font-family: var(--sans);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--ink);
  text-decoration: none;
  background: none;
  cursor: pointer;
  width: 100%;
  text-align: left;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}
.share-panel__link:hover {
  background: var(--bg-tint);
  border-color: var(--rule-strong);
  transform: translateX(2px);
}
.share-panel__link svg {
  flex-shrink: 0;
  color: var(--ink-soft);
}
.share-panel__link:hover svg {
  color: var(--ink);
}

/* ----- Paragraph quote button ----- */
.para-quote-btn {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 4px;
  border: 1px solid var(--rule-strong);
  background: var(--bg);
  color: var(--ink-soft);
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease, background 0.15s ease, color 0.15s ease;
  z-index: 10;
  padding: 0;
}
.para-quote-btn.is-visible {
  opacity: 1;
  pointer-events: auto;
}
.para-quote-btn:hover {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}
.para-quote-btn.is-copied {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}
.prose p {
  position: relative;
}

/* Subscribe callout (also in footer) */
.subscribe-callout {
  margin: 2.5rem 0 0;
  padding: 1.5rem 1.6rem;
  border: 1px solid var(--rule);
  border-radius: 4px;
  display: flex; flex-wrap: wrap; gap: 1rem 1.5rem;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-soft);
}
.subscribe-callout__body { flex: 1 1 280px; min-width: 0; }
.subscribe-callout__title {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: -0.01em;
  margin: 0 0 0.3rem;
  color: var(--ink);
}
.subscribe-callout__copy {
  font-family: var(--serif);
  font-size: 0.98rem;
  line-height: 1.5;
  color: var(--ink-soft);
  margin: 0;
}
.subscribe-callout__actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.subscribe-callout__actions .btn { background: var(--bg); }
.subscribe-callout__actions .btn--rss {
  color: var(--ink);
  border-color: var(--ink);
}

/* ----- Email subscription form ----- */
.subscribe-email {
  width: 100%;
  margin-top: 0.25rem;
}
.subscribe-email__form {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.subscribe-email__input {
  flex: 1 1 200px;
  max-width: 280px;
  padding: 0.5rem 0.75rem;
  font-family: var(--sans);
  font-size: 0.85rem;
  border: 1px solid var(--rule-strong);
  border-radius: 4px;
  background: var(--bg);
  color: var(--ink);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.subscribe-email__input::placeholder {
  color: var(--ink-mute);
}
.subscribe-email__input:focus {
  outline: none;
  border-color: var(--ink);
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.06);
}
.subscribe-email__input.is-invalid {
  border-color: #c0392b;
  box-shadow: 0 0 0 2px rgba(192, 57, 43, 0.1);
}
.btn--subscribe-email {
  font-size: 0.8rem;
  padding: 0.5rem 1rem;
}
.subscribe-email__success {
  font-family: var(--sans);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink);
  margin: 0.25rem 0 0;
  animation: fade-slide-in 0.3s ease;
}
@keyframes fade-slide-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}


@media (prefers-reduced-motion: reduce) {
  .chart-tooltip { transition: none; }
  .section-time { opacity: 1 !important; transition: none !important; }
  .figure svg [data-detail]:hover { filter: none; }
}