@import url('https://fonts.googleapis.com/css2?family=Inter:ital,wght@0,300;0,400;0,500;0,600;0,700;1,400&family=Space+Grotesk:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

/* ─── DESIGN TOKENS ─────────────────────────────────────────── */
:root {
  --bg:           #0a0a0f;
  --bg-2:         #111118;
  --bg-3:         #1a1a24;
  --surface:      #16161e;
  --surface-2:    #1e1e28;
  --border:       rgba(255,255,255,0.08);
  --border-hover: rgba(255,255,255,0.16);

  --text-primary:   #f1f1f5;
  --text-secondary: #9898aa;
  --text-muted:     #5c5c70;

  --accent:         #7c6fff;
  --accent-glow:    rgba(124,111,255,0.20);
  --accent-subtle:  rgba(124,111,255,0.08);

  --green:  #34d399;
  --blue:   #60a5fa;
  --orange: #fb923c;
  --red:    #f87171;

  --radius-sm: 6px;
  --radius:    10px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  --font-body:  'Inter', -apple-system, sans-serif;
  --font-head:  'Space Grotesk', sans-serif;
  --font-mono:  'JetBrains Mono', 'Fira Code', monospace;

  --nav-h: 64px;
  --content-w: 740px;
  --wide-w:    1100px;
}

/* ─── RESET & BASE ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; font-size: 16px; }

body {
  background: var(--bg);
  color: var(--text-primary);
  font-family: var(--font-body);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  padding-top: var(--nav-h);
}

/* ─── READING PROGRESS BAR ──────────────────────────────────── */
#progress-bar {
  position: fixed;
  top: var(--nav-h);
  left: 0;
  height: 2px;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), #a78bfa);
  z-index: 200;
  transition: width 0.1s linear;
}

/* ─── NAVIGATION ────────────────────────────────────────────── */
.nav {
  position: fixed;
  inset-block-start: 0;
  inset-inline: 0;
  height: var(--nav-h);
  background: rgba(10,10,15,0.85);
  backdrop-filter: blur(18px) saturate(180%);
  -webkit-backdrop-filter: blur(18px) saturate(180%);
  border-bottom: 1px solid var(--border);
  z-index: 100;
  display: flex;
  align-items: center;
}

.nav__inner {
  width: 100%;
  max-width: var(--wide-w);
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.nav__logo {
  font-family: var(--font-head);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  text-decoration: none;
  letter-spacing: -0.01em;
  transition: color 0.2s;
  flex-shrink: 0;
}
.nav__logo:hover { color: var(--accent); }

.nav__links {
  display: flex;
  align-items: center;
  gap: 4px;
  list-style: none;
}

.nav__links a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  transition: color 0.2s, background 0.2s;
}
.nav__links a:hover { color: var(--text-primary); background: var(--surface); }

.nav__cta {
  background: var(--accent);
  color: #fff !important;
  padding: 8px 18px !important;
  border-radius: var(--radius) !important;
  font-weight: 600 !important;
  font-size: 0.85rem !important;
  transition: opacity 0.2s, transform 0.2s !important;
}
.nav__cta:hover { opacity: 0.88 !important; transform: translateY(-1px); background: var(--accent) !important; }

/* ─── HERO SECTION ──────────────────────────────────────────── */
.article-hero {
  background: linear-gradient(160deg, var(--bg-2) 0%, var(--bg) 100%);
  border-bottom: 1px solid var(--border);
  padding: 64px 24px 56px;
}

.article-hero__inner {
  max-width: var(--content-w);
  margin: 0 auto;
}

/* Category Tag */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  background: var(--accent-subtle);
  border: 1px solid rgba(124,111,255,0.2);
  padding: 4px 12px;
  border-radius: 999px;
  margin-bottom: 20px;
}

/* Title */
.article-title {
  font-family: var(--font-head);
  font-size: clamp(1.9rem, 4.5vw, 2.75rem);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.025em;
  color: var(--text-primary);
  margin-bottom: 20px;
}

/* Subtitle / Excerpt */
.article-subtitle {
  font-size: 1.125rem;
  line-height: 1.7;
  color: var(--text-secondary);
  margin-bottom: 32px;
  max-width: 620px;
}

/* Author Row */
.author-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.author-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #a78bfa);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 0.9rem;
  color: #fff;
  flex-shrink: 0;
}

.author-info { display: flex; flex-direction: column; gap: 2px; }
.author-name { font-weight: 600; font-size: 0.95rem; color: var(--text-primary); }
.author-meta { font-size: 0.82rem; color: var(--text-muted); display: flex; align-items: center; gap: 8px; }
.dot { color: var(--text-muted); }

.read-badge {
  margin-left: auto;
  font-size: 0.8rem;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 4px 12px;
  border-radius: 999px;
  white-space: nowrap;
}

/* ─── LAYOUT: CONTENT + SIDEBAR ─────────────────────────────── */
.page-layout {
  max-width: var(--wide-w);
  margin: 0 auto;
  padding: 0 24px;
  display: grid;
  grid-template-columns: 1fr 260px;
  gap: 56px;
  align-items: start;
  padding-top: 56px;
  padding-bottom: 80px;
}

@media (max-width: 960px) {
  .page-layout {
    grid-template-columns: 1fr;
    gap: 40px;
  }
  .sidebar { display: none; }
}

/* ─── SIDEBAR ────────────────────────────────────────────────── */
.sidebar {
  position: sticky;
  top: calc(var(--nav-h) + 24px);
}

.toc-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px 20px;
  margin-bottom: 20px;
}

.toc-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 14px;
}

.toc-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.toc-list a {
  display: block;
  font-size: 0.84rem;
  color: var(--text-secondary);
  text-decoration: none;
  padding: 5px 10px;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
  line-height: 1.4;
}
.toc-list a:hover { color: var(--accent); background: var(--accent-subtle); }

.author-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px 20px;
  text-align: center;
}

.author-card .avatar-lg {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #a78bfa);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 1.1rem;
  color: #fff;
  margin: 0 auto 12px;
}

.author-card h4 { font-size: 0.95rem; font-weight: 600; margin-bottom: 4px; }
.author-card p  { font-size: 0.82rem; color: var(--text-secondary); margin-bottom: 14px; line-height: 1.5; }

.btn-sm {
  display: inline-block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-subtle);
  border: 1px solid rgba(124,111,255,0.2);
  padding: 7px 16px;
  border-radius: var(--radius);
  text-decoration: none;
  transition: background 0.2s;
}
.btn-sm:hover { background: rgba(124,111,255,0.16); }

/* ─── ARTICLE BODY ───────────────────────────────────────────── */
.article-body {
  min-width: 0;
}

.prose {
  font-size: 1.05rem;
  line-height: 1.85;
  color: var(--text-secondary);
}

.prose p { margin-bottom: 1.6rem; }
.prose p:last-child { margin-bottom: 0; }

.prose strong { color: var(--text-primary); font-weight: 600; }
.prose em     { font-style: italic; }

.prose a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: opacity 0.2s;
}
.prose a:hover { opacity: 0.75; }

/* Headings */
.prose h2 {
  font-family: var(--font-head);
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  margin: 2.8rem 0 1rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
}

.prose h3 {
  font-family: var(--font-head);
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 2rem 0 0.75rem;
}

/* Lists */
.prose ul, .prose ol {
  padding-left: 1.5rem;
  margin-bottom: 1.6rem;
}
.prose li { margin-bottom: 0.5rem; }
.prose ul { list-style: disc; }
.prose ul li::marker { color: var(--accent); }
.prose ol { list-style: decimal; }

/* Blockquote */
.prose blockquote {
  margin: 2rem 0;
  padding: 18px 24px;
  background: var(--accent-subtle);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  font-style: italic;
  color: var(--text-primary);
  font-size: 1.05rem;
}

/* Inline Code */
.prose code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--accent);
  padding: 2px 7px;
  border-radius: 5px;
}

/* Code Block */
.prose pre {
  position: relative;
  background: #0d0d14;
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: var(--radius-lg);
  padding: 24px 24px 24px 24px;
  overflow-x: auto;
  margin: 2rem 0;
  box-shadow: 0 4px 24px rgba(0,0,0,0.4);
}

.prose pre::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, var(--accent), transparent 70%);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.code-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.code-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
}
.code-dot-red    { background: #ff5f57; }
.code-dot-yellow { background: #ffbd2e; }
.code-dot-green  { background: #28c840; }
.code-lang {
  margin-left: auto;
  font-size: 0.72rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.prose pre code {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  line-height: 1.75;
  background: transparent;
  border: none;
  padding: 0;
  color: #cdd6f4;
  white-space: pre;
}

/* Syntax highlights (manual coloring) */
.kw   { color: #89b4fa; }  /* keyword */
.fn   { color: #cba6f7; }  /* function */
.str  { color: #a6e3a1; }  /* string */
.cm   { color: #585b70; font-style: italic; } /* comment */
.num  { color: #fab387; }  /* number */
.cls  { color: #f9e2af; }  /* class/type */

/* ─── CALLOUT BOXES ──────────────────────────────────────────── */
.callout {
  display: flex;
  gap: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  margin: 2rem 0;
}

.callout-icon { font-size: 1.3rem; flex-shrink: 0; margin-top: 2px; }

.callout--tip    { border-left: 3px solid var(--green);  background: rgba(52,211,153,0.05); }
.callout--warn   { border-left: 3px solid var(--orange); background: rgba(251,146,60,0.05); }
.callout--info   { border-left: 3px solid var(--blue);   background: rgba(96,165,250,0.05); }
.callout--danger { border-left: 3px solid var(--red);    background: rgba(248,113,113,0.05); }

.callout-content h4 {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 6px;
  font-family: var(--font-head);
}
.callout-content p {
  font-size: 0.9rem;
  margin: 0;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* ─── SECTION DIVIDER ────────────────────────────────────────── */
.section-divider {
  width: 100%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border), transparent);
  margin: 3rem 0;
}

/* ─── KEY POINTS GRID ────────────────────────────────────────── */
.key-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin: 2rem 0;
}

.key-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  transition: border-color 0.2s, transform 0.2s;
}
.key-card:hover { border-color: var(--border-hover); transform: translateY(-2px); }

.key-card__icon { font-size: 1.5rem; margin-bottom: 10px; }
.key-card__title { font-size: 0.9rem; font-weight: 700; font-family: var(--font-head); color: var(--text-primary); margin-bottom: 6px; }
.key-card__desc  { font-size: 0.82rem; color: var(--text-secondary); line-height: 1.5; }

/* ─── TOOL TABLE ─────────────────────────────────────────────── */
.tool-table {
  width: 100%;
  border-collapse: collapse;
  margin: 2rem 0;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border);
}

.tool-table th {
  background: var(--surface-2);
  padding: 12px 16px;
  text-align: left;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

.tool-table td {
  padding: 12px 16px;
  font-size: 0.9rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
  vertical-align: top;
}

.tool-table tr:last-child td { border-bottom: none; }
.tool-table tr:hover td { background: var(--surface); }
.tool-table td strong { color: var(--text-primary); font-weight: 600; }

.badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.badge--green  { background: rgba(52,211,153,0.12); color: var(--green); }
.badge--blue   { background: rgba(96,165,250,0.12);  color: var(--blue);  }
.badge--orange { background: rgba(251,146,60,0.12);  color: var(--orange);}
.badge--purple { background: var(--accent-subtle);   color: var(--accent);}

/* ─── ARTICLE FOOTER ─────────────────────────────────────────── */
.article-footer {
  margin-top: 4rem;
  padding-top: 2.5rem;
  border-top: 1px solid var(--border);
}

.tags-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 32px;
}

.tag-chip {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 5px 12px;
  border-radius: 999px;
  text-decoration: none;
  transition: border-color 0.2s, color 0.2s;
}
.tag-chip:hover { border-color: var(--accent); color: var(--accent); }

.nav-articles {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 32px;
}

@media (max-width: 600px) { .nav-articles { grid-template-columns: 1fr; } }

.nav-article {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  text-decoration: none;
  transition: border-color 0.2s, transform 0.2s;
  display: block;
}
.nav-article:hover { border-color: var(--accent); transform: translateY(-2px); }
.nav-article__label { font-size: 0.72rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 6px; display: block; }
.nav-article__title { font-size: 0.9rem; font-weight: 600; color: var(--text-primary); line-height: 1.4; }

/* Back link */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 0.2s;
}
.back-link:hover { color: var(--accent); }
.back-link svg { transition: transform 0.2s; }
.back-link:hover svg { transform: translateX(-3px); }

/* ─── RELATED POSTS ──────────────────────────────────────────── */
.related-section { margin-top: 4rem; }
.related-section h3 {
  font-family: var(--font-head);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 16px;
}

.related-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
}

.related-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  text-decoration: none;
  transition: border-color 0.2s, transform 0.2s;
  display: block;
}
.related-card:hover { border-color: var(--border-hover); transform: translateY(-2px); }
.related-card__cat  { font-size: 0.72rem; font-weight: 600; color: var(--accent); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 6px; }
.related-card__title { font-size: 0.88rem; font-weight: 600; color: var(--text-primary); line-height: 1.4; }

/* ─── SITE FOOTER ────────────────────────────────────────────── */
.site-footer {
  background: var(--bg-2);
  border-top: 1px solid var(--border);
  padding: 40px 24px;
  margin-top: 80px;
}

.site-footer__inner {
  max-width: var(--wide-w);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}

.footer-logo {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text-primary);
  text-decoration: none;
}
.footer-logo:hover { color: var(--accent); }

.footer-links {
  display: flex;
  gap: 24px;
  list-style: none;
  flex-wrap: wrap;
}
.footer-links a { font-size: 0.85rem; color: var(--text-muted); text-decoration: none; transition: color 0.2s; }
.footer-links a:hover { color: var(--text-primary); }

.footer-copy { font-size: 0.82rem; color: var(--text-muted); }

/* ─── RESPONSIVE ─────────────────────────────────────────────── */
@media (max-width: 640px) {
  .nav__links { display: none; }
  .article-hero { padding: 40px 20px 36px; }
  .page-layout  { padding: 32px 20px 60px; }
  .article-title { font-size: 1.75rem; }
}
