/**
 * Editorial / blog surfaces on felt shell.
 * Blog archive: featured + predictable 3-column grid (no masonry).
 * Page-end spacing owned by .site-main (--page-end-space).
 */

.blog-hub-header {
  max-width: 46rem;
  margin: 0 0 var(--space-5);
  padding: 0;
}

.blog-hub-header .display-title {
  margin-bottom: var(--space-3);
}

.blog-hub-header .lead {
  margin: 0;
}

/* Topic discovery — intentional component-local horizontal scroll (TASK 48.4) */
.blog-topic-nav {
  display: flex;
  gap: var(--space-4);
  overflow-x: auto;
  overscroll-behavior-x: contain;
  margin: 0 0 var(--section-gap-sm);
  padding: 0 1.25rem 0 0;
  max-width: 100%;
  min-width: 0;
  border-bottom: 1px solid var(--olimp-separator);
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x proximity;
  scroll-padding-inline: 0.25rem;
  mask-image: linear-gradient(90deg, #000 0%, #000 calc(100% - 1.35rem), transparent 100%);
}

.blog-topic-nav::-webkit-scrollbar {
  height: 3px;
}

.blog-topic-nav a {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
  padding: 0.35rem 0 0.5rem;
  margin-bottom: -1px;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: none;
  box-shadow: none;
  color: var(--olimp-text-secondary);
  font-weight: 600;
  font-size: 0.9375rem;
  letter-spacing: -0.01em;
  text-decoration: none;
  white-space: nowrap;
  scroll-snap-align: start;
}

.blog-topic-nav a:hover,
.blog-topic-nav a:focus-visible {
  color: var(--olimp-text-primary);
}

/* Featured — one intentional horizontal composition */
.article-featured {
  display: grid;
  gap: var(--space-4);
  align-items: start;
  margin: 0 0 var(--section-gap-md);
}

.article-featured__media {
  display: block;
  border-radius: var(--radius-xl);
  overflow: hidden;
  aspect-ratio: 3 / 2;
  max-height: 14rem; /* keep featured compact on mobile */
  background: var(--felt-deep);
  min-height: 0;
  height: auto;
}

@media (min-width: 768px) {
  .article-featured__media {
    max-height: none;
  }
}

.article-featured__media--fallback,
.article-card__media--fallback {
  background:
    linear-gradient(145deg, rgba(47, 143, 91, 0.22), transparent 55%),
    var(--felt-deep);
}

.article-featured__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.article-featured__body {
  display: grid;
  gap: var(--space-2);
  align-content: start;
}

.article-featured__title {
  margin: 0;
  font-size: clamp(1.35rem, 1.15rem + 0.7vw, 1.75rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: var(--lh-tight);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  max-width: none;
}

.article-featured__title a {
  color: inherit;
  text-decoration: none;
}

.article-featured__title a:hover,
.article-featured__title a:focus-visible {
  color: var(--link-hover);
}

.article-featured__excerpt {
  margin: 0;
  color: var(--olimp-text-secondary);
  font-size: var(--fs-small);
  font-weight: 500;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

@media (min-width: 900px) {
  .article-featured {
    grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
    gap: var(--grid-gap-lg);
    align-items: start;
  }

  .article-featured__body {
    padding-top: var(--space-2);
  }
}

/* Standard archive grid — no arbitrary spans */
.blog-grid {
  display: grid;
  gap: var(--grid-gap);
  grid-template-columns: 1fr;
  margin: 0 0 var(--section-gap-sm);
  align-items: start;
}

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

@media (min-width: 1100px) {
  .blog-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* Legacy feed class — keep simple stack for search/archive reuse */
.article-feed {
  display: grid;
  gap: var(--grid-gap);
  margin-bottom: var(--section-gap-sm);
  grid-template-columns: 1fr;
}

@media (min-width: 768px) {
  .article-feed:not(.blog-grid) {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1100px) {
  .article-feed:not(.blog-grid) {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.article-card__body {
  display: grid;
  gap: var(--space-2);
}

.article-card__meta,
.entry-meta {
  margin: 0;
  color: var(--olimp-text-tertiary);
  font-size: var(--fs-small);
  font-weight: 500;
}

.article-card__title {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.article-card__title a {
  color: inherit;
  text-decoration: none;
}

.article-card__title a:hover,
.article-card__title a:focus-visible {
  color: var(--link-hover);
}

/* Pagination */
.blog-archive .navigation.pagination,
.blog-archive .nav-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.35rem 0.5rem;
  margin: 0 0 var(--section-gap-md);
  padding: 0;
}

.blog-archive .nav-links {
  width: 100%;
}

.blog-archive .page-numbers {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.5rem;
  min-height: 2.5rem;
  padding: 0 0.55rem;
  border-radius: var(--radius-sm);
  color: var(--olimp-text-secondary);
  font-weight: 600;
  font-size: 0.9375rem;
  text-decoration: none;
  background: transparent;
  border: 0;
}

.blog-archive .page-numbers:hover,
.blog-archive .page-numbers:focus-visible {
  color: var(--olimp-text-primary);
  background: rgba(243, 239, 230, 0.06);
}

.blog-archive .page-numbers.current {
  color: var(--olimp-text-primary);
  box-shadow: inset 0 -2px 0 var(--olimp-accent);
  background: transparent;
  pointer-events: none;
}

.blog-archive .page-numbers.prev,
.blog-archive .page-numbers.next {
  min-width: auto;
  padding-inline: 0.75rem;
}

.blog-archive .page-numbers.dots {
  pointer-events: none;
  opacity: 0.6;
}

/* Final CTA — compact, centered rail */
.blog-hub-cta {
  margin: 0 auto;
  max-width: var(--container-medium);
  border-radius: var(--radius-xl);
  padding: var(--space-5) var(--space-5);
  width: 100%;
  background: var(--surface-raised);
  border: 1px solid var(--border-on-dark);
  text-align: center;
}

.blog-hub-cta__header {
  margin: 0 0 var(--space-4);
}

.blog-hub-cta__header h2 {
  margin: 0 0 var(--space-2);
  max-width: none;
}

.blog-hub-cta__header .lead {
  margin: 0 auto;
  max-width: var(--measure-lead);
}

.blog-hub-cta .btn-group {
  justify-content: center;
}

.reading-column {
  width: min(100% - (var(--gutter-page) * 2), var(--container-reading));
  margin-inline: auto;
}

/*
 * Single article: no outer card chrome — content sits on page canvas.
 * Keep .reading-surface as a semantic wrapper for typography hooks only.
 */
.layout-article-shell .reading-surface,
.page-shell .layout-article-shell .reading-surface {
  width: 100%;
  max-width: none;
  margin-inline: 0;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  color: var(--text-primary-on-dark);
}

.layout-article-shell .display-title,
.layout-article-shell .entry-title,
.reading-surface .display-title,
.reading-surface h1.entry-title {
  max-width: min(100%, var(--article-prose-width));
  font-size: clamp(1.85rem, 1.45rem + 1.2vw, 2.65rem);
  text-align: left;
}

.layout-article-shell .entry-content,
.layout-article-shell .prose {
  max-width: var(--article-prose-width);
  width: 100%;
  text-align: left;
}

/*
 * Canonical single-post column: header, featured image, prose, CTA —
 * shared max-width, horizontally centered inside the article shell.
 */
.layout-article-shell .entry-header,
.layout-article-shell .entry-thumb,
.layout-article-shell .entry-content,
.layout-article-shell .entry--single > .grouped {
  max-width: var(--article-prose-width);
  width: 100%;
  margin-inline: auto;
}

/* Featured image may use the slightly wider media rail when shell allows */
.layout-article-shell .entry-thumb {
  max-width: min(100%, var(--container-article-media));
}

.layout-article-shell .entry-content .table-scroll,
.layout-article-shell .entry-content .wp-block-table,
.layout-article-shell .entry-content .wp-block-image,
.layout-article-shell .entry-content .wp-block-gallery,
.layout-article-shell .entry-content .alignwide,
.layout-article-shell .entry-content .alignfull {
  max-width: 100%;
}

/*
 * Kill global measure caps that shrink article blocks below the prose column:
 * - .lead → --measure-lead (36rem / 576px) — bold intros
 * - h2/h3 → --measure-body (40rem / 640px) — TOC + section titles inside wrappers
 * - .page-shell .lead duplicate
 * Scope: single-post shell only (not hub / commercial pages).
 */
.layout-article-shell .entry-content .lead,
.layout-article-shell .entry-content p.lead,
.layout-article-shell .reading-surface .entry-content .lead,
.page-shell .layout-article-shell .entry-content .lead {
  max-width: none;
  width: 100%;
}

.layout-article-shell .entry-content h1,
.layout-article-shell .entry-content h2,
.layout-article-shell .entry-content h3,
.layout-article-shell .entry-content h4,
.layout-article-shell .entry-content h5,
.layout-article-shell .entry-content h6,
.layout-article-shell .entry-content .toc,
.layout-article-shell .entry-content .toc h2,
.layout-article-shell .entry-content .mls-faq,
.layout-article-shell .entry-content .wp-block-group,
.layout-article-shell .entry-content .wp-block-group__inner-container,
.layout-article-shell .entry-content .wp-block-columns,
.layout-article-shell .entry-content .wp-block-column,
.layout-article-shell .entry-content .is-layout-constrained > :where(:not(.alignleft):not(.alignright):not(.alignfull)) {
  max-width: none;
}

.layout-article-shell .entry-content .wp-block-group,
.layout-article-shell .entry-content .wp-block-group__inner-container,
.layout-article-shell .entry-content .toc,
.layout-article-shell .entry-content .mls-faq {
  width: 100%;
}

/* Non-article surfaces that still use .reading-surface (if any) keep local token fallbacks */
.reading-surface {
  color: var(--text-primary-on-dark);
}

.reading-surface .display-title,
.reading-surface h1,
.reading-surface h2,
.reading-surface h3 {
  color: var(--text-primary-on-dark);
}

.reading-surface .entry-meta,
.reading-surface .lead,
.reading-surface .breadcrumbs,
.reading-surface .breadcrumbs a {
  color: var(--text-secondary-on-dark);
}

.entry-back {
  margin: 0 0 var(--space-3);
}

.entry-back a {
  font-weight: 600;
  color: var(--link-on-dark);
  text-decoration: none;
}

.reading-surface .entry-back a {
  color: var(--link-on-dark);
}

.reading-surface .entry-back a:hover,
.reading-surface .entry-back a:focus-visible {
  color: var(--accent-on-dark);
  text-decoration: underline;
}

.entry-thumb {
  margin: var(--space-5) 0 var(--space-6);
  border-radius: var(--radius-media);
  overflow: hidden;
  background: var(--felt-deep);
  border: 0;
  box-shadow: none;
  aspect-ratio: var(--ratio-gallery);
  min-width: 0;
}

.entry-thumb img {
  width: 100%;
  max-width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.reading-surface .breadcrumbs a:hover {
  color: var(--link-on-dark);
}

@media (max-width: 480px) {
  .reading-surface .display-title,
  .reading-surface h1.entry-title {
    font-size: clamp(1.65rem, 6.5vw, 2rem);
    line-height: 1.2;
  }

  .entry-thumb {
    margin: var(--space-4) 0 var(--space-5);
  }
}

/* Keep long search queries within the page. */
body.search .archive-title {
  overflow-wrap: anywhere;
}
