/* Blog pages — layered on top of the site's style.css.
   The site's h1/h2 carry a clearance for the floated identity block,
   which post pages do not have. */

h1,
h2 {
  max-width: none;
}
/* Subsections in the accent color, a step below the h2 sections. */
.post-body h3,
.post-body h4 {
  margin: 2.2rem 0 0.8rem;
  color: var(--accent);
  line-height: 1.25;
}
.post-body h3 {
  font-size: 1.4rem;
}
.post-body h4 {
  font-size: 1.18rem;
}
/* Blog text fills the card width so lines run longer (the shared
   style.css caps paragraphs at 68ch, which leaves an empty right margin). */
p {
  max-width: none;
}

.back {
  display: inline-block;
  margin-bottom: 2rem;
  font-family: "IBM Plex Sans", sans-serif;
  font-size: 0.82rem;
}

.post-body pre {
  margin: 1.5rem 0;
  padding: 0.9rem 1.1rem;
  border: 1px solid var(--accent-soft);
  background: rgba(255, 255, 255, 0.06);
  font-size: 0.85rem;
  overflow-x: auto;
}

.post-body code {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.9em;
}

.post-body pre code {
  font-size: inherit;
}

/* Listen mode (src/pages/blog/[slug].astro): equations as spoken words. */
.listen-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.8rem;
  align-items: center;
  margin: 0.4rem 0 0;
  color: var(--muted);
  font-family: "IBM Plex Sans", sans-serif;
  font-size: 0.82rem;
}
.listen-toggle {
  flex: none;
  padding: 0.2rem 0.7rem;
  border: 1px solid var(--accent-soft);
  border-radius: 4px;
  background: none;
  color: var(--muted);
  font-family: "IBM Plex Sans", sans-serif;
  font-size: 0.82rem;
  cursor: pointer;
}
.listen-toggle[aria-pressed="true"] {
  border-color: var(--accent);
  color: var(--accent);
}
/* The math still shows: its glyphs are drawn as generated content, which
   read-aloud tools skip, and its words sit beside it, visually hidden. */
.eq-speech {
  display: none;
}
html.listen .katex-mathml {
  display: none;
}
html.listen [data-glyph]::before {
  content: attr(data-glyph);
}
html.listen .eq-speech {
  display: inline-block;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
/* A display equation is its own line already: take its words out of flow. */
html.listen .katex-display > .eq-speech {
  position: absolute;
}

.post-body kbd {
  padding: 0 0.35em;
  border: 1px solid var(--accent-soft);
  border-bottom-width: 2px;
  border-radius: 4px;
  font-family: "IBM Plex Sans", sans-serif;
  font-size: 0.85em;
  font-weight: 600;
}

.post-body blockquote {
  margin: 1.5rem 0;
  padding: 0.25rem 0 0.25rem 1rem;
  border-left: 3px solid var(--accent-soft);
  color: var(--muted);
}

.post-body blockquote p {
  margin: 0.5rem 0;
}

.post-body .poem {
  font-style: italic;
}

/* Build-time KaTeX */
.post-body .katex-display {
  margin: 1.25rem 0;
  overflow-x: auto;
  overflow-y: hidden;
}

/* A post's contents: numbered sections, each with its subsections beneath
   in small type; two columns where they fit. */
.toc {
  margin: 2rem 0 2.5rem;
  padding: 1.1rem 1.4rem 0.7rem;
  border: 1px solid var(--accent-soft);
  border-radius: 6px;
  font-family: "IBM Plex Sans", sans-serif;
  text-align: left;
  hyphens: manual;
}
.toc-title {
  margin: 0 0 0.7rem;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.toc ol {
  margin: 0;
  padding-left: 1.4rem;
  columns: 2 17rem;
  column-gap: 1.75rem;
  font-size: 0.95rem;
}
.toc li {
  break-inside: avoid;
  margin-bottom: 0.6rem;
  padding-left: 0.2rem;
}
.toc li::marker {
  color: var(--muted);
  font-size: 0.85em;
}
.toc a {
  text-decoration: none;
}
.toc a:hover {
  text-decoration: underline;
}
.toc span {
  display: block;
  font-size: 0.8rem;
  line-height: 1.55;
}
.toc span,
.toc span a {
  color: var(--muted);
}
/* Lines break only after a separator, never inside a name. */
.toc span a {
  white-space: nowrap;
}

/* Live demos embedded in posts (src/pages/demos). */
.demo-figure {
  margin: 1.75rem 0;
}
.demo-figure iframe {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 1px solid var(--accent-soft);
  border-radius: 6px;
  background: #03050a;
}
/* Taller on phones, so stars, labels and controls have room. */
@media (max-width: 600px) {
  .demo-figure iframe {
    aspect-ratio: 4 / 3;
  }
}
/* The Fullscreen button under each frame ([slug].astro), and the window-
   filling fallback where the browser cannot take a frame fullscreen. */
.demo-expand {
  float: right;
  margin: 0.4rem 0 0 0.8rem;
  padding: 0.15rem 0.6rem;
  border: 1px solid var(--accent-soft);
  border-radius: 4px;
  background: none;
  color: var(--muted);
  font-family: "IBM Plex Sans", sans-serif;
  font-size: 0.78rem;
  cursor: pointer;
}
.demo-expand:hover {
  border-color: var(--accent);
  color: var(--accent);
}
html.demo-open {
  overflow: hidden;
}
.demo-figure.demo-expanded {
  position: fixed;
  inset: 0;
  z-index: 1000;
  margin: 0;
  background: #03050a;
}
.demo-expanded iframe {
  width: 100%;
  height: 100%;
  aspect-ratio: auto;
  border: none;
  border-radius: 0;
}
.demo-expanded .demo-expand {
  position: absolute;
  right: 12px;
  bottom: 12px;
  float: none;
  margin: 0;
  background: #03050a;
}
.demo-expanded figcaption {
  display: none;
}
.demo-figure img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--accent-soft);
  border-radius: 6px;
}
.demo-figure figcaption {
  margin-top: 0.5rem;
  font-family: "IBM Plex Sans", sans-serif;
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--ink);
}

/* Tables in posts. */
.post-body table {
  margin: 1.25rem auto;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.post-body th,
.post-body td {
  padding: 0.35rem 0.8rem;
  border-bottom: 1px solid var(--accent-soft);
  text-align: left;
}
.post-body th {
  color: var(--accent);
  font-weight: 600;
}
/* Markdown's right-aligned columns (numbers) come through as align="right". */
.post-body th[align="right"],
.post-body td[align="right"] {
  text-align: right;
}
