:root {
  --blog-title-size: clamp(1.875rem, 1.2rem + 2.2vw, 3rem);
  --blog-article-title-size: clamp(1.5rem, 1.1rem + 1.4vw, 2rem);
  --blog-lead-size: clamp(0.9375rem, 0.85rem + 0.45vw, 1.125rem);
  --blog-h2-size: 1.5rem;
  --blog-h3-size: 1.25rem;
  --blog-body-size: 1rem;
  --blog-small-size: 0.8125rem;
  --blog-code-size: 0.875rem;
  --blog-close-size: 1.75rem;
  --blog-crumb-gap: 0.5rem;
  --blog-muted-opacity: 0.65;
  --blog-separator-opacity: 0.35;
  --blog-modal-speed: 180ms;
  --blog-modal-width: 30rem;
  --blog-modal-layer: 1000;
  --blog-focus-width: 2px;
  --blog-focus-offset: 4px;
  --blog-grid-gap: 1.25rem;
}

.blog-main {
  padding-top: var(--space-5, 2rem);
  padding-bottom: var(--space-7, 4rem);
}

.blog-main:has(> .reading) {
  padding-top: 32px;
}

.blog-hero {
  padding-block: 1rem 2rem;
}

.blog-hero h1 {
  max-width: 100%;
  margin-block: 1rem;
  color: var(--text);
  font-family: var(--font-display);
  font-size: var(--blog-title-size);
  font-weight: var(--weight-heavy);
  line-height: 1.25;
  letter-spacing: -0.035em;
}

.blog-intro {
  max-width: 48rem;
  margin: 0;
  color: var(--muted);
  font-size: var(--blog-lead-size);
  line-height: 1.7;
}

.blog-catalog {
  padding-top: 2rem;
}

.blog-catalog-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem 1.5rem;
  margin-bottom: 1.25rem;
}

.blog-catalog-heading h2,
#related-posts > h2 {
  margin: 0;
  color: var(--text);
  font-family: var(--font-display);
  font-size: var(--blog-h2-size);
  font-weight: var(--weight-heavy);
  line-height: 1.4;
}

.blog-count {
  margin: 0;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: var(--blog-small-size);
  line-height: 1.6;
}

.blog-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.blog-filter {
  position: relative;
  min-height: 2.75rem;
  padding: 0.65rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--muted);
  font-family: var(--font-body);
  font-size: var(--blog-code-size);
  font-weight: var(--weight-medium);
  line-height: 1.4;
  cursor: pointer;
  transition: color var(--speed), border-color var(--speed);
}

.blog-filter:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.blog-filter[aria-pressed="true"] {
  border-color: var(--accent);
  color: var(--accent);
}

.blog-filter[aria-pressed="true"]::after {
  position: absolute;
  inset: auto 0 0;
  height: 2px;
  background: var(--accent);
  content: "";
}

.blog-filter:focus-visible,
.post-card a:focus-visible,
#post-nav a:focus-visible,
.blog-download-dialog a:focus-visible,
.blog-download-close:focus-visible {
  outline: var(--blog-focus-width) solid var(--accent);
  outline-offset: var(--blog-focus-offset);
}

.blog-post-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--blog-grid-gap);
}

.post-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100%;
  padding: 1.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
}

.post-meta,
.article-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.6rem 0.85rem;
  color: var(--muted);
  font-size: var(--blog-small-size);
  line-height: 1.6;
}

.post-meta time,
.article-meta time {
  font-family: var(--font-mono);
  font-size: var(--blog-small-size);
}

.post-card .post-meta {
  margin: 0 0 1rem;
}

.post-card h3 {
  margin: 0 0 0.875rem;
  color: var(--text);
  font-family: var(--font-display);
  font-size: var(--blog-h3-size);
  font-weight: var(--weight-bold);
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.post-card h3 a {
  color: var(--text);
  text-decoration: none;
}

.post-card h3 a:hover {
  color: var(--accent);
}

.post-card .post-summary {
  margin: 0 0 1.25rem;
  color: var(--muted);
  font-size: var(--blog-code-size);
  line-height: 1.85;
}

.post-card .read-link {
  align-self: flex-start;
  margin-top: auto;
  color: var(--accent);
  font-size: var(--blog-code-size);
  font-weight: var(--weight-medium);
  line-height: 1.6;
  text-decoration: none;
}

.post-card .read-link:hover {
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

.blog-empty {
  grid-column: 1 / -1;
  margin: 0;
  padding: 1.5rem;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--muted);
  line-height: 1.8;
}

.blog-empty a {
  color: var(--accent);
}

.blog-breadcrumb,
nav.breadcrumb,
nav.breadcrumbs {
  display: flex;
  align-items: center;
  gap: var(--blog-crumb-gap);
  min-width: 0;
  margin-top: 1.25rem;
  margin-bottom: 1.25rem;
  padding: 0;
  overflow: hidden;
  color: var(--muted);
  font-family: var(--font-body);
  font-size: var(--blog-small-size);
  line-height: 1.6;
  white-space: nowrap;
}

.blog-breadcrumb a,
nav.breadcrumb a,
nav.breadcrumbs a {
  flex: 0 0 auto;
  color: var(--muted);
  text-decoration: none;
  opacity: var(--blog-muted-opacity);
}

.blog-breadcrumb a:hover,
nav.breadcrumb a:hover,
nav.breadcrumbs a:hover {
  color: var(--accent);
  opacity: 1;
}

.blog-breadcrumb > [aria-hidden="true"],
nav.breadcrumb > [aria-hidden="true"],
nav.breadcrumbs > [aria-hidden="true"] {
  flex: 0 0 auto;
  opacity: var(--blog-separator-opacity);
}

.blog-breadcrumb [aria-current="page"],
nav.breadcrumb [aria-current="page"],
nav.breadcrumbs [aria-current="page"] {
  flex: 0 1 auto;
  max-width: 30ch;
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
}

.section:has(.blog-breadcrumb),
.section:has(nav.breadcrumb),
.section:has(nav.breadcrumbs) {
  padding-top: 0;
}

.article-page > main,
.blog-article > main,
.article-main {
  padding-top: 0;
}

.article-hero,
.article-header,
.post-header,
.article-hero.section,
.article-header.section,
.post-header.section {
  padding-top: 0.5rem;
  padding-bottom: 1.5rem;
}

.article-hero .post-meta,
.article-hero .article-meta,
.article-header .post-meta,
.article-header .article-meta,
.post-header .post-meta,
.post-header .article-meta {
  margin-top: 0;
  margin-bottom: 1rem;
}

.article-hero h1,
.article-header h1,
.post-header h1,
.blog-article h1,
.article-page h1 {
  max-width: 100%;
  margin-block: 1rem;
  color: var(--text);
  font-family: var(--font-display);
  font-size: var(--blog-article-title-size);
  font-weight: var(--weight-heavy);
  line-height: 1.32;
  letter-spacing: -0.025em;
  overflow-wrap: anywhere;
}

.article-lead,
.post-lead,
.article-summary,
.article-hero > p:last-child,
.article-header > p:last-child,
.post-header > p:last-child {
  margin-top: 1rem;
  margin-bottom: 0;
  color: var(--muted);
  font-size: var(--blog-lead-size);
  line-height: 1.7;
}

.article-body,
.prose {
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--blog-body-size);
  line-height: 1.85;
  overflow-wrap: anywhere;
}

.article-body > :first-child,
.prose > :first-child {
  margin-top: 0;
}

.article-body h2,
.prose h2 {
  margin: 2rem 0 1rem;
  color: var(--text);
  font-family: var(--font-display);
  font-size: var(--blog-h2-size);
  font-weight: var(--weight-bold);
  line-height: 1.5;
  scroll-margin-top: calc(var(--bar-h) + 1rem);
}

.article-body > h2:first-of-type,
.prose > h2:first-of-type,
.article-body > section:first-child > h2:first-child,
.prose > section:first-child > h2:first-child {
  margin-top: 0;
}

.article-body h3,
.prose h3 {
  margin: 1.5rem 0 0.75rem;
  color: var(--text);
  font-family: var(--font-display);
  font-size: var(--blog-h3-size);
  font-weight: var(--weight-bold);
  line-height: 1.5;
}

.article-body p,
.prose p,
.article-body ul,
.prose ul,
.article-body ol,
.prose ol {
  margin-block: 0 1rem;
}

.article-body li + li,
.prose li + li {
  margin-top: 0.4rem;
}

.article-body ul,
.article-body ol,
.prose ul,
.prose ol {
  padding-left: 1.5rem;
}

.article-body section,
.prose section,
.article-body section.section,
.prose section.section {
  margin-block: 0 1.5rem;
  padding-block: 0;
}

.article-body section > :last-child,
.prose section > :last-child {
  margin-bottom: 0;
}

.article-body section + section,
.prose section + section {
  margin-top: 1.5rem;
}

.article-body section + section > h2:first-child,
.prose section + section > h2:first-child {
  margin-top: 0;
}

.article-body a:not([class*="btn"]):not([class*="button"]),
.prose a:not([class*="btn"]):not([class*="button"]) {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}

.article-body code,
.prose code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  overflow-wrap: anywhere;
}

.article-body :not(pre) > code,
.prose :not(pre) > code {
  padding: 0.1em 0.3em;
  background: var(--panel-2);
  color: var(--text);
}

.article-body pre,
.prose pre {
  max-width: 100%;
  margin-block: 1.25rem;
  padding: 1.25rem;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: var(--blog-code-size);
  line-height: 1.75;
  white-space: pre;
}

.article-body pre code,
.prose pre code {
  font-size: inherit;
  overflow-wrap: normal;
  word-break: normal;
  white-space: pre;
}

.article-body .code-window pre,
.prose .code-window pre {
  margin: 0;
  border: 0;
}

.article-body blockquote,
.prose blockquote {
  margin: 1.25rem 0;
  padding: 0.75rem 1.25rem;
  border-left: 2px solid var(--accent);
  background: var(--panel);
  color: var(--muted);
}

.article-body blockquote > :last-child,
.prose blockquote > :last-child {
  margin-bottom: 0;
}

.article-body table,
.prose table {
  display: block;
  width: 100%;
  max-width: 100%;
  margin-block: 1.25rem;
  overflow-x: auto;
  border-collapse: collapse;
  color: var(--text);
  font-size: var(--blog-code-size);
}

.article-body th,
.article-body td,
.prose th,
.prose td {
  min-width: 7em;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.article-body th,
.prose th {
  background: var(--panel-2);
  color: var(--text);
  font-weight: var(--weight-bold);
}

.article-body img,
.prose img {
  max-width: 100%;
  height: auto;
}

.dl-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1.25rem 1.5rem;
  margin-block: 2rem;
  padding: 1.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
}

.dl-card h2 {
  margin: 0 0 0.75rem;
  color: var(--text);
  font-family: var(--font-display);
  font-size: var(--blog-h2-size);
  font-weight: var(--weight-heavy);
  line-height: 1.5;
}

.dl-card p {
  margin: 0;
  color: var(--muted);
  font-size: var(--blog-body-size);
  line-height: 1.75;
}

.dl-card > div:first-child {
  flex: 1 1 18rem;
  min-width: 0;
}

.dl-card-actions,
.article-download-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

#related-posts {
  margin-block: 2rem;
  padding-block: 1.5rem 0;
  border-top: 1px solid var(--border);
}

#related-posts > h2 {
  margin-bottom: 1.25rem;
}

#related-posts .related-post-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
  gap: var(--blog-grid-gap);
}

#related-posts .post-card h3 {
  font-size: var(--blog-body-size);
}

#post-nav {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin-block: 2rem;
}

.post-nav-link {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-width: 0;
  padding: 1.25rem;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  text-decoration: none;
}

.post-nav-link:hover {
  border-color: var(--accent);
}

.post-nav-link--next {
  grid-column: 2;
}

.post-nav-caption {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: var(--blog-small-size);
  line-height: 1.6;
}

.post-nav-title {
  color: var(--text);
  font-size: var(--blog-body-size);
  font-weight: var(--weight-medium);
  line-height: 1.7;
  overflow-wrap: anywhere;
}

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

#post-nav[hidden],
#related-posts[hidden] {
  display: none;
}

body.blog-dialog-open {
  overflow: hidden;
}

.blog-download-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--blog-modal-layer);
  display: grid;
  place-items: center;
  padding: 1.25rem;
  overflow-y: auto;
  background: var(--veil);
  color: var(--text);
  opacity: 0;
  transition: opacity var(--blog-modal-speed) ease;
}

.blog-download-overlay.is-open {
  opacity: 1;
}

.blog-download-dialog {
  position: relative;
  width: 100%;
  max-width: var(--blog-modal-width);
  max-height: calc(100dvh - 2.5rem);
  padding: 2rem;
  overflow-y: auto;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
  transform: translateY(0.5rem);
  transition: transform var(--blog-modal-speed) ease;
}

.is-open .blog-download-dialog {
  transform: translateY(0);
}

.blog-download-dialog .eyebrow {
  margin: 0 3rem 1rem 0;
}

.blog-download-dialog h2 {
  margin: 0 2rem 1rem 0;
  color: var(--text);
  font-family: var(--font-display);
  font-size: var(--blog-h2-size);
  font-weight: var(--weight-heavy);
  line-height: 1.4;
}

.blog-download-dialog > p:not(.eyebrow) {
  margin: 0 0 1.5rem;
  color: var(--muted);
  font-size: var(--blog-body-size);
  line-height: 1.8;
}

.blog-download-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--blog-close-size);
  line-height: 1;
  cursor: pointer;
}

.blog-download-close:hover {
  border-color: var(--accent);
  color: var(--accent);
}

@media (min-width: 821px) {
  #related-posts .related-post-grid {
    grid-template-columns: repeat(2, minmax(300px, 1fr));
  }
}

@media (max-width: 1000px) {
  .blog-post-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .blog-main {
    padding-top: 1.25rem;
  }

  .blog-hero {
    padding-block: 0.5rem 1.5rem;
  }

  .blog-hero h1 {
    font-size: min(var(--blog-title-size), 1.875rem);
  }

  .article-hero h1,
  .article-header h1,
  .post-header h1,
  .blog-article h1,
  .article-page h1 {
    font-size: 1.5rem;
  }

  .blog-post-grid,
  #post-nav {
    grid-template-columns: minmax(0, 1fr);
  }

  .post-nav-link--next {
    grid-column: 1;
  }

  .post-card,
  .dl-card {
    padding: 1.25rem;
  }

  .blog-download-dialog {
    padding: 1.5rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .blog-filter,
  .blog-download-overlay,
  .blog-download-dialog {
    transition: none;
  }

  .blog-download-dialog {
    transform: none;
  }
}