/* ==========================================================================
   Keygraph blog styles — index + post pages.
   Uses ONLY existing theme variables, so it inherits the site's light-first
   token palette automatically. Code surfaces use --bg-alt (not --bg-dark,
   which is reserved for deliberate dark anchors) to stay readable.
   ========================================================================== */

/* ---------- shared shell ---------- */
.blog-index,
.blog-post {
  width: 100%;
  margin: 0 auto;
  padding: 160px 20px 64px;
}
.blog-index { max-width: 1080px; }
.blog-post { max-width: 760px; }

/* ==========================================================================
   Index
   ========================================================================== */
.blog-index-head { margin-bottom: 36px; }
.blog-index-title {
  font-size: var(--fs-3xl);
  font-weight: 600;
  letter-spacing: -0.045em;
  color: var(--text);
  margin: 0;
}
.blog-index-sub {
  margin: 10px 0 0;
  font-size: var(--fs-lg);
  color: var(--text-sec);
  line-height: 1.5;
}

/* controls: tabs (left) + search (right), matching the reference */
.blog-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 8px;
  padding-bottom: 14px;
}

.blog-search {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 16px;
  min-width: 180px;
  transition: border-color 0.18s ease;
}
.blog-search:focus-within { border-color: var(--text-tri); }
.blog-search svg { width: 15px; height: 15px; color: var(--text-tri); flex-shrink: 0; }
.blog-search input {
  border: none;
  background: none;
  outline: none;
  color: var(--text);
  font-family: var(--sans);
  font-size: var(--fs-sm);
  width: 100%;
}
.blog-search input::placeholder { color: var(--text-tri); }

/* list rows */
.blog-list {
  border-top: 1px solid var(--border-lt);
}
.blog-row {
  display: grid;
  grid-template-columns: minmax(170px, 230px) 1fr minmax(120px, 220px);
  gap: 24px;
  align-items: baseline;
  padding: 24px 16px;
  margin: 0 -16px;
  border-bottom: 1px solid var(--border-lt);
  text-decoration: none;
  border-radius: 10px;
  transition: background-color 0.16s ease;
}
.blog-row:hover { background: var(--bg-alt); }
.blog-row-meta {
  font-size: var(--fs-sm);
  color: var(--text-tri);
  white-space: nowrap;
}
.blog-row-cat { color: var(--text-tri); }
.blog-row-title {
  font-size: var(--fs-lg);
  font-weight: 500;
  color: var(--text);
  line-height: 1.4;
  letter-spacing: -0.01em;
}
.blog-row:hover .blog-row-title { color: var(--accent); }
.blog-row-author {
  font-size: var(--fs-sm);
  color: var(--text-tri);
  text-align: right;
}
.blog-empty {
  padding: 40px 16px;
  color: var(--text-tri);
  font-size: var(--fs-base);
  text-align: center;
}

/* ==========================================================================
   Post
   ========================================================================== */
.blog-back {
  display: inline-block;
  font-family: var(--mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-tri);
  text-decoration: none;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 7px 16px;
  transition: color 0.18s ease, border-color 0.18s ease;
}
.blog-back:hover { color: var(--text); border-color: var(--text-tri); }

.blog-post-header { margin: 28px 0 24px; }
.blog-post-eyebrow {
  font-family: var(--mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-tri);
  margin-bottom: 14px;
}
.blog-post-title {
  font-size: var(--fs-3xl);
  font-weight: 600;
  line-height: 1.12;
  letter-spacing: -0.045em;
  color: var(--text);
  margin: 0 0 18px;
}
.blog-post-byline {
  font-size: var(--fs-sm);
  color: var(--text-sec);
}
.blog-post-byline .blog-dot { color: var(--text-tri); margin: 0 4px; }

.blog-hero {
  margin: 0 0 36px;
}
.blog-hero img {
  width: 100%;
  height: auto;
  border-radius: 14px;
  border: 1px solid var(--border-lt);
  display: block;
}

/* ---------- rendered markdown body ---------- */
.blog-post-body {
  font-size: var(--fs-lg);
  line-height: 1.75;
  color: var(--text-sec);
}
.blog-post-body > *:first-child { margin-top: 0; }
.blog-post-body h2,
.blog-post-body h3,
.blog-post-body h4,
.blog-post-body h5,
.blog-post-body h6 {
  color: var(--text);
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.25;
  margin: 1.8em 0 0.6em;
  scroll-margin-top: 120px;
}
.blog-post-body h2 { font-size: var(--fs-2xl); }
.blog-post-body h3 { font-size: var(--fs-xl); }
.blog-post-body h4 { font-size: var(--fs-lg); }
.blog-post-body p { margin: 0 0 1.2em; }
.blog-post-body a {
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-color: var(--text-tri);
  transition: text-decoration-color 0.18s ease;
}
.blog-post-body a:hover { text-decoration-color: var(--text); }
.blog-post-body strong { color: var(--text); font-weight: 600; }
.blog-post-body em { font-style: italic; }
.blog-post-body ul,
.blog-post-body ol { margin: 0 0 1.2em; padding-left: 1.4em; }
.blog-post-body li { margin: 0.4em 0; }
.blog-post-body li::marker { color: var(--text-tri); }
.blog-post-body ul ul,
.blog-post-body ol ol,
.blog-post-body ul ol,
.blog-post-body ol ul { margin: 0.4em 0; }

.blog-post-body blockquote {
  margin: 1.5em 0;
  padding: 6px 0 6px 22px;
  border-left: 2px solid var(--accent);
  color: var(--text-sec);
  font-style: italic;
}
.blog-post-body blockquote p:last-child { margin-bottom: 0; }

/* code — uses --bg-alt + border so it reads in both themes */
.blog-post-body code {
  font-family: var(--mono);
  font-size: 0.88em;
  background: var(--bg-alt);
  border: 1px solid var(--border-lt);
  border-radius: 5px;
  padding: 1px 6px;
  color: var(--text);
}
.blog-post-body pre {
  margin: 1.5em 0;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 20px;
  overflow-x: auto;
}
.blog-post-body pre code {
  background: none;
  border: none;
  border-radius: 0;
  padding: 0;
  font-size: var(--fs-sm);
  line-height: 1.6;
  color: var(--text);
  white-space: pre;
}

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

/* tables */
.blog-table-wrap { overflow-x: auto; margin: 1.6em 0; border: 1px solid var(--border); border-radius: 12px; }
.blog-table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.blog-table th,
.blog-table td { text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--border-lt); vertical-align: top; line-height: 1.55; }
.blog-table thead th {
  font-family: var(--mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-tri);
  font-weight: 700;
  background: var(--bg-alt);
}
.blog-table td { color: var(--text-sec); }
.blog-table tbody tr:last-child td { border-bottom: 0; }

/* images + figures inside the body */
.blog-post-body img { max-width: 100%; height: auto; border-radius: 12px; display: block; }
.blog-figure { margin: 1.8em 0; }
.blog-figure img { border: 1px solid var(--border-lt); }
.blog-figure figcaption {
  margin-top: 10px;
  font-size: var(--fs-sm);
  color: var(--text-tri);
  text-align: center;
}

/* responsive video embeds (16:9) */
.blog-embed {
  position: relative;
  margin: 1.8em 0;
  aspect-ratio: 16 / 9;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border-lt);
  background: var(--bg-alt);
}
.blog-embed iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

/* Scoped higher than the chrome's generic `footer` rules (incl. the
   [data-theme="light"] variant), which would otherwise paint this in-article
   footer with the site-footer background and padding. */
.blog-post .blog-post-footer {
  margin-top: 48px;
  padding: 24px 0 0;
  border-top: 1px solid var(--border-lt);
  background: none;
}

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 720px) {
  .blog-index,
  .blog-post { padding: 100px 20px 48px; }

  .blog-controls { align-items: stretch; }
  .blog-search { width: 100%; }

  .blog-row {
    grid-template-columns: 1fr;
    gap: 6px;
    padding: 18px 14px;
    margin: 0 -14px;
  }
  .blog-row-meta { order: -1; }
  .blog-row-author { text-align: left; }
}
