/*
  04-blog.css
  Blog listing, post cards, single article layout, the article table of
  contents, the author box and related posts.
  Card markup lives in template-parts/blog/card.php.
  Layouts follow the approved prototype: a left aligned listing header
  with a tight gap to a grid of compact cards, and a single article
  with a breadcrumb, a wide hero image and a sticky contents sidebar.
*/

/* Listing: header and grid share one band, so no stacked band padding
   builds up above the cards. */
.tm-band.tm-band-blog { padding: 34px 0 64px; }
.tm-blog-head { max-width: 720px; }
.tm-blog-head h1 { font-size: clamp(2rem, 4.5vw, 2.8rem); margin: 14px 0 12px; }
.tm-blog-head p { color: var(--tm-ink-soft); font-size: 1.06rem; margin: 0; }
.tm-blog .tm-post-grid { margin-top: 26px; }
.tm-blog-empty { margin: 26px 0 0; color: var(--tm-ink-soft); }

.tm-post-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

/* Post card: compact, the image sits inset inside the card padding */
.tm-post-card {
  display: flex;
  flex-direction: column;
  background: var(--tm-surface-raised);
  border: 1px solid var(--tm-border);
  border-radius: var(--tm-radius);
  padding: 24px;
  box-shadow: var(--tm-shadow-card);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}
.tm-post-card:hover { transform: translateY(-4px); box-shadow: var(--tm-shadow-lift); }
.tm-post-thumb {
  display: block; height: 118px; overflow: hidden;
  border-radius: var(--tm-radius-sm);
  background: var(--tm-primary-tint);
}
.tm-post-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tm-post-thumb-empty {
  display: flex; align-items: center; justify-content: center;
  width: 100%; height: 100%;
  color: var(--tm-primary);
  background: linear-gradient(150deg, var(--tm-primary-tint), var(--tm-bg-band));
}
.tm-post-body { margin-top: 14px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.tm-post-body h3 { font-size: 1.06rem; margin: 0; line-height: 1.35; }
.tm-post-body h3 a { color: var(--tm-ink); }
.tm-post-body h3 a:hover { color: var(--tm-primary); }
.tm-post-body p { color: var(--tm-ink-soft); font-size: 0.84rem; margin: 0; flex: 1; }
.tm-post-meta {
  display: flex; gap: 14px; flex-wrap: wrap; align-items: center;
  color: var(--tm-muted); font-size: 0.83rem; font-weight: 600;
}
.tm-post-body .tm-post-meta {
  gap: 0;
  font-size: 0.78rem; letter-spacing: 0.03em; text-transform: uppercase;
}
.tm-post-body .tm-post-meta span + span::before { content: "·"; margin: 0 8px; }
.tm-read-more { font-weight: 700; display: inline-flex; align-items: center; gap: 7px; margin-top: 2px; }

/* Dark mode: Astra's separate container paints the loop article box
   white with a stronger rule, which left the card white while its
   title and excerpt switched to the dark palette. Pin the card to
   the raised surface token so background and text flip together. */
html[data-theme="dark"] .tm-post-card { background: var(--tm-surface-raised); }

/* Pagination */
.tm-pagination { margin-top: 28px; text-align: center; }
.tm-pagination .page-numbers {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 42px; height: 42px; padding: 0 12px; margin: 0 3px;
  border-radius: 12px; border: 1px solid var(--tm-border);
  background: var(--tm-surface); color: var(--tm-ink-soft); font-weight: 700;
}
.tm-pagination .page-numbers.current { background: var(--tm-primary); border-color: var(--tm-primary); color: #ffffff; }

/* Single article */
/* Astra narrows the content container on single posts to 750px,
   which leaves large empty sides and makes the article a very long
   scroll. Take the Astra wrapper out of the width calculation
   entirely and let the theme container inside the band govern, sized
   to Astra's standard container geometry (1320px including 20px of
   padding each side, the same box the header uses), so the article
   area runs full width with its left edge on the logo line and its
   right edge on the header's right edge. The selector carries #content
   because Astra's separate container padding rule uses that id, and
   the wrapper must be a block, not Astra's flex row: as a flex row it
   shrink wraps its child to the left, which left the centred theme
   container stuck against the left edge of the screen. */
@media (min-width: 922px) {
  body.single-post #content > .ast-container { max-width: none; padding-left: 0; padding-right: 0; display: block; }
  body.single-post .tm-band-article .tm-container { max-width: 1320px; padding-left: 20px; padding-right: 20px; }
}
body.single-post .ast-article-single { padding: 0; }

/* One background only on single posts: Astra's separate container
   paints the page canvas a tinted colour around the white article
   box, which reads as two backgrounds stacked on each other. Pin the
   canvas to the same background token the article band uses, so the
   whole page reads as a single background, white in light mode and
   the dark navy in dark mode. */
body.single-post.ast-separate-container,
body.single-post #content,
body.single-post #content > .ast-container { background-color: var(--tm-bg); }

.tm-band.tm-band-article { padding: 24px 0 64px; }
.tm-breadcrumb { font-size: 0.84rem; color: var(--tm-muted); margin: 0 0 24px; }
.tm-breadcrumb a { color: var(--tm-muted); font-weight: 600; }
.tm-breadcrumb a:hover { color: var(--tm-primary); }
.tm-breadcrumb .tm-breadcrumb-sep { margin: 0 7px; }
.tm-breadcrumb b { color: var(--tm-ink); font-weight: 700; }

.tm-article-head { max-width: 760px; margin-top: 26px; }
.tm-article-head h1 { font-size: clamp(1.9rem, 4.4vw, 2.7rem); margin: 14px 0 12px; }
.tm-article-lead { font-size: 1.13rem; color: var(--tm-ink-soft); margin: 0; }
.tm-author-row { display: flex; gap: 14px; align-items: center; margin-top: 18px; }
.tm-author-row img { border-radius: 999px; display: block; }
.tm-author-name { font-weight: 700; font-size: 0.91rem; color: var(--tm-ink); line-height: 1.3; }

.tm-article-hero { margin: 0; }
.tm-article-hero img {
  width: 100%; height: auto;
  border-radius: 22px; display: block; box-shadow: var(--tm-shadow-lift);
}

/* Article layout: sticky contents sidebar on the left, the text
   column in the middle and a right rail (ad widget area, recent articles,
   ad widget area) filling what used to be empty space beside the
   text. The text column is sized by the grid, so no separate
   max-width cap is needed on the article itself. */
.tm-article-layout {
  margin-top: 34px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 30px;
  align-items: start;
}
.tm-article-layout.tm-has-toc {
  grid-template-columns: 230px minmax(0, 1fr) 280px;
}
/* When the rail has nothing to show it is not rendered, and the
   article column takes its space instead of leaving a gap. */
.tm-article-layout.tm-no-rail { grid-template-columns: minmax(0, 1fr); }
.tm-article-layout.tm-has-toc.tm-no-rail { grid-template-columns: 230px minmax(0, 1fr); }
.tm-article {
  font-size: 1.03rem;
  line-height: 1.8;
}
.tm-article p { color: var(--tm-ink-soft); margin: 0 0 1.3em; }
.tm-article h2 { font-size: 1.55rem; margin: 1.6em 0 0.6em; scroll-margin-top: 90px; }
.tm-article h2:first-child { margin-top: 0; }
.tm-article h3 { font-size: 1.25rem; margin: 1.4em 0 0.5em; }
.tm-article ul, .tm-article ol { color: var(--tm-ink-soft); line-height: 1.7; margin: 0 0 1.3em; padding-left: 1.3em; }
.tm-article li { margin-bottom: 0.4em; }
.tm-article blockquote {
  border-left: 4px solid var(--tm-primary);
  background: var(--tm-bg-soft);
  margin: 0 0 1.3em; padding: 18px 22px;
  border-radius: 0 var(--tm-radius-sm) var(--tm-radius-sm) 0;
  font-size: 1.08rem; color: var(--tm-ink);
}
.tm-article img { border-radius: var(--tm-radius-sm); max-width: 100%; height: auto; }
.tm-article code {
  background: var(--tm-bg-band); color: var(--tm-ink);
  padding: 2px 7px; border-radius: 6px; font-size: 0.9em;
}
.tm-article table { width: 100%; border-collapse: collapse; margin: 0 0 1.3em; }
.tm-article th, .tm-article td { border: 1px solid var(--tm-border); padding: 10px 14px; text-align: left; }

/* Article table of contents: sticky sidebar card */
.tm-toc {
  position: sticky; top: 88px;
  background: var(--tm-surface);
  border: 1px solid var(--tm-border);
  border-radius: var(--tm-radius);
  padding: 20px;
  box-shadow: var(--tm-shadow-card);
}
.tm-toc h2 { font-size: 0.88rem; margin: 0 0 10px; letter-spacing: 0.02em; }
.tm-toc ol { margin: 0; padding: 0; list-style: none; color: var(--tm-ink-soft); }
.tm-toc li a {
  display: block; padding: 7px 0;
  font-size: 0.88rem; font-weight: 500; color: var(--tm-ink-soft);
}
.tm-toc a:hover { color: var(--tm-primary); }
.tm-toc-cta {
  background: var(--tm-bg-soft);
  border: 1px solid var(--tm-border);
  border-radius: var(--tm-radius-sm);
  padding: 15px; margin-top: 16px;
}
.tm-toc-cta b { font-size: 0.88rem; color: var(--tm-ink); }
.tm-toc-cta p { font-size: 0.84rem; color: var(--tm-muted); margin: 6px 0 12px; }
.tm-toc-cta .tm-btn { width: 100%; justify-content: center; padding: 10px 16px; font-size: 0.9rem; }

/* Article right rail: ad widget area first, then recent articles.
   There is no tool promo card here on purpose: the tool call to
   action already lives in the left contents sidebar. */
.tm-article-rail {
  position: sticky; top: 88px;
  display: flex; flex-direction: column; gap: 16px;
  min-width: 0;
}
.tm-rail-card {
  background: var(--tm-surface);
  border: 1px solid var(--tm-border);
  border-radius: var(--tm-radius);
  padding: 20px;
  box-shadow: var(--tm-shadow-card);
}
.tm-rail-card h2 { font-size: 0.95rem; margin: 0 0 12px; }
.tm-rail-recent { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.tm-rail-recent-item {
  display: flex; gap: 12px; align-items: center;
  padding: 6px; border-radius: var(--tm-radius-sm);
}
.tm-rail-recent-item:hover { background: var(--tm-bg-soft); }
.tm-rail-recent-item img {
  width: 56px; height: 56px; object-fit: cover;
  border-radius: 10px; flex: none; box-shadow: none;
}
.tm-rail-recent-title { display: block; font-weight: 700; font-size: 0.9rem; color: var(--tm-ink); line-height: 1.35; }
.tm-rail-recent-meta { display: block; font-size: 0.78rem; color: var(--tm-muted); margin-top: 2px; }
.tm-rail-ad .tm-banner-widget { text-align: center; }
.tm-rail-ad img { max-width: 100%; height: auto; display: block; margin: 0 auto; }

/* Author box: sits under the article, inside the text column */
.tm-author-box {
  margin: 28px 0 0;
  display: flex; gap: 14px; align-items: center;
  background: var(--tm-surface-raised);
  border: 1px solid var(--tm-border);
  border-radius: var(--tm-radius);
  padding: 24px;
  box-shadow: var(--tm-shadow-card);
}
.tm-author-box img { border-radius: 999px; width: 46px; height: 46px; }
.tm-author-box h3 { margin: 0 0 4px; font-size: 1rem; }
.tm-author-box p { margin: 0; color: var(--tm-ink-soft); font-size: 0.93rem; }

/* Related posts */
.tm-related { margin-top: 48px; }
.tm-related h2 { font-size: 1.5rem; margin: 0 0 16px; }
