/* ─── tokens ─────────────────────────────────────────── */
:root {
  --bg: #ffffff;
  --fg: #111111;
  --muted: #666666;
  --border: #dddddd;
  --reading: 660px;
  --wide: 860px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --mono: "SF Mono", "Fira Code", "Cascadia Code", Consolas, monospace;
}

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.72;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ─── responsive media ───────────────────────────────── */
/* Global safety net: any figure not wrapped in .narrow-figure
   would otherwise render at natural width and overflow on phones.
   SVG is excluded so KaTeX radicals and stretchy delimiters keep
   their explicit dimensions. */
img,
video,
iframe {
  max-width: 100%;
  height: auto;
}

/* ─── links ──────────────────────────────────────────── */
a {
  color: inherit;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  text-decoration-color: var(--border);
  transition: text-decoration-color 0.12s;
}

a:hover {
  text-decoration-color: var(--fg);
}

/* ─── nav ────────────────────────────────────────────── */
.site-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  padding: 1rem 2rem;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.nav-name {
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--fg);
  text-decoration: none;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.nav-links a {
  font-size: 0.84rem;
  color: var(--muted);
  text-decoration: none;
  transition: color 0.12s;
}

.nav-links a:hover {
  color: var(--fg);
}

/* ─── base content layout ────────────────────────────── */
/* With `theme: none`, Quarto renders content as direct children
   of <body>, so these blocks carry the page gutters themselves. */
body > p,
body > h1,
body > h2,
body > h3,
body > h4,
body > h5,
body > h6,
body > ul,
body > ol,
body > blockquote,
body > pre,
body > hr,
body > section,
body > div,
body > header {
  max-width: var(--wide);
  margin-left: auto;
  margin-right: auto;
  padding-left: 2rem;
  padding-right: 2rem;
}

/* ─── quarto main content ────────────────────────────── */
#quarto-content {
  max-width: var(--wide);
  margin: 0 auto;
  padding: 2.75rem 2rem 5rem;
}

/* Section pages: use the same reading column as the homepage.
   On desktop this keeps the clean centered column; on mobile the
   gutter is restored below so text does not touch the screen edge. */
body.about-page #title-block-header,
body.about-page > p,
body.about-page > h2,
body.projects-page #title-block-header,
body.projects-page > p,
body.projects-page > h2,
body.writings-page #title-block-header,
body.writings-page > p,
body.writings-page > h2,
body.writings-page #listing-listing,
body.writings-page .quarto-listing-container-default {
  max-width: var(--reading) !important;
  margin-left: auto !important;
  margin-right: auto !important;
  padding-left: 0 !important;
  padding-right: 0 !important;
}

/* Move the Greek quote slightly to the right on desktop only. */
body.about-page .epigraph {
  max-width: var(--reading) !important;
  margin-left: auto !important;
  margin-right: auto !important;
  padding-left: 0 !important;
  padding-right: 0 !important;
  transform: translateX(1.25rem);
}

@media (max-width: 700px) {
  body.about-page .epigraph {
    transform: none;
  }
}

/* Writings page: keep Quarto content wide, but center title/listing column */
body.writings-page #title-block-header,
body.writings-page > p,
body.writings-page > h2,
body.writings-page #listing-listing,
body.writings-page .quarto-listing-container-default {
  max-width: var(--reading) !important;
  margin-left: auto !important;
  margin-right: auto !important;
  padding-left: 0 !important;
  padding-right: 0 !important;
}

/* ─── typography ─────────────────────────────────────── */
h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: var(--font);
  color: var(--fg);
}

h1 {
  max-width: var(--reading);
  margin: 0 0 1rem;
  font-size: clamp(2rem, 5vw, 2.8rem);
  font-weight: 650;
  line-height: 1.1;
  letter-spacing: -0.035em;
}

h2 {
  max-width: var(--reading);
  margin: 3rem 0 0.9rem;
  font-size: 1.45rem;
  font-weight: 650;
  line-height: 1.2;
  letter-spacing: -0.02em;
  color: var(--fg);
  text-transform: none;
}

h3 {
  max-width: var(--reading);
  margin: 2rem 0 0.65rem;
  font-size: 1.14rem;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.01em;
}

h4,
h5,
h6 {
  max-width: var(--reading);
  margin: 1.5rem 0 0.5rem;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.35;
}

body.section-page h1 {
  max-width: var(--reading);
  margin: 0 0 1.1rem;
  font-size: 1.55rem;
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

p {
  max-width: var(--reading);
  margin: 0 0 1.15rem;
}

ul,
ol {
  max-width: var(--reading);
  margin: 0 0 1.15rem;
  padding-left: 1.25rem;
}

li {
  margin-bottom: 0.28rem;
}

/* ─── horizontal rules ───────────────────────────────── */
hr {
  max-width: var(--reading);
  margin: 2.75rem auto;
  border: 0;
  border-top: 1px solid var(--border);
}

/* ─── optional eyebrow class ─────────────────────────── */
.eyebrow {
  max-width: var(--reading);
  margin: 2.5rem 0 0.75rem;
  font-size: 0.76rem;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ─── homepage ───────────────────────────────────────── */
/* These blocks are direct children of <body>, so they inherit the
   2rem gutter above. Overriding max-width alone leaves that padding
   in place, which is why dividers are drawn with pseudo-elements:
   a border on the element itself would span the padding box and sit
   wider than the text column. */
body.home-page h1,
body.home-page h2,
body.home-page p,
body.home-page .lede,
body.home-page .home-links,
body.home-page .home-note,
body.home-page .themes,
body.home-page .proj {
  max-width: var(--reading);
  margin-left: auto;
  margin-right: auto;
}

/* Smaller than the global h1 so it stops competing with the
   persistent name in the nav bar. */
body.home-page h1 {
  margin-bottom: 0.5rem;
  font-size: clamp(1.9rem, 4vw, 2.35rem);
}

body.home-page .lede {
  margin-bottom: 1.1rem;
  font-size: 1.1rem;
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: -0.015em;
  text-wrap: balance;
}

body.home-page .lede p {
  max-width: none;
  margin: 0;
  font-size: inherit;
  font-weight: inherit;
  line-height: inherit;
  letter-spacing: inherit;
}

body.home-page h2 {
  margin-top: 3.25rem;
}

/* ─── homepage: contact line and divider ─────────────── */
body.home-page .home-links {
  margin-top: 1.6rem;
  font-size: 0.92rem;
}

body.home-page .home-links p {
  max-width: none;
  margin: 0;
  font-size: inherit;
}

body.home-page .home-links::after {
  content: "";
  display: block;
  margin-top: 2.25rem;
  border-top: 1px solid var(--border);
}

/* ─── homepage: what I work on ───────────────────────── */
.themes {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
  margin-top: 1.5rem;
}

.themes h3 {
  max-width: none;
  margin: 0 0 0.35rem;
  font-size: 0.98rem;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: 0;
}

.themes p {
  max-width: none;
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.55;
  color: var(--muted);
}

/* ─── homepage: projects ─────────────────────────────── */
.proj {
  margin-top: 1.25rem;
  margin-bottom: 1.5rem;
}

.proj p {
  max-width: none;
  margin: 0 0 0.85rem;
  font-size: 0.92rem;
  line-height: 1.6;
}

/* Project names are links first, code second: drop the chip
   background so the underline reads as a link. */
.proj a code {
  padding: 0;
  background: none;
  font-size: 0.9em;
  font-weight: 600;
}

/* ─── homepage: closing note ─────────────────────────── */
body.home-page .home-note {
  margin-top: 3.5rem;
  font-size: 0.84rem;
  line-height: 1.5;
  color: var(--muted);
}

body.home-page .home-note::before {
  content: "";
  display: block;
  margin-bottom: 1.25rem;
  border-top: 1px solid var(--border);
}

body.home-page .home-note p {
  max-width: none;
  margin: 0;
  font-size: inherit;
  line-height: inherit;
  color: inherit;
}

/* ─── section-page font-size alignment ───────────────── */
/* Match About/Projects body copy to the homepage scale. */
body.about-page > p,
body.projects-page > p,
body.writings-page > p {
  font-size: 0.96rem;
  line-height: 1.55;
}

/* ─── writings: section labels ───────────────────────── */
/* The page h1 (1.55rem) and a normal h2 (1.45rem) sit too close to
   read as different levels. Section labels take the eyebrow
   treatment so the page title stays dominant and the labels stop
   competing with post titles. */
body.writings-page > h2 {
  margin-top: 2.75rem;
  margin-bottom: 0.75rem;
  font-size: 0.76rem;
  font-weight: 650;
  line-height: 1.4;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

/* Keep Home and Writings listing titles on the same scale. */
.quarto-post .body h3 {
  font-size: 0.96rem;
}

/* ─── blockquotes ────────────────────────────────────── */
blockquote {
  max-width: var(--reading);
  margin: 1.4rem auto 1.5rem;
  padding: 0.25rem 0 0.25rem 1rem;
  border-left: 2px solid var(--border);
  color: var(--muted);
}

blockquote p {
  max-width: none;
  margin: 0;
}

/* ─── blog listing ───────────────────────────────────── */
#listing-listing,
.quarto-listing-container-default {
  max-width: var(--reading) !important;
  margin-left: auto !important;
  margin-right: auto !important;
}

.quarto-listing-container-default {
  padding: 0 !important;
}

.quarto-post {
  display: flex !important;
  align-items: baseline !important;
  justify-content: space-between !important;
  gap: 2rem !important;
  max-width: none !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
  padding: 1rem 0 !important;
  border-top: none !important;
  border-bottom: 1px solid var(--border) !important;
}

.quarto-post:first-child {
  border-top: 1px solid var(--border) !important;
}

.quarto-post .thumbnail {
  display: none !important;
}

.quarto-post .body {
  flex: 1;
  padding: 0 !important;
}

.quarto-post .body h3 {
  margin: 0 0 0.22rem;
  font-size: 0.96rem;
  font-weight: 500;
  line-height: 1.35;
  letter-spacing: 0;
  color: var(--fg);
  text-transform: none;
}

/* Quarto wraps the whole post row in an anchor; only the title
   should read as a link. */
.quarto-post a {
  text-decoration: none;
}

.quarto-post .body h3 a {
  text-decoration: none;
}

.quarto-post .body h3 a:hover {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.quarto-post .body .listing-description {
  margin: 0;
  font-size: 0.84rem;
  line-height: 1.45;
  color: var(--muted);
}

.quarto-post .metadata {
  flex-shrink: 0;
  padding: 0 !important;
  font-size: 0.76rem;
  color: var(--muted);
  white-space: nowrap;
}

.listing-category,
.quarto-listing-category {
  display: none !important;
}

.listing-no-matching,
.quarto-listing .listing-no-matching,
#listing-listing .listing-no-matching {
  display: none !important;
}

/* ─── inner pages ────────────────────────────────────── */
.quarto-title-banner {
  display: none !important;
}

.quarto-title-meta {
  display: none;
}

#title-block-header {
  margin-top: 2rem;
}

.epigraph {
  padding-top: 2rem;
  margin-bottom: 2rem;
  font-size: 0.84rem;
  color: var(--muted);
}

.epigraph p {
  margin: 0;
}

.epigraph .translation {
  margin-top: 0.25rem;
  font-size: 0.78rem;
}

.post-meta {
  max-width: var(--reading);
  margin: 0 0 2.5rem;
  font-size: 0.82rem;
  color: var(--muted);
}

/* ─── figures ────────────────────────────────────────── */
.narrow-figure {
  max-width: 620px;
  margin: 1.25rem auto;
}

.narrow-figure figure,
.narrow-figure .quarto-figure {
  max-width: 100%;
  margin-left: auto;
  margin-right: auto;
}

.narrow-figure img {
  display: block;
  width: 100%;
  height: auto;
  margin-left: auto;
  margin-right: auto;
}

/* ─── math ───────────────────────────────────────────── */
p .math.inline,
li .math.inline {
  font-size: 1.03em;
}

.math.display {
  max-width: var(--reading);
  margin: 1rem 0 1.15rem;
}

.katex {
  font-size: 1.08em;
}

.katex-display {
  margin: 1rem 0 1.15rem;
  overflow-x: auto;
  overflow-y: hidden;
}

/* ─── tables ─────────────────────────────────────────── */
table,
.table {
  width: auto !important;
  max-width: var(--reading);
  margin: 1.25rem auto 1.5rem !important;
  border-collapse: collapse;
  font-size: 0.95rem;
  line-height: 1.55;
}

caption,
.quarto-float-caption {
  max-width: var(--reading);
  margin: 0.5rem auto 0.75rem;
  font-size: 0.82rem;
  line-height: 1.4;
  color: var(--muted);
  text-align: left;
}

table th,
table td,
.table th,
.table td {
  padding: 0.35rem 0.75rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

table th,
.table th {
  font-weight: 600;
}

.table-responsive,
.quarto-table,
.cell-output-display:has(table) {
  max-width: var(--reading);
  margin-left: auto;
  margin-right: auto;
  overflow-x: auto;
}

/* ─── wider technical tables ─────────────────────────── */
.wide-table {
  max-width: min(100vw - 2rem, 980px);
  margin-left: 50%;
  transform: translateX(-50%);
  overflow-x: auto;
}

.wide-table table,
.wide-table .table {
  width: 100% !important;
  max-width: none !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
}

.wide-table th,
.wide-table td {
  white-space: nowrap;
}

/* ─── code ───────────────────────────────────────────── */
code {
  padding: 0.15em 0.35em;
  border-radius: 3px;
  background: #f5f5f5;
  font-family: var(--mono);
  font-size: 0.875em;
}

pre {
  max-width: var(--reading);
  padding: 1.1rem;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #f8f8f8;
}

pre code {
  padding: 0;
  background: none;
  font-size: 0.875rem;
  line-height: 1.6;
}

/* ─── hide quarto chrome ─────────────────────────────── */
#quarto-sidebar,
#quarto-margin-sidebar,
#quarto-back-to-top,
.quarto-secondary-nav,
.breadcrumb,
.page-navigation,
footer.footer,
.footer {
  display: none !important;
}

/* ─── footer ─────────────────────────────────────────── */
.site-footer {
  max-width: var(--reading);
  margin: 4rem auto 1.25rem;
  padding: 1rem 1.25rem 1.25rem;
  border-top: 1px solid var(--border);
  text-align: center;
}

.site-disclaimer {
  display: block;
  font-size: 0.76rem;
  line-height: 1.35;
  color: var(--muted);
  font-weight: 400;
}

/* ─── left article table of contents ─────────────────── */
@media (min-width: 1180px) {
  #TOC {
    position: fixed;
    top: 5.25rem;
    left: max(1.5rem, calc((100vw - var(--wide)) / 2 - 245px));
    z-index: 50;
    width: 215px;
    max-height: calc(100vh - 6.5rem);
    margin: 0;
    padding: 0 1rem 0 0;
    overflow-y: auto;
    border: 0;
    font-size: 0.76rem;
    line-height: 1.28;
    color: var(--muted);
  }

  #TOC #toc-title {
    display: none;
  }

  #TOC ul {
    max-width: none;
    margin: 0;
    padding: 0;
    list-style: none;
  }

  #TOC li {
    margin: 0;
    padding: 0;
  }

  #TOC a {
    display: block;
    padding: 0.18rem 0;
    color: #8a8a8a;
    text-decoration: none;
    overflow-wrap: anywhere;
    transition: color 0.12s, transform 0.12s;
  }

  #TOC a:hover {
    color: #222222;
    transform: translateX(2px);
  }

  #TOC ul ul {
    margin: 0.12rem 0 0.24rem 0.75rem;
    padding-left: 0.65rem;
    border-left: 1px solid #e6e6e6;
  }

  #TOC ul ul a {
    font-size: 0.72rem;
    color: #8a8a8a;
  }

  #TOC a.active {
    color: #222222;
    font-weight: 600;
  }
}

@media (max-width: 1179px) {
  #TOC {
    display: none;
  }
}

/* ─── responsive ─────────────────────────────────────── */
@media (max-width: 760px) {
  .themes {
    grid-template-columns: 1fr;
    gap: 1.6rem;
  }
}

@media (max-width: 700px) {
  .site-footer {
    margin-top: 3rem;
    padding-left: 1.75rem;
    padding-right: 1.75rem;
  }

  .site-disclaimer {
    font-size: 0.72rem;
  }
}

@media (max-width: 640px) {
  .site-nav {
    padding: 0.9rem 1.25rem;
  }

  body > p,
  body > h1,
  body > h2,
  body > h3,
  body > h4,
  body > h5,
  body > h6,
  body > ul,
  body > ol,
  body > blockquote,
  body > pre,
  body > hr,
  body > section,
  body > div,
  body > header {
    padding-left: 1.5rem;
    padding-right: 1.5rem;
  }

  #quarto-content {
    padding-left: 1.75rem !important;
    padding-right: 1.75rem !important;
    padding-top: 2.25rem;
    padding-bottom: 5rem;
  }

  #listing-listing,
  .quarto-listing-container-default {
    padding-left: 1.5rem !important;
    padding-right: 1.5rem !important;
  }

  body.about-page #title-block-header,
  body.about-page > .epigraph,
  body.about-page > p,
  body.about-page > h2,
  body.projects-page #title-block-header,
  body.projects-page > p,
  body.projects-page > h2,
  body.writings-page #title-block-header,
  body.writings-page > p,
  body.writings-page > h2,
  body.writings-page #listing-listing,
  body.writings-page .quarto-listing-container-default {
    padding-left: 1.5rem !important;
    padding-right: 1.5rem !important;
  }

  .quarto-post {
    width: 100% !important;
    max-width: 100% !important;
    padding: 1.05rem 0.35rem !important;
    flex-direction: column !important;
    gap: 0.18rem !important;
  }

  .quarto-post .body h3 {
    margin-bottom: 0.22rem;
    font-size: 0.96rem;
    line-height: 1.35;
  }

  .quarto-post .metadata {
    font-size: 0.78rem;
  }

  #title-block-header {
    margin-top: 1.5rem;
  }

  h1 {
    font-size: 2rem;
  }

  h2 {
    font-size: 1.28rem;
  }

  h3 {
    font-size: 1.08rem;
  }

  body.home-page .lede {
    font-size: 1.05rem;
  }

  body.home-page h2 {
    margin-top: 2.5rem;
  }

  body.home-page .home-note {
    margin-top: 2.75rem;
  }
}

@media (max-width: 420px) {
  .nav-links {
    gap: 0.9rem;
  }

  .nav-links a {
    font-size: 0.8rem;
  }
}
