/* ==========================================================================
   Blog — article layout, prose typography, TOC and post cards.
   Uses only the global brand tokens from theme.css (--b1..--b4, --white,
   --white-dim, --muted, --yellow1..--yellow3, --green, --font-ui). No bespoke colors.
   ========================================================================== */

/* --- Article shell -------------------------------------------------------- */

.blog-article{
  width: 100%;
  margin: 0 auto;
  text-align: left;
}

/* --- Hero banner ---------------------------------------------------------- */

.blog-hero{
  position: relative;
  overflow: hidden;
  margin: 24px 0 44px;
  display: flex;
  flex-direction: row;
  border: 1px solid var(--b3);
  border-radius: 20px;
  background:
    radial-gradient(120% 140% at 100% 0%, color-mix(in srgb, var(--yellow1) 10%, transparent) 0%, transparent 42%),
    linear-gradient(180deg, var(--b3) 0%, var(--b2) 100%);
}

.blog-hero-inner{
  position: relative;
  z-index: 1;
  flex: 1 1 0;
  min-width: 0;
  max-width: 760px;
  padding: 44px 40px 40px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 14px;
}

/* Cover image: an equal-width panel on the right (desktop), stacked on top on mobile.
   flex-basis 50% (not "1 1 0") so it exactly matches the inner half — the inner's
   horizontal padding floors its own basis, which would otherwise make it wider. */
.blog-hero-media{
  align-self: stretch;
  flex: 0 0 50%;
  background-size: cover;
  background-position: center;
}

.blog-back{
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .3px;
  transition: color .15s ease, transform .15s ease;
}
.blog-back:hover{ color: var(--white); }
.blog-back svg{ transition: transform .15s ease; }
.blog-back:hover svg{ transform: translateX(-2px); }

.blog-title{
  margin: 0;
  font-size: clamp(1.65rem, 3.4vw, 2.4rem);
  font-weight: 600;
  line-height: 1.16;
  padding-bottom: 0.08em; /* room for descenders — background-clip:text otherwise cuts g/y/p */
  letter-spacing: -0.9px;
  background: linear-gradient(110deg, var(--white) 0%, var(--muted) 100%);
  -webkit-background-clip: text;
          background-clip: text;
  color: transparent;
}


.blog-meta{
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 6px;
  font-size: 13.5px;
  color: var(--muted);
}
.blog-meta-dot{ color: var(--b4); }

.blog-hero-cta{
  margin-top: 8px;
}

/* --- Two-column layout: prose (left) + sticky TOC (right) ----------------- */

.blog-grid{
  display: grid;
  grid-template-columns: minmax(0, 1fr) 244px;
  gap: 56px;
  align-items: start;
}

.post-toc{
  position: sticky;
  top: 96px;
  align-self: start;
}
.post-toc-inner{
  border-left: 1px solid var(--b3);
  padding-left: 20px;
}
.post-toc-title{
  margin: 0 0 12px;
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}
.post-toc-nav{
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: calc(100vh - 160px);
  overflow-y: auto;
}
.toc-link{
  display: block;
  padding: 6px 0 6px 12px;
  margin-left: -1px;
  border-left: 2px solid transparent;
  color: var(--muted);
  text-decoration: none;
  font-size: 13.5px;
  line-height: 1.45;
  transition: color .15s ease, border-color .15s ease;
}
.toc-link.toc-h3{
  padding-left: 26px;
  font-size: 13px;
}
.toc-link:hover{ color: var(--white); }
.toc-link.is-active{
  color: var(--white);
  border-left-color: var(--yellow1);
  font-weight: 700;
}

/* --- Prose typography ----------------------------------------------------- */

.prose{
  min-width: 0; /* let the grid item shrink so wide children (code/tables/images) don't push the page wider */
  max-width: 100%;
  color: var(--white-dim);
  font-size: 1.05rem;
  line-height: 1.75;
}

.prose > *:first-child{ margin-top: 0; }
.prose > *:last-child{ margin-bottom: 0; }

.prose h2, .prose h3, .prose h4{
  color: var(--white);
  font-weight: 650;
  letter-spacing: -0.4px;
  line-height: 1.25;
  scroll-margin-top: 96px;
}
.prose h2{
  margin: 2.4em 0 0.7em;
  font-size: 1.6rem;
  padding-bottom: 0.4em;
  border-bottom: 1px solid var(--b3);
}
.prose h3{ margin: 1.9em 0 0.6em; font-size: 1.28rem; }
.prose h4{ margin: 1.6em 0 0.5em; font-size: 1.08rem; }

.prose p{ margin: 0 0 1.15em; }

.prose a{
  text-decoration: underline;
  text-decoration-color: var(--yellow2);
  text-underline-offset: 3px;
  text-decoration-thickness: 1.5px;
  transition: color .15s ease, text-decoration-color .15s ease;
}
.prose a:hover{
  color: var(--yellow1);
  text-decoration-color: var(--yellow1);
}
/* CTA buttons keep their button look inside prose (no link underline/colour). */
.prose a.cta{ text-decoration: none; }
.prose a.cta:hover{ color: var(--b1); }

.prose strong{ color: var(--white); font-weight: 700; }
.prose em{ color: var(--white); }

.prose ul, .prose ol{
  margin: 0 0 1.15em;
  padding-left: 1.4em;
}
.prose li{ margin: 0.4em 0; padding-left: 0.2em; }
.prose li::marker{ color: var(--yellow1); }
.prose ul ul, .prose ol ol, .prose ul ol, .prose ol ul{ margin: 0.4em 0; }

.prose blockquote{
  margin: 1.6em 0;
  padding: 4px 0 4px 22px;
  border-left: 3px solid var(--yellow1);
  color: var(--white);
  font-style: italic;
}
.prose blockquote p:last-child{ margin-bottom: 0; }

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

/* Inline code + code blocks */
.prose code{
  font-family: ui-monospace, monospace;
  font-size: 0.88em;
  background: var(--b3);
  border-radius: 6px;
  padding: 0.12em 0.4em;
  color: var(--yellow1);
}
.prose pre{
  margin: 1.6em 0;
  padding: 18px 20px;
  background: var(--b2);
  border: 1px solid var(--b3);
  border-radius: 12px;
  overflow-x: auto;
  line-height: 1.6;
  font-size: 0.9rem;
}
.prose pre code{
  background: transparent;
  border-radius: 0;
  padding: 0;
  color: var(--white);
  font-size: inherit;
}

/* Images / figures */
.prose img{
  display: block;
  max-width: 100%;
  height: auto;
  margin: 1.8em auto;
  border: 1px solid var(--b3);
  border-radius: 14px;
}
.prose figure{ margin: 1.8em 0; }
.prose figure img{ margin: 0 auto; }
.prose figcaption{
  margin-top: 10px;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
}

/* Tables */
.prose table{
  width: 100%;
  margin: 1.8em 0;
  border-collapse: collapse;
  font-size: 0.95rem;
  border: 1px solid var(--b3);
  border-radius: 12px;
  overflow: hidden;
  display: table;
}
.prose thead{
  background: var(--b3);
}
.prose th{
  text-align: left;
  font-weight: 700;
  color: var(--white);
  letter-spacing: 0.2px;
}
.prose th, .prose td{
  padding: 12px 16px;
  border-bottom: 1px solid var(--b3);
  vertical-align: top;
}
.prose tbody tr:last-child td{ border-bottom: 0; }
.prose tbody tr:nth-child(even){ background: var(--b2); }

.prose th.col-highlight,
.prose td.col-highlight{
  background: color-mix(in srgb, var(--yellow1) 13%, transparent);
  color: var(--white);
}
.prose thead th.col-highlight{
  background: color-mix(in srgb, var(--yellow1) 26%, var(--b3));
}

.prose tbody tr.row-highlight > th,
.prose tbody tr.row-highlight > td{
  background: color-mix(in srgb, var(--yellow1) 13%, transparent);
  color: var(--white);
}

/* Wrap wide tables so they scroll instead of breaking the layout */
.prose .table-scroll{
  margin: 1.8em 0;
  overflow-x: auto;
}
.prose .table-scroll table{ margin: 0; }

.prose kbd{
  font-family: ui-monospace, monospace;
  font-size: 0.82em;
  background: var(--b4);
  border: 1px solid var(--b3);
  border-bottom-width: 2px;
  border-radius: 6px;
  padding: 1px 6px;
}

/* --- In-article CTA (inserted via the {% cta %} shortcode) ---------------- */

.post-cta{
  margin: 2.6em 0;
  padding: 34px 28px;
  border: 1px solid var(--b3);
  border-radius: 14px;
  text-align: center;
  background:
    radial-gradient(130% 150% at 50% 0%, color-mix(in srgb, var(--yellow1) 12%, transparent) 0%, transparent 55%),
    linear-gradient(180deg, var(--b3) 0%, var(--b2) 100%);
}
.post-cta-inner{
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  max-width: 520px;
  margin: 0 auto;
}
.post-cta .post-cta-text{
  margin: 0;
  font-size: 1.25rem;
  font-weight: 650;
  line-height: 1.4;
  color: var(--white);
}

/* --- "More articles" grid ------------------------------------------------- */

.more-posts{
  margin-top: 80px;
  padding-top: 44px;
  border-top: 1px solid var(--b3);
}
.more-posts-title{
  margin: 0 0 26px;
  font-size: 1.7rem;
  font-weight: 500;
  letter-spacing: -0.5px;
  background: linear-gradient(10deg, var(--white), var(--muted));
  -webkit-background-clip: text;
          background-clip: text;
  color: transparent;
}

.post-grid{
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 22px;
}

.post-card{
  display: flex;
  flex-direction: column;
  border: 1px solid var(--b4);
  border-radius: 14px;
  background: var(--b3);
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  transition: transform .18s ease, border-color .18s ease, background .18s ease;
}
.post-card:hover{
  transform: scale(1.02);
  border-color: var(--b4);
  background: var(--b3);
}

.post-card-media{
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: var(--b1);
  border-bottom: 1px solid var(--b3);
}
.post-card-media img{
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.post-card-body{
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 20px 20px 22px;
  flex: 1;
}
.post-card-meta{
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}
.post-card-title{
  margin: 0;
  font-size: 1.12rem;
  font-weight: 650;
  line-height: 1.3;
  letter-spacing: -0.3px;
  color: var(--white);
}
.post-card-desc{
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.55;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.post-card-cta{
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: auto;
  padding-top: 6px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .3px;
  color: var(--yellow1);
}
.post-card-cta svg{ transition: transform .15s ease; }
.post-card:hover .post-card-cta svg{ transform: translateX(3px); }

/* --- Blog index ----------------------------------------------------------- */

.blog-index-hero{
  max-width: 720px;
  margin: 0 auto;
  padding: 46px 0 40px;
  text-align: center;
}
.blog-index-heading{
  margin: 0 0 16px;
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 600;
  letter-spacing: -0.9px;
  line-height: 1.16;
  padding-bottom: 0.08em;
  background: linear-gradient(110deg, var(--white) 0%, var(--muted) 100%);
  -webkit-background-clip: text;
          background-clip: text;
  color: transparent;
}
.blog-index-sub{
  margin: 0 auto;
  max-width: 560px;
  font-size: 1.08rem;
  line-height: 1.6;
  color: var(--muted);
}
.blog-index-empty{
  text-align: center;
  color: var(--muted);
  padding: 40px 0 60px;
}

/* --- Responsive ----------------------------------------------------------- */

@media (max-width: 900px){
  .blog-grid{
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
  }
  .post-toc{
    position: static;
    top: auto;
    order: -1;
    margin-bottom: 30px;
  }
  .post-toc-inner{
    border-left: 0;
    border: 1px solid var(--b3);
    border-radius: 12px;
    padding: 16px 18px;
    background: var(--b2);
  }
  .post-toc-nav{ max-height: none; }
  .toc-link{ padding-left: 12px; }
  .toc-link.is-active{ border-left-width: 2px; }
}

@media (max-width: 760px){
  /* Cover image moves to the top of the hero on narrow screens. */
  .blog-hero{ flex-direction: column-reverse; }
  .blog-hero-inner{ max-width: none; }
  .blog-hero-media{
    flex: none;
    width: 100%;
    height: 170px;
    background-size: cover;
  }
}

@media (max-width: 640px){
  .blog-hero{
    border-radius: 14px;
    margin: 12px 0 32px;
  }
  .blog-hero-inner{
    padding: 30px 22px 26px;
  }
  .prose{ font-size: 1.0rem; }
  .prose h2{ font-size: 1.4rem; }
  .prose h3{ font-size: 1.18rem; }
  .more-posts{ margin-top: 56px; }
  .post-grid{ grid-template-columns: 1fr; }
}
