/* Blog redesign, loaded after styles.css on blog pages only (body.blog).
   Headings and UI stay in IBM Plex Sans like the rest of the site,
   long-form text switches to IBM Plex Serif from the same family. */

body.blog {
  --font-serif: 'IBM Plex Serif', Georgia, 'Times New Roman', serif;
  --read-bg: #f7f2e8;
  --read-text: #2b2520;
  --read-soft: #5a5048;
  --read-meta: #72675c;
  --read-rule: var(--color-border);
  --read-link-line: rgba(2, 132, 199, 0.4);
  --post-width: 680px;
  --sidenote-width: 250px;
  --sidenote-gap: 48px;

  /* plain reading surface: no grid, no gradient */
  background: var(--read-bg);
}

/* light theme: warmer paper for reading, so the site's surfaces follow it */
:root:not([data-theme="dark"]) body.blog {
  --color-surface: #fffdf8;
  --color-border: #e5ddcf;
  --color-code-bg: #efe8db;
  --color-nav-bg: rgba(247, 242, 232, 0.88);
  --color-nav-border: #e5ddcf;
  --color-bottom-nav-bg: rgba(247, 242, 232, 0.95);
}

/* dark theme: same switch as styles.css */
[data-theme="dark"] body.blog {
  --read-bg: var(--color-bg);
  --read-text: #d5deea;
  --read-soft: #a3b1c6;
  --read-meta: #8a98ae;
  --read-link-line: rgba(125, 211, 252, 0.45);
}

body.blog::before {
  display: none;
}

/* no entrance animation, the text is there immediately */
body.blog .post,
body.blog .post-item {
  animation: none;
}

/* ---------- Index ---------- */

.post-index {
  max-width: 760px;
  margin: 0 auto;
  padding: var(--spacing-xxl) 0 var(--spacing-xxl);
}

.post-index-header {
  margin-bottom: var(--spacing-xxl);
  padding-left: 7rem;
}

.post-index-header h1 {
  font-size: 2.5rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  margin-bottom: 0.4rem;
}

.post-index-intro {
  color: var(--read-meta);
  margin: 0;
}

.post-index-intro a {
  margin-left: 0.4rem;
  white-space: nowrap;
  color: var(--read-meta);
  text-decoration: underline;
  text-decoration-color: var(--read-rule);
  text-underline-offset: 0.2em;
}

.post-index-intro a:hover {
  color: var(--color-accent-dark);
  text-decoration-color: currentColor;
}

/* the year sits in a left column, shown once per group */
.post-year {
  display: grid;
  grid-template-columns: 7rem 1fr;
  padding-top: var(--spacing-lg);
  border-top: 1px solid var(--read-rule);
  margin-bottom: var(--spacing-lg);
}

.post-year-label {
  margin: 0.15rem 0 0;
  font-size: 1rem;
  font-weight: 500;
  color: var(--read-meta);
  font-variant-numeric: tabular-nums;
}

body.blog .post-item {
  display: block;
  background: none;
  border: none;
  border-radius: 0;
  box-shadow: none;
  padding: 0;
  margin: 0 0 var(--spacing-xl);
  color: var(--read-text);
  transition: none;
}

body.blog .post-item:last-child {
  margin-bottom: var(--spacing-md);
}

body.blog .post-item:hover {
  transform: none;
  box-shadow: none;
}

body.blog .post-item-title {
  font-size: 1.35rem;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.01em;
  margin: 0 0 0.35rem;
  text-wrap: balance;
  text-decoration: underline;
  text-decoration-color: transparent;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 0.18em;
  transition: text-decoration-color 0.15s ease, color 0.15s ease;
}

body.blog .post-item:hover .post-item-title,
body.blog .post-item:focus-visible .post-item-title {
  color: var(--color-accent-dark);
  text-decoration-color: currentColor;
}

body.blog .post-item-description {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  line-height: 1.6;
  color: var(--read-soft);
  margin: 0 0 0.4rem;
}

/* ---------- Meta lines (index and post) ---------- */

body.blog .post-item-date,
body.blog .post-meta {
  font-family: var(--font-sans);
  font-size: 0.875rem;
  color: var(--read-meta);
  margin: 0;
}

body.blog .post-meta a {
  color: var(--read-meta);
  text-decoration: underline;
  text-decoration-color: var(--read-rule);
  text-underline-offset: 0.2em;
}

body.blog .post-meta a:hover {
  color: var(--color-accent-dark);
  text-decoration-color: currentColor;
}

/* ---------- Post ---------- */

body.blog .post {
  padding: var(--spacing-xl) 0 var(--spacing-xxl);
}

body.blog .post-header {
  margin-bottom: var(--spacing-xl);
  padding-bottom: var(--spacing-lg);
  border-bottom: 1px solid var(--read-rule);
}

body.blog .post-back {
  font-family: var(--font-sans);
  font-size: 0.9rem;
  color: var(--read-meta);
}

body.blog .post-back:hover {
  color: var(--color-accent-dark);
}

body.blog .post-title {
  font-size: 2.6rem;
  line-height: 1.15;
  letter-spacing: -0.028em;
  margin: var(--spacing-md) 0 var(--spacing-sm);
  text-wrap: balance;
}

body.blog .post-content {
  font-family: var(--font-serif);
  font-size: 1.1875rem;
  line-height: 1.7;
  color: var(--read-text);
  hanging-punctuation: first;
}

body.blog .post-content p {
  margin-bottom: 1.35em;
}

/* links read as text with a quiet underline, so reference-heavy paragraphs stay calm */
body.blog .post-content a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: var(--read-link-line);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
  transition: color 0.15s ease, text-decoration-color 0.15s ease;
}

body.blog .post-content a:hover {
  color: var(--color-accent-dark);
  text-decoration-color: currentColor;
}

body.blog .post-content h2,
body.blog .post-content h3 {
  font-family: var(--font-sans);
  letter-spacing: -0.015em;
  text-wrap: balance;
}

body.blog .post-content h2 {
  font-size: 1.6rem;
  line-height: 1.25;
  margin: 2.6em 0 0.7em;
}

body.blog .post-content h3 {
  font-size: 1.25rem;
  margin: 2em 0 0.5em;
}

body.blog .post-content h2 + h3 {
  margin-top: 1em;
}

body.blog .post-content li {
  margin-bottom: 0.45em;
}

body.blog .post-content ul,
body.blog .post-content ol {
  margin-left: 1.3em;
  margin-bottom: 1.35em;
}

body.blog .post-content li::marker {
  color: var(--read-meta);
}

body.blog .post-content blockquote {
  border-left: 2px solid var(--color-accent);
  padding-left: 1.1em;
  color: var(--read-soft);
  font-style: italic;
}

body.blog .post-content details {
  border-left: 2px solid var(--read-rule);
  padding-left: 1.1em;
  margin-bottom: 1.35em;
}

body.blog .post-content details summary {
  font-family: var(--font-sans);
  font-size: 1rem;
  color: var(--read-soft);
}

body.blog .post-content details summary:hover {
  color: var(--color-accent-dark);
}

body.blog .post-content code {
  font-size: 0.82em;
  background: var(--color-code-bg);
  border-radius: 4px;
  padding: 0.12em 0.35em;
}

body.blog .post-content pre {
  font-size: 0.85rem;
  border-radius: 6px;
  background: var(--color-code-bg);
}

body.blog .post-content pre code {
  font-size: inherit;
  background: none;
  padding: 0;
}

body.blog .post-content img {
  border-radius: 6px;
  border-color: var(--read-rule);
  margin: 2em auto;
}

body.blog .post-content figure {
  margin: 2em 0;
}

body.blog .post-content figure img {
  margin: 0 auto;
}

body.blog .post-content figcaption {
  font-family: var(--font-sans);
  font-size: 0.85rem;
  color: var(--read-meta);
  margin-top: 0.7em;
}

body.blog .post-content table {
  font-family: var(--font-sans);
  font-size: 0.9rem;
}

body.blog .post-content hr {
  border-top-color: var(--read-rule);
  margin: 2.6em 0;
}

/* footnote list at the bottom (mobile, and without JS) */
body.blog .post-content .footnotes {
  font-family: var(--font-sans);
  font-size: 0.875rem;
  line-height: 1.6;
  color: var(--read-soft);
}

body.blog .post-content .footnotes a {
  color: var(--color-accent-dark);
}

/* footnote numbers in the text */
body.blog .post-content sup a {
  color: var(--color-accent-dark);
  text-decoration: none;
  font-family: var(--font-sans);
  font-weight: 500;
  font-size: 0.7rem;
}

/* sidenotes keep the sans face, small and quiet */
@media (min-width: 1100px) {
  body.blog .sidenote {
    font-family: var(--font-sans);
    font-size: 0.8125rem;
    color: var(--read-meta);
  }

  body.blog .sidenote a {
    color: var(--read-soft);
    text-decoration: underline;
    text-decoration-color: var(--read-rule);
    text-underline-offset: 0.18em;
  }

  body.blog .sidenote.is-active,
  body.blog .sidenote:hover {
    color: var(--read-text);
  }

  body.blog .sidenote-number {
    font-family: var(--font-sans);
  }
}

/* ---------- End of post ---------- */

body.blog .post-crosspost {
  font-family: var(--font-sans);
  font-size: 0.95rem;
  margin-top: var(--spacing-xl);
  padding-top: var(--spacing-md);
  border-top: 1px solid var(--read-rule);
}

/* one column when the post has only one neighbour, two when it has both */
.post-pager {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: var(--spacing-md);
  margin-top: var(--spacing-xl);
  padding-top: var(--spacing-lg);
  border-top: 1px solid var(--read-rule);
}

body.blog .post-crosspost + .post-pager {
  border-top: none;
  padding-top: 0;
  margin-top: var(--spacing-md);
}

.post-pager-link {
  display: block;
  color: var(--read-text);
}

.post-pager-link.is-newer {
  text-align: right;
}

.post-pager-label {
  display: block;
  font-size: 0.85rem;
  color: var(--read-meta);
  margin-bottom: 0.2rem;
}

.post-pager-title {
  display: block;
  font-weight: 600;
  line-height: 1.35;
  text-wrap: balance;
}

.post-pager-link:hover .post-pager-title {
  color: var(--color-accent-dark);
}

/* ---------- Keyboard focus ---------- */

body.blog a:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 3px;
  border-radius: 2px;
}

/* ---------- Small screens ---------- */

@media (max-width: 768px) {
  .post-index {
    padding-top: var(--spacing-lg);
    padding-bottom: 6rem;
  }

  .post-index-header {
    padding-left: 0;
    margin-bottom: var(--spacing-xl);
  }

  .post-index-header h1 {
    font-size: 2rem;
  }

  .post-year {
    grid-template-columns: 1fr;
    padding-top: var(--spacing-md);
  }

  .post-year-label {
    margin-bottom: var(--spacing-md);
  }

  body.blog .post-item-title {
    font-size: 1.2rem;
  }

  body.blog .post {
    padding: var(--spacing-md) 0 6rem;
  }

  body.blog .post-title {
    font-size: 1.9rem;
  }

  body.blog .post-content {
    font-size: 1.0625rem;
    line-height: 1.68;
  }

  body.blog .post-content h2 {
    font-size: 1.35rem;
  }

  .post-pager {
    grid-auto-flow: row;
  }

  .post-pager-link.is-newer {
    text-align: left;
  }
}
