/* =========================================
   Modern Technical Blog Style 2026
   Clean, Minimalist, Developer-Friendly
   ========================================= */

/* CSS Variables - Light/Dark Mode */
:root {
  /* Light theme */
  --bg-primary: #ffffff;
  --bg-secondary: #f8f9fa;
  --bg-tertiary: #e9ecef;
  --text-primary: #212529;
  --text-secondary: #495057;
  --text-muted: #6c757d;
  --accent: #228be6;
  --accent-hover: #1c7ed6;
  --border: #dee2e6;
  --code-bg: #f1f3f5;
  --card-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 4px 12px rgba(0,0,0,0.05);
  --transition: all 0.2s ease;
}

[data-theme="dark"] {
  --bg-primary: #1a1b1e;
  --bg-secondary: #25262b;
  --bg-tertiary: #2c2e33;
  --text-primary: #f1f3f5;
  --text-secondary: #ced4da;
  --text-muted: #909296;
  --accent: #4dabf7;
  --accent-hover: #339af0;
  --border: #373a40;
  --code-bg: #2c2e33;
  --card-shadow: 0 1px 3px rgba(0,0,0,0.3), 0 4px 12px rgba(0,0,0,0.2);
}

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

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  line-height: 1.6;
  transition: var(--transition);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Container */
.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* Site wrapper */
.site {
  background-color: var(--bg-primary);
  min-height: 100vh;
  box-shadow: 0 0 40px rgba(0,0,0,0.05);
}

/* Header */
.header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 3rem 0;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.header::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: url('/articles/assets/images/home-bg.png') center/cover;
  opacity: 0.15;
}

.header-content {
  position: relative;
  z-index: 1;
}

.header h1 {
  font-size: 2.5rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  letter-spacing: -0.5px;
}

.header .sub-title {
  font-size: 1.1rem;
  opacity: 0.9;
  font-weight: 400;
}

.header-nav {
  margin-top: 1.5rem;
  display: flex;
  justify-content: center;
  gap: 1.5rem;
}

.header-nav a {
  color: white;
  font-size: 1.5rem;
  transition: transform 0.2s ease, opacity 0.2s ease;
  display: inline-block;
}

.header-nav a:hover {
  transform: translateY(-3px);
  opacity: 0.8;
}

/* Theme Toggle */
.theme-toggle {
  position: fixed;
  top: 1rem;
  right: 1rem;
  background: var(--bg-tertiary);
  border: none;
  border-radius: 50%;
  width: 48px;
  height: 48px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  box-shadow: var(--card-shadow);
  z-index: 1000;
  transition: var(--transition);
}

.theme-toggle:hover {
  transform: scale(1.1);
}

/* Main content */
.site > .container {
  padding: 2rem 0;
}

/* Article Card List */
.posts-list {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.post-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  transition: var(--transition);
  box-shadow: var(--card-shadow);
  position: relative;
  overflow: hidden;
}

.post-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: linear-gradient(90deg, #667eea, #764ba2, #f093fb);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.post-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
}

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

.post-card .post-date {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  font-family: 'SF Mono', Monaco, monospace;
}

.post-card .post-title {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
  letter-spacing: -0.3px;
}

.post-card .post-title a {
  color: var(--text-primary);
  text-decoration: none;
  transition: color 0.2s ease;
}

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

.post-card .post-excerpt {
  color: var(--text-secondary);
  margin-bottom: 1rem;
  line-height: 1.7;
}

.post-card .post-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
}

.post-card .category {
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  color: white;
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

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

.post-card .tag {
  color: var(--text-secondary);
  background: var(--bg-tertiary);
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  font-size: 0.75rem;
  text-decoration: none;
  transition: var(--transition);
  border: 1px solid transparent;
}

.post-card .tag:hover {
  background: var(--accent);
  color: white;
  border-color: var(--accent-hover);
  transform: translateY(-1px);
}

.post-card .author {
  color: var(--text-muted);
  margin-left: auto;
  font-size: 0.8rem;
}

/* Category Pages */
.category-header {
  text-align: center;
  padding: 2rem 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2rem;
}

.category-header h1 {
  font-size: 2rem;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

/* Pagination */
.pagination {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin: 3rem 0;
}

.pagination a,
.pagination span {
  padding: 0.5rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  text-decoration: none;
  color: var(--text-primary);
  transition: var(--transition);
}

.pagination a:hover {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.pagination .current {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

/* Footer */
.footer {
  text-align: center;
  padding: 2rem 0;
  color: var(--text-muted);
  font-size: 0.9rem;
  border-top: 1px solid var(--border);
  margin-top: 4rem;
}

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

.footer a:hover {
  text-decoration: underline;
}

/* Reading progress bar */
.progress-container {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: transparent;
  z-index: 9999;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #667eea, #764ba2);
  width: 0%;
  transition: width 0.1s ease;
}

/* Single Post Page */
.post-content {
  max-width: 800px;
  margin: 0 auto;
  padding: 2rem 0;
}

.post-header {
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.post-header h1 {
  font-size: 2.25rem;
  font-weight: 800;
  letter-spacing: -1px;
  line-height: 1.2;
  margin-bottom: 1rem;
  color: var(--text-primary);
}

.post-header .post-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  font-size: 0.9rem;
  color: var(--text-muted);
  border: none;
  padding: 0;
  margin: 0;
}

.post-header .category {
  background: var(--accent);
  color: white;
  padding: 0.3rem 0.8rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}

/* Table of Contents */
.toc {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  margin: 2rem 0;
}

.toc-title {
  font-weight: 700;
  margin-bottom: 1rem;
  color: var(--text-primary);
}

.toc ul {
  list-style: none;
  padding-left: 0;
}

.toc li {
  padding: 0.3rem 0;
  color: var(--text-secondary);
}

.toc a {
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 0.2s;
}

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

.toc .toc-h2 { padding-left: 0; }
.toc .toc-h3 { padding-left: 1rem; }
.toc .toc-h4 { padding-left: 2rem; }

/* Article Body */
.post-content {
  font-size: 1.05rem;
  line-height: 1.8;
}

.post-content h1,
.post-content h2,
.post-content h3,
.post-content h4 {
  margin-top: 2rem;
  margin-bottom: 1rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--text-primary);
}

.post-content h1 { font-size: 1.8rem; }
.post-content h2 { font-size: 1.5rem; border-bottom: 2px solid var(--border); padding-bottom: 0.5rem; }
.post-content h3 { font-size: 1.3rem; }
.post-content h4 { font-size: 1.15rem; }

.post-content p {
  margin-bottom: 1.2rem;
}

.post-content ul,
.post-content ol {
  margin: 1rem 0 1.5rem 1.5rem;
}

.post-content li {
  margin-bottom: 0.5rem;
}

.post-content blockquote {
  border-left: 4px solid var(--accent);
  padding-left: 1.5rem;
  margin: 1.5rem 0;
  color: var(--text-secondary);
  font-style: italic;
  background: var(--bg-secondary);
  padding: 1rem 1.5rem;
  border-radius: 0 8px 8px 0;
}

.post-content code {
  background: var(--code-bg);
  padding: 0.2em 0.4em;
  border-radius: 4px;
  font-size: 0.85em;
  font-family: 'SF Mono', Monaco, 'Consolas', 'Fira Code', monospace;
  color: var(--text-primary);
}

.post-content pre {
  background: var(--code-bg);
  padding: 1.5rem;
  border-radius: 12px;
  overflow-x: auto;
  margin: 1.5rem 0;
  border: 1px solid var(--border);
  position: relative;
}

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

/* Code block header with language label */
.code-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-tertiary);
  padding: 0.5rem 1rem;
  border-radius: 12px 12px 0 0;
  margin: -1.5rem -1.5rem 1.5rem -1.5rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

/* Links */
.post-content a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: var(--transition);
}

.post-content a:hover {
  color: var(--accent-hover);
  border-bottom-color: var(--accent);
}

/* Tables */
.post-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  display: block;
  overflow-x: auto;
}

.post-content th,
.post-content td {
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  text-align: left;
}

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

.post-content tr:nth-child(even) {
  background: var(--bg-secondary);
}

/* Images */
.post-content img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  margin: 1.5rem 0;
  box-shadow: var(--card-shadow);
}

/* Blockquotes */
.post-content blockquote {
  border-left: 4px solid var(--accent);
  padding-left: 1.5rem;
  margin: 1.5rem 0;
  color: var(--text-secondary);
  font-style: italic;
  background: var(--bg-secondary);
  padding: 1rem 1.5rem;
  border-radius: 0 8px 8px 0;
}

.post-content img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  margin: 1.5rem 0;
}

.post-content hr {
  border: none;
  border-top: 2px solid var(--border);
  margin: 3rem 0;
}

/* Back to home link */
.back-home {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 2rem;
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
  transition: var(--transition);
}

.back-home:hover {
  gap: 0.75rem;
}

/* Responsive */
@media (max-width: 768px) {
  .container {
    padding: 0 1rem;
  }
  
  .header {
    padding: 2rem 0;
  }
  
  .header h1 {
    font-size: 1.8rem;
  }
  
  .site {
    width: 100%;
  }
  
  .site > .container {
    padding: 1.5rem 0;
  }
  
  .post-card {
    padding: 1.25rem;
  }
  
  .post-card .post-title {
    font-size: 1.2rem;
  }
  
  .post-header h1 {
    font-size: 1.75rem;
  }
}

/* Print styles */
@media print {
  .header,
  .footer,
  .theme-toggle,
  .progress-container {
    display: none;
  }
  
  body {
    background: white;
  }
  
  .site {
    box-shadow: none;
  }
}

/* Selection color */
::selection {
  background: rgba(34, 139, 230, 0.2);
}

::-moz-selection {
  background: rgba(34, 139, 230, 0.2);
}

/* Smooth scrolling for anchor links */
html {
  scroll-behavior: smooth;
}

/* Focus styles for accessibility */
a:focus,
button:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Scroll margins for fixed headers */
[id] {
  scroll-margin-top: 4rem;
}

/* Quick Tags on Homepage */
.quick-tags {
    margin-top: 1.5rem;
}

.quick-tag {
    position: relative;
    transition: var(--transition);
}

.quick-tag:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

/* Responsive adjustments for quick tags */
@media (max-width: 768px) {
    .quick-tags {
        display: flex;
        flex-wrap: wrap;
        gap: 0.4rem;
    }
    
    .quick-tag {
        font-size: 0.8rem !important;
        padding: 0.3rem 0.6rem !important;
    }
}

/* Post card excerpt */
.post-excerpt {
    color: var(--text-secondary);
    margin-bottom: 1rem;
    line-height: 1.7;
}

/* Author in post card */
.post-card .author {
    color: var(--text-muted);
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

/* Tag navigation in header (optional responsive) */
@media (max-width: 600px) {
    .header-nav a {
        font-size: 1.2rem;
        padding: 0.3rem;
    }
    
    .header h1 {
        font-size: 1.5rem;
    }
}