/* ---------------------------------------------------------------------------
   soundsonacid — warm dark, typographic, zero JS.
   Fonts: Young Serif (display) · Newsreader (body) · IBM Plex Mono (code/meta)
--------------------------------------------------------------------------- */

@font-face {
  font-family: "Young Serif";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/young-serif-400-normal.woff2") format("woff2");
}
@font-face {
  font-family: "Newsreader";
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src: url("/fonts/newsreader-200-800-normal.woff2") format("woff2");
}
@font-face {
  font-family: "Newsreader";
  font-style: italic;
  font-weight: 200 800;
  font-display: swap;
  src: url("/fonts/newsreader-200-800-italic.woff2") format("woff2");
}
@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 100 800;
  font-display: swap;
  src: url("/fonts/jetbrains-mono-100-800-normal.woff2") format("woff2");
}
@font-face {
  font-family: "JetBrains Mono";
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/jetbrains-mono-400-italic.woff2") format("woff2");
}

/* ------------------------------------------------------------------ tokens */

:root {
  --bg: #1d1a16;         /* warm charcoal */
  --bg-deep: #14120f;    /* sidebar, code blocks */
  --bg-raise: #262219;   /* inline code, table stripes */
  --ink: #cdc4b4;        /* body text */
  --ink-bright: #f2ead9; /* headings, strong */
  --ink-dim: #8d8577;    /* meta, muted */
  --acid: #d8f34e;       /* the accent */
  --acid-dim: #9aad3b;
  --line: #3a352c;       /* hairlines */

  --serif: "Newsreader", "Iowan Old Style", Georgia, serif;
  --display: "Young Serif", Georgia, serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

/* ------------------------------------------------------------------- base */

* { box-sizing: border-box; }

html {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 20px;
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
}

body { margin: 0; }

::selection {
  background: var(--acid);
  color: var(--bg-deep);
}

/* scrollable areas get a slim scrollbar in the site's palette */
pre,
.toc-side,
.post-body table,
.post-body object {
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}

/* ----------------------------------------------------------------- layout */

.sidebar {
  background: var(--bg-deep);
  padding: 2rem 1.5rem;
}

.content {
  max-width: 40rem;
  padding: 2rem 1.25rem 4rem;
  margin: 0 auto;
}

@media (min-width: 60em) {
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 17rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 3rem 2rem;
  }
  .content {
    margin-left: calc(17rem + 5vw);
    padding-top: 5rem;
  }
}
/* content stays put at large widths; the right margin is the sidenote rail */

/* ---------------------------------------------------------------- sidebar */

.wordmark {
  font-family: var(--display);
  font-size: 1.5rem;
  color: var(--ink-bright);
  text-decoration: none;
  letter-spacing: -0.01em;
}
.wordmark:hover { color: var(--acid); }
.wordmark .wave { color: var(--acid); }

.sidebar-nav {
  margin-top: 1.25rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
  font-family: var(--mono);
  font-size: 0.7rem;
}
.sidebar-nav a {
  color: var(--ink);
  text-decoration: none;
}
.sidebar-nav a::before {
  content: "/";
  color: var(--acid-dim);
  margin-right: 0.15em;
}
.sidebar-nav a:hover { color: var(--acid); }

.sidebar-footer {
  font-family: var(--mono);
  font-size: 0.65rem;
  color: var(--ink-dim);
}
.sidebar-footer p { margin: 0; }

/* on tight screens the sidebar becomes a footer */
@media (max-width: 59.98em) {
  body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
  }
  /* min-width:0 lets the flex item shrink below its content's intrinsic
     width — otherwise one long code line inflates the page past the
     viewport and the footer/background only paints partway */
  .content {
    order: 1;
    min-width: 0;
    width: 100%;
    /* explicit width defeats the fit-content flex sizing (mobile overflow);
       auto margins keep the clamped column centered just below the
       sidebar breakpoint */
    margin: 0 auto;
  }
  .sidebar {
    order: 2;
    margin-top: auto;
    border-top: 1px solid var(--line);
    padding: 2rem 1.25rem;
  }
  .sidebar-inner {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem 1.5rem;
    max-width: 40rem;
    margin: 0 auto;
  }
  .sidebar-nav { margin-top: 0; }
  .sidebar-footer {
    max-width: 40rem;
    margin: 1.5rem auto 0;
  }
}

.to-top { display: none; }
.sidebar-nav a.to-top::before { content: none; }
@media (max-width: 59.98em) {
  .to-top { display: inline; }
}

/* ------------------------------------------------------------------- home */

.year-group { margin-bottom: 2.5rem; }

h2.year::before {
  content: "∿ ";
  color: var(--acid-dim);
}
h2.year {
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--ink-dim);
  letter-spacing: 0.15em;
  border-bottom: 1px solid var(--line);
  padding-bottom: 0.4rem;
  margin: 0 0 1rem;
}

.post-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.post-list li {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  margin-bottom: 0.6rem;
}
.post-list a {
  color: var(--ink-bright);
  text-decoration: none;
  font-size: 1.05rem;
}
.post-list a:hover { color: var(--acid); }
.post-list .dots {
  flex: 1;
  border-bottom: 1px dotted var(--line);
  transform: translateY(-0.25em);
}
.post-list time {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--ink-dim);
  white-space: nowrap;
}

/* ------------------------------------------------------------------ posts */

.post-header { margin-bottom: 2.5rem; }

.post-title {
  font-family: var(--display);
  font-weight: 400;
  font-size: 2.1rem;
  line-height: 1.15;
  color: var(--ink-bright);
  margin: 0 0 0.75rem;
  letter-spacing: -0.01em;
}

.post-meta {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--ink-dim);
  margin: 0;
}
.post-meta .sep { color: var(--acid-dim); margin: 0 0.35em; }

.post-end {
  margin-top: 3rem;
  color: var(--acid);
  font-size: 1.3rem;
  text-align: center;
  letter-spacing: 0.5em;
}

/* -------------------------------------------------------------- prose */

.post-body h2,
.post-body h3,
.post-body h4 {
  font-family: var(--display);
  font-weight: 400;
  color: var(--ink-bright);
  line-height: 1.2;
  margin: 2.2em 0 0.6em;
}
.post-body h2 { font-size: 1.45rem; }
.post-body h3 { font-size: 1.15rem; }
.post-body h4 { font-size: 1rem; }

/* markdown-it-anchor wraps headings in a self-link */
.post-body :is(h2, h3, h4) a {
  color: inherit;
  text-decoration: none;
}
.post-body :is(h2, h3, h4) a:hover { color: var(--acid); }
.post-body :is(h2, h3, h4) a:hover::before {
  content: "∿ ";
  color: var(--acid);
}

/* break long identifiers (types, paths) rather than overflow the viewport;
   inherited everywhere in the prose, only kicks in when a token can't fit */
.post-body { overflow-wrap: break-word; }

.post-body p { margin: 0 0 1.1em; }

.post-body a {
  color: var(--ink-bright);
  text-decoration: underline;
  text-decoration-color: var(--acid-dim);
  text-decoration-thickness: 1.5px;
  text-underline-offset: 0.2em;
}
.post-body a:hover {
  color: var(--acid);
  text-decoration-color: var(--acid);
}

.post-body strong { color: var(--ink-bright); }
.post-body em { color: var(--ink-bright); }

.post-body hr {
  border: 0;
  margin: 2.5rem auto;
  text-align: center;
}
.post-body hr::after {
  content: "∿ ∿ ∿";
  color: var(--acid-dim);
  letter-spacing: 0.6em;
}

.post-body blockquote {
  margin: 1.5em 0;
  padding: 0.1em 0 0.1em 1.25em;
  border-left: 2px solid var(--acid-dim);
  color: var(--ink-dim);
  font-style: italic;
  font-size: 1.02em;
}
.post-body blockquote em { font-style: normal; }

.post-body ul, .post-body ol { padding-left: 1.4em; margin: 0 0 1.1em; }
.post-body li { margin-bottom: 0.3em; }
.post-body li::marker { color: var(--acid-dim); }

.post-body img {
  max-width: 100%;
  border-radius: 6px;
  display: block;
  margin: 1.5em auto;
}
.post-body figcaption {
  text-align: center;
  font-size: 0.85em;
  font-style: italic;
  color: var(--ink-dim);
  margin-top: 0.5em;
}

.post-body figure {
  margin: 1.5em 0;
}

/* inlined svgs scale with the column */
.post-body figure > svg,
.post-body > svg {
  display: block;
  width: 100%;
  height: auto;
  margin: 0 auto;
}

/* scripted svgs (flamegraphs etc.) embedded as their own documents */
.post-body object {
  display: block;
  border-radius: 6px;
}

/* ------------------------------------------------------------------- code */

code {
  font-family: var(--mono);
  font-size: 0.72em;
}

.post-body :not(pre) > code {
  background: var(--bg-raise);
  padding: 0.15em 0.35em;
  border-radius: 4px;
  color: var(--ink-bright);
}

pre {
  background: var(--bg-deep);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1rem 1.2rem;
  overflow-x: auto;
  line-height: 1.5;
  margin: 1.5em 0;
}
pre code { font-size: 0.7rem; }

/* long code lines break out of the prose column instead of scrolling,
   growing to fit up to a cap. pre's overflow makes it a BFC, so if a
   sidenote occupies the margin the block narrows instead of overlapping. */
@media (min-width: 60em) {
  .post-body pre {
    width: fit-content;
    min-width: 100%;
    max-width: min(58rem, calc(100vw - 17rem - 5vw - 3rem));
  }
}
/* code needs to grow on small screens, not shrink with the column */
@media (max-width: 40em) {
  pre { padding: 0.8rem 0.9rem; }
  pre code { font-size: 0.75rem; }
  .post-body :not(pre) > code { font-size: 0.78em; }
}

/* highlight.js theme, tuned to the palette */
.hljs-comment, .hljs-quote { color: #7a7264; font-style: italic; }
.hljs-keyword, .hljs-selector-tag, .hljs-meta { color: #e0a458; }
.hljs-string, .hljs-regexp, .hljs-addition { color: #b5c877; }
.hljs-number, .hljs-literal, .hljs-deletion { color: #e07a5f; }
.hljs-title, .hljs-title.function_, .hljs-section { color: #f2ead9; }
.hljs-type, .hljs-title.class_, .hljs-built_in { color: #93c7b2; }
.hljs-attr, .hljs-attribute, .hljs-variable, .hljs-template-variable { color: #cdc4b4; }
.hljs-symbol, .hljs-bullet, .hljs-link { color: #d8f34e; }
.hljs-emphasis { font-style: italic; }
.hljs-strong { font-weight: 600; }

/* ----------------------------------------------------------------- tables */

.post-body table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85em;
  margin: 1.5em 0;
}
.post-body th {
  font-family: var(--mono);
  font-size: 0.75em;
  font-weight: 600;
  text-align: left;
  color: var(--ink-dim);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--acid-dim);
  padding: 0.4em 0.75em;
}
.post-body td {
  padding: 0.45em 0.75em;
  border-bottom: 1px solid var(--line);
}
.post-body tr:nth-child(even) td { background: rgb(255 255 255 / 0.02); }

/* wide tables scroll sideways on narrow screens instead of breaking layout */
@media (max-width: 40em) {
  .post-body table {
    display: block;
    overflow-x: auto;
    border-spacing: 0;
  }
}

/* ------------------------------------------------------ table of contents */

.toc {
  font-family: var(--mono);
  font-size: 0.7rem;
}
.toc ol {
  list-style: none;
  margin: 0;
  padding: 0;
}
.toc ol ol { padding-left: 1.1em; }
.toc li { margin: 0.4em 0; }
.toc a {
  color: var(--ink-dim);
  text-decoration: none;
}
.toc a:hover { color: var(--acid); }
.toc-label, .toc-inline summary {
  color: var(--ink-dim);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  font-size: 0.65rem;
}
.toc-label::before {
  content: "∿ ";
  color: var(--acid-dim);
}

.toc-inline {
  background: var(--bg-deep);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  margin-bottom: 2rem;
}
.toc-inline summary { cursor: pointer; }
.toc-inline summary:hover { color: var(--acid); }
.toc-inline[open] summary { margin-bottom: 0.6rem; }

/* the side toc lives in the left sidebar, under the nav */
.toc-side { display: none; }
@media (min-width: 60em) {
  .toc-inline { display: none; }
  .toc-side {
    display: block;
    position: fixed;
    top: 12rem;
    left: 2rem;
    width: 13rem;
    max-height: calc(100vh - 17rem);
    overflow-y: auto;
    overflow-x: hidden;
  }
  .toc-side a { overflow-wrap: break-word; }
  .toc-label {
    display: block;
    margin-bottom: 0.7rem;
  }
  .toc-side a.current { color: var(--acid); }
}

/* -------------------------------------------------------------- sidenotes */

/* footnotes float into the right margin as sidenotes when there's room;
   below that they stay as regular bottom footnotes */
.sidenote { display: none; }
.sidenote-num {
  font-family: var(--mono);
  font-size: 0.85em;
  color: var(--acid);
}
@media (min-width: 96em) {
  .sidenote {
    display: block;
    float: right;
    clear: right;
    width: 13rem;
    margin-right: -15rem;
    margin-top: 0.15rem;
    margin-bottom: 0.7rem;
    font-size: 0.78rem;
    line-height: 1.55;
    color: var(--ink-dim);
  }
  .sidenote a { color: var(--ink); }
  .footnotes-sep,
  .footnotes { display: none; }
}

/* block sidenotes (asides with code, lists…) */
aside.sidenote p { margin: 0 0 0.5em; }
aside.sidenote p:last-child { margin-bottom: 0; }
.post-body .sidenote pre {
  width: auto;
  min-width: 0;
  max-width: 100%;
  margin: 0.5em 0 0;
  padding: 0.5rem 0.65rem;
}
.post-body .sidenote pre code { font-size: 0.58rem; }

.post-body::after {
  content: "";
  display: block;
  clear: both;
}

/* ------------------------------------------------------- link previews */

.post-body a.has-preview { position: relative; }
.link-preview {
  position: absolute;
  top: calc(100% + 0.5em);
  left: 0;
  width: max-content;
  max-width: 18rem;
  background: var(--bg-deep);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.4);
  padding: 0.6rem 0.8rem;
  font-family: var(--mono);
  font-style: normal;
  font-size: 0.65rem;
  line-height: 1.5;
  color: var(--ink-dim);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s ease, visibility 0.15s;
  transition-delay: 0.3s;
  pointer-events: none;
  z-index: 5;
}
.link-preview-title {
  display: block;
  color: var(--ink-bright);
  margin-bottom: 0.15rem;
}
.link-preview-desc { display: block; }
.post-body a.has-preview:hover .link-preview,
.post-body a.has-preview:focus .link-preview {
  opacity: 1;
  visibility: visible;
}

/* -------------------------------------------------------------- footnotes */

.footnotes-sep { display: none; }
.footnotes {
  font-size: 0.85em;
  color: var(--ink-dim);
  margin-top: 3rem;
  border-top: 1px solid var(--line);
  padding-top: 1.25rem;
}
.footnotes p { display: inline; }
.footnote-ref a, a.footnote-backref {
  font-family: var(--mono);
  font-size: 0.8em;
  text-decoration: none;
  color: var(--acid);
}
/* obvious way back from a footnote to the sentence that spawned it */
a.footnote-backref {
  display: inline-block;
  margin-left: 0.4em;
  padding: 0.1em 0.55em;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.75em;
}
a.footnote-backref:hover {
  border-color: var(--acid);
  background: var(--bg-raise);
}
sup.footnote-ref { line-height: 0; }
