/* Plain HTML, system fonts, and a single stylesheet. */
:root {
  color-scheme: light;
  --paper: #fbfbfa;
  --ink: #191918;
  --body: #42423f;
  --muted: #6b6b65;
  --line: #deded9;
  --surface: #f0f0ec;
  --serif: Georgia, "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #0b0b0b;
  --ink: #eeeeea;
  --body: #c0c0ba;
  --muted: #a0a099;
  --line: #2d2d29;
  --surface: #181816;
}

* { box-sizing: border-box; }
html { font-size: 16px; scrollbar-gutter: stable; }
body { margin: 0; color: var(--body); background: var(--paper); font: 400 1rem/1.7 var(--sans); }
[hidden] { display: none !important; }
a { color: var(--ink); text-decoration-color: var(--line); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { text-decoration-color: currentColor; }
a:focus-visible, button:focus-visible, summary:focus-visible { outline: 2px solid var(--ink); outline-offset: 4px; }
img { max-width: 100%; height: auto; }
svg { display: block; }
p { margin: 0 0 1rem; }
h1, h2, h3 { color: var(--ink); }
h1, h2 { font-family: var(--serif); font-weight: 400; letter-spacing: -0.035em; }
h1 { margin: 0; font-size: clamp(2.25rem, 5vw, 3rem); line-height: 1.15; }
h2 { margin: 2.5rem 0 1rem; font-size: 1.6rem; line-height: 1.25; }
h3 { margin: 1.75rem 0 0.75rem; font-size: 1rem; line-height: 1.5; }
ul, ol { padding-left: 1.3rem; }
li { margin-bottom: 0.35rem; }

/* Inner pages retain a small home link, rather than a crowded top menu. */
.site-shell { width: calc(100% - 3rem); max-width: 40rem; margin: 0 auto; }
.site-header { padding: 2rem 3.5rem 0 0; }
.site-name { font: italic 1.2rem var(--serif); text-decoration: none; }
main { padding: 3.5rem 0 0; overflow-wrap: break-word; }
.page-header, .post-header { margin-bottom: 2.5rem; }
.lede { margin: 0.75rem 0 0; color: var(--muted); }
.eyebrow { margin: 0 0 0.65rem; color: var(--muted); font-size: 0.8rem; }
.site-footer { margin: 3.5rem 0 2.5rem; }
.site-links { display: flex; flex-wrap: wrap; gap: 0.5rem 1.4rem; font-size: 0.9rem; }
.site-links a { padding: 0.2rem 0; color: var(--body); text-decoration: underline; text-decoration-color: transparent; }
.site-links a:hover, .site-links a[aria-current] { color: var(--ink); text-decoration-color: var(--line); }
.social-links { display: flex; gap: 0.75rem; margin-top: 1.75rem; }
.social-links a { display: grid; place-items: center; width: 36px; height: 36px; color: var(--muted); }
.social-links a:hover { color: var(--ink); }
.social-links svg { width: 17px; height: 17px; fill: currentColor; }
.local-time { margin: 1.25rem 0 0; color: var(--muted); font-size: 0.8rem; }
.local-time time { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* The front page is a short introduction, not a banner or a dashboard. */
.home-page { min-height: 100vh; min-height: 100svh; }
.home-page .site-shell { max-width: 35rem; padding: clamp(6rem, 16vh, 11rem) 0 4rem; }
.home-page main { padding: 0; }
.home-page .site-footer { margin: 2.25rem 0 0; }
.home-identity { display: flex; align-items: center; gap: 1.25rem; margin-bottom: 2.25rem; }
.home-portraits { position: relative; flex: none; width: 96px; height: 96px; }
.home-portraits img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border-radius: 10px; opacity: 0; }
.home-portraits img.is-active { opacity: 1; }
.home-identity h1 { font-size: clamp(1.85rem, 5vw, 2.8rem); font-style: italic; }
.home-identity p { margin: 0.3rem 0 0; color: var(--muted); font-size: 0.9rem; letter-spacing: 0.02em; }
.home-about { line-height: 1.8; }
.home-about p { margin-bottom: 1.3rem; }
.home-about p:last-child { margin-bottom: 0; }
.home-about a { font-weight: 500; }
.home-details { margin-top: 1.75rem; font-size: 0.9rem; }
.home-details details { margin-top: 0.25rem; }
.home-details summary { display: flex; align-items: baseline; gap: 0.7rem; padding: 0.6rem 0; color: var(--muted); cursor: pointer; list-style: none; }
.home-details summary::-webkit-details-marker { display: none; }
.home-details summary::before { content: ""; flex: none; width: 6px; height: 6px; border-top: 1px solid currentColor; border-right: 1px solid currentColor; transform: rotate(45deg); }
.home-details details[open] > summary::before { transform: rotate(135deg); }
.home-details summary:hover, .home-details details[open] summary { color: var(--ink); }
.home-details ul { margin-top: 0.6rem; margin-bottom: 1.25rem; }
.home-details li { margin-bottom: 0.7rem; }
.home-details li::marker { color: var(--muted); }

/* A single accessible control, shared by every page. */
.theme-toggle { position: fixed; top: 20px; right: 20px; z-index: 2; display: grid; place-items: center; width: 42px; height: 42px; padding: 0; border: 1px solid var(--line); border-radius: 50%; background: var(--paper); color: var(--body); cursor: pointer; }
.theme-toggle:hover { color: var(--ink); border-color: var(--muted); }
.theme-toggle svg { width: 18px; height: 18px; }
.theme-moon { fill: currentColor; }
.theme-sun { display: none; fill: none; stroke: currentColor; stroke-linecap: round; stroke-width: 1.5; }
:root[data-theme="dark"] .theme-moon { display: none; }
:root[data-theme="dark"] .theme-sun { display: block; }
.skip-link { position: fixed; top: 0.5rem; left: 0.5rem; padding: 0.5rem; background: var(--paper); transform: translateY(-200%); z-index: 3; }
.skip-link:focus { transform: none; }

/* Page intro note with inline links. */
.page-note { margin: 1rem 0 0; color: var(--muted); font-size: 0.95rem; }
.page-note a { color: var(--ink); text-decoration: underline; text-decoration-color: var(--line); }
.page-note a:hover { text-decoration-color: currentColor; }

/* Search: a plain field that filters the writing list. */
.search-form { display: flex; align-items: center; gap: 0.5rem; margin: 0 0 0.75rem; padding: 0.15rem 0; border-bottom: 1px solid var(--line); transition: border-color 220ms ease; }
.search-form:focus-within { border-bottom-color: var(--ink); }
.search-icon { flex: none; width: 16px; height: 16px; fill: none; stroke: var(--muted); stroke-width: 1.6; stroke-linecap: round; }
.search-input { flex: 1 1 auto; min-width: 0; padding: 0.45rem 0; border: 0; background: transparent; color: var(--ink); font: 400 0.95rem var(--sans); }
.search-input::placeholder { color: var(--muted); }
.search-input:focus { outline: none; }
.search-input:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.search-input::-webkit-search-cancel-button { -webkit-appearance: none; }
.search-status { margin: 0.75rem 0 0; color: var(--muted); font-size: 0.8rem; }
.search-status:empty { display: none; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* Writing: a stacked list of dated entries, separated by hairlines. */
.post-list { list-style: none; margin: 0; padding: 0; border-bottom: 1px solid var(--line); }
.post-list li { margin: 0; padding: 1.6rem 0; border-top: 1px solid var(--line); }
.post-list li:first-child { border-top: 0; }
.post-list:empty { border-bottom: 0; }
.post-list time { display: block; margin-bottom: 0.4rem; color: var(--muted); font: 0.7rem var(--sans); letter-spacing: 0.09em; text-transform: uppercase; }
.post-list h3 { margin: 0; font-family: var(--serif); font-size: 1.4rem; font-weight: 400; line-height: 1.3; letter-spacing: -0.01em; }
.post-list h3 a { text-decoration: underline; text-decoration-color: transparent; }
.post-list h3 a:hover { text-decoration-color: var(--muted); }

/* The tag archive stays compact: date on the left, title on the right. */
.post-list.compact { border-bottom: 0; }
.post-list.compact li { display: grid; grid-template-columns: 5.5rem minmax(0, 1fr); gap: 1rem; padding: 1rem 0; }
.post-list.compact li:first-child { border-top: 1px solid var(--line); }
.post-list.compact time { margin: 0; padding-top: 0.15rem; font-size: 0.8rem; letter-spacing: 0; text-transform: none; font-variant-numeric: tabular-nums; }
.post-list.compact h3 { font-family: var(--sans); font-size: 1rem; font-weight: 500; line-height: 1.5; letter-spacing: 0; text-align: right; }
.post-content { color: var(--ink); font-family: var(--serif); font-size: 1.15rem; line-height: 1.8; }
.post-content h2, .post-content h3 { font-family: var(--sans); font-weight: 600; }
.post-content h2 { font-size: 1.25rem; }
.post-content h3 { font-size: 1.1rem; }
.post-content img { display: block; margin: 2rem auto; }
.post-content blockquote { margin: 1.75rem 0; padding-left: 1.25rem; border-left: 2px solid var(--line); color: var(--muted); }
.post-content pre { overflow-x: auto; padding: 1rem; background: var(--surface); font-size: 0.85rem; }
.post-content code { font-size: 0.85em; }
.post-content table { display: block; max-width: 100%; overflow-x: auto; border-collapse: collapse; font-size: 0.9em; }
.post-content th, .post-content td { padding: 0.5rem; border-bottom: 1px solid var(--line); text-align: left; }
.back-link { margin: 3rem 0 0; font-size: 0.9rem; }

/* Click-to-zoom for images in the writing. */
.post-content img.is-zoomable, .page-content img.is-zoomable { cursor: zoom-in; }
.post-content img.is-zoomable:focus-visible, .page-content img.is-zoomable:focus-visible { outline: 2px solid var(--ink); outline-offset: 4px; }
.lightbox { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; padding: clamp(1rem, 4vw, 3rem); background: rgba(8, 8, 8, 0.9); }
.lightbox figure { display: grid; gap: 1rem; justify-items: center; margin: 0; max-width: 100%; }
.lightbox img { max-width: 100%; max-height: 82vh; width: auto; height: auto; border-radius: 6px; }
.lightbox figcaption { max-width: 60ch; color: rgba(255, 255, 255, 0.72); font-size: 0.85rem; line-height: 1.5; text-align: center; }
.lightbox-close { position: absolute; top: 1rem; right: 1rem; display: grid; place-items: center; width: 42px; height: 42px; padding: 0; border: 1px solid rgba(255, 255, 255, 0.35); border-radius: 50%; background: transparent; color: #fff; font-size: 1.4rem; line-height: 1; cursor: pointer; }
.lightbox-close:hover { background: rgba(255, 255, 255, 0.12); }

/* Content pages keep their own small, plain lists. */
.headshot { float: right; width: 32%; max-width: 11rem; height: auto; margin: 0 0 1rem 1.5rem; border-radius: 8px; }
.update-list { list-style: none; margin: 0; padding: 0; }
.update-list li { display: grid; grid-template-columns: 5.5rem minmax(0, 1fr); gap: 1rem; margin: 0; padding: 0.45rem 0; }
.update-list time { color: var(--muted); font-size: 0.8rem; }
.publication-list { margin: 0; padding: 0; list-style: none; }
.publication-list li { margin: 0; padding: 1.25rem 0; border-top: 1px solid var(--line); }
.publication-list p { margin: 0; font-size: 0.95rem; }
.publication-list strong { color: var(--ink); font-weight: 500; }
.scholar-summary { margin-top: 1rem; }
.scholar-summary, .publication-citations { color: var(--muted); font-size: 0.8rem; }
.publication-citations { margin-left: 0.35rem; white-space: nowrap; }
.tag-list, .tag-index { display: flex; flex-wrap: wrap; gap: 0.35rem 1rem; list-style: none; margin: 1rem 0 0; padding: 0; }
.tag-list a, .tag-index a { color: var(--muted); font: 0.85rem var(--sans); }
.tag-index a span { margin-left: 0.25rem; }
.tag-section { margin-top: 3rem; scroll-margin-top: 2rem; }

/* Motion is a small enhancement, never a prerequisite for reading or navigation. */
@media (prefers-reduced-motion: no-preference) {
  @keyframes arrive {
    from { opacity: 0.85; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
  }
  @keyframes breeze-in {
    from { opacity: 0; transform: translateY(9px); }
    to { opacity: 1; transform: translateY(0); }
  }
  main { animation: arrive 480ms var(--ease); }
  .home-page main { animation: none; }
  .home-page .home-identity,
  .home-page .home-about p,
  .home-page .home-details,
  .home-page .site-links,
  .home-page .social-links,
  .home-page .local-time {
    animation: breeze-in 680ms var(--ease) both;
  }
  .home-page .home-identity { animation-delay: 80ms; }
  .home-page .home-about p:nth-child(1) { animation-delay: 190ms; }
  .home-page .home-about p:nth-child(2) { animation-delay: 310ms; }
  .home-page .home-about p:nth-child(3) { animation-delay: 430ms; }
  .home-page .home-about p:nth-child(4) { animation-delay: 550ms; }
  .home-page .home-about p:nth-child(5) { animation-delay: 670ms; }
  .home-page .home-details { animation-delay: 790ms; }
  .home-page .site-links { animation-delay: 930ms; }
  .home-page .social-links { animation-delay: 1070ms; }
  .home-page .local-time { animation-delay: 1190ms; }
  .home-page .theme-toggle { animation: breeze-in 520ms var(--ease) 100ms both; }
  .home-portraits img { transition: opacity 900ms var(--ease); }
  .lightbox:not([hidden]) { animation: breeze-in 220ms var(--ease); }

  /* Theme change: the new palette irises out from the toggle and swallows
     the screen. View Transitions snapshots the page, so this is GPU-cheap. */
  ::view-transition-group(root) { z-index: 100; }
  ::view-transition-old(root),
  ::view-transition-new(root) { animation: none; mix-blend-mode: normal; }
  ::view-transition-new(root) {
    clip-path: circle(0 at var(--vt-x, 50%) var(--vt-y, 50%));
    animation: theme-reveal 640ms cubic-bezier(0.33, 1, 0.68, 1) forwards;
  }
  @keyframes theme-reveal {
    to { clip-path: circle(var(--vt-r, 150vmax) at var(--vt-x, 50%) var(--vt-y, 50%)); }
  }

  /* Inner pages: content settles in, and the writing list drifts in title by title. */
  .flow-page main { animation: none; }
  .flow-page .page-header,
  .flow-page .section-heading,
  .flow-page .search-form { animation: breeze-in 640ms var(--ease) both; }
  .flow-page .page-header { animation-delay: 80ms; }
  .flow-page .section-heading { animation-delay: 200ms; }
  .flow-page .search-form { animation-delay: 300ms; }
  .flow-page .post-list--intro li {
    animation: breeze-in 760ms var(--ease) both;
    animation-delay: min(calc(380ms + var(--i, 0) * 45ms), 1.3s);
  }

  /* A single post: header details arrive first, then the writing settles in. */
  .flow-page .post-header .eyebrow,
  .flow-page .post-header h1,
  .flow-page .post-header .lede,
  .flow-page .post-header .tag-list,
  .flow-page .post-content,
  .flow-page .back-link { animation: breeze-in 680ms var(--ease) both; }
  .flow-page .post-header .eyebrow { animation-delay: 80ms; }
  .flow-page .post-header h1 { animation-delay: 170ms; }
  .flow-page .post-header .lede { animation-delay: 260ms; }
  .flow-page .post-header .tag-list { animation-delay: 340ms; }
  .flow-page .post-content { animation-delay: 430ms; }
  .flow-page .back-link { animation-delay: 560ms; }
  a { transition: color 220ms ease, text-decoration-color 220ms ease; }
  .theme-toggle { transition: color 220ms ease, border-color 220ms ease; }
  .home-details summary { transition: color 220ms ease; }
  .home-details summary::before { transition: transform 260ms var(--ease); }
  .home-details details[open] > ul { animation: arrive 360ms var(--ease); }
  html[data-theme-transition] body,
  html[data-theme-transition] .theme-toggle { transition: background-color 320ms ease, color 320ms ease, border-color 320ms ease; }

  /* Smooth native disclosures where supported; elsewhere they open normally. */
  @supports (interpolate-size: allow-keywords) and selector(details::details-content) {
    .home-details details { interpolate-size: allow-keywords; }
    .home-details details::details-content {
      height: 0;
      overflow: clip;
      transition: height 360ms var(--ease), content-visibility 360ms;
      transition-behavior: allow-discrete;
    }
    .home-details details[open]::details-content { height: auto; }
  }
}

@media (max-width: 600px) {
  .site-shell { width: calc(100% - 2.5rem); }
  .home-page .site-shell { padding: 6rem 0 3rem; }
  .home-identity { gap: 0.8rem; }
  .home-portraits { width: 76px; height: 76px; }
  .home-identity p { font-size: 0.8rem; }
  .theme-toggle { top: 16px; right: 16px; }
  .post-list.compact li, .update-list li { grid-template-columns: 4.5rem minmax(0, 1fr); gap: 0.75rem; }
  .search-form { padding-left: 0.7rem; }
  .headshot { width: 30%; margin-left: 1rem; }
  .site-links { gap: 0.45rem 1.15rem; }
}
