/* ==========================================================
   ARTICLE PAGE STYLES - article.css
   ========================================================== */

/* ── Layout ─────────────────────────────────────────────── */
.article-main {
  padding-block: 80px;
  background: var(--bg);
  min-height: 80vh;
}

.article-container {
  max-width: 760px;
}

/* ── Breadcrumb ─────────────────────────────────────────── */
.article-breadcrumb {
  margin-bottom: 28px;
}

.breadcrumb-list {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 2px;
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 0.83rem;
}

.breadcrumb-item a {
  color: var(--text-muted);
  transition: color 0.2s;
}
.breadcrumb-item a:hover { color: var(--brand); }

.breadcrumb-current {
  color: var(--text);
  font-weight: 500;
  max-width: 260px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.breadcrumb-sep {
  color: var(--border);
  display: flex;
  align-items: center;
}

.bc-chevron {
  width: 14px;
  height: 14px;
}

[dir="rtl"] .bc-chevron { transform: scaleX(-1); }

/* ── Article header ─────────────────────────────────────── */
.article-header {
  margin-bottom: 36px;
}

.article-category-badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 4px 14px;
  border-radius: var(--radius-full);
  margin-bottom: 16px;
}

.article-title {
  font-size: clamp(1.7rem, 4vw, 2.4rem);
  font-weight: 800;
  color: var(--text);
  line-height: 1.3;
  letter-spacing: -0.02em;
  margin-bottom: 18px;
}

.article-meta-row {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.article-author-meta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
}

.article-author-avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  object-fit: cover;
}

.article-date,
.article-read-time,
.article-updated {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.84rem;
  color: var(--text-light);
}

.article-updated {
  color: var(--brand);
  font-size: 0.8rem;
}

/* ── Article Hero Cover Image ───────────────────────────── */
.article-hero-cover {
  width: 100%;
  max-height: 420px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-top: 28px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  background: var(--surface);
}

.article-hero-cover img {
  width: 100%;
  height: 100%;
  max-height: 420px;
  object-fit: cover;
  display: block;
  margin: 0;
}

/* ── Table of Contents ──────────────────────────────────── */
.article-toc {
  margin-bottom: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  overflow: hidden;
}

.toc-details {
  padding: 0;
}

.toc-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 20px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  user-select: none;
  list-style: none;
  transition: background 0.2s;
}

.toc-toggle:hover { background: var(--bg); }
.toc-toggle::-webkit-details-marker { display: none; }
.toc-toggle svg { width: 16px; height: 16px; color: var(--brand); }

.toc-nav {
  padding: 12px 20px;
}

.toc-list {
  list-style: none;
  padding: 0;
  margin: 0;
  counter-reset: toc-counter;
}

.toc-item {
  counter-increment: toc-counter;
  margin-bottom: 2px;
}

.toc-item-h3 {
  padding-inline-start: 18px;
}

.toc-link {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 5px 8px;
  border-radius: 6px;
  font-size: 0.86rem;
  color: var(--text-muted);
  transition: color 0.15s, background 0.15s;
  line-height: 1.4;
}

.toc-link::before {
  content: counter(toc-counter) ".";
  font-size: 0.75rem;
  color: var(--brand);
  font-weight: 700;
  flex-shrink: 0;
}

.toc-item-h3 .toc-link::before {
  content: "–";
  color: var(--text-light);
}

.toc-link:hover {
  color: var(--brand);
  background: var(--brand-light, #EEF0FF);
}

/* ── AdSense slots ──────────────────────────────────────── */
.adsense-slot {
  margin-block: 32px;
  background: var(--border-light);
  border-radius: var(--radius);
  min-height: 90px;
  overflow: hidden;
}

/* ── Article body content ───────────────────────────────── */
.article-body {
  font-size: 1.06rem;
  line-height: 1.9;
  color: var(--text-muted);
}

.article-body h2 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  margin-top: 48px;
  margin-bottom: 16px;
  letter-spacing: -0.01em;
  padding-block-start: 8px;
  border-top: 2px solid var(--border);
  scroll-margin-top: 80px;
}

.article-body h3 {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text);
  margin-top: 32px;
  margin-bottom: 12px;
  scroll-margin-top: 80px;
}

.article-body h4 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  margin-top: 20px;
  margin-bottom: 8px;
  scroll-margin-top: 80px;
}

.article-body p {
  margin-bottom: 18px;
}

.article-body ul,
.article-body ol {
  padding-inline-start: 24px;
  margin-bottom: 18px;
}

.article-body li { margin-bottom: 8px; }

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

.article-body blockquote {
  border-inline-start: 3px solid var(--brand);
  padding-inline-start: 18px;
  margin-inline: 0;
  color: var(--text-muted);
  font-style: italic;
  margin-block: 24px;
  background: var(--surface);
  padding-block: 12px;
  border-radius: 0 var(--radius) var(--radius) 0;
}

/* ── Code blocks ────────────────────────────────────────── */
.code-block-wrapper {
  position: relative;
  margin-block: 24px;
}

.code-block-wrapper pre {
  margin: 0;
}

.code-copy-btn {
  position: absolute;
  top: 10px;
  inset-inline-end: 10px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  background: rgba(255,255,255,0.08);
  color: #E2E8F0;
  border: 1px solid rgba(255,255,255,0.12);
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  z-index: 2;
}

.code-copy-btn:hover {
  background: rgba(255,255,255,0.18);
  color: #fff;
}

.code-copy-btn svg {
  width: 13px;
  height: 13px;
}

.article-body pre {
  background: #0D0D0D;
  color: #E2E8F0;
  padding: 20px;
  border-radius: var(--radius);
  overflow-x: auto;
  font-size: 0.9rem;
  line-height: 1.6;
  margin-block: 0;
  -webkit-overflow-scrolling: touch;
}

.article-body code {
  background: var(--brand-light, #EEF0FF);
  color: var(--brand);
  padding: 2px 7px;
  border-radius: 5px;
  font-size: 0.88em;
  font-family: 'Fira Code', 'Consolas', monospace;
}

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

/* ── Table styles ────────────────────────────────────────── */
.article-body table {
  width: 100%;
  border-collapse: collapse;
  margin-block: 24px;
  font-size: 0.9rem;
  overflow-x: auto;
  display: block;
}

.article-body th,
.article-body td {
  padding: 10px 14px;
  border: 1px solid var(--border);
  text-align: start;
}

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

.article-body img {
  width: 100%;
  border-radius: var(--radius-lg);
  margin-block: 24px;
}

.article-body hr {
  border: none;
  border-top: 1px solid var(--border);
  margin-block: 36px;
}

/* ── Author card ────────────────────────────────────────── */
.article-author-card {
  display: flex;
  align-items: flex-start;
  gap: 20px;
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-block: 40px;
}

.author-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 2px solid var(--brand-mid, #4338CA);
}

.author-info {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.author-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}

.author-role {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--brand);
  margin: 0;
}

.author-bio {
  font-size: 0.86rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin: 0;
}

.author-cta {
  align-self: flex-start;
  margin-top: 8px;
  font-size: 0.82rem;
  padding: 8px 18px;
}

/* ── Related Articles ───────────────────────────────────── */
.related-articles {
  margin-block: 48px 24px;
}

.related-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--border);
}

.related-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 18px;
}

/* ── Prev / Next Navigation ─────────────────────────────── */
.article-nav-links {
  display: flex;
  gap: 16px;
  margin-block: 32px;
  flex-wrap: wrap;
}

.article-nav-prev,
.article-nav-next {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  transition: border-color 0.2s, box-shadow 0.2s;
  flex: 1;
  min-width: 200px;
  text-decoration: none;
}

.article-nav-prev:hover,
.article-nav-next:hover {
  border-color: var(--brand);
  box-shadow: var(--shadow-sm);
}

.article-nav-next { justify-content: flex-end; }

.nav-arrow {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--brand);
}

.nav-arrow svg { width: 16px; height: 16px; }

.nav-meta {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.nav-meta small {
  font-size: 0.72rem;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.nav-meta strong {
  font-size: 0.88rem;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-weight: 600;
}

/* ── Not found state ────────────────────────────────────── */
.article-not-found {
  text-align: center;
  padding: 80px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.article-not-found h2 {
  font-size: 1.5rem;
  color: var(--text);
  margin: 0;
}

.article-not-found p {
  color: var(--text-muted);
  margin: 0;
}

/* ── Skeleton loaders ───────────────────────────────────── */
.article-skeleton {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.skeleton-line {
  height: 16px;
  background: linear-gradient(90deg, var(--border-light) 25%, var(--border) 50%, var(--border-light) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: 6px;
}
.skeleton-line.full   { width: 100%; }
.skeleton-line.medium { width: 75%; }
.skeleton-line.short  { width: 45%; }

@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Blog card skeleton ─────────────────────────────────── */
.blog-card-skeleton { pointer-events: none; }
.skeleton-img {
  width: 100%;
  height: 140px;
  background: linear-gradient(90deg, var(--border-light) 25%, var(--border) 50%, var(--border-light) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
}

/* ── Empty state ────────────────────────────────────────── */
.blog-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 80px 20px;
  color: var(--text-muted);
}

/* ── Blog card title link ────────────────────────────────── */
.blog-card-title-link {
  color: inherit;
  text-decoration: none;
  transition: color 0.2s;
}
.blog-card-title-link:hover { color: var(--brand); }

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 640px) {
  .article-main { padding-block: 48px; }
  .article-author-card { flex-direction: column; }
  .related-grid { grid-template-columns: 1fr; }
  .article-nav-links { flex-direction: column; }
  .article-nav-prev,
  .article-nav-next { min-width: unset; }
  .article-nav-next { justify-content: flex-start; }
  .breadcrumb-current { max-width: 140px; }
}

@media (max-width: 480px) {
  .article-title { font-size: 1.5rem; }
  .toc-toggle { font-size: 0.85rem; }
}
