/* ============================================
   TECHNICAL BLOG DESIGN SYSTEM
   Theme: Dark-first, modern technical blog
   Font: Inter (Google Fonts loaded in layout)
   ============================================ */

/* --- CSS Custom Properties --- */
:root {
  /* Colors - Dark Mode (default) */
  --bg-primary: #0f1117;
  --bg-secondary: #161822;
  --bg-card: #1c1f2e;
  --bg-card-hover: #232738;
  --bg-code: #1a1d2e;
  --bg-nav: rgba(15, 17, 23, 0.85);
  --text-primary: #e4e6f0;
  --text-secondary: #9ca3b8;
  --text-muted: #6b7394;
  --accent: #22d3ee;
  --accent-secondary: #06b6d4;
  --accent-gradient: linear-gradient(135deg, #22d3ee, #0ea5e9);
  --border-color: rgba(255, 255, 255, 0.06);
  --border-hover: rgba(34, 211, 238, 0.3);
  --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.25);
  --shadow-card-hover: 0 8px 40px rgba(0, 0, 0, 0.4);
  --tag-bg: rgba(34, 211, 238, 0.1);
  --tag-text: #22d3ee;
  --hero-bg: linear-gradient(135deg, #0f1117 0%, #1a1040 50%, #0f1117 100%);

  /* Typography */
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
  --fs-xs: 0.75rem;
  --fs-sm: 0.875rem;
  --fs-base: 1rem;
  --fs-lg: 1.125rem;
  --fs-xl: 1.25rem;
  --fs-2xl: 1.5rem;
  --fs-3xl: 1.875rem;
  --fs-4xl: 2.25rem;
  --fs-hero: clamp(2rem, 5vw, 3.5rem);

  /* Spacing */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;
  --space-3xl: 4rem;

  /* Layout */
  --max-width: 1200px;
  --content-width: 800px;
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 16px;

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 250ms ease;
  --transition-slow: 400ms ease;
}

/* Light mode */
[data-theme="light"] {
  --bg-primary: #f8f9fc;
  --bg-secondary: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #f0f2f8;
  --bg-code: #f4f5f9;
  --bg-nav: rgba(248, 249, 252, 0.9);
  --text-primary: #1a1d2e;
  --text-secondary: #4a5068;
  --text-muted: #8890a8;
  --accent: #0891b2;
  --accent-secondary: #06b6d4;
  --accent-gradient: linear-gradient(135deg, #0891b2, #0284c7);
  --border-color: rgba(0, 0, 0, 0.08);
  --border-hover: rgba(8, 145, 178, 0.3);
  --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.06);
  --shadow-card-hover: 0 8px 40px rgba(0, 0, 0, 0.1);
  --tag-bg: rgba(8, 145, 178, 0.08);
  --tag-text: #0891b2;
  --hero-bg: linear-gradient(135deg, #f8f9fc 0%, #e0e7ff 50%, #f8f9fc 100%);
}

/* --- Reset & Base --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-body);
  font-size: var(--fs-base);
  line-height: 1.7;
  color: var(--text-primary);
  background-color: var(--bg-primary);
  transition: background-color var(--transition-base), color var(--transition-base);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--transition-fast);
}

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

img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-md);
}

/* --- Navigation --- */
.site-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-nav);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-color);
  padding: var(--space-md) 0;
}

.nav-container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--space-xl);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: var(--fs-xl);
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.nav-brand:hover {
  color: var(--accent);
}

.nav-brand .brand-icon {
  font-size: var(--fs-2xl);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
  list-style: none;
}

.nav-links a {
  color: var(--text-secondary);
  font-size: var(--fs-sm);
  font-weight: 500;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  padding: var(--space-xs) 0;
  position: relative;
  transition: color var(--transition-fast);
}

.nav-links a::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--accent-gradient);
  border-radius: 1px;
  transition: width var(--transition-base);
}

.nav-links a:hover {
  color: var(--text-primary);
}

.nav-links a:hover::after {
  width: 100%;
}

/* Theme Toggle */
.theme-toggle {
  background: none;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  cursor: pointer;
  padding: var(--space-sm);
  border-radius: var(--radius-sm);
  font-size: var(--fs-lg);
  line-height: 1;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
}

.theme-toggle:hover {
  background: var(--bg-card);
  color: var(--accent);
  border-color: var(--border-hover);
}

/* Mobile menu */
.nav-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: var(--fs-xl);
  cursor: pointer;
  padding: var(--space-sm);
}

/* --- Hero Section --- */
.hero {
  background: var(--hero-bg);
  padding: var(--space-3xl) var(--space-xl);
  text-align: center;
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(34, 211, 238, 0.08) 0%, transparent 70%);
  pointer-events: none;
}

.hero-content {
  max-width: var(--content-width);
  margin: 0 auto;
  position: relative;
  z-index: 1;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  background: var(--tag-bg);
  color: var(--tag-text);
  padding: var(--space-xs) var(--space-md);
  border-radius: 50px;
  font-size: var(--fs-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: var(--space-lg);
  border: 1px solid rgba(34, 211, 238, 0.15);
}

.hero h1 {
  font-size: var(--fs-hero);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.03em;
  margin-bottom: var(--space-lg);
}

.hero h1 .gradient-text {
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero p {
  font-size: var(--fs-lg);
  color: var(--text-secondary);
  max-width: 600px;
  margin: 0 auto;
  line-height: 1.8;
}

/* --- Main Content --- */
.site-main {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: var(--space-2xl) var(--space-xl);
  width: 100%;
  flex: 1;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-xl);
}

.section-header h2 {
  font-size: var(--fs-2xl);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.section-header .view-all {
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--accent);
}

/* --- Post Grid --- */
.post-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: var(--space-xl);
}

/* --- Post Card --- */
.post-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: all var(--transition-base);
  display: flex;
  flex-direction: column;
}

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

.post-card-thumbnail {
  width: 100%;
  height: 200px;
  object-fit: cover;
  background: linear-gradient(135deg, var(--bg-secondary), var(--bg-card));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  color: var(--text-muted);
  position: relative;
  overflow: hidden;
}

.post-card-thumbnail::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(34, 211, 238, 0.05) 0%, rgba(14, 165, 233, 0.05) 100%);
}

.post-card-body {
  padding: var(--space-lg);
  display: flex;
  flex-direction: column;
  flex: 1;
}

.post-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}

.tag {
  background: var(--tag-bg);
  color: var(--tag-text);
  padding: 2px var(--space-sm);
  border-radius: var(--radius-sm);
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.02em;
}

.post-card-title {
  font-size: var(--fs-xl);
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: -0.01em;
  margin-bottom: var(--space-sm);
}

.post-card-title a {
  color: var(--text-primary);
  transition: color var(--transition-fast);
}

.post-card-title a:hover {
  color: var(--accent);
}

.post-card-excerpt {
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: var(--space-md);
  flex: 1;
}

.post-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: var(--space-md);
  border-top: 1px solid var(--border-color);
  font-size: var(--fs-xs);
  color: var(--text-muted);
}

.post-card-meta .read-time {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* --- Featured Post --- */
.featured-post {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: var(--space-2xl);
  margin-bottom: var(--space-2xl);
  position: relative;
  overflow: hidden;
  transition: all var(--transition-base);
}

.featured-post:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow-card-hover);
}

.featured-post::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--accent-gradient);
}

.featured-label {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  background: var(--accent-gradient);
  color: #fff;
  padding: 3px var(--space-md);
  border-radius: 50px;
  font-size: var(--fs-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: var(--space-lg);
}

.featured-post h2 {
  font-size: var(--fs-3xl);
  font-weight: 800;
  line-height: 1.25;
  letter-spacing: -0.02em;
  margin-bottom: var(--space-md);
}

.featured-post h2 a {
  color: var(--text-primary);
}

.featured-post h2 a:hover {
  color: var(--accent);
}

.featured-post .excerpt {
  font-size: var(--fs-lg);
  color: var(--text-secondary);
  line-height: 1.8;
  margin-bottom: var(--space-lg);
}

.featured-meta {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
  font-size: var(--fs-sm);
  color: var(--text-muted);
}

/* --- Article (Post) Layout --- */
.article-container {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: var(--space-2xl) var(--space-xl);
}

.article-header {
  margin-bottom: var(--space-2xl);
  padding-bottom: var(--space-xl);
  border-bottom: 1px solid var(--border-color);
}

.article-header .post-tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
}

.article-header h1 {
  font-size: var(--fs-4xl);
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.03em;
  margin-bottom: var(--space-lg);
}

.article-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-lg);
  color: var(--text-muted);
  font-size: var(--fs-sm);
}

.article-meta .meta-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* --- Article Content --- */
.article-content {
  font-size: var(--fs-lg);
  line-height: 1.85;
  color: var(--text-secondary);
}

.article-content h2 {
  font-size: var(--fs-2xl);
  font-weight: 700;
  color: var(--text-primary);
  margin-top: var(--space-2xl);
  margin-bottom: var(--space-md);
  letter-spacing: -0.02em;
}

.article-content h3 {
  font-size: var(--fs-xl);
  font-weight: 600;
  color: var(--text-primary);
  margin-top: var(--space-xl);
  margin-bottom: var(--space-md);
}

.article-content p {
  margin-bottom: var(--space-lg);
}

.article-content ul, .article-content ol {
  margin-bottom: var(--space-lg);
  padding-left: var(--space-xl);
}

.article-content li {
  margin-bottom: var(--space-sm);
}

.article-content strong {
  color: var(--text-primary);
  font-weight: 600;
}

.article-content a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: rgba(34, 211, 238, 0.3);
  text-underline-offset: 3px;
  transition: text-decoration-color var(--transition-fast);
}

.article-content a:hover {
  text-decoration-color: var(--accent);
}

.article-content blockquote {
  border-left: 3px solid var(--accent);
  padding: var(--space-md) var(--space-lg);
  margin: var(--space-xl) 0;
  background: var(--bg-card);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  color: var(--text-secondary);
  font-style: italic;
}

/* Code Blocks */
.article-content code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--bg-code);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--accent);
}

.article-content pre {
  background: var(--bg-code);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  overflow-x: auto;
  margin: var(--space-xl) 0;
  position: relative;
}

.article-content pre code {
  background: none;
  padding: 0;
  color: var(--text-primary);
  font-size: var(--fs-sm);
  line-height: 1.7;
}

.article-content table {
  width: 100%;
  border-collapse: collapse;
  margin: var(--space-xl) 0;
  font-size: var(--fs-sm);
}

.article-content th, .article-content td {
  text-align: left;
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--border-color);
}

.article-content th {
  color: var(--text-primary);
  font-weight: 600;
  background: var(--bg-card);
}

.article-content img {
  margin: var(--space-xl) 0;
  border: 1px solid var(--border-color);
}

/* --- Article Footer --- */
.article-footer {
  margin-top: var(--space-2xl);
  padding-top: var(--space-xl);
  border-top: 1px solid var(--border-color);
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  color: var(--accent);
  font-weight: 500;
  font-size: var(--fs-sm);
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.back-link:hover {
  background: var(--tag-bg);
  border-color: var(--border-hover);
}

/* --- Related Posts --- */
.related-posts {
  margin-top: var(--space-2xl);
}

.related-posts h3 {
  font-size: var(--fs-xl);
  font-weight: 700;
  margin-bottom: var(--space-lg);
}

.related-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: var(--space-md);
}

.related-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  transition: all var(--transition-fast);
}

.related-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-2px);
}

.related-card h4 {
  font-size: var(--fs-base);
  font-weight: 600;
  margin-bottom: var(--space-xs);
}

.related-card h4 a {
  color: var(--text-primary);
}

.related-card h4 a:hover {
  color: var(--accent);
}

.related-card .date {
  font-size: var(--fs-xs);
  color: var(--text-muted);
}

/* --- Footer --- */
.site-footer {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  padding: var(--space-2xl) var(--space-xl);
  margin-top: auto;
}

.footer-container {
  max-width: var(--max-width);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: var(--space-2xl);
}

.footer-brand h3 {
  font-size: var(--fs-xl);
  font-weight: 700;
  margin-bottom: var(--space-md);
}

.footer-brand p {
  color: var(--text-secondary);
  font-size: var(--fs-sm);
  line-height: 1.7;
  max-width: 350px;
}

.footer-section h4 {
  font-size: var(--fs-sm);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: var(--space-md);
}

.footer-section ul {
  list-style: none;
}

.footer-section li {
  margin-bottom: var(--space-sm);
}

.footer-section a {
  color: var(--text-secondary);
  font-size: var(--fs-sm);
  transition: color var(--transition-fast);
}

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

.footer-bottom {
  max-width: var(--max-width);
  margin: var(--space-xl) auto 0;
  padding-top: var(--space-lg);
  border-top: 1px solid var(--border-color);
  text-align: center;
  color: var(--text-muted);
  font-size: var(--fs-xs);
}

/* --- Empty State --- */
.empty-state {
  text-align: center;
  padding: var(--space-3xl) var(--space-xl);
}

.empty-state .emoji {
  font-size: 3rem;
  margin-bottom: var(--space-md);
}

.empty-state h3 {
  font-size: var(--fs-xl);
  margin-bottom: var(--space-sm);
}

.empty-state p {
  color: var(--text-secondary);
}

/* --- Responsive --- */
@media (max-width: 768px) {
  .nav-links {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-nav);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-color);
    flex-direction: column;
    padding: var(--space-md) var(--space-xl);
    gap: var(--space-sm);
  }

  .nav-links.open {
    display: flex;
  }

  .nav-toggle {
    display: block;
  }

  .post-grid {
    grid-template-columns: 1fr;
  }

  .footer-container {
    grid-template-columns: 1fr;
    gap: var(--space-xl);
  }

  .hero {
    padding: var(--space-2xl) var(--space-lg);
  }

  .featured-post {
    padding: var(--space-lg);
  }

  .article-header h1 {
    font-size: var(--fs-2xl);
  }

  .article-container {
    padding: var(--space-lg);
  }
}

@media (max-width: 480px) {
  .post-grid {
    grid-template-columns: 1fr;
  }
  
  .post-card-thumbnail {
    height: 160px;
  }

  .related-grid {
    grid-template-columns: 1fr;
  }
}

/* --- Selection --- */
::selection {
  background: rgba(34, 211, 238, 0.25);
  color: var(--text-primary);
}

/* --- Scrollbar --- */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
  background: var(--text-muted);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}

/* --- Animations --- */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.post-card {
  animation: fadeInUp 0.5s ease both;
}

.post-card:nth-child(2) { animation-delay: 0.1s; }
.post-card:nth-child(3) { animation-delay: 0.2s; }
.post-card:nth-child(4) { animation-delay: 0.3s; }
.post-card:nth-child(5) { animation-delay: 0.4s; }
.post-card:nth-child(6) { animation-delay: 0.5s; }
