/* TechPulse — Premium Technical Blog */
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600&family=Outfit:wght@300;400;500;600;700;800&display=swap');

:root {
  --bg-deep: #0a0b0f;
  --bg-card: rgba(18, 20, 28, 0.72);
  --bg-elevated: #14161f;
  --border: rgba(255, 255, 255, 0.06);
  --border-hover: rgba(255, 255, 255, 0.14);
  --text: #e8eaef;
  --text-muted: #8b92a8;
  --text-dim: #5c6378;
  --accent: #6366f1;
  --accent-glow: rgba(99, 102, 241, 0.35);
  --gradient-1: #6366f1;
  --gradient-2: #8b5cf6;
  --gradient-3: #06b6d4;
  --js: #f7df1e;
  --css-c: #264de4;
  --jquery: #0769ad;
  --vue: #42b883;
  --react: #61dafb;
  --node: #68a063;
  --python: #3776ab;
  --ai: #ff6b9d;
  --algo: #f59e0b;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
  --font-sans: 'Outfit', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --nav-h: 72px;
  --transition: 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  --nav-bg: rgba(10, 11, 15, 0.75);
  --nav-bg-scrolled: rgba(10, 11, 15, 0.92);
  --text-body: #c5c9d6;
}

[data-theme="light"] {
  --bg-deep: #eef0f6;
  --bg-card: rgba(255, 255, 255, 0.85);
  --bg-elevated: #ffffff;
  --border: rgba(15, 23, 42, 0.08);
  --border-hover: rgba(15, 23, 42, 0.16);
  --text: #1a1d28;
  --text-muted: #5c6378;
  --text-dim: #8b92a8;
  --text-body: #3d4455;
  --accent-glow: rgba(99, 102, 241, 0.2);
  --shadow: 0 20px 60px rgba(15, 23, 42, 0.1);
  --nav-bg: rgba(238, 240, 246, 0.88);
  --nav-bg-scrolled: rgba(255, 255, 255, 0.95);
}

[data-theme="light"] .bg-mesh {
  background:
    radial-gradient(ellipse 80% 50% at 20% -10%, rgba(99, 102, 241, 0.1), transparent),
    radial-gradient(ellipse 60% 40% at 90% 20%, rgba(139, 92, 246, 0.06), transparent),
    var(--bg-deep);
}

[data-theme="light"] .bg-grid {
  background-image:
    linear-gradient(rgba(15, 23, 42, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(15, 23, 42, 0.04) 1px, transparent 1px);
}

[data-theme="light"] .hero h1 .gradient-text {
  background: linear-gradient(135deg, #1a1d28 0%, #4f46e5 50%, #0891b2 100%);
  -webkit-background-clip: text;
  background-clip: text;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

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

body {
  font-family: var(--font-sans);
  background: var(--bg-deep);
  color: var(--text);
  line-height: 1.65;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Ambient background */
.bg-mesh {
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    radial-gradient(ellipse 80% 50% at 20% -10%, rgba(99, 102, 241, 0.18), transparent),
    radial-gradient(ellipse 60% 40% at 90% 20%, rgba(139, 92, 246, 0.12), transparent),
    radial-gradient(ellipse 50% 30% at 50% 100%, rgba(6, 182, 212, 0.08), transparent),
    var(--bg-deep);
}

.bg-grid {
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image:
    linear-gradient(rgba(255,255,255,0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.02) 1px, transparent 1px);
  background-size: 64px 64px;
  mask-image: radial-gradient(ellipse 70% 60% at 50% 30%, black, transparent);
}

/* Navigation */
.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--nav-h);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 clamp(1.25rem, 4vw, 3rem);
  background: var(--nav-bg);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  transition: var(--transition);
}

.nav.scrolled { background: var(--nav-bg-scrolled); }

.nav-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
}

.theme-toggle:hover {
  color: var(--text);
  border-color: var(--border-hover);
}

[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle .icon-moon { display: block; }
[data-theme="light"] .theme-toggle .icon-sun { display: block; }
[data-theme="light"] .theme-toggle .icon-moon { display: none; }

.nav-brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
  color: var(--text);
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: -0.02em;
}

.nav-brand-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--gradient-1), var(--gradient-2));
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
}

.nav-links {
  display: flex;
  gap: 0.25rem;
  list-style: none;
}

.nav-links a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  padding: 0.5rem 0.85rem;
  border-radius: 8px;
  transition: var(--transition);
}

.nav-links a:hover,
.nav-links a.active {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
}

.nav-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  padding: 0.5rem;
}

/* Hero */
.hero {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: calc(var(--nav-h) + 3rem) 1.5rem 4rem;
  position: relative;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 1rem;
  border-radius: 100px;
  background: rgba(99, 102, 241, 0.12);
  border: 1px solid rgba(99, 102, 241, 0.25);
  color: #a5b4fc;
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 1.75rem;
  animation: fadeUp 0.8s ease both;
}

.hero-badge::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 12px #22c55e;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.hero h1 {
  font-size: clamp(2.75rem, 7vw, 5rem);
  font-weight: 800;
  line-height: 1.08;
  letter-spacing: -0.03em;
  max-width: 900px;
  animation: fadeUp 0.8s 0.1s ease both;
}

.hero h1 .gradient-text {
  background: linear-gradient(135deg, #fff 0%, #a5b4fc 50%, #67e8f9 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-desc {
  font-size: clamp(1.05rem, 2vw, 1.25rem);
  color: var(--text-muted);
  max-width: 620px;
  margin: 1.5rem auto 2.5rem;
  font-weight: 400;
  animation: fadeUp 0.8s 0.2s ease both;
}

.hero-stats {
  display: flex;
  gap: 3rem;
  flex-wrap: wrap;
  justify-content: center;
  animation: fadeUp 0.8s 0.3s ease both;
}

.hero-stat strong {
  display: block;
  font-size: 2rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--gradient-1), var(--gradient-3));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-stat span {
  font-size: 0.85rem;
  color: var(--text-dim);
}

.hero-cta {
  display: flex;
  gap: 1rem;
  margin-top: 2.5rem;
  animation: fadeUp 0.8s 0.4s ease both;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(24px); }
  to { opacity: 1; transform: translateY(0); }
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.85rem 1.75rem;
  border-radius: 12px;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  border: none;
  transition: var(--transition);
}

.btn-primary {
  background: linear-gradient(135deg, var(--gradient-1), var(--gradient-2));
  color: white;
  box-shadow: 0 8px 32px var(--accent-glow);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 40px var(--accent-glow);
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--border-hover);
}

/* Sections */
.section {
  padding: 5rem clamp(1.25rem, 4vw, 3rem);
  max-width: 1280px;
  margin: 0 auto;
}

.section-header {
  text-align: center;
  margin-bottom: 3.5rem;
}

.section-label {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.15em;
  margin-bottom: 0.75rem;
}

.section-header h2 {
  font-size: clamp(2rem, 4vw, 2.75rem);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.section-header p {
  color: var(--text-muted);
  max-width: 560px;
  margin: 0.75rem auto 0;
}

/* Module cards grid */
.modules-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.5rem;
}

.module-card {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem;
  text-decoration: none;
  color: inherit;
  overflow: hidden;
  transition: var(--transition);
  backdrop-filter: blur(12px);
}

.module-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--card-accent, var(--accent));
  opacity: 0;
  transition: var(--transition);
}

.module-card:hover {
  transform: translateY(-6px);
  border-color: var(--border-hover);
  box-shadow: var(--shadow);
}

.module-card:hover::before { opacity: 1; }

.module-card-icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 1.25rem;
  font-family: var(--font-mono);
}

.module-card h3 {
  font-size: 1.35rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.module-card > p {
  color: var(--text-muted);
  font-size: 0.92rem;
  margin-bottom: 1.25rem;
  line-height: 1.55;
}

.module-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.module-tag {
  font-size: 0.72rem;
  padding: 0.25rem 0.6rem;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-dim);
  font-family: var(--font-mono);
}

/* Module page */
.module-hero {
  padding: calc(var(--nav-h) + 3rem) clamp(1.25rem, 4vw, 3rem) 3rem;
  max-width: 1280px;
  margin: 0 auto;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.88rem;
  color: var(--text-dim);
  margin-bottom: 1.5rem;
}

.breadcrumb a {
  color: var(--text-muted);
  text-decoration: none;
}

.breadcrumb a:hover { color: var(--accent); }

.module-hero-header {
  display: flex;
  align-items: flex-start;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.module-hero-icon {
  width: 72px;
  height: 72px;
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: 700;
  font-family: var(--font-mono);
  flex-shrink: 0;
}

.module-hero h1 {
  font-size: clamp(2rem, 4vw, 2.75rem);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.module-hero-desc {
  color: var(--text-muted);
  margin-top: 0.5rem;
  max-width: 640px;
}

.module-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 2.5rem;
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 clamp(1.25rem, 4vw, 3rem) 5rem;
}

.sidebar {
  position: sticky;
  top: calc(var(--nav-h) + 1.5rem);
  height: fit-content;
}

.sidebar-nav {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  backdrop-filter: blur(12px);
}

.sidebar-nav h4 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.25rem;
}

.sidebar-nav a {
  display: block;
  padding: 0.6rem 0.75rem;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  border-radius: 8px;
  transition: var(--transition);
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
}

/* Topic sections */
.topic-section {
  margin-bottom: 3rem;
  scroll-margin-top: calc(var(--nav-h) + 1.5rem);
}

.topic-section h2 {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.topic-section h2 .num {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text-dim);
  font-weight: 500;
}

.article-cards {
  display: grid;
  gap: 1rem;
}

.article-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1.35rem 1.5rem;
  text-decoration: none;
  color: inherit;
  transition: var(--transition);
  display: block;
}

.article-card:hover {
  border-color: var(--border-hover);
  background: rgba(22, 24, 34, 0.9);
  transform: translateX(4px);
}

.article-card h3 {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
}

.article-card p {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.55;
}

.article-meta {
  display: flex;
  gap: 1rem;
  margin-top: 0.75rem;
  font-size: 0.78rem;
  color: var(--text-dim);
  font-family: var(--font-mono);
}

/* Article reader */
.article-page {
  max-width: 780px;
  margin: 0 auto;
  padding: calc(var(--nav-h) + 2rem) clamp(1.25rem, 4vw, 3rem) 5rem;
}

.article-page header {
  margin-bottom: 2.5rem;
}

.article-page .category {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.article-page h1 {
  font-size: clamp(1.85rem, 4vw, 2.5rem);
  font-weight: 700;
  line-height: 1.2;
  margin: 0.75rem 0 1rem;
  letter-spacing: -0.02em;
}

.article-page .lead {
  font-size: 1.15rem;
  color: var(--text-muted);
  line-height: 1.7;
}

.article-content {
  font-size: 1.02rem;
  line-height: 1.8;
}

.article-content h2 {
  font-size: 1.45rem;
  font-weight: 600;
  margin: 2.5rem 0 1rem;
  padding-top: 0.5rem;
}

.article-content h3 {
  font-size: 1.15rem;
  font-weight: 600;
  margin: 1.75rem 0 0.75rem;
}

.article-content p {
  margin-bottom: 1.15rem;
  color: var(--text-body);
}

.article-content ul,
.article-content ol {
  margin: 0 0 1.15rem 1.5rem;
  color: var(--text-body);
}

.article-content li { margin-bottom: 0.4rem; }

.article-content code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: rgba(99, 102, 241, 0.12);
  color: #a5b4fc;
  padding: 0.15em 0.45em;
  border-radius: 5px;
}

.article-content pre {
  background: #0d0e14;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1.25rem 1.5rem;
  overflow-x: auto;
  margin: 1.25rem 0 1.5rem;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.6;
  color: #c5c9d6;
}

.article-content pre code {
  background: none;
  padding: 0;
  color: inherit;
}

.article-content blockquote {
  border-left: 3px solid var(--accent);
  padding: 0.75rem 0 0.75rem 1.25rem;
  margin: 1.5rem 0;
  color: var(--text-muted);
  font-style: italic;
}

.article-content .tip {
  background: rgba(34, 197, 94, 0.08);
  border: 1px solid rgba(34, 197, 94, 0.2);
  border-radius: var(--radius-sm);
  padding: 1rem 1.25rem;
  margin: 1.5rem 0;
  font-size: 0.95rem;
}

.article-content .tip strong {
  color: #4ade80;
  display: block;
  margin-bottom: 0.35rem;
}

.article-nav {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
}

.article-nav a {
  flex: 1;
  max-width: 48%;
  padding: 1rem 1.25rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: inherit;
  transition: var(--transition);
}

.article-nav a:hover {
  border-color: var(--border-hover);
}

.article-nav .label {
  font-size: 0.75rem;
  color: var(--text-dim);
  font-family: var(--font-mono);
}

.article-nav .title {
  font-weight: 600;
  margin-top: 0.25rem;
  font-size: 0.95rem;
}

.article-nav .next { text-align: right; }

/* Footer */
.footer {
  border-top: 1px solid var(--border);
  padding: 3rem clamp(1.25rem, 4vw, 3rem);
  text-align: center;
  color: var(--text-dim);
  font-size: 0.88rem;
}

.footer-brand {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text);
  margin-bottom: 0.5rem;
}

.footer-links {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  margin: 1rem 0;
  flex-wrap: wrap;
}

.footer-links a {
  color: var(--text-muted);
  text-decoration: none;
}

.footer-links a:hover { color: var(--accent); }

/* Search */
.search-box {
  position: relative;
  max-width: 400px;
  margin: 0 auto 2rem;
}

.search-box input {
  width: 100%;
  padding: 0.85rem 1rem 0.85rem 2.75rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
  outline: none;
  transition: var(--transition);
}

.search-box input:focus {
  border-color: rgba(99, 102, 241, 0.5);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.search-box svg {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
}

/* Responsive */
@media (max-width: 900px) {
  .module-layout {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: static;
  }
  .sidebar-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
  }
  .sidebar-nav h4 { width: 100%; }
  .nav-links { display: none; }
  .nav-links.open {
    display: flex;
    flex-direction: column;
    position: absolute;
    top: var(--nav-h);
    left: 0;
    right: 0;
    background: rgba(10, 11, 15, 0.98);
    padding: 1rem;
    border-bottom: 1px solid var(--border);
  }
  .nav-toggle { display: block; }
  .nav-actions { margin-left: auto; }
}

/* Comments */
.comments-section {
  margin-top: 3.5rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
}

.comments-title {
  font-size: 1.35rem;
  font-weight: 600;
  margin-bottom: 1.25rem;
}

.comment-count {
  font-size: 0.9rem;
  color: var(--text-dim);
  font-weight: 400;
}

.comment-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 2rem;
  max-width: 560px;
}

.comment-form input,
.comment-form textarea {
  font-family: inherit;
  font-size: 0.95rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  outline: none;
  transition: var(--transition);
}

.comment-form input:focus,
.comment-form textarea:focus {
  border-color: rgba(99, 102, 241, 0.5);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}

.comment-form textarea { resize: vertical; min-height: 100px; }

.comment-hint {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin: 0;
}

.comment-list { display: flex; flex-direction: column; gap: 1rem; }

.comment-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem 1.25rem;
}

.comment-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.5rem;
  font-size: 0.88rem;
}

.comment-item-header strong { color: var(--text); }

.comment-item-header time { color: var(--text-dim); font-family: var(--font-mono); font-size: 0.78rem; }

.comment-item p {
  color: var(--text-body);
  font-size: 0.95rem;
  line-height: 1.6;
}

.comment-empty { color: var(--text-muted); font-size: 0.95rem; }

.loading-state, .error-msg {
  color: var(--text-muted);
  padding: 2rem 0;
  text-align: center;
}

.error-msg { color: #f87171; }

.article-content blockquote {
  border-left: 3px solid var(--accent);
  padding: 0.75rem 0 0.75rem 1.25rem;
  margin: 1.5rem 0;
  color: var(--text-muted);
}

@media (max-width: 600px) {
  .hero-stats { gap: 1.5rem; }
  .hero-cta { flex-direction: column; width: 100%; max-width: 280px; }
  .btn { justify-content: center; }
}
