/* Blog: the article page and the listing.
 *
 * Scoped entirely under .blog-* so it cannot reach any existing page, and built
 * on the tokens in tokens.css rather than new colour values — a second palette
 * is how a site stops looking like one site.
 *
 * Reading measure is capped at 68ch on the article body. That is the whole
 * point of a separate stylesheet here: pages.css lays out marketing sections at
 * --max-width, which is far too wide for 1,500 words of prose. */

.blog-article,
.blog-index {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: calc(var(--space-xl) + 40px) var(--container-padding) var(--space-xl);
  background: var(--agf-bg);
}

/* Two columns: a narrow rail for share links and the contents list, then the
 * prose. The pair is centred rather than left-aligned, so the reading column
 * stays near the middle of the page as it does on a single-column layout.
 * minmax(0, 68ch) rather than 68ch so a long unbreakable token cannot push the
 * column wider than its track. */
.blog-article {
  display: grid;
  grid-template-columns: 190px minmax(0, 68ch);
  gap: var(--space-lg);
  justify-content: center;
  align-items: start;
}
.blog-crumbs,
.blog-article-head {
  grid-column: 1 / -1;
}
.blog-body,
.blog-cta {
  grid-column: 2;
}

/* ── Breadcrumbs ── */
.blog-crumbs {
  display: flex;
  gap: var(--space-xs);
  align-items: center;
  font-family: var(--font-body);
  font-size: 0.875rem;
  color: var(--agf-text-secondary);
  margin-bottom: var(--space-lg);
}
.blog-crumbs a {
  color: var(--agf-text-secondary);
  text-decoration: none;
}
.blog-crumbs a:hover {
  color: var(--agf-text);
  text-decoration: underline;
}

/* ── Article head ── */
.blog-article-head {
  margin-bottom: var(--space-lg);
}
/* Body font, sentence case, editorial size — a deliberate departure from the
 * display headline used elsewhere, for two reasons that are not taste:
 *
 * global.css sets font-display: block on the BIGGER face, so a display-font
 * title is INVISIBLE while the font loads. On a marketing page that is a
 * considered tradeoff (GR-334 left it alone); on an article, where the title is
 * the first thing a reader wants and is plausibly the LCP element, it is the
 * wrong one. Inter is already loaded as the body font, so this paints at once.
 *
 * And uppercase costs reading speed on a sentence. "STRUCTURE CREATES FREEDOM"
 * is three words; an article title is twelve.
 *
 * The listing's own card titles already use the body font at 700, so this is
 * consistent with them and departs only from the marketing pages. */
.blog-article-head h1 {
  font-family: var(--font-body);
  font-size: clamp(1.875rem, 3.6vw, 2.625rem);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.02em;
  color: var(--agf-text);
  max-width: 34ch;
}

/* Date above the title, editorial convention. */
.blog-date {
  font-family: var(--font-body);
  font-size: 0.875rem;
  color: var(--agf-text-secondary);
  margin-bottom: var(--space-sm);
}
.blog-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  align-items: baseline;
  margin-top: var(--space-md);
  font-family: var(--font-body);
  font-size: 0.9375rem;
  color: var(--agf-text-secondary);
}
.blog-author {
  color: var(--agf-text);
  font-weight: 600;
}

/* A monogram, not a photograph. A stock face beside a byline misrepresents who
 * wrote the article. Replace with the real portrait when it arrives — and only
 * then add it to the JSON-LD, which deliberately declares no author image. */
.blog-avatar {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--agf-card-dark);
  color: var(--agf-off-white);
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  flex: 0 0 auto;
}
/* The separator dot belongs between text items, not after the monogram. */
.blog-avatar + *::before {
  content: none !important;
  margin-right: 0 !important;
}
.blog-meta > * + *::before {
  content: "·";
  margin-right: var(--space-sm);
  color: var(--agf-sand);
}

/* ── Article body ── */
.blog-body {
  max-width: 68ch;
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.7;
  color: var(--agf-text);
}
.blog-body > * + * {
  margin-top: var(--space-md);
}
.blog-body h2,
.blog-body h3,
.blog-body h4 {
  font-family: var(--font-body);
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.01em;
  scroll-margin-top: 100px; /* the nav is fixed; an #anchor must clear it */
}
.blog-body h2 {
  font-size: 1.625rem;
  margin-top: var(--space-lg);
}
.blog-body h3 {
  font-size: 1.25rem;
  margin-top: var(--space-md);
}
.blog-body h4 {
  font-size: 1.0625rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--agf-text-secondary);
}
.blog-body a {
  color: var(--agf-text);
  text-decoration: underline;
  text-decoration-color: var(--agf-coral);
  text-underline-offset: 3px;
}
.blog-body a:hover {
  color: var(--agf-coral);
}
.blog-body ul,
.blog-body ol {
  padding-left: 1.35em;
}
.blog-body li + li {
  margin-top: var(--space-xs);
}
.blog-body ul li {
  list-style: disc;
}
.blog-body ol li {
  list-style: decimal;
}
.blog-body strong {
  font-weight: 650;
}
.blog-body hr {
  border: 0;
  border-top: 1px solid var(--agf-sand);
  margin-top: var(--space-lg);
}
.blog-body blockquote {
  background: var(--agf-card-light);
  border-left: 3px solid var(--agf-coral);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  padding: var(--space-md) var(--space-md) var(--space-md) var(--space-md);
  font-size: 1rem;
}
.blog-body blockquote > * + * {
  margin-top: var(--space-xs);
}
.blog-body blockquote ul {
  padding-left: 1.2em;
}
.blog-body code {
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 0.9em;
  background: var(--agf-off-white);
  border: 1px solid var(--agf-sand);
  border-radius: var(--radius-sm);
  padding: 0.1em 0.35em;
}

/* ── Left rail: share links and contents ── */
.blog-rail {
  grid-column: 1;
  position: sticky;
  /* The nav is fixed; a sticky rail has to clear it. */
  top: 110px;
  align-self: start;
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  font-family: var(--font-body);
  /* A sticky element taller than the viewport cannot stick usefully — it just
   * scrolls away. Seven headings fit comfortably today, but a longer article or
   * a 13-inch laptop would not, so the rail scrolls internally instead. No
   * visual change at current lengths; this only engages when it has to. */
  max-height: calc(100vh - 130px);
  overflow-y: auto;
}
.blog-share {
  display: flex;
  gap: var(--space-xs);
}
.blog-share-link {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--agf-sand);
  border-radius: 50%;
  color: var(--agf-text-secondary);
  font-size: 0.8125rem;
  font-weight: 600;
  text-decoration: none;
  transition: border-color var(--duration-fast) var(--easing),
    color var(--duration-fast) var(--easing);
}
.blog-share-link:hover {
  border-color: var(--agf-coral);
  color: var(--agf-text);
}
.blog-toc-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--agf-text-secondary);
  margin-bottom: var(--space-sm);
}
.blog-toc ol {
  list-style: none;
  padding: 0;
  border-left: 1px solid var(--agf-sand);
}
.blog-toc li + li {
  margin-top: var(--space-xs);
}
.blog-toc a {
  display: block;
  padding: 2px 0 2px var(--space-sm);
  margin-left: -1px;
  border-left: 2px solid transparent;
  font-size: 0.875rem;
  line-height: 1.4;
  color: var(--agf-text-secondary);
  text-decoration: none;
}
.blog-toc a:hover {
  color: var(--agf-text);
  border-left-color: var(--agf-coral);
}

/* ── End-of-article CTA ── */
.blog-cta {
  max-width: 68ch;
  margin-top: var(--space-xl);
  padding: var(--space-lg);
  background: var(--agf-card-dark);
  border-radius: var(--radius-lg);
  color: var(--agf-off-white);
}
.blog-cta h2 {
  font-family: var(--font-headline);
  font-size: clamp(1.5rem, 3vw, 2rem);
  text-transform: uppercase;
  line-height: 1;
  color: var(--agf-off-white);
}
.blog-cta p {
  margin-top: var(--space-sm);
  font-family: var(--font-body);
  color: var(--agf-sand);
}
.blog-cta-btn {
  display: inline-block;
  margin-top: var(--space-md);
  padding: 14px 28px;
  border-radius: 999px;
  background: var(--agf-coral);
  color: var(--agf-off-black);
  font-family: var(--font-body);
  font-weight: 600;
  text-decoration: none;
  transition: transform var(--duration-fast) var(--easing);
}
.blog-cta-btn:hover {
  transform: translateY(-2px);
}

/* ── Listing ── */
.blog-index-head {
  margin-bottom: var(--space-lg);
}
.blog-index-head h1 {
  font-family: var(--font-headline);
  font-size: clamp(2.5rem, 7vw, 4.5rem);
  line-height: 0.95;
  text-transform: uppercase;
  max-width: 24ch;
}
.blog-index-intro {
  max-width: 60ch;
  margin-top: var(--space-md);
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.6;
  color: var(--agf-text-secondary);
}
.blog-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: var(--space-md);
}
.blog-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  padding: var(--space-md);
  background: var(--agf-off-white);
  border: 1px solid var(--agf-sand);
  border-radius: var(--radius-lg);
  text-decoration: none;
  color: var(--agf-text);
  transition: transform var(--duration-fast) var(--easing),
    border-color var(--duration-fast) var(--easing);
}
.blog-card:hover {
  transform: translateY(-3px);
  border-color: var(--agf-coral);
}
.blog-card-title {
  font-family: var(--font-body);
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.3;
}
.blog-card-desc {
  font-family: var(--font-body);
  font-size: 0.9375rem;
  line-height: 1.6;
  color: var(--agf-text-secondary);
}
.blog-card-meta {
  display: flex;
  gap: var(--space-sm);
  margin-top: auto;
  font-family: var(--font-body);
  font-size: 0.8125rem;
  color: var(--agf-tan);
}
.blog-card-meta > * + *::before {
  content: "·";
  margin-right: var(--space-sm);
}

/* Below the rail's breakpoint the grid collapses to one column and the rail
 * stops being sticky — a sticky block in a single-column flow just eats the
 * viewport. It sits above the body, which is where a contents list belongs when
 * there is no margin to put it in. */
@media (max-width: 900px) {
  .blog-article {
    grid-template-columns: minmax(0, 1fr);
  }
  .blog-crumbs,
  .blog-article-head,
  .blog-rail,
  .blog-body,
  .blog-cta {
    grid-column: 1;
  }
  .blog-rail {
    position: static;
    top: auto;
    padding-bottom: var(--space-sm);
    border-bottom: 1px solid var(--agf-sand);
  }
}

@media (max-width: 640px) {
  .blog-article,
  .blog-index {
    padding-top: calc(var(--space-xl) + 8px);
  }
  .blog-cta {
    padding: var(--space-md);
  }
  /* The byline wraps at this width and the separator dot ended up orphaned at
   * the START of the new line, which reads as broken markup. Give the updated
   * date its own line and drop its dot rather than let it wrap mid-list. */
  .blog-updated {
    flex-basis: 100%;
  }
  .blog-updated::before {
    content: none !important;
    margin-right: 0 !important;
  }
}

/* Shown only when dateModified differs from datePublished — see build-blog.py. */
.blog-updated {
  color: var(--agf-text);
}
