/* ============================================================
   Chance Ecom - blog.css
   Article + blog-index styles. Builds on the :root design tokens
   defined at the top of styles.css (do NOT redefine tokens here).
   Loaded after styles.css on /blog/ pages only.
   ============================================================ */

/* ---------- Breadcrumb trail ---------- */
.breadcrumb {
  font-size: .85rem;
  color: var(--muted);
  margin-bottom: 28px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.breadcrumb a { color: var(--muted); transition: color .15s; }
.breadcrumb a:hover { color: var(--text); }
.breadcrumb span[aria-hidden="true"] { color: var(--border-2); }
.breadcrumb [aria-current="page"] { color: var(--text); }

/* ---------- Article shell ---------- */
.article { padding-block: clamp(40px, 7vw, 80px); }
.article__head { margin-bottom: clamp(28px, 5vw, 44px); }
.article__title {
  font-size: clamp(2rem, 5vw, 3.2rem);
  max-width: 24ch;
  margin-bottom: 16px;
}
.article__byline {
  color: var(--muted);
  font-size: .95rem;
  font-weight: 500;
}

/* ---------- Article prose ---------- */
.article__body { font-size: 1.08rem; line-height: 1.75; }
.article__body > * + * { margin-top: 1.25em; }

.article__body h2 {
  font-size: clamp(1.5rem, 3.2vw, 2rem);
  margin-top: 1.8em;
  margin-bottom: .2em;
}
.article__body h3 {
  font-size: 1.3rem;
  margin-top: 1.5em;
  margin-bottom: .2em;
}
.article__body p { color: var(--text); }

.article__body a {
  color: var(--accent-2);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
  transition: color .15s;
}
.article__body a:hover { color: var(--accent); }

.article__body ul,
.article__body ol { padding-left: 1.4em; color: var(--text); }
.article__body li { margin-top: .5em; }
.article__body li::marker { color: var(--accent-2); }

.article__body blockquote {
  border-left: 3px solid var(--accent);
  padding: 4px 0 4px 20px;
  margin-left: 0;
  color: var(--muted);
  font-style: italic;
}

.article__body img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  display: block;
}

.article__body hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin-block: 2em;
}

.article__body code {
  font-family: ui-monospace, "SFMono-Regular", "Menlo", monospace;
  font-size: .9em;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1px 6px;
}
.article__body pre {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  overflow-x: auto;
}
.article__body pre code {
  background: none;
  border: 0;
  padding: 0;
  font-size: .92rem;
}

.article__body table {
  width: 100%;
  border-collapse: collapse;
  font-size: .98rem;
}
.article__body th,
.article__body td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.article__body th {
  font-family: "Space Grotesk", sans-serif;
  color: var(--text);
}
.article__body td { color: var(--muted); }

/* Responsive tables: wrap a markdown table in horizontal scroll on small
   screens so wide comparison tables never break the layout. The generator
   does not wrap them, so make the table itself scrollable as a fallback. */
@media (max-width: 600px) {
  .article__body table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
  }
}

/* ---------- Inline SVG framework diagrams ---------- */
.diagram {
  margin: 1.6em 0;
  padding: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.diagram svg {
  display: block;
  width: 100%;
  height: auto;
  min-width: 520px;   /* keep labels crisp; scroll on narrow screens */
  max-width: 100%;
  border: 0;          /* override .article__body img border rules */
  border-radius: 0;
}
.diagram img {
  display: block;
  width: 100%;
  height: auto;
  border: 0;          /* override .article__body img border rules */
  border-radius: 0;
}
.diagram figcaption {
  font-size: .85rem;
  color: var(--muted);
  text-align: center;
  margin-top: 8px;
  white-space: normal;
}

/* ---------- Blog index: post list ---------- */
.post-list {
  list-style: none;
  display: grid;
  gap: 18px;
}
.post-card {
  display: block;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px 30px;
  transition: transform .2s ease, border-color .2s ease, box-shadow .2s ease;
}
.post-card:hover {
  transform: translateY(-3px);
  border-color: var(--border-2);
  box-shadow: 0 16px 40px rgba(0, 0, 0, .35);
}
.post-card__date {
  display: block;
  font-size: .82rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--accent-2);
  margin-bottom: 10px;
}
.post-card__title {
  font-size: 1.4rem;
  color: var(--text);
  margin-bottom: 8px;
}
.post-card__desc {
  color: var(--muted);
  font-size: 1rem;
  margin: 0;
}

/* ---------- Linked byline ---------- */
.article__author {
  color: var(--accent-2);
  text-decoration: none;
  transition: color .15s;
}
.article__author:hover { color: var(--accent); text-decoration: underline; }

/* ---------- Hero / featured image ---------- */
.article__hero {
  margin: 0 0 clamp(28px, 5vw, 44px);
}
.article__hero img {
  width: 100%;
  height: auto;
  aspect-ratio: 1200 / 630;
  object-fit: cover;
  display: block;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
}

/* ---------- Table of contents ---------- */
.toc {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: clamp(28px, 5vw, 40px);
}
.toc__title {
  font-family: "Space Grotesk", sans-serif;
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--accent-2);
  margin: 0 0 12px;
}
.toc__list,
.toc__sublist {
  list-style: none;
  margin: 0;
  padding: 0;
}
.toc__sublist {
  padding-left: 16px;
  margin-top: 6px;
}
.toc__item { margin-top: 8px; }
.toc__item:first-child { margin-top: 0; }
.toc__link {
  color: var(--muted);
  font-size: .98rem;
  text-decoration: none;
  transition: color .15s;
}
.toc__link:hover { color: var(--text); }

/* ---------- TOC layout (sticky right rail at desktop) ---------- */
/* Mobile-first: single column. The whole article (breadcrumb, header, hero,
   prose, author box, CTA, related) stacks in .article__main and the .toc-rail
   follows it; .toc keeps its existing boxed, full-width, non-sticky look ABOVE
   the prose. TOC posts use .article-wrap--toc (the wide default container) so
   the desktop grid is not trapped inside .container--narrow (760px). Below the
   desktop breakpoint .article-wrap--toc caps to the same narrow reading width
   so a TOC post matches a no-TOC post on tablet/mobile.
   The rail and grid are transparent pass-throughs until the desktop breakpoint. */
.article-wrap--toc { max-width: 760px; }
.article__layout { display: block; }
.article__main { display: block; }
.toc-rail { display: block; }
/* On single-column widths, hide the TOC entirely; prose is the normal
   single column with no boxed TOC above it. */
@media (max-width: 1079px) {
  .article__layout { display: block; }
  .toc-rail { display: none; }
}

@media (min-width: 1080px) {
  /* Escape .container--narrow: the wrapper is now the wide default container,
     so the grid can lay out a full-measure prose column plus a right rail and
     center the whole block in the viewport. */
  .article-wrap--toc { max-width: var(--maxw); }
  .article__layout {
    display: grid;
    grid-template-columns: minmax(0, 712px) 248px;
    justify-content: center;
    gap: clamp(32px, 4vw, 56px);
    align-items: start;
  }
  /* Main column: everything (breadcrumb -> related) stacks here at the prose
     measure and left-aligns. minmax(0, 712px) caps the reading width. */
  .article__main {
    min-width: 0;
    grid-column: 1;
  }
  /* Right rail: sticky, scrolls with the reader, does not push prose down. */
  .toc-rail {
    grid-column: 2;
    position: sticky;
    top: 96px;
    align-self: start;
  }
  /* Inside the rail the box stays, but it no longer needs bottom margin
     (it is a column, not a stacked block). */
  .toc-rail .toc {
    margin-bottom: 0;
  }
}

/* ---------- End-of-post CTA ---------- */
.post-cta {
  margin-top: clamp(40px, 7vw, 64px);
  padding: clamp(28px, 5vw, 44px);
  text-align: center;
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-lg);
}
.post-cta__heading {
  font-size: clamp(1.5rem, 3.2vw, 2rem);
  margin: 0 0 10px;
}
.post-cta__sub {
  color: var(--muted);
  font-size: 1.05rem;
  max-width: 48ch;
  margin: 0 auto 22px;
}

/* ---------- Related posts ---------- */
.related {
  margin-top: clamp(40px, 7vw, 64px);
  padding-top: clamp(32px, 5vw, 48px);
  border-top: 1px solid var(--border);
}
.related__heading {
  font-size: clamp(1.4rem, 3vw, 1.8rem);
  margin: 0 0 22px;
}
.related__grid {
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}
.related-card {
  display: block;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  transition: transform .2s ease, border-color .2s ease, box-shadow .2s ease;
}
.related-card:hover {
  transform: translateY(-3px);
  border-color: var(--border-2);
  box-shadow: 0 16px 40px rgba(0, 0, 0, .35);
}
.related-card__title {
  font-size: 1.15rem;
  color: var(--text);
  margin: 0 0 8px;
}
.related-card__desc {
  color: var(--muted);
  font-size: .95rem;
  margin: 0;
}

/* ---------- Author bio box ---------- */
.author-box {
  margin-top: clamp(40px, 7vw, 64px);
  padding: clamp(24px, 4vw, 32px);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.author-box__name {
  font-family: "Space Grotesk", sans-serif;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text);
  margin: 0 0 8px;
}
.author-box__name a {
  color: var(--text);
  text-decoration: none;
  transition: color .15s;
}
.author-box__name a:hover { color: var(--accent-2); }
.author-box__role {
  color: var(--muted);
  font-weight: 500;
  font-size: .92rem;
}
.author-box__role::before { content: " \00b7 "; color: var(--border-2); }
.author-box__bio {
  color: var(--muted);
  font-size: 1rem;
  margin: 0;
  line-height: 1.65;
}
