/* ── Blog hub: Read-mode index ───────────────────────────────────────────
   /blogs/ and /<lang>/blogs/ on the site layout. An editorial index, not a
   card wall: the title and a short lede, three image-led lead articles and
   the newest guide as a ruled band, then a topic filter over a dense ruled
   list of every article grouped by topic. Rows carry the article's own
   topic tag and read time; each row and tile wears its article's catalog
   accent (the linked tool's group), groups wear their topic's accent.
   Behaviour: assets/site/blog-hub.js (the list works without it).
   Tokens only; logical properties throughout so RTL needs no overrides. */

.blog-hub {
  padding-block: var(--space-7) var(--space-10);
  -webkit-user-select: text;
  user-select: text;
}

/* ── Title block ───────────────────────────────────────────────────── */
.bh-head { max-inline-size: 60rem; }
.bh-head h1 { margin: 0; }
.bh-lede {
  max-inline-size: 60ch;
  margin: var(--space-4) 0 0;
  color: var(--text-muted);
  font-size: var(--step-1);
  line-height: 1.5;
  text-wrap: pretty;
}

/* Section titles: generous above, tight below. */
.bh-featured { margin-block-start: var(--space-8); }
.bh-index { margin-block-start: var(--space-9); }
.bh-featured > h2,
.bh-index-head h2 { margin: 0 0 var(--space-5); }
.bh-index-head { margin-block-end: var(--space-5); }
.bh-index-head h2 { margin-block-end: 0; }
.bh-index-lede {
  max-inline-size: 60ch;
  margin: var(--space-2) 0 0;
  color: var(--text-muted);
}

/* ── Lead articles ─────────────────────────────────────────────────── */
.bh-feature-grid {
  display: grid;
  gap: var(--space-4);
}
.bh-feature {
  display: flex;
  min-inline-size: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-block-start-color: var(--accent);
  border-radius: var(--radius-lg);
  background: var(--surface-1);
  box-shadow: inset 0 2px 0 var(--accent), var(--shadow-1);
  transition:
    border-color var(--dur-fast) var(--ease),
    box-shadow var(--dur-med) var(--ease);
}
.bh-feature-link {
  display: grid;
  grid-template-columns: minmax(7rem, 36%) minmax(0, 1fr);
  flex: 1;
  min-inline-size: 0;
  color: inherit;
  text-decoration: none;
}
.bh-feature-media {
  position: relative;
  overflow: hidden;
  background: var(--bg-raised);
}
.bh-feature-media img {
  display: block;
  inline-size: 100%;
  block-size: 100%;
  object-fit: cover;
  transition: transform var(--dur-med) var(--ease);
}
.bh-feature-body {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  min-inline-size: 0;
  padding: var(--space-4);
}
.bh-feature-title {
  margin: 0;
  font-size: var(--step-1);
  line-height: 1.1;
  text-wrap: balance;
  line-break: strict;
}
.bh-feature-excerpt {
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  color: var(--text-muted);
  font-size: var(--step--1);
  line-height: 1.5;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  line-clamp: 3;
}
.bh-feature-body > .bh-meta { margin-block-start: auto; padding-block-start: var(--space-1); }
/* The lead stacks its image over the text at every width. */
.bh-feature--lead .bh-feature-link { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
.bh-feature--lead .bh-feature-media { aspect-ratio: 960 / 582; }
.bh-feature--lead .bh-feature-title { font-size: var(--step-2); line-height: 1.05; }
.bh-feature--lead .bh-feature-excerpt { font-size: var(--step-0); -webkit-line-clamp: 4; line-clamp: 4; }

.bh-feature:hover {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--border));
  border-block-start-color: var(--accent);
  box-shadow: inset 0 2px 0 var(--accent), var(--shadow-2);
}
.bh-feature:hover .bh-feature-media img { transform: scale(1.045); }
.bh-feature:has(.bh-feature-link:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }
.bh-feature-link:focus-visible { outline: none; }

@media (max-width: 479.98px) {
  .bh-feature-link { grid-template-columns: 7rem minmax(0, 1fr); }
  .bh-feature:not(.bh-feature--lead) .bh-feature-excerpt { display: none; }
  .bh-feature-body { padding: var(--space-3) var(--space-4); }
}
@media (min-width: 768px) {
  .bh-feature-grid {
    grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
    grid-template-rows: 1fr 1fr;
    gap: var(--space-5);
  }
  .bh-feature--lead { grid-row: span 2; }
  .bh-feature-link { grid-template-columns: minmax(0, 40%) minmax(0, 1fr); }
  .bh-feature-body { padding: var(--space-5); }
  .bh-feature--lead .bh-feature-body { padding: var(--space-5) var(--space-6) var(--space-6); gap: var(--space-3); }
}

/* ── Newest guide band ─────────────────────────────────────────────── */
.bh-release {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  gap: var(--space-2) var(--space-4);
  margin-block-start: var(--space-6);
  padding-block: var(--space-5);
  border-block: 1px solid var(--border);
}
.bh-release-key {
  display: grid;
  place-items: center;
  inline-size: var(--tap);
  block-size: var(--tap);
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--accent) 14%, var(--surface-2));
  color: var(--accent);
  font-size: var(--step-1);
}
.bh-release-body { min-inline-size: 0; }
.bh-release-body h3 { margin: 0; font-size: var(--step-1); line-height: 1.1; }
.bh-release-body p {
  max-inline-size: 70ch;
  margin: var(--space-1) 0 0;
  color: var(--text-muted);
  font-size: var(--step--1);
}
.bh-action {
  display: inline-flex;
  grid-column: 2;
  justify-self: start;
  align-items: center;
  gap: var(--space-2);
  min-block-size: var(--tap);
  color: var(--text);
  font-size: var(--step--1);
  font-weight: 600;
  white-space: nowrap;
  text-decoration: underline 1px color-mix(in srgb, var(--accent) 60%, transparent);
  text-underline-offset: 5px;
  transition: text-decoration-color var(--dur-fast) var(--ease);
}
.bh-action i { color: var(--accent); transition: transform var(--dur-fast) var(--ease); }
.bh-action:hover { color: var(--text); text-decoration-color: var(--accent); }
.bh-action:hover i { transform: translateX(3px); }
[dir="rtl"] .bh-action i { transform: scaleX(-1); }
[dir="rtl"] .bh-action:hover i { transform: scaleX(-1) translateX(3px); }
@media (min-width: 768px) {
  .bh-release { grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: var(--space-5); }
  .bh-action { grid-column: auto; justify-self: end; }
}

/* ── Topic filter ──────────────────────────────────────────────────── */
.bh-filter {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-block-end: var(--space-7);
  scroll-margin-block-start: calc(var(--header-stuck) + var(--space-4));
}
.bh-filter-chip {
  position: relative;
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: var(--space-2);
  min-block-size: 36px;
  padding-inline: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: var(--step--1);
  font-weight: 500;
  line-height: 1.2;
  white-space: nowrap;
  text-decoration: none;
  transition:
    background-color var(--dur-fast) var(--ease),
    border-color var(--dur-fast) var(--ease),
    color var(--dur-fast) var(--ease);
}
/* 36px pill, 44px hit area. */
.bh-filter-chip::after { content: ''; position: absolute; inset: calc(-1 * var(--space-1)) 0; }
.bh-filter-chip::before {
  content: '';
  flex: none;
  inline-size: 6px;
  block-size: 6px;
  border-radius: 50%;
  background: var(--accent);
}
.bh-n {
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}
.bh-filter-chip:hover {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--border));
  background: var(--surface-3);
  color: var(--text);
}
.bh-filter-chip:hover .bh-n { color: var(--text-muted); }
.bh-filter-chip[aria-current="true"] {
  border-color: color-mix(in srgb, var(--accent) 50%, var(--border-strong));
  background: color-mix(in srgb, var(--accent) 14%, var(--surface-2));
  color: var(--text);
  box-shadow: var(--shadow-1);
}
.bh-filter-chip[aria-current="true"] .bh-n { color: var(--text-muted); }
/* Phones: one row that scrolls sideways, bleeding to the screen edges. */
@media (max-width: 767.98px) {
  .bh-filter {
    flex-wrap: nowrap;
    margin-inline: calc(-1 * var(--gutter));
    padding: var(--space-1) var(--gutter);
    overflow-x: auto;
    scrollbar-width: none;
    scroll-padding-inline: var(--gutter);
    overscroll-behavior-inline: contain;
  }
  .bh-filter::-webkit-scrollbar { display: none; }
}

/* ── Topic groups and the article list ─────────────────────────────── */
.bh-group { scroll-margin-block-start: calc(var(--header-stuck) + var(--space-4)); }
.bh-group[hidden] { display: none; }
.bh-group + .bh-group { margin-block-start: var(--space-9); }
.bh-group-head {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.bh-group-head::before {
  content: '';
  flex: none;
  inline-size: var(--space-2);
  block-size: var(--space-2);
  border-radius: 50%;
  background: var(--accent);
}
.bh-group-head h3 {
  margin: 0;
  font-size: var(--step-2);
  line-height: 1.05;
}
.bh-group-n {
  display: flex;
  flex: 1;
  align-items: center;
  gap: var(--space-3);
  min-inline-size: 4rem;
  color: var(--text-faint);
  font-size: var(--step--1);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.bh-group-n::before { content: ''; flex: 1; border-block-start: 1px solid var(--border); }
.bh-group-desc {
  max-inline-size: 70ch;
  margin: var(--space-2) 0 0;
  color: var(--text-muted);
  font-size: var(--step--1);
  text-wrap: pretty;
}

.bh-list {
  display: grid;
  margin: var(--space-3) 0 0;
  padding: 0;
  list-style: none;
}
@media (min-width: 768px) {
  .bh-list { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: var(--space-7); }
}
.bh-item {
  position: relative;
  display: flex;
  flex-direction: column;
  min-inline-size: 0;
  margin: 0;
  margin-inline: calc(-1 * var(--space-3));
  padding: var(--space-4) var(--space-3);
  border-radius: var(--radius-md);
  box-shadow: inset 0 -1px 0 var(--border);
  transition: background-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.bh-item:hover { background: var(--surface-1); box-shadow: none; }
.bh-link {
  display: block;
  color: inherit;
  text-decoration: none;
}
/* The whole row is the link target; the meta line sits under the cover. */
.bh-link::after { content: ''; position: absolute; inset: 0; border-radius: inherit; }
.bh-link:focus-visible { outline: none; }
.bh-link:focus-visible::after { outline: 2px solid var(--focus); outline-offset: 2px; }
.bh-title {
  margin: 0;
  color: var(--text);
  font-size: var(--step-0);
  font-weight: 600;
  line-height: 1.3;
  text-wrap: pretty;
  text-decoration: underline 1px transparent;
  text-underline-offset: 0.22em;
  transition: text-decoration-color var(--dur-fast) var(--ease);
}
.bh-item:hover .bh-title { text-decoration-color: color-mix(in srgb, var(--accent) 70%, transparent); }
.bh-excerpt {
  display: -webkit-box;
  margin: var(--space-1) 0 0;
  overflow: hidden;
  color: var(--text-muted);
  font-size: var(--step--1);
  line-height: 1.5;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
}

/* Topic tag · read time: a quiet facts line under the excerpt. */
.bh-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-4);
  margin: var(--space-3) 0 0;
  color: var(--text-faint);
  font-size: var(--step--1);
  line-height: 1.2;
}
.bh-tag {
  display: inline-flex;
  align-items: center;
  max-inline-size: 100%;
  min-block-size: 26px;
  padding-inline: 10px;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
  border-radius: var(--radius-pill);
  background: color-mix(in srgb, var(--accent) 12%, var(--surface-1));
  color: var(--accent);
  font-weight: 500;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.bh-time {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.bh-time i { font-size: 0.9em; }

/* Filter switch: the list settles in from just below. */
.bh-index.is-filtering .bh-groups { animation: bh-settle var(--dur-med) var(--ease); }
@keyframes bh-settle {
  from { opacity: 0.35; transform: translateY(var(--space-2)); }
  to { opacity: 1; transform: none; }
}

.bh-top { margin: var(--space-8) 0 0; }
.bh-top a {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-block-size: var(--tap);
  color: var(--text-muted);
  font-size: var(--step--1);
  font-weight: 600;
  text-decoration: none;
}
.bh-top a:hover { color: var(--text); }
.bh-top i { color: var(--accent); }

/* CJK titles keep phrases whole. */
:is(:lang(zh), :lang(ja)) :is(.bh-title, .bh-feature-title, .bh-filter-chip) { word-break: keep-all; line-break: strict; }
:lang(ja) :is(.bh-title, .bh-feature-title) { word-break: auto-phrase; }

@media (prefers-reduced-motion: reduce) {
  .bh-feature:hover .bh-feature-media img,
  .bh-action:hover i { transform: none; }
  [dir="rtl"] .bh-action:hover i { transform: scaleX(-1); }
  .bh-index.is-filtering .bh-groups { animation: none; }
}

/* Editorial leads stay open; topic color guides the eye through the index. */
.bh-feature { border: 0; border-radius: 0; box-shadow: none; border-block-start: 2px solid var(--accent); background: linear-gradient(140deg, color-mix(in srgb, var(--accent) 10%, var(--bg)), transparent); }
.bh-feature:hover { box-shadow: none; }
.bh-feature-title { line-height: 1.22; }
.bh-feature-media img { border-radius: 0; }
.bh-index-head { padding-block-start: var(--space-5); border-block-start: 1px solid var(--border-strong); }
.bh-filter { scroll-padding-inline: var(--space-3); }
.bh-group { scroll-margin-block-start: calc(var(--header-stuck) + var(--space-5)); }
.bh-title a { text-decoration-thickness: 1px; text-underline-offset: .22em; }
@media (prefers-reduced-motion: no-preference) {
  .bh-filter-chip, .article-quick-play-action { transition: background-color var(--dur-fast) var(--ease), scale 120ms var(--ease); }
  .bh-filter-chip:active, .article-quick-play:active .article-quick-play-action { scale: .98; }
}

.blog-hub > .bh-featured:first-child { margin-block-start: var(--space-4); }
