/* Articles */
.articles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.5rem;
  margin: 2rem 0;
}
.article-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  transition: border-color .2s, box-shadow .2s;
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
}
.article-card:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 20px rgba(99, 102, 241, .12);
}
.article-card__tag {
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--accent);
  margin-bottom: .5rem;
}
.article-card__title {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--fg);
  margin-bottom: .5rem;
  line-height: 1.4;
}
.article-card__desc {
  font-size: .9rem;
  color: var(--fg-muted);
  line-height: 1.6;
  flex: 1;
}
.article-card__meta {
  margin-top: 1rem;
  font-size: .8rem;
  color: var(--fg-muted);
  opacity: .7;
}

/* Article page */
.article {
  max-width: 780px;
  margin: 0 auto;
  padding: 2rem 0 3rem;
}
.article__back {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  font-size: .85rem;
  color: var(--accent);
  text-decoration: none;
  margin-bottom: 1.5rem;
}
.article__back:hover { text-decoration: underline; }
.article__tag {
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--accent);
  margin-bottom: .5rem;
}
.article__title {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.3;
  color: var(--fg);
  margin-bottom: .75rem;
}
.article__meta {
  font-size: .85rem;
  color: var(--fg-muted);
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}
.article h2 {
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--fg);
  margin: 2.5rem 0 1rem;
}
.article h3 {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--fg);
  margin: 2rem 0 .75rem;
}
.article p {
  font-size: .95rem;
  line-height: 1.8;
  color: var(--fg-muted);
  margin-bottom: 1rem;
}
.article ul, .article ol {
  margin: 1rem 0 1.5rem 1.5rem;
  color: var(--fg-muted);
  font-size: .95rem;
  line-height: 1.8;
}
.article li { margin-bottom: .5rem; }
.article code {
  font-family: 'JetBrains Mono', monospace;
  font-size: .85rem;
  background: var(--bg);
  border: 1px solid var(--border);
  padding: .15em .4em;
  border-radius: 4px;
}
.article pre {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem;
  overflow-x: auto;
  margin: 1rem 0 1.5rem;
}
.article pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: .85rem;
  line-height: 1.6;
}
.article table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0 1.5rem;
  font-size: .9rem;
}
.article th, .article td {
  text-align: left;
  padding: .65rem .75rem;
  border-bottom: 1px solid var(--border);
  color: var(--fg-muted);
}
.article th {
  font-weight: 600;
  color: var(--fg);
  background: var(--surface);
}
.article__cta {
  margin-top: 2.5rem;
  padding: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  text-align: center;
}
.article__cta p {
  margin-bottom: .75rem;
  color: var(--fg);
  font-weight: 500;
}
.article__cta a {
  display: inline-block;
  padding: .6rem 1.5rem;
  background: var(--accent);
  color: var(--white);
  border-radius: 8px;
  text-decoration: none;
  font-weight: 500;
  font-size: .9rem;
  transition: opacity .2s;
}
.article__cta a:hover { opacity: .85; }

@media (max-width: 600px) {
  .article__title { font-size: 1.5rem; }
  .article h2 { font-size: 1.2rem; }
  .articles-grid { grid-template-columns: 1fr; }
}

/* ── Table of Contents ─────────────────────────────────────────────── */
.article__toc {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin: 24px 0 32px;
}
.article__toc-title {
  font-size: .85rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
  font-family: var(--mono);
}
.article__toc ol {
  list-style: none;
  counter-reset: toc;
  padding: 0;
  margin: 0;
}
.article__toc li {
  counter-increment: toc;
  margin-bottom: 4px;
}
.article__toc li::before {
  content: counter(toc) ".";
  color: var(--accent);
  font-weight: 600;
  font-family: var(--mono);
  font-size: .8rem;
  margin-right: 8px;
  min-width: 24px;
  display: inline-block;
}
.article__toc li a {
  color: var(--muted2);
  text-decoration: none;
  font-size: .88rem;
  transition: color .15s;
}
.article__toc li a:hover {
  color: var(--accent);
}
.article__toc-sub {
  padding-left: 28px;
}
.article__toc-sub::before {
  font-size: .75rem;
}

/* Smooth scroll targets with offset for sticky nav */
.article h2[id], .article h3[id] {
  scroll-margin-top: 120px;
}
/* Article content links — inside article body only (not cards, not CTA) */
.article > h2 a, .article > h3 a,
.article > p a, .article > ul a, .article > ol a,
.article > table a, .article > blockquote a,
.article > div:not(.article__cta):not(.article__toc) a:not(.article__back) {
  color: #a8c4ff;
  text-decoration: underline;
  text-decoration-color: rgba(168,196,255,.35);
  text-underline-offset: 2px;
  transition: color .15s, text-decoration-color .15s;
}
.article > p a:hover, .article > ul a:hover, .article > ol a:hover,
.article > table a:hover, .article > blockquote a:hover {
  color: #c8dbff;
  text-decoration-color: rgba(200,219,255,.7);
}
.article > p a:visited, .article > ul a:visited, .article > ol a:visited,
.article > table a:visited, .article > blockquote a:visited {
  color: #cdb4f5;
  text-decoration-color: rgba(205,180,245,.35);
}
.article > p a:visited:hover, .article > ul a:visited:hover, .article > ol a:visited:hover {
  color: #ddc8ff;
  text-decoration-color: rgba(221,200,255,.7);
}

/* Articles listing page wrapper */
.articles-page {
  max-width: 960px;
  margin: 0 auto;
  padding: 2rem 0 3rem;
}
.articles-page a {
  text-decoration: none;
  color: inherit;
}

/* ── Pagination ────────────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 3rem 0 1.5rem;
  padding: 1.25rem 0;
  flex-wrap: wrap;
}
.pagination a,
.pagination span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  height: 44px;
  padding: 0 14px;
  border-radius: 10px;
  font-size: .95rem;
  font-weight: 600;
  text-decoration: none;
  transition: all .2s ease;
}
.pagination a {
  color: var(--text2, #c8cfe0);
  background: var(--surface2, #1e2234);
  border: 1px solid var(--border2, rgba(255,255,255,.12));
}
.pagination a:hover {
  color: var(--white);
  border-color: var(--accent, #4da3ff);
  background: rgba(77,163,255,.15);
  box-shadow: 0 0 12px rgba(77,163,255,.2);
  transform: translateY(-1px);
}
.pagination .active {
  color: var(--white);
  background: var(--accent, #4da3ff);
  border: 1px solid var(--accent, #4da3ff);
  box-shadow: 0 2px 12px rgba(77,163,255,.35);
  pointer-events: none;
}
.pagination .dots {
  color: var(--muted2, #95a2ba);
  border: none;
  background: none;
  min-width: 32px;
  pointer-events: none;
  font-size: 1.1rem;
}
.pagination .prev,
.pagination .next {
  font-size: 1rem;
  font-weight: 700;
  padding: 0 16px;
}

/* ── Focus-visible (accessibility) ── */
:focus-visible {
  outline: 2px solid var(--accent, #59a8ff);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ── Related Articles ─────────────────────────────────── */
.article-related {
  max-width: 760px;
  margin: 48px auto 0;
  padding: 0 24px 40px;
}
.article-related__title {
  font-size: 15px;
  font-weight: 600;
  color: var(--muted2);
  margin-bottom: 18px;
}
.article-related__tag {
  color: var(--accent);
}
.article-related__grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}
.article-related__card {
  display: block;
  padding: 18px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  transition: border-color .15s ease, transform .15s ease, box-shadow .15s ease;
}
.article-related__card:hover {
  border-color: rgba(89,168,255,.35);
  transform: translateY(-2px);
  box-shadow: 0 4px 18px rgba(0,0,0,.18);
}
.article-related__card-tag {
  font-size: 10px;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: .6px;
  margin-bottom: 8px;
}
.article-related__card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.5;
  margin-bottom: 10px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.article-related__card-meta {
  font-size: 11px;
  color: var(--muted);
}
@media (max-width: 640px) {
  .article-related { padding: 0 16px 32px; }
  .article-related__grid { grid-template-columns: 1fr; }
}
