/* soundings — the entire design. Measures taken from darioamodei.com:
   38.75rem column, 1.25rem/1.6 body at every width, header as one flex row.
   Palette: warm paper + ink; titles in Flexoki blue (the vault's accent). */

:root {
  --bg: #faf9f5;
  --text: #1f1e1b;
  --muted: #9a948a;
  --soft: #4a463f;
  --line: #e6e2d9;
  --title: #1f1e1b; /* colorless, dario-style; was Flexoki blue #205ea6 */
  --serif: "Newsreader", Georgia, serif; /* was Source Serif 4 — read as typewriter-ish */
  --sans: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, monospace;
}

.dark {
  --bg: #191817;
  --text: #eae6df;
  --muted: #6e6a63;
  --soft: #c9c4bb;
  --line: #33312e;
  --title: #eae6df; /* was #4385be */
}

* { box-sizing: border-box; }

html {
  /* background on the root too: no default-white frame can ever flash;
     transitions with body so the area below short content fades in step */
  background: var(--bg);
  transition: background-color 0.07s linear;
  text-size-adjust: none;
  /* publications scrolls, the homepage may not: reserve the scrollbar
     gutter so the centered column cannot drift between pages */
  overflow-y: scroll;
  scrollbar-gutter: stable;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--soft);
  font-family: var(--serif);
  font-size: 1.25rem;
  line-height: 1.6;
}

.wrap {
  max-width: 38.75rem;
  margin: 0 auto;
  padding: 0 1.25rem 4rem;
}

/* --- header: name left, tools right; sticky, hides on scroll down --- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 0 1.5rem;
  padding: 1.2rem 0 0.75rem;
  transition: transform 0.3s cubic-bezier(0.165, 0.84, 0.44, 1);
}

.site-header.hidden { transform: translateY(-110%); }

.header-tools {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}



.site-name {
  font-family: var(--sans);
  font-size: 1.6rem;
  font-weight: 600;
  line-height: 1;
  color: var(--title);
}

.site-name a {
  color: inherit;
  text-decoration: none;
}

.site-name a:hover { opacity: 0.8; }

.theme-toggle {
  border: none;
  background: none;
  padding: 0.2rem;
  cursor: pointer;
  color: var(--muted);
}

.theme-toggle:hover { color: var(--text); }
html.dark .theme-toggle .sun { display: none; }
html:not(.dark) .theme-toggle .moon { display: none; }

/* --- headings --- */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--sans);
  font-weight: 500;
  color: var(--title);
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.essay-title {
  /* dario-style serif display title, at a restrained size */
  font-family: var(--serif);
  font-weight: 600;
  font-size: 2.3rem;
  line-height: 1.15;
  margin: 2.5rem 0 0.35rem;
}

/* anthropic scale: headings ~1.9x body, weight 600, text hugging below */
main h2 { font-size: 1.9rem; font-weight: 600; margin: 2.8rem 0 0.4rem; }
main h3 { font-size: 1.25rem; font-weight: 600; margin: 2.2rem 0 0.3rem; }
main h2 + p, main h3 + p, main h2 + ul, main h3 + ul { margin-top: 0.45em; }

/* homepage section labels: body-sized, sans, blue */
body.home main :is(h2, h3, h4) {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 2.9rem 0 0.35rem;
}

.meta {
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.02em;
  color: var(--muted);
  margin: 0.25rem 0 2rem;
}

/* --- links: text-colored, quiet underline --- */
a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: currentcolor;
  text-underline-offset: 0.15em;
}

a:hover {
  color: var(--muted);
}

/* external links carry a small arrow, anthropic-style */
main a[href^="http"]::after {
  content: "\2197";
  font-family: var(--sans);
  font-size: 0.65em;
  margin-left: 0.12em;
  vertical-align: 0.2em;
  color: var(--muted);
  display: inline-block;
}

/* --- homepage writing list: bare rows, mono date stamps --- */
main ul {
  list-style: none;
  padding-left: 0;
}

main li { margin: 0.4rem 0; }

li > code, p > code {
  font-family: var(--mono);
  background: none;
  padding: 0;
  font-size: 0.78em;
  color: var(--muted);
}

/* --- code blocks: plain mono on a quiet ground --- */
pre {
  background: color-mix(in srgb, var(--line) 40%, var(--bg));
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.8rem 1rem;
  overflow-x: auto;
}

pre code {
  font-family: var(--mono);
  font-size: 0.85rem;
  line-height: 1.5;
  background: none;
  padding: 0;
}

/* --- table of contents: aside when wide, header hamburger when narrow --- */
.toc-side { display: none; }
.toc-toggle {
  border: none;
  background: none;
  padding: 0.2rem;
  cursor: pointer;
  color: var(--muted);
}
.toc-toggle:hover { color: var(--text); }

@media (min-width: 1150px) {
  .toc-side {
    display: block;
    position: fixed;
    top: 6.6rem; /* the Contents label sits on the essay title's line */
    /* left aligns with the corner toggle above it */
    left: 2rem;
    width: 13rem;
    border-left: 1px solid var(--line);
    padding-left: 0.85rem;
  }

  .toc-toggle, .toc-panel { display: none; }
}

/* full-page contents overlay, dario-style: fades and slides in under the header */
.toc-panel {
  position: fixed;
  inset: 0;
  z-index: 6; /* covers the header; only the corner button stays on top */
  background: var(--bg);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-0.5rem);
  transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s;
}

.toc-panel.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

/* wide view: corner button on the header line collapses the side contents */
.toc-side-toggle { display: none; }

@media (min-width: 1150px) {
  .toc-side-toggle {
    display: block;
    position: fixed;
    top: 1.2rem;
    left: 2rem;
    z-index: 5;
    border: none;
    background: none;
    padding: 0.2rem;
    cursor: pointer;
    color: var(--muted);
  }

  .toc-side-toggle:hover { color: var(--text); }
  .toc-side-toggle .ico-b { display: none; }
  html.side-toc-hidden .toc-side-toggle .ico-x { display: none; }
  html.side-toc-hidden .toc-side-toggle .ico-b { display: inline; }
  html.side-toc-hidden .toc-side { display: none; }
}

/* the overlay's own close button, top-left like dario's */
.toc-close {
  position: absolute;
  top: 1.15rem;
  left: 1.1rem;
  border: none;
  background: none;
  padding: 0.2rem;
  cursor: pointer;
  color: var(--soft);
}

.toc-panel-inner {
  max-width: 38.75rem;
  margin: 0 auto;
  padding: 6.5rem 1.25rem 0;
}



html.no-scroll { overflow: hidden; }

.toc-toggle .ico-close { display: none; }
.toc-toggle.open .ico-burger { display: none; }
.toc-toggle.open .ico-close { display: inline; }

.toc-label {
  font-family: var(--sans);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.toc-side ul, .toc-panel ul {
  list-style: none;
  padding-left: 0;
  margin: 0.5rem 0 0;
}

.toc-side li, .toc-panel li {
  font-family: var(--sans);
  font-size: 0.95rem;
  margin: 0.45rem 0;
}

.toc-side li.lvl-3, .toc-panel li.lvl-3 { padding-left: 0.8rem; }

.toc-side a, .toc-panel a {
  color: var(--muted);
  text-decoration: none;
}

.toc-side a:hover, .toc-panel a:hover { color: var(--text); }



/* --- footnotes --- */
.footnotes-sep { border: none; border-top: 1px solid var(--line); margin-top: 3rem; }
.footnotes { font-size: 0.95rem; }
.footnote-ref a, a.footnote-backref { text-decoration: none; }

/* --- images --- */
img { max-width: 100%; height: auto; }

hr { border: none; border-top: 1px solid var(--line); margin: 2em 0; }

blockquote {
  margin: 1em 0;
  padding-left: 1em;
  border-left: 2px solid var(--line);
  color: var(--muted);
}

/* inside the overlay: dario's treatment — serif, ink, generous */
.toc-panel .toc-label {
  font-family: var(--serif);
  font-size: 2rem;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  color: var(--text);
}

.toc-panel ul { margin-top: 1.6rem; }

.toc-panel li {
  font-family: var(--serif);
  font-size: 1.55rem;
  margin: 1.35rem 0;
}

.toc-panel li.lvl-3 { padding-left: 0; }

.toc-panel a { color: var(--soft); }
.toc-panel a:hover { color: var(--text); }

/* header buttons: comfortable size, optically on the name's centerline */
.theme-toggle svg,
.toc-toggle svg,
.toc-side-toggle svg,
.toc-close svg {
  display: block;
  width: 25px;
  height: 25px;
}

/* side contents: dario's treatment — serif heading, serif entries, no rule line */
.toc-side {
  border-left: none !important;
  padding-left: 0 !important;
  width: 13rem !important;
}

.toc-side .toc-label {
  font-family: var(--serif);
  font-size: 1.4rem;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  color: var(--text);
}

.toc-side ul { margin-top: 1.2rem; }

.toc-side li {
  font-family: var(--serif);
  font-size: 1.1rem;
  line-height: 1.35;
  margin: 0.85rem 0;
}

.toc-side li.lvl-3 { padding-left: 0.8rem; }

.toc-side a { color: var(--muted); }

.toc-side a:hover { color: var(--soft); }

.toc-side a.in-view {
  color: var(--text);
  font-weight: 600;
}


/* anchor jumps land with air below the sticky header, not flush to it */
h1, h2, h3, h4, h5, h6 {
  scroll-margin-top: 5.5rem;
}

/* day/night switch, dario-style: permanent per-element color transitions.
   The variables flip instantly; each element glides at its own speed —
   links deliberately slower, giving the staggered feel. */
body {
  transition: background-color 0.07s linear, color 0.07s linear;
}

h1, h2, h3, h4, h5, h6,
.site-name,
.theme-toggle svg,
.toc-toggle svg {
  transition: color 0.07s linear, fill 0.07s linear;
}

a {
  transition: color 0.07s linear;
}

main a[href^="http"]::after {
  transition: color 0.07s linear;
}

pre, hr, blockquote {
  transition: background-color 0.07s linear, border-color 0.07s linear;
}

.toc-panel {
  transition:
    opacity 0.25s ease,
    transform 0.25s ease,
    visibility 0.25s,
    background-color 0.07s linear;
}

.site-header {
  transition:
    transform 0.3s cubic-bezier(0.165, 0.84, 0.44, 1),
    background-color 0.07s linear;
}
