/* Post style — et-book Tufte typography, 60% content width, sidenotes.
   Active when body has class "page-style-post". */

body.page-style-post {
  font-family: var(--s-body);
  font-size: 1.1rem;
  line-height: 1.7;
  color: var(--s-text);
}

/* ── Content width: 60% to leave room for sidenotes ── */

body.page-style-post .post-content > p,
body.page-style-post .post-content > ul,
body.page-style-post .post-content > ol,
body.page-style-post .post-content > dl,
body.page-style-post .post-content > blockquote,
body.page-style-post .post-content > pre,
body.page-style-post .post-content > figure,
body.page-style-post .post-content > table,
body.page-style-post .post-content > header,
body.page-style-post .post-content > div.sourceCode,
body.page-style-post .post-content > div.highlighter-rouge,
body.page-style-post .post-content > div.center,
body.page-style-post .post-content > mjx-container[display="true"],
body.page-style-post .post-content section > p,
body.page-style-post .post-content section > ul,
body.page-style-post .post-content section > ol,
body.page-style-post .post-content section > dl,
body.page-style-post .post-content section > blockquote,
body.page-style-post .post-content section > pre,
body.page-style-post .post-content section > figure,
body.page-style-post .post-content section > table,
body.page-style-post .post-content section > div.sourceCode,
body.page-style-post .post-content section > div.highlighter-rouge,
body.page-style-post .post-content section > div.center,
body.page-style-post .post-content section > mjx-container[display="true"],
body.page-style-post .post-content h1,
body.page-style-post .post-content h2,
body.page-style-post .post-content h3,
body.page-style-post .post-content h4,
body.page-style-post .post-content h5,
body.page-style-post .post-content h6 {
  width: 60%;
}

/* ── Title block ───────────────────────────────────── */

body.page-style-post .post-header {
  width: 100% !important;
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--s-border);
}
body.page-style-post .post-title {
  /* Scale linearly from 1.9rem at 400px viewport to 2.4rem at 660px
     (the hamburger breakpoint). Below 400px: clamped to 1.9rem.
     Above 660px: clamped to 2.4rem. Formula reads:
       font = 1.9rem + (2.4rem - 1.9rem) * (vw - 400px) / (660px - 400px)
     (length/length = unitless in modern CSS, so the inner division
     gives a scalar that multiplies the rem span.) */
  font-size: clamp(
    1.9rem,
    calc(1.9rem + (2.4rem - 1.9rem) * (100vw - 400px) / (660px - 400px)),
    2.4rem
  );
  font-weight: 400;
  line-height: 1.2;
  margin: 0 0 0.6rem;
}
body.page-style-post .post-meta {
  font-size: 0.9rem;
  color: var(--s-text-dim);
  margin: 0.15rem 0;
}
body.page-style-post .post-meta .post-tags,
.post-list .post-meta .post-tags {
  font-style: italic;
}

body.page-style-post #title-block-header {
  width: 100% !important;
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--s-border);
}
body.page-style-post #title-block-header .title { margin-bottom: 0.2rem; }
body.page-style-post #title-block-header .subtitle {
  font-size: 1.2rem;
  color: var(--s-text-dim);
  margin-top: 0;
}
body.page-style-post #title-block-header .author,
body.page-style-post #title-block-header .date {
  font-size: 0.9rem;
  color: var(--s-text-dim);
  margin: 0.15rem 0;
}
body.page-style-post .exploration-meta {
  font-size: 0.9rem;
  color: var(--s-text-dim);
  margin-bottom: 1rem;
}
body.page-style-post #title-block-header .abstract {
  margin-top: 1rem;
  font-size: 0.85rem;
  line-height: 1.35;
}
body.page-style-post #title-block-header .abstract-title {
  font-weight: 600;
  margin-bottom: 0.3rem;
}

/* ── Sidenotes (Tufte-style) ────────────────────────── */

body.page-style-post .sidenote,
body.page-style-post .marginnote {
  float: right;
  clear: right;
  margin-right: -62%;
  width: 55%;
  margin-top: 0.3rem;
  margin-bottom: 1rem;
  font-size: 0.85rem;
  line-height: 1.4;
  color: #555;
}

body.page-style-post .sidenote {
  padding-top: 0.1rem;
  text-indent: -0.8em;
  padding-left: 0.8em;
}
body.page-style-post .marginnote {
  padding-left: 0.8em;
}

/* Block-level marginnotes (from ::: {.marginnote} fenced divs) */
body.page-style-post div.marginnote {
  width: 33%;
  margin-right: 3%;
}

/* Sidenote counter */
body.page-style-post .post-content { counter-reset: sidenote-counter; }

body.page-style-post .sidenote-number { counter-increment: sidenote-counter; }
body.page-style-post .sidenote-number::after {
  content: counter(sidenote-counter);
  font-size: 0.75rem;
  vertical-align: super;
  line-height: 0;
}
/* Hanging number at the start of the sidenote */
body.page-style-post .sidenote::before {
  content: counter(sidenote-counter) "\2002";
  font-size: 0.75rem;
  vertical-align: super;
  line-height: 0;
  color: #aaa;
}

/* Sidenote numbers (in main text and in margin) */
body.page-style-post .sidenote-number,
body.page-style-post .sidenote > sup {
  font-size: 0.75rem;
  vertical-align: super;
  line-height: 0;
  cursor: default;
  color: #aaa;
}

/* Margin note toggle symbol */
body.page-style-post label.margin-toggle:not(.sidenote-number) {
  display: none;
  font-size: 0.75rem;
  vertical-align: super;
  line-height: 0;
  cursor: pointer;
}

/* Always hide the checkbox */
body.page-style-post input.margin-toggle { display: none; }

/* ── Heading typography ────────────────────────────── */

body.page-style-post .post-content h1,
body.page-style-post .post-content h2,
body.page-style-post .post-content h3,
body.page-style-post .post-content h4,
body.page-style-post .post-content h5,
body.page-style-post .post-content h6 {
  font-weight: 400;
  color: var(--s-text);
  line-height: 1.2;
}

body.page-style-post .post-content h1 {
  font-size: 2.2rem;
  margin-top: 2rem;
  margin-bottom: 0.5rem;
}
body.page-style-post .post-content section > h1 {
  font-size: 1.8rem;
  margin-left: -0.8rem;
  padding-left: calc(0.8rem - 3px);
  border-left: 3px solid var(--s-accent);
}
body.page-style-post .post-content h2 {
  font-size: 1.5rem;
  font-style: italic;
  margin-top: 2rem;
  margin-left: -0.8rem;
  padding-left: calc(0.8rem - 3px);
  border-left: 3px solid var(--s-accent);
}
body.page-style-post .post-content h3 {
  font-size: 1.2rem;
  font-style: italic;
  margin-top: 1.5rem;
  margin-left: -0.8rem;
  padding-left: calc(0.8rem - 2px);
  border-left: 2px solid var(--s-border);
}
body.page-style-post .post-content h4,
body.page-style-post .post-content h5,
body.page-style-post .post-content h6 {
  margin-left: -0.8rem;
  padding-left: calc(0.8rem - 2px);
  border-left: 2px solid var(--s-border);
}

/* ── Collapsible sections ──────────────────────────── */

body.page-style-post .post-content section > h1,
body.page-style-post .post-content section > h2,
body.page-style-post .post-content section > h3,
body.page-style-post .post-content section > h4 {
  cursor: pointer;
  position: relative;
}
body.page-style-post .post-content section > h1::after,
body.page-style-post .post-content section > h2::after,
body.page-style-post .post-content section > h3::after,
body.page-style-post .post-content section > h4::after {
  content: '';
  display: inline-block;
  width: 0.4em;
  height: 0.4em;
  border-right: 2px solid var(--s-text-dim);
  border-bottom: 2px solid var(--s-text-dim);
  transform: rotate(45deg);
  margin-left: 0.5em;
  vertical-align: middle;
  transition: transform 0.2s;
  opacity: 0;
}
body.page-style-post .post-content section > h1:hover::after,
body.page-style-post .post-content section > h2:hover::after,
body.page-style-post .post-content section > h3:hover::after,
body.page-style-post .post-content section > h4:hover::after {
  opacity: 0.5;
}
body.page-style-post .post-content section.collapsed > h1::after,
body.page-style-post .post-content section.collapsed > h2::after,
body.page-style-post .post-content section.collapsed > h3::after,
body.page-style-post .post-content section.collapsed > h4::after {
  transform: rotate(-45deg);
  opacity: 0.5;
}
body.page-style-post .post-content section.collapsed > :not(h1):not(h2):not(h3):not(h4):not(h5):not(h6) {
  display: none !important;
}
body.page-style-post .post-content section.collapsed > section {
  display: none !important;
}

/* ── Code block widths ─────────────────────────────── */

body.page-style-post .post-content > pre,
body.page-style-post .post-content > div.sourceCode,
body.page-style-post .post-content > div.highlighter-rouge,
body.page-style-post .post-content section > pre,
body.page-style-post .post-content section > div.sourceCode,
body.page-style-post .post-content section > div.highlighter-rouge {
  width: 100%;
}
body.page-style-post .post-content > div.code-sidenote,
body.page-style-post .post-content > pre.code-sidenote,
body.page-style-post .post-content section > div.code-sidenote,
body.page-style-post .post-content section > pre.code-sidenote { width: 60%; }
/* Pre inside div.sourceCode: fill the width-constrained parent */
body.page-style-post .post-content div.sourceCode pre,
body.page-style-post .post-content div.highlighter-rouge pre {
  width: 100%;
}

/* ── No-sidenotes mode ── */

body.page-style-post .page-content.no-sidenotes {
  padding: 2rem 2rem 4rem 2rem;
}
body.page-style-post .no-sidenotes .post-content > p,
body.page-style-post .no-sidenotes .post-content > ul,
body.page-style-post .no-sidenotes .post-content > ol,
body.page-style-post .no-sidenotes .post-content > dl,
body.page-style-post .no-sidenotes .post-content > blockquote,
body.page-style-post .no-sidenotes .post-content > pre,
body.page-style-post .no-sidenotes .post-content > figure,
body.page-style-post .no-sidenotes .post-content > table,
body.page-style-post .no-sidenotes .post-content > header,
body.page-style-post .no-sidenotes .post-content > div.sourceCode,
body.page-style-post .no-sidenotes .post-content > div.center,
body.page-style-post .no-sidenotes .post-content section > p,
body.page-style-post .no-sidenotes .post-content section > ul,
body.page-style-post .no-sidenotes .post-content section > ol,
body.page-style-post .no-sidenotes .post-content section > dl,
body.page-style-post .no-sidenotes .post-content section > blockquote,
body.page-style-post .no-sidenotes .post-content section > pre,
body.page-style-post .no-sidenotes .post-content section > figure,
body.page-style-post .no-sidenotes .post-content section > table,
body.page-style-post .no-sidenotes .post-content section > div.sourceCode,
body.page-style-post .no-sidenotes .post-content h1,
body.page-style-post .no-sidenotes .post-content h2,
body.page-style-post .no-sidenotes .post-content h3,
body.page-style-post .no-sidenotes .post-content h4,
body.page-style-post .no-sidenotes .post-content h5,
body.page-style-post .no-sidenotes .post-content h6 {
  width: 100%;
  max-width: 800px;
}
body.page-style-post .no-sidenotes .post-content .sidenote,
body.page-style-post .no-sidenotes .post-content .marginnote {
  display: none;
}
body.page-style-post .no-sidenotes .post-content .margin-toggle:checked + .sidenote,
body.page-style-post .no-sidenotes .post-content .margin-toggle:checked + .marginnote {
  display: block;
  float: none;
  clear: both;
  width: 100%;
  max-width: 800px;
  margin: 0.5rem 0;
  padding: 0.5rem 0.75rem;
  text-indent: 0;
  padding-left: 0.75rem;
  border-left: 2px solid var(--s-border);
  font-size: 0.9rem;
}
body.page-style-post .no-sidenotes .post-content .sidenote::before {
  display: none;
}
body.page-style-post .no-sidenotes .post-content label.margin-toggle:not(.sidenote-number) {
  display: inline;
  cursor: pointer;
  color: var(--s-accent);
  font-size: 0.75rem;
  vertical-align: super;
  line-height: 0;
}
body.page-style-post .no-sidenotes .post-content .sidenote-number {
  cursor: pointer;
  color: var(--s-accent);
}

/* ── Responsive: narrow mode at <= 800px ── */

@media (max-width: 800px) {
  body.page-style-post .post-content > p,
  body.page-style-post .post-content > ul,
  body.page-style-post .post-content > ol,
  body.page-style-post .post-content > dl,
  body.page-style-post .post-content > blockquote,
  body.page-style-post .post-content > pre,
  body.page-style-post .post-content > figure,
  body.page-style-post .post-content > table,
  body.page-style-post .post-content > header,
  body.page-style-post .post-content > div.sourceCode,
  body.page-style-post .post-content > div.highlighter-rouge,
  body.page-style-post .post-content > div.center,
  body.page-style-post .post-content > mjx-container[display="true"],
  body.page-style-post .post-content section > p,
  body.page-style-post .post-content section > ul,
  body.page-style-post .post-content section > ol,
  body.page-style-post .post-content section > dl,
  body.page-style-post .post-content section > blockquote,
  body.page-style-post .post-content section > pre,
  body.page-style-post .post-content section > figure,
  body.page-style-post .post-content section > table,
  body.page-style-post .post-content section > div.sourceCode,
  body.page-style-post .post-content section > div.highlighter-rouge,
  body.page-style-post .post-content section > div.center,
  body.page-style-post .post-content section > mjx-container[display="true"],
  body.page-style-post .post-content h1,
  body.page-style-post .post-content h2,
  body.page-style-post .post-content h3,
  body.page-style-post .post-content h4,
  body.page-style-post .post-content h5,
  body.page-style-post .post-content h6 {
    width: 100%;
  }
  /* Sidenotes: hidden by default, expand inline on click */
  body.page-style-post .post-content .sidenote,
  body.page-style-post .post-content .marginnote {
    display: none;
  }
  body.page-style-post .post-content .margin-toggle:checked + .sidenote,
  body.page-style-post .post-content .margin-toggle:checked + .marginnote {
    display: block;
    float: none;
    clear: both;
    width: 100%;
    margin: 0.5rem 0;
    padding: 0.5rem 0.75rem;
    text-indent: 0;
    padding-left: 0.75rem;
    border-left: 2px solid var(--s-border);
    font-size: 0.9rem;
  }
  body.page-style-post .post-content .sidenote > sup {
    display: none;
  }
  body.page-style-post .post-content label.margin-toggle:not(.sidenote-number) {
    display: inline;
    cursor: pointer;
    color: var(--s-accent);
    font-size: 0.75rem;
    vertical-align: super;
    line-height: 0;
  }
  body.page-style-post .post-content .sidenote-number {
    cursor: pointer;
    color: var(--s-accent);
  }
  body.page-style-post .post-content > div.code-sidenote,
  body.page-style-post .post-content > pre.code-sidenote,
  body.page-style-post .post-content section > div.code-sidenote,
  body.page-style-post .post-content section > pre.code-sidenote { width: 100%; }
}

/* ── Blog listing ──────────────────────────────────── */

.post-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.post-list li {
  margin-bottom: 1.5rem;
}
.post-list h3 {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 400;
  line-height: 1.3;
}
/* Post-list h3: upright (overrides global .post-content h3 italic) and
   full-width (overrides the 60% rule). Border styling from the global rule stays. */
body.page-style-post .post-content .post-list h3 {
  font-style: normal;
  width: auto;
}
.post-content a.post-link {
  color: var(--s-text);
  text-decoration: underline 0.66rem #fafafa;
  text-underline-offset: -0.33rem;
  text-decoration-skip-ink: none;
}
.post-content a.post-link:hover {
  color: var(--s-accent);
}
.post-content a.post-link-highlighted {
  color: var(--s-text);
  text-decoration: underline 0.66rem lightgoldenrodyellow;
  text-underline-offset: -0.33rem;
  text-decoration-skip-ink: none;
}
.post-content a.post-link-highlighted:hover {
  color: var(--s-accent);
}
.post-list .post-meta {
  font-size: 0.85rem;
  color: var(--s-text-dim);
}

/* Post list: in wide mode with sidenotes, float date+tags into the margin column.
   In narrow mode (<=800px) or .no-sidenotes, they fall back to inline below the title. */
@media (min-width: 801px) {
  body.page-style-post .page-content:not(.no-sidenotes) .post-list li {
    position: relative;
  }
  body.page-style-post .page-content:not(.no-sidenotes) .post-list .post-meta {
    position: absolute;
    top: 0.2rem;
    left: 100%;
    margin-left: 3%;
    width: 55%;
    font-size: 0.85rem;
    line-height: 1.4;
    color: #555;
  }
}
