:root {
  --bg: #eeece7;
  --surface: #f8f7f4;
  --text: #141414;
  --muted: #5f5c56;
  --rule: #d4d1ca;
  --accent: #2f3fe0;
  --accent-hover: #1c2ab8;
  --ok: #2f6b3a;
  --err: #a12b2b;
  --display: "Inter Tight", system-ui, -apple-system, "Segoe UI", sans-serif;
  --serif: "Newsreader", Georgia, "Times New Roman", serif;
  --gutter: clamp(1rem, 4vw, 3rem);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131312;
    --surface: #1c1c1a;
    --text: #ecebe6;
    --muted: #a19e96;
    --rule: #33322f;
    --accent: #8f9bff;
    --accent-hover: #b4bcff;
    --ok: #7cc48a;
    --err: #ef8a8a;
    color-scheme: dark;
  }
}

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

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 5rem; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--serif);
  font-size: 1.1875rem;
  line-height: 1.6;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}
body.menu-open { overflow: hidden; }

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 0.18em; }
a:hover { color: var(--accent-hover); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 2px; }

.skip { position: absolute; left: -9999px; }
.skip:focus { left: 1rem; top: 1rem; z-index: 30; background: var(--bg); padding: 0.5rem 0.75rem; }

h1, h2, h3 {
  font-family: var(--display);
  font-weight: 700;
  letter-spacing: -0.035em;
  line-height: 1.02;
  margin: 0;
}

/* Header and menu ------------------------------------------------------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.1rem var(--gutter);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  font-family: var(--display);
  font-weight: 600;
  font-size: 1rem;
}
.site-name { color: var(--text); text-decoration: none; letter-spacing: -0.01em; }
.menu-toggle {
  font: inherit;
  color: var(--text);
  background: none;
  border: 0;
  padding: 0.25rem 0;
  cursor: pointer;
  border-bottom: 1px solid transparent;
}
.menu-toggle:hover { border-bottom-color: currentColor; }

.menu {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 6rem var(--gutter) 3rem;
  background: var(--bg);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.35s var(--ease), visibility 0s linear 0.35s;
}
.menu-open .menu { opacity: 1; visibility: visible; transition: opacity 0.35s var(--ease); }
.menu ul { list-style: none; margin: 0 0 0 auto; padding: 0; width: min(100%, 60rem); }
/* Each word slides up inside its own clipped line; the padding leaves room for descenders (g, p). */
.menu li {
  overflow: hidden;
  font-size: clamp(3.25rem, 11vw, 9rem);
  line-height: 1.02;
  padding-bottom: 0.18em;
  margin-bottom: -0.18em;
}
.menu ul a {
  display: inline-block;
  font-family: var(--display);
  font-weight: 700;
  font-size: inherit;
  vertical-align: top;
  line-height: 1.02;
  letter-spacing: -0.045em;
  text-decoration: none;
  transform: translateY(105%);
  transition: transform 0.6s var(--ease);
}
.menu-open .menu ul a { transform: none; }
.menu ul a:focus-visible { outline: none; text-decoration: underline; text-decoration-thickness: 0.06em; text-underline-offset: 0.12em; }
.menu li:nth-child(2) a { transition-delay: 0.05s; }
.menu li:nth-child(3) a { transition-delay: 0.1s; }
.menu-links { display: flex; gap: 1.5rem; margin: 2.5rem 0 0 auto; width: min(100%, 60rem); font-family: var(--display); font-weight: 500; font-size: 1rem; }

/* Sections -------------------------------------------------------------- */

main { padding: 0 var(--gutter); }

.label {
  margin: 0;
  font-family: var(--display);
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--accent);
}
.label::before {
  content: "";
  display: inline-block;
  width: 0.55em;
  height: 0.55em;
  margin-right: 0.55em;
  border-radius: 50%;
  background: var(--accent);
  vertical-align: 0.05em;
}
.label a { text-decoration: none; }

.lede { color: var(--muted); font-size: 1.3rem; line-height: 1.5; margin: 1rem 0 0; max-width: 36rem; }
.muted { color: var(--muted); }

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: center;
  gap: 3rem;
  min-height: min(82vh, 52rem);
  padding: 3rem 0 4rem;
}
.statement { font-size: clamp(2.6rem, 6.6vw, 5.75rem); max-width: 13em; }
.statement em { font-style: normal; color: var(--accent); }
.hero-intro { max-width: 34rem; margin: 2rem 0 0; font-size: 1.3rem; line-height: 1.55; }
.hero-links { display: flex; flex-wrap: wrap; gap: 0.75rem 2rem; margin: 2rem 0 0; font-family: var(--display); font-weight: 600; font-size: 1rem; }
.hero-links a { text-decoration: none; border-bottom: 1.5px solid currentColor; padding-bottom: 0.2rem; }

.approx { width: min(100%, 26rem); justify-self: center; overflow: visible; }
.approx polygon, .approx circle {
  fill: none;
  stroke: var(--text);
  stroke-width: 0.22;
  stroke-linejoin: round;
  stroke-opacity: calc(0.3 + var(--i) * 0.08);
}
.approx circle { stroke: var(--accent); stroke-width: 0.6; stroke-opacity: 1; }

@media (min-width: 60rem) {
  .hero { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); }
  .approx { justify-self: end; }
}
/* The drawing only shows when it fits beside the text; on narrow screens the statement leads. */
@media (max-width: 59.99rem) {
  .approx { display: none; }
  .hero { min-height: 0; padding: 2.5rem 0 4rem; }
}

.section {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.25rem;
  padding: 5rem 0;
  border-top: 1px solid var(--rule);
}
.section h2 { font-size: clamp(2.4rem, 5.5vw, 4.5rem); }
@media (min-width: 60rem) {
  .section { grid-template-columns: 14rem minmax(0, 1fr); gap: 2rem; padding: 7rem 0; }
  .section .label { padding-top: 0.5rem; }
}

/* Writing --------------------------------------------------------------- */

.post-list { list-style: none; margin: 3.5rem 0 0; padding: 0; border-top: 1px solid var(--rule); }
.post {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.5rem 2rem;
  padding: 1.75rem 0;
  border-bottom: 1px solid var(--rule);
}
@media (min-width: 48rem) { .post { grid-template-columns: 15rem minmax(0, 1fr); } }

.post-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.75rem;
  margin: 0;
  font-family: var(--display);
  font-size: 0.95rem;
  color: var(--muted);
  padding-top: 0.3rem;
}
.post-meta span { font-weight: 600; color: var(--text); }
.post-meta span + time, .post-meta time + time { padding-left: 0.75rem; border-left: 1px solid var(--muted); }
.post .post-meta { flex-direction: column; align-items: flex-start; gap: 0.15rem; }
.post .post-meta span + time { padding-left: 0; border-left: 0; }

.post h3 { font-size: clamp(1.6rem, 3vw, 2.3rem); line-height: 1.08; }
.post h3 a { text-decoration: none; }
.post h3 a:hover { text-decoration: underline; text-decoration-thickness: 2px; }
.post .ext { font-weight: 600; }
.post-main p { margin: 0.6rem 0 0; color: var(--muted); max-width: 40rem; }

.tag-filter { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 2.5rem; }
.tag-filter button {
  font-family: var(--display);
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text);
  background: none;
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 0.45rem 0.95rem;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}
.tag-filter button:hover { border-color: var(--accent); color: var(--accent); }
.tag-filter button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--bg); }
.tag-filter + .post-list { margin-top: 1.5rem; }

.post-tags { display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; margin: 0.75rem 0 0; font-family: var(--display); font-size: 0.85rem; font-weight: 500; }
.post-tags a { color: var(--muted); text-decoration: none; }
.post-tags a::before { content: "#"; opacity: 0.6; }
.post-tags a:hover { color: var(--accent); }
.essay-header .post-tags { margin-top: 0.75rem; }
.post[hidden] { display: none; }

.empty { margin-top: 3.5rem; padding: 2rem 0; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
.empty p { margin: 0 0 0.35rem; }

.subscribe {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem 2rem;
  margin-top: 3.5rem;
  padding: 1.75rem 1.75rem;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 12px;
}
.subscribe div { flex: 1 1 18rem; }
.subscribe h2 { font-size: 1.5rem; letter-spacing: -0.02em; }
.subscribe p { margin: 0.4rem 0 0; color: var(--muted); font-size: 1rem; }

.button {
  display: inline-block;
  font-family: var(--display);
  font-weight: 600;
  font-size: 1rem;
  color: var(--bg);
  background: var(--accent);
  border-radius: 999px;
  padding: 0.8rem 1.5rem;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.2s;
}
.button:hover { color: var(--bg); background: var(--accent-hover); }

.see-all { margin: 1.75rem 0 0; font-family: var(--display); font-weight: 600; font-size: 1rem; }
.see-all a { text-decoration: none; border-bottom: 1.5px solid currentColor; padding-bottom: 0.2rem; }

/* The Writing page */
.archive { border-top: 0; padding-top: 3rem; }
.archive h1 { font-size: clamp(2.6rem, 6vw, 5rem); }

/* Featured analysis ----------------------------------------------------- */

.featured-body { display: grid; gap: 3rem; align-items: center; }
@media (min-width: 60rem) { .featured-body { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 4rem; } }
.featured h2 { font-size: clamp(2.6rem, 6vw, 5rem); }
.featured h2 a { color: var(--accent); text-decoration: none; }
.featured h2 a:hover { color: var(--accent-hover); }
.featured .post-meta { margin-top: 1.5rem; padding: 0; }
/* On phones the chart is too detailed to read; the text carries the section. */
@media (max-width: 40rem) { .featured-chart { display: none; } }
.featured-summary { margin: 1.25rem 0 0; max-width: 36rem; color: var(--muted); }

.area-chart { margin: 0; max-width: 30rem; }
.area-chart svg { display: block; width: 100%; height: auto; overflow: visible; margin-top: 1rem; }
.area-chart rect { fill: none; stroke: var(--muted); stroke-width: 0.25; }
.area-chart rect.hl { fill: var(--accent); stroke: var(--accent); }
.area-chart text { font-family: var(--display); font-size: 3.1px; fill: var(--muted); }
.area-chart text .name { font-weight: 600; fill: var(--text); }
.area-chart text.hl .name { font-weight: 700; }
.area-chart .leader { fill: none; stroke: var(--muted); stroke-width: 0.2; }
.chart-title { font-family: var(--display); font-weight: 600; font-size: 0.95rem; }
.chart-caption { margin: 0.75rem 0 0; font-family: var(--display); font-size: 0.8rem; color: var(--muted); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* About ----------------------------------------------------------------- */

.prose p, .prose ul, .prose ol { margin: 0 0 1.1rem; }
.prose ul, .prose ol { padding-left: 1.25rem; }
.about-intro { max-width: 38rem; margin-top: 2rem; font-size: 1.3rem; line-height: 1.55; }
.portrait { display: block; width: min(100%, 20rem); height: auto; margin-top: 2rem; border-radius: 4px; object-fit: cover; }

.about-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
  gap: 2rem 3rem;
  margin-top: 3rem;
}
.about-grid h3 { font-size: 1.15rem; letter-spacing: -0.015em; margin-bottom: 0.9rem; }
.about-grid ul { list-style: none; margin: 0; padding: 0; font-size: 1.0625rem; }
.about-grid li { padding: 0.6rem 0; border-top: 1px solid var(--rule); }
.about-grid strong { font-weight: 500; }

/* Contact --------------------------------------------------------------- */

.contact { display: grid; gap: 2.5rem; }
@media (min-width: 60rem) { .contact { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 4rem; } }

.form { display: grid; gap: 1.1rem; font-family: var(--display); font-size: 1rem; }
.form label { display: grid; gap: 0.35rem; font-weight: 600; font-size: 0.95rem; }
.form input, .form textarea {
  font: inherit;
  font-weight: 400;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 0.75rem 0.85rem;
  width: 100%;
}
.form input:focus, .form textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.form textarea { min-height: 10rem; resize: vertical; }
.form .hp { display: none; }
.form button {
  justify-self: start;
  font: inherit;
  font-weight: 600;
  color: var(--bg);
  background: var(--accent);
  border: 0;
  border-radius: 999px;
  padding: 0.8rem 1.6rem;
  cursor: pointer;
  transition: background 0.2s;
}
.form button:hover { background: var(--accent-hover); }
.form button:disabled { opacity: 0.6; cursor: default; }
.form-status { margin: 0; min-height: 1.5em; }
.form-status.ok { color: var(--ok); }
.form-status.err { color: var(--err); }

.placeholder { padding: 1.25rem 1.5rem; border: 1px dashed var(--rule); border-radius: 8px; color: var(--muted); font-family: var(--display); font-size: 0.95rem; }

/* Post pages and plain pages -------------------------------------------- */

.essay, .plain-page { max-width: 46rem; margin: 0 auto; padding: 4rem 0 2rem; }
.essay-header h1, .plain-page h1 { font-size: clamp(2.4rem, 6vw, 4.25rem); margin-top: 1.5rem; }
.essay-header .post-meta { margin-top: 1.5rem; padding: 0; }
.essay .prose { margin-top: 3rem; }
.prose h2 { font-size: 1.75rem; letter-spacing: -0.025em; margin: 2.5rem 0 0.75rem; }
.prose h3 { font-size: 1.3rem; letter-spacing: -0.02em; margin: 2rem 0 0.5rem; }
.prose blockquote { margin: 1.5rem 0; padding-left: 1.25rem; border-left: 3px solid var(--accent); color: var(--muted); font-style: italic; }
.prose img { max-width: 100%; height: auto; border-radius: 6px; }
.prose pre { overflow-x: auto; padding: 1rem; background: var(--surface); border-radius: 6px; font-size: 0.875rem; }
.prose code { font-size: 0.9em; }
.prose hr { border: 0; border-top: 1px solid var(--rule); margin: 2.5rem 0; }
.back { margin: 3rem 0 0; font-family: var(--display); font-weight: 600; font-size: 1rem; }
.back a { text-decoration: none; }

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

.site-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem 1.5rem;
  margin: 0 var(--gutter);
  padding: 2rem 0 3rem;
  border-top: 1px solid var(--rule);
  font-family: var(--display);
  font-size: 0.9rem;
  color: var(--muted);
}
.footer-links { display: flex; gap: 1.25rem; }
.site-footer a { color: var(--muted); }

/* Motion ---------------------------------------------------------------- */

@media (prefers-reduced-motion: no-preference) {
  .js .reveal { opacity: 0; transform: translateY(1.25rem); transition: opacity 0.9s var(--ease), transform 0.9s var(--ease); }
  .js .reveal.in { opacity: 1; transform: none; }
  .js .post.reveal:nth-child(2) { transition-delay: 0.06s; }
  .js .post.reveal:nth-child(3) { transition-delay: 0.12s; }

  .statement { animation: rise 1.1s var(--ease) both; }
  .statement em { animation: ink 1.4s var(--ease) both; }
  .statement em:nth-of-type(1) { animation-delay: 0.5s; }
  .statement em:nth-of-type(2) { animation-delay: 0.7s; }
  .statement em:nth-of-type(3) { animation-delay: 0.9s; }

  /* The polygons draw in one after another, each a little closer to the circle. */
  .approx polygon, .approx circle {
    stroke-dasharray: 1;
    stroke-dashoffset: 1;
    animation: draw 1.6s var(--ease) forwards;
    animation-delay: calc(0.3s + var(--i) * 0.22s);
  }
}

@keyframes rise { from { opacity: 0; transform: translateY(1.5rem); } }
@keyframes ink { from { color: var(--text); } }
@keyframes draw { to { stroke-dashoffset: 0; } }
