/* Layout engine: defaults + consumers of --layout tokens.
   Presets set tokens on body.blog-layout-* (see sibling CSS files). */

:where(body[class*="blog-layout-"]) {
  --posts-cols: 1;
  --posts-gap: 0.25rem;
  --profile-max: 850px;
  --post-show-max: 860px;
  --content-tracking: normal;
  --title-weight: 700;
  --title-tracking: normal;
  --cover-radius: var(--blog-radius, 0.75rem);
  --featured-span: auto;
  --featured-title-size: inherit;
  --featured-title-weight: var(--title-weight, 700);
  --featured-title-tracking: var(--title-tracking, normal);
  --featured-excerpt-size: inherit;
  --featured-excerpt-max: none;
  --featured-image-max-h: none;
  --grid-card-bg: transparent;
  --grid-card-border: none;
  --grid-card-padding: 0;
  --grid-card-radius: 0;
  --grid-card-shadow: none;
  --grid-card-margin-bottom: 0;
  --grid-card-height: auto;
  --grid-title-size: inherit;
  --grid-image-radius: var(--cover-radius);
  --post-show-article-bg: transparent;
  --post-show-article-padding: 0;
  --post-show-article-radius: 0;
  --post-show-article-shadow: none;
  --post-show-title-size: inherit;
}

@media (max-width: 768px) {
  :where(body[class*="blog-layout-"]) {
    --posts-cols: 1;
  }
}

/* Shared profile chrome */

.profile-divider {
  display: none;
}

.profile-container,
.posts-index {
  max-width: var(--profile-max, 850px);
  margin-inline: auto;
  letter-spacing: var(--content-tracking, normal);
}

.series-posts-grid,
.posts-index-grid {
  display: grid;
  grid-template-columns: repeat(var(--posts-cols, 1), minmax(0, 1fr));
  gap: var(--posts-gap, 0.25rem);
}

.series-post-item--featured,
.posts-index-item--featured {
  grid-column: var(--featured-span, auto);
}

.series-posts-grid .post-card,
.posts-index-grid .post-card {
  background-color: var(--grid-card-bg, transparent);
  border: var(--grid-card-border, none);
  border-radius: var(--grid-card-radius, 0);
  box-shadow: var(--grid-card-shadow, none);
  padding: var(--grid-card-padding, 0);
  margin-bottom: var(--grid-card-margin-bottom, 0);
  height: var(--grid-card-height, auto);
}

.series-posts-grid .post-card:last-child,
.posts-index-grid .post-card:last-child {
  border-bottom: var(--grid-card-border, none);
}

.series-posts-grid .post-title,
.posts-index-grid .post-title {
  font-weight: var(--title-weight, 700);
  font-size: var(--grid-title-size, inherit);
  letter-spacing: var(--title-tracking, normal);
}

.series-posts-grid .post-image,
.posts-index-grid .post-image {
  border-radius: var(--grid-image-radius, var(--cover-radius, 0.75rem));
}

.series-post-item--featured .post-title,
.posts-index-item--featured .post-title {
  font-size: var(--featured-title-size, var(--grid-title-size, inherit));
  font-weight: var(--featured-title-weight, var(--title-weight, 700));
  letter-spacing: var(--featured-title-tracking, var(--title-tracking, normal));
  line-height: 1.15;
}

.series-post-item--featured .post-excerpt,
.posts-index-item--featured .post-excerpt {
  font-size: var(--featured-excerpt-size, inherit);
  max-width: var(--featured-excerpt-max, none);
}

.series-post-item--featured .post-image,
.posts-index-item--featured .post-image {
  width: 100%;
  max-height: var(--featured-image-max-h, none);
  object-fit: cover;
  border-radius: var(--cover-radius, var(--blog-radius, 0.75rem));
}

/* Magazine hero: reset grid-card chrome on the featured item */
.blog-layout-magazine .series-post-item--featured .post-card,
.blog-layout-magazine .posts-index-item--featured .post-card {
  background-color: var(--featured-card-bg, transparent);
  border: var(--featured-card-border, none);
  border-radius: var(--featured-card-radius, 0);
  box-shadow: var(--featured-card-shadow, none);
  padding: var(--featured-card-padding, 0);
  padding-bottom: var(--featured-card-padding-bottom, 2rem);
  margin-bottom: var(--featured-card-margin-bottom, 0.5rem);
  border-bottom: var(--featured-card-border-bottom, 1px solid var(--bs-border-color, #dee2e6));
  height: auto;
}

.post-show {
  max-width: var(--post-show-max, 860px);
  margin-inline: auto;
  letter-spacing: var(--content-tracking, normal);
}

.post-show-article {
  background-color: var(--post-show-article-bg, transparent);
  border-radius: var(--post-show-article-radius, 0);
  box-shadow: var(--post-show-article-shadow, none);
  padding: var(--post-show-article-padding, 0);
}

.post-show .cover-image {
  border-radius: var(--cover-radius, var(--blog-radius, 0.75rem));
}

.post-show-header h1,
.post-show-title {
  font-weight: var(--title-weight, 700);
  letter-spacing: var(--title-tracking, normal);
  font-size: var(--post-show-title-size, inherit);
  line-height: 1.15;
}

.category-profile-header {
  margin-bottom: 1.5rem;
}

.category-cover {
  margin: 0 0 1rem;
}

.category-cover-image {
  display: block;
  width: 100%;
  height: clamp(140px, 28vw, 220px);
  object-fit: cover;
  border-radius: var(--cover-radius, var(--blog-radius, 0.75rem));
}

.category-profile-body {
  align-items: flex-start;
  row-gap: 1rem;
}

.category-description {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 8;
  overflow: hidden;
}

.category-description > :last-child {
  margin-bottom: 0;
}
