:root {
  --blog-title-size: clamp(1.5rem, 1.1rem + 1.4vw, 2rem);
  --blog-index-title-size: clamp(1.75rem, 1.25rem + 2vw, 3rem);
  --blog-lead-size: clamp(0.9375rem, 0.85rem + 0.45vw, 1.125rem);
  --blog-meta-size: 13px;
  --blog-h2-size: clamp(1.25rem, 1.1rem + 0.5vw, 1.5rem);
  --blog-h3-size: clamp(1.0625rem, 1rem + 0.35vw, 1.25rem);
  --blog-reading-width: 820px;
  --blog-separator-tone: color-mix(in srgb, var(--text) 35%, var(--bg));
}

.blog-index {
  padding-block: clamp(2.5rem, 7vw, 6rem);
}

.blog-intro {
  margin-bottom: 2rem;
}

.blog-intro h1,
:is(.article-hero, main.wrap > article > header:has(> h1)) h1 {
  display: block;
  margin: 0;
  max-width: 100%;
  font-family: var(--font-display);
  font-weight: var(--weight-normal);
  line-height: 1.32;
  overflow-wrap: anywhere;
}

.blog-intro h1 {
  font-size: var(--blog-index-title-size);
}

.blog-intro p,
.article-lead,
:is(.article-hero, main.wrap > article > header:has(> h1)) > p {
  margin: 12px 0 0;
  color: var(--text-muted);
  font-size: var(--blog-lead-size);
  line-height: 1.7;
}

.blog-filters:not([hidden]),
.blog-card-meta,
.article-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
}

.blog-filters button {
  padding: 0.55rem 0.9rem;
  min-height: 44px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-pill);
  background: var(--bg);
  color: var(--text-muted);
  font: inherit;
  cursor: pointer;
}

.blog-filters button:hover,
.blog-filters button[aria-pressed="true"] {
  color: var(--text);
}

.blog-filters button[aria-pressed="true"] {
  background: var(--bg-panel);
  box-shadow: inset 0 -2px var(--accent);
}

.blog-filters button:focus-visible,
.blog-index a:focus-visible,
.blog-article a:focus-visible,
.article-page a:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 3px;
}

.blog-status {
  min-height: 1.5em;
  margin-block: 0.9rem 1rem;
  color: var(--text-muted);
  font-size: var(--blog-meta-size);
}

.blog-post-grid,
.blog-related-grid,
#post-nav:not([hidden]):not(:empty) {
  display: grid;
  gap: 1rem;
}

.blog-post-grid {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 21rem), 1fr));
}

.blog-post-grid .post-card,
.blog-related-grid .post-card,
#post-nav .blog-neighbor {
  min-width: 0;
  margin: 0;
  padding: clamp(1rem, 2.4vw, 1.5rem);
  border: 1px solid var(--border);
  border-radius: var(--r-panel);
  background: var(--bg-panel);
  color: var(--text);
  overflow-wrap: anywhere;
}

.blog-post-grid .post-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.blog-card-meta,
.article-meta,
.article-hero .post-meta {
  color: var(--text-muted);
  font-size: var(--blog-meta-size);
}

.blog-card-meta .tag,
.article-hero .tag {
  color: var(--text);
  background: var(--bg-panel-2);
}

.post-card :is(h2, h3) {
  margin: 0.8rem 0 0;
  font-size: var(--blog-h3-size);
  font-weight: var(--weight-medium);
  line-height: 1.55;
}

.blog-post-grid .post-card p {
  margin: 0.65rem 0 1rem;
  color: var(--text-muted);
  line-height: 1.75;
}

.post-card :is(h2, h3) a,
.blog-read-link,
#post-nav .blog-neighbor {
  color: var(--text);
  text-decoration: none;
}

.blog-read-link {
  margin-top: auto;
  padding-block: 0.45rem;
  font-size: var(--size-small);
}

.post-card :is(h2, h3) a:hover,
.blog-read-link:hover,
#post-nav .blog-neighbor:hover span:last-child {
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-underline-offset: 0.22em;
}

:is(.blog-breadcrumb, nav.breadcrumb, nav.breadcrumbs, :where(main.wrap > nav, main.wrap > article > nav):has(> [aria-current="page"])) {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  margin-block: 0 20px;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  font-size: var(--blog-meta-size);
  line-height: 1.5;
  color: var(--text-muted);
}

:is(.blog-breadcrumb, nav.breadcrumb, nav.breadcrumbs, :where(main.wrap > nav, main.wrap > article > nav):has(> [aria-current="page"])) a {
  flex: none;
  color: var(--text-muted);
  text-decoration: none;
}

:is(.blog-breadcrumb, nav.breadcrumb, nav.breadcrumbs, :where(main.wrap > nav, main.wrap > article > nav):has(> [aria-current="page"])) a:hover {
  color: var(--text);
}

:is(.blog-breadcrumb, nav.breadcrumb, nav.breadcrumbs, :where(main.wrap > nav, main.wrap > article > nav):has(> [aria-current="page"])) [aria-hidden="true"] {
  flex: none;
  color: var(--blog-separator-tone);
}

:is(.blog-breadcrumb, nav.breadcrumb, nav.breadcrumbs, :where(main.wrap > nav, main.wrap > article > nav):has(> [aria-current="page"])) [aria-current="page"] {
  max-width: 30ch;
  min-width: 0;
  flex: 0 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Keep the breadcrumbs, title and body in the same reading column. */
main.wrap:has(> article > header > h1) {
  padding-top: 28px;
}

main.wrap > :is(article:has(> header > h1), nav:has(> [aria-current="page"])) {
  max-width: var(--blog-reading-width);
  margin-inline: auto;
}

:is(.article-hero, main.wrap > article > header:has(> h1)) {
  padding-block: 0 12px;
  margin-bottom: 8px;
}

:is(.article-hero, main.wrap > article > header:has(> h1)) > .flow-row:has(+ h1) {
  margin-block: 0 14px;
  color: var(--text-muted);
  font-size: var(--blog-meta-size);
}

:is(.article-hero, main.wrap > article > header:has(> h1)) h1 {
  font-size: var(--blog-title-size);
}

:where(.blog-article, .article-page, main.wrap:has(> article > header > h1)) .prose {
  width: 100%;
  max-width: var(--blog-reading-width);
  margin-inline: auto;
  color: var(--text);
  line-height: 1.85;
  overflow-wrap: anywhere;
}

:where(.blog-article, .article-page, main.wrap:has(> article > header > h1)) .prose > :first-child {
  margin-top: 0;
}

:where(.blog-article, .article-page, main.wrap:has(> article > header > h1)) .prose section {
  margin: 0;
  padding-block: 0;
}

:where(.blog-article, .article-page, main.wrap:has(> article > header > h1)) .prose section + section {
  margin-top: 2rem;
}

:where(.blog-article, .article-page, main.wrap:has(> article > header > h1)) .prose h2 {
  margin-block: 2rem 0.65rem;
  font-size: var(--blog-h2-size);
  line-height: 1.45;
}

:where(.blog-article, .article-page, main.wrap:has(> article > header > h1)) .prose > h2:first-of-type,
:where(.blog-article, .article-page, main.wrap:has(> article > header > h1)) .prose section > h2:first-child {
  margin-top: 0;
}

:where(.blog-article, .article-page, main.wrap:has(> article > header > h1)) .prose h3 {
  margin-block: 1.4rem 0.5rem;
  font-size: var(--blog-h3-size);
  line-height: 1.5;
}

:where(.blog-article, .article-page, main.wrap:has(> article > header > h1)) .prose :is(p, ul, ol, blockquote, pre) {
  margin-block: 0.75rem;
}

:where(.blog-article, .article-page, main.wrap:has(> article > header > h1)) .prose :is(ul, ol) {
  padding-inline-start: 1.5em;
}

:where(.blog-article, .article-page, main.wrap:has(> article > header > h1)) .prose a:not([class*="btn"]):not([class*="button"]) {
  color: var(--text);
  text-decoration-color: var(--text-muted);
  text-underline-offset: 0.22em;
}

:where(.blog-article, .article-page, main.wrap:has(> article > header > h1)) .prose a:not([class*="btn"]):not([class*="button"]):hover {
  text-decoration-color: var(--accent);
}

:where(.blog-article, .article-page, main.wrap:has(> article > header > h1)) .prose :not(pre) > code {
  font-family: var(--font-mono);
  background: var(--bg-panel-2);
  color: var(--text);
  border-radius: var(--r-chip);
  padding: 0.1em 0.3em;
  overflow-wrap: anywhere;
}

:where(.blog-article, .article-page, main.wrap:has(> article > header > h1)) .prose pre {
  max-width: 100%;
  padding: 1rem;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  background: var(--bg-panel);
  color: var(--text);
}

:where(.blog-article, .article-page, main.wrap:has(> article > header > h1)) .prose pre code {
  font-family: var(--font-mono);
  white-space: pre;
  overflow-wrap: normal;
}

.article-download {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  margin-block: 2rem 0;
  padding: clamp(1rem, 3vw, 1.5rem);
  border: 1px solid var(--border);
  border-radius: var(--r-panel);
  background: var(--bg-panel);
}

.article-download h3,
:where(.blog-article, .article-page, main.wrap:has(> article > header > h1)) .prose .article-download h3 {
  margin: 0;
  font-size: var(--blog-h3-size);
}

.article-download p,
:where(.blog-article, .article-page, main.wrap:has(> article > header > h1)) .prose .article-download p {
  margin: 0.25rem 0 0;
  color: var(--text-muted);
}

#related-posts:not([hidden]):not(:empty),
#post-nav:not([hidden]):not(:empty) {
  max-width: var(--blog-reading-width);
  margin: 2rem auto 0;
}

#related-posts > h2 {
  margin: 0 0 0.85rem;
  font-size: var(--blog-h2-size);
}

.blog-related-grid,
#post-nav:not([hidden]):not(:empty) {
  grid-template-columns: repeat(2, minmax(300px, 1fr));
}

#related-posts,
#post-nav {
  container-type: inline-size;
}

#post-nav .blog-neighbor-label {
  display: block;
  margin-bottom: 0.4rem;
  color: var(--text-muted);
  font-size: var(--blog-meta-size);
}

#post-nav .blog-neighbor-next {
  grid-column: 2;
}

#post-nav {
  padding-bottom: 2rem;
}

@container (width < 616px) {
  .blog-related-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 700px) {
  #post-nav:not([hidden]):not(:empty) {
    grid-template-columns: minmax(0, 1fr);
  }

  #post-nav .blog-neighbor-next {
    grid-column: auto;
  }
}

@media (max-width: 600px) {
  .blog-intro h1 {
    font-size: min(var(--blog-index-title-size), 1.875rem);
  }

  :is(.article-hero, main.wrap > article > header:has(> h1)) h1 {
    font-size: 1.5rem;
  }

  main.wrap > article > header > h1 .keep {
    white-space: normal;
  }
}