/* ==========================================================================
   Blog stylesheet - a self-contained add-on to styles.css
   --------------------------------------------------------------------------

   This file is loaded ONLY by the pages inside /blog/. It is deliberately
   isolated so it cannot change a single property of the existing app:

     - Every selector is namespaced under .blog-*, .post-*, or .article-*.
       Nothing here matches a bare element, .btn, .shell, .site-header, .card
       or any other class already defined in styles.css.
     - Colour, radius, shadow, font and spacing all come from the design
       tokens in styles.css (--brand, --accent, --surface, --border, --wash,
       --radius-*, --shadow-*, --display, --sans ...). That means the blog
       follows the brand palette and flips to dark mode automatically, with
       no second palette to keep in sync.

   Brand treatment used here:
     - White / near-white surfaces   -> --surface, --surface-2
     - Orange accents                -> --brand, --accent, --brand-soft
     - Dark-blue links and highlights-> --brand-bright, --info, --text
     - Light grey structural panels  -> --bg-alt, --surface-2, --border

   Contents:
     1. Blog landing page
     2. Article cards
     3. Article page
     4. Long-form body typography
     5. Responsive
     6. Reduced motion
   ========================================================================== */

/* === 1. Blog landing page =============================================== */

.blog-page {
  padding: 56px 0 24px;
}

/* Masthead panel. Reuses the hero wash as one rounded block, the same device
   the static pages (.doc-header) use, so the blog opens in the same visual
   register as the rest of the site. */
.blog-masthead {
  margin-bottom: 46px;
  padding: 46px 48px;
  background: var(--wash);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
}

.blog-eyebrow {
  margin: 0 0 10px;
  color: var(--brand);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.blog-masthead h1 {
  max-width: 24ch;
  margin-bottom: 16px;
  letter-spacing: -0.03em;
}

.blog-lede {
  max-width: 64ch;
  margin: 0;
  color: var(--text-muted);
  font-size: 1.06rem;
  line-height: 1.7;
}

.blog-masthead__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 18px;
  margin-top: 24px;
  color: var(--text-dim);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: -0.004em;
}

.blog-masthead__meta span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.blog-masthead__meta .blog-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--brand);
}

/* Section heading row: title left, count / link right, hairline underneath. */
.blog-section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin: 0 0 24px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.blog-section-head h2 {
  margin: 0;
  font-size: clamp(1.4rem, 3vw, 1.9rem);
  letter-spacing: -0.026em;
}

.blog-section-head__note {
  margin: 0;
  color: var(--text-dim);
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
}

/* Closing call-to-action panel under the grid. */
.blog-cta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 20px 30px;
  margin-top: 52px;
  padding: 30px 32px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
}

.blog-cta__copy h2 {
  margin: 0 0 8px;
  font-size: 1.35rem;
  letter-spacing: -0.024em;
}

.blog-cta__copy p {
  max-width: 56ch;
  margin: 0;
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.65;
}

/* === 2. Article cards =================================================== */

/* Auto-fill grid: as many ~300px columns as fit, each stretching to share the
   row. Collapses to one column on phones with no media query needed. */
.post-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 26px;
  margin: 0;
  padding: 0;
  list-style: none;
}

/* Each grid item is a flex box so the card inside stretches to the row's full
   height, which is what lets the CTA buttons line up across a row. */
.post-grid > li {
  display: flex;
}

.post-card {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition), box-shadow var(--transition),
              border-color var(--transition);
}

.post-card:hover {
  transform: translateY(-3px);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
}

.post-card:focus-within {
  border-color: var(--brand-soft-border);
  box-shadow: var(--shadow-md);
}

/* Featured image slot. A fixed 16:9 box keeps every card the same height
   regardless of the source image, and the grey ground shows while the image
   loads or if it is ever missing. */
.post-card__media {
  display: block;
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}

.post-card__media img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 500ms cubic-bezier(0.4, 0, 0.2, 1);
}

.post-card:hover .post-card__media img {
  transform: scale(1.04);
}

.post-card__body {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 10px;
  padding: 22px 22px 24px;
}

.post-card__eyebrow {
  margin: 0;
  color: var(--brand);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.post-card__title {
  margin: 0;
  font-size: 1.18rem;
  line-height: 1.28;
  letter-spacing: -0.022em;
}

/* The title owns the click target; the eyebrow, image and CTA all point at the
   same URL, so the card is easy to hit without turning every element into a
   separate tab stop. */
.post-card__title a {
  color: var(--text);
  text-decoration: none;
  transition: color var(--transition);
}

.post-card__title a:hover {
  color: var(--brand);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.post-card__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
  margin: 0;
  color: var(--text-dim);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: -0.004em;
}

.post-card__meta .post-sep {
  color: var(--border-strong);
}

.post-card__excerpt {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.94rem;
  line-height: 1.62;
}

/* margin-top:auto pins the button to the bottom so it lines up across a row of
   cards whose excerpts differ in length. */
.post-card__cta {
  align-self: flex-start;
  margin-top: auto;
}

/* === 3. Article page ==================================================== */

.article-page {
  padding: 48px 0 24px;
}

/* A single centred reading column; every part of the article shares it so the
   title, image and prose all line up on the same measure. */
.article-wrap {
  max-width: 740px;
  margin-inline: auto;
}

.article-back {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 24px;
  color: var(--text-muted);
  font-size: 0.88rem;
  font-weight: 600;
  letter-spacing: -0.004em;
  transition: color var(--transition);
}

.article-back:hover {
  color: var(--brand);
  text-decoration: none;
}

.article-back svg {
  flex: 0 0 auto;
}

.article-header {
  margin-bottom: 32px;
  padding-bottom: 30px;
  border-bottom: 1px solid var(--border);
}

.article-eyebrow {
  margin: 0 0 12px;
  color: var(--brand);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.article-title {
  max-width: 24ch;
  margin-bottom: 18px;
  font-size: clamp(2.1rem, 5vw, 3.15rem);
  line-height: 1.1;
  letter-spacing: -0.032em;
}

.article-lede {
  max-width: 64ch;
  margin: 0 0 24px;
  color: var(--text-muted);
  font-size: 1.1rem;
  line-height: 1.68;
}

/* Author / date / reading-time bar. Wraps to two rows on narrow screens. */
.article-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
  color: var(--text-dim);
  font-size: 0.86rem;
  font-weight: 600;
  letter-spacing: -0.004em;
}

.article-meta__author {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
}

.article-meta__avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.article-meta__sep {
  width: 1px;
  height: 18px;
  background: var(--border-strong);
}

.article-meta__tag {
  display: inline-flex;
  align-items: center;
  padding: 5px 13px;
  background: var(--brand-soft);
  border: 1px solid var(--brand-soft-border);
  border-radius: var(--pill);
  color: var(--brand);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

/* Featured image. aspect-ratio reserves the space before the file loads, so a
   slow image cannot push the first paragraph down (no layout shift). */
.article-featured {
  margin: 0 0 40px;
}

.article-featured img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
}

.article-featured figcaption {
  margin-top: 12px;
  color: var(--text-dim);
  font-size: 0.82rem;
  line-height: 1.6;
  text-align: center;
}

/* Table of contents. A grey structural panel, not a content block. */
.article-toc {
  margin: 0 0 38px;
  padding: 22px 24px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.article-toc__title {
  margin: 0 0 12px;
  color: var(--text-dim);
  font-family: var(--sans);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.article-toc ol {
  margin: 0;
  padding-left: 1.2em;
  columns: 2;
  column-gap: 34px;
}

.article-toc li {
  margin-bottom: 8px;
  break-inside: avoid;
  color: var(--text-muted);
  font-size: 0.92rem;
  line-height: 1.5;
}

.article-toc a {
  color: var(--text-muted);
  font-weight: 600;
}

.article-toc a:hover {
  color: var(--brand);
}

/* Footer: tags plus the closing call-to-action. */
.article-footer {
  margin-top: 48px;
  padding-top: 30px;
  border-top: 1px solid var(--border);
}

.article-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 28px;
  padding: 0;
  list-style: none;
}

.article-tags a {
  display: inline-flex;
  padding: 7px 15px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--pill);
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  transition: border-color var(--transition), color var(--transition);
}

.article-tags a:hover {
  border-color: var(--brand);
  color: var(--brand);
  text-decoration: none;
}

.article-cta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 20px 30px;
  padding: 28px 30px;
  background: var(--wash);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
}

.article-cta__copy h2 {
  margin: 0 0 6px;
  font-size: 1.25rem;
  letter-spacing: -0.024em;
}

.article-cta__copy p {
  max-width: 52ch;
  margin: 0;
  color: var(--text-muted);
  font-size: 0.92rem;
  line-height: 1.65;
}

/* === 4. Long-form body typography =======================================
   Tuned for sustained reading: a slightly larger body size, a generous
   line-height, and vertical rhythm driven by the headings so paragraphs never
   need manual spacing. Only descendants of .article-body are touched. */

.article-body {
  font-size: 1.0625rem;
  line-height: 1.76;
  color: var(--text);
  overflow-wrap: break-word;
}

.article-body > :first-child {
  margin-top: 0;
}

.article-body p {
  margin: 0 0 1.35em;
}

.article-body h2 {
  margin: 2.2em 0 0.55em;
  font-size: clamp(1.45rem, 3vw, 1.8rem);
  line-height: 1.22;
  letter-spacing: -0.026em;
}

.article-body h3 {
  margin: 1.7em 0 0.5em;
  font-size: 1.2rem;
  line-height: 1.3;
  letter-spacing: -0.016em;
}

.article-body h2 + h3 {
  margin-top: 0.5em;
}

.article-body ul,
.article-body ol {
  margin: 0 0 1.35em;
  padding-left: 1.45em;
}

.article-body li {
  margin-bottom: 0.55em;
  padding-left: 0.15em;
}

.article-body li:last-child {
  margin-bottom: 0;
}

.article-body li::marker {
  color: var(--brand);
  font-weight: 700;
}

.article-body strong {
  font-weight: 650;
  color: var(--text);
}

.article-body a {
  color: var(--brand-bright);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: color var(--transition);
}

.article-body a:hover {
  color: var(--brand);
}

.article-body blockquote {
  margin: 1.7em 0;
  padding: 4px 0 4px 22px;
  border-left: 4px solid var(--brand);
  color: var(--text-muted);
  font-size: 1.12rem;
  font-style: italic;
  line-height: 1.68;
}

.article-body blockquote p:last-child {
  margin-bottom: 0;
}

.article-body blockquote cite {
  display: block;
  margin-top: 12px;
  color: var(--text-dim);
  font-size: 0.85rem;
  font-style: normal;
  font-weight: 600;
}

/* Inline code keeps the global styles.css treatment; only block code is styled
   here, and it stays dark in both themes for legibility (--code-* tokens). */
.article-body pre {
  margin: 1.7em 0;
  padding: 18px 20px;
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  border-radius: var(--radius-lg);
  overflow-x: auto;
  color: var(--code-text);
  font-size: 0.86rem;
  line-height: 1.62;
  -webkit-overflow-scrolling: touch;
}

.article-body pre code {
  background: none;
  border: 0;
  padding: 0;
  color: inherit;
  font-size: inherit;
}

.article-body img {
  max-width: 100%;
  height: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.article-body figure {
  margin: 1.8em 0;
}

.article-body figcaption {
  margin-top: 10px;
  color: var(--text-dim);
  font-size: 0.84rem;
  line-height: 1.6;
  text-align: center;
}

.article-body hr {
  margin: 2.4em 0;
  border: 0;
  border-top: 1px solid var(--border);
}

/* Tables scroll sideways on narrow screens rather than forcing the page wide.
   Wrap the table in <div class="article-table-wrap">. */
.article-table-wrap {
  margin: 1.7em 0;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.article-body .article-table-wrap table {
  margin: 0;
}

.article-body table {
  width: 100%;
  margin: 1.7em 0;
  border-collapse: collapse;
  font-size: 0.94rem;
  line-height: 1.55;
}

.article-body th,
.article-body td {
  padding: 11px 15px;
  border: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.article-body thead th {
  background: var(--surface-2);
  font-weight: 650;
  color: var(--text);
}

.article-body tbody tr:nth-child(even) {
  background: var(--surface-2);
}

/* Pull-out callout for key guidance. Orange edge, soft ground. */
.article-callout {
  margin: 1.8em 0;
  padding: 20px 22px;
  background: var(--brand-soft);
  border: 1px solid var(--brand-soft-border);
  border-left: 4px solid var(--brand);
  border-radius: var(--radius-lg);
}

.article-callout__title {
  margin: 0 0 6px;
  color: var(--brand);
  font-family: var(--sans);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.article-callout p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.98rem;
  line-height: 1.66;
}

/* Status line for the article grid and the reader: shown while posts load, and
   again when the list is empty or the API cannot be reached. */
.blog-empty {
  margin: 0;
  padding: 26px 22px;
  background: var(--surface-2);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.6;
  text-align: center;
}

/* === 5. Responsive ====================================================== */

@media (max-width: 900px) {
  .blog-masthead {
    padding: 36px 34px;
  }

  .blog-page {
    padding-top: 44px;
  }
}

@media (max-width: 760px) {
  .blog-masthead {
    margin-bottom: 34px;
    padding: 30px 24px;
    border-radius: var(--radius-lg);
  }

  .blog-masthead__meta {
    margin-top: 20px;
  }

  .blog-page,
  .article-page {
    padding-top: 36px;
  }

  .post-grid {
    gap: 20px;
  }

  .article-lede {
    font-size: 1.04rem;
  }

  .article-body {
    font-size: 1.03rem;
  }

  .article-toc ol {
    columns: 1;
  }

  .article-featured {
    margin-bottom: 32px;
  }

  .article-cta,
  .blog-cta {
    padding: 24px 22px;
  }

  .blog-section-head {
    flex-wrap: wrap;
  }
}

@media (max-width: 560px) {
  .post-card__body {
    padding: 20px 20px 22px;
  }

  .article-featured img {
    border-radius: var(--radius-lg);
  }

  .article-meta__sep {
    display: none;
  }

  .article-cta .btn,
  .blog-cta .btn {
    width: 100%;
  }
}

/* === 6. Reduced motion ================================================== */

@media (prefers-reduced-motion: reduce) {
  .post-card,
  .post-card__media img,
  .post-card__title a,
  .article-back,
  .article-tags a,
  .article-body a {
    transition: none;
  }

  .post-card:hover {
    transform: none;
  }

  .post-card:hover .post-card__media img {
    transform: none;
  }
}
