/* ============================================================
   Blog styles - the /blog index + /blog/<slug> article pages.

   Loaded AFTER styles.css on blog.html + article.html only, so it
   reuses every design token (colours, radii, fonts, easing) already
   defined in styles.css :root. Nothing here is inline: the site CSP
   is `style-src 'self'` (no 'unsafe-inline'), so every rule lives in
   a stylesheet file served from the same origin.
   ============================================================ */

/* ---------- shared: tag chips ---------- */
.tag {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-3);
  background: var(--accent-soft);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 3px 8px;
  white-space: nowrap;
}
.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* ============================================================
   /blog index
   ============================================================ */

.blog-list-section {
  padding: clamp(40px, 6vw, 72px) 0 clamp(64px, 9vw, 120px);
}

.blog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 16px;
}

.blog-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 26px 24px 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: inherit;
  text-decoration: none;
  transition: border-color 0.18s var(--ease), background 0.18s var(--ease),
              transform 0.18s var(--ease), box-shadow 0.18s var(--ease);
}
.blog-card:hover {
  border-color: var(--accent);
  background: var(--surface-2);
  transform: translateY(-2px);
  box-shadow: 0 14px 40px -24px var(--accent-glow);
  color: inherit;
}
/* Keyboard focus only: :has(:focus-visible) paints the card ring when the
   title link is focused via the keyboard, and NOT on a mouse click (plain
   :focus-within would leave a ring after clicking). */
.blog-card:has(.blog-card-link:focus-visible) {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.blog-card-title {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(1.35rem, 2.2vw, 1.7rem);
  line-height: 1.12;
  letter-spacing: -0.01em;
  color: var(--text);
  margin: 0;
  text-wrap: balance;
}
.blog-card:hover .blog-card-title { color: var(--accent-2); }

/* The card title is an <h2> containing the link (not the reverse), so
   the heading is never nested inside interactive content. The link's
   ::after overlay stretches to make the whole card clickable, while the
   heading keeps its document-outline semantics. */
.blog-card-link {
  color: inherit;
  text-decoration: none;
}
.blog-card-link::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
  border-radius: var(--radius);
}
/* Focus ring is painted on the card (:has(:focus-visible) above), so the
   inner link does not draw its own (would double the ring). */
.blog-card-link:focus-visible { outline: none; }

.blog-card-excerpt {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-2);
  margin: 0;
  /* Clamp the teaser so cards stay balanced regardless of copy length. */
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.blog-card-meta {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--text-3);
}
.blog-card-meta .sep { color: var(--text-muted); }
.blog-card-readmore {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--accent);
  transition: gap 0.18s var(--ease);
}
.blog-card:hover .blog-card-readmore { gap: 10px; }
.blog-card-readmore svg { width: 13px; height: 13px; }

/* ---------- list states: loading / empty / error ---------- */
.blog-state {
  padding: 56px 24px;
  text-align: center;
  color: var(--text-2);
  border: 1px dashed var(--border-2);
  border-radius: var(--radius);
  background: var(--bg-2);
}
.blog-state h2 {
  font-size: clamp(1.4rem, 2.4vw, 1.9rem);
  margin-bottom: 10px;
}
.blog-state p { max-width: 460px; margin: 0 auto; }

/* Skeleton cards while the fetch is in flight. */
.blog-skeleton {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 26px 24px 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.sk-line {
  height: 12px;
  border-radius: var(--radius-sm);
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 37%, var(--surface-2) 63%);
  background-size: 400% 100%;
  animation: blog-shimmer 1.4s ease-in-out infinite;
}
.sk-line.title { height: 22px; width: 80%; }
.sk-line.short { width: 55%; }
.sk-line.tag { height: 16px; width: 72px; }
@keyframes blog-shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: 0 0; }
}
@media (prefers-reduced-motion: reduce) {
  .sk-line { animation: none; }
}

/* ============================================================
   /blog/<slug> article
   ============================================================ */

.article-wrap {
  padding: clamp(28px, 4vw, 48px) 0 clamp(64px, 9vw, 120px);
}
.article {
  max-width: 760px;
  margin: 0 auto;
}

.article-breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 28px;
}
.article-breadcrumb a { color: var(--text-3); }
.article-breadcrumb a:hover { color: var(--accent); }
.article-breadcrumb .sep { color: var(--text-muted); }
.article-breadcrumb .current { color: var(--text-2); }

.article-header { margin-bottom: 36px; }
.article-header .tag-row { margin-bottom: 20px; }
.article-title {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(2.2rem, 5vw, 3.4rem);
  line-height: 1.06;
  letter-spacing: -0.01em;
  color: var(--text);
  margin: 0 0 20px;
  text-wrap: balance;
}
.article-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.05em;
  color: var(--text-3);
}
.article-meta .sep { color: var(--text-muted); }
.article-author { color: var(--text-2); }

.article-hero-img {
  width: 100%;
  height: auto;
  margin: 0 0 40px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

/* Divider under the header. */
.article-rule {
  border: 0;
  border-top: 1px solid var(--hairline);
  margin: 0 0 40px;
}

/* ---------- injected + sanitized article body typography ---------- */
.article-body {
  font-size: 17px;
  line-height: 1.75;
  color: var(--text-2);
}
.article-body > *:first-child { margin-top: 0; }
.article-body p {
  margin: 0 0 1.4em;
  color: var(--text-2);
  text-wrap: pretty;
}
.article-body h2 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(1.6rem, 3vw, 2.1rem);
  line-height: 1.15;
  letter-spacing: -0.01em;
  color: var(--text);
  margin: 1.8em 0 0.6em;
}
.article-body h3 {
  font-weight: 600;
  font-size: 1.3rem;
  color: var(--text);
  margin: 1.6em 0 0.5em;
}
.article-body h4 {
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--text);
  margin: 1.4em 0 0.4em;
  text-transform: none;
  letter-spacing: -0.01em;
  font-family: var(--font-sans);
}
.article-body a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: var(--accent-soft);
  text-underline-offset: 3px;
  transition: text-decoration-color 0.15s var(--ease), color 0.15s var(--ease);
}
.article-body a:hover {
  color: var(--accent-2);
  text-decoration-color: var(--accent-2);
}
.article-body strong { color: var(--text); font-weight: 600; }
.article-body em { font-style: italic; }
.article-body ul,
.article-body ol {
  margin: 0 0 1.4em;
  padding-left: 1.4em;
  color: var(--text-2);
}
.article-body li { margin: 0 0 0.5em; }
.article-body li::marker { color: var(--accent); }
.article-body blockquote {
  margin: 1.6em 0;
  padding: 4px 0 4px 22px;
  border-left: 2px solid var(--accent);
  color: var(--text);
  font-style: italic;
}
.article-body blockquote p { color: var(--text); }
.article-body img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin: 1.4em 0;
}
.article-body hr {
  border: 0;
  border-top: 1px solid var(--hairline);
  margin: 2.4em 0;
}
.article-body code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--accent-soft);
  padding: 0.12em 0.4em;
  border-radius: var(--radius-sm);
  color: var(--text);
  border: 1px solid var(--border-soft);
}
.article-body pre {
  margin: 1.6em 0;
  padding: 18px 20px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
  font-size: 13.5px;
  line-height: 1.65;
}
.article-body pre code {
  background: none;
  border: 0;
  padding: 0;
  border-radius: 0;
  font-size: inherit;
  color: var(--text-2);
}
.article-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.6em 0;
  font-size: 15px;
  display: block;
  overflow-x: auto;
}
.article-body th,
.article-body td {
  border: 1px solid var(--border);
  padding: 10px 14px;
  text-align: left;
}
.article-body th {
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  font-family: var(--font-mono);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ---------- article footer: back link + CTA ---------- */
.article-foot {
  max-width: 760px;
  margin: 56px auto 0;
  padding-top: 32px;
  border-top: 1px solid var(--hairline);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}
.article-back {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-3);
}
.article-back:hover { color: var(--accent); }
.article-back svg { width: 13px; height: 13px; }

/* ---------- article states ---------- */
.article-loading .sk-line { max-width: 760px; margin-left: auto; margin-right: auto; }

@media (max-width: 640px) {
  .blog-grid { grid-template-columns: 1fr; }
  .article-body { font-size: 16px; }
}
