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

:root {
  --bg:        #0d1117;
  --surface:   #161b22;
  --surface2:  #1e2530;
  --border:    #30363d;
  --text:      #c9d1d9;
  --text-muted:#8b949e;
  --heading:   #e6edf3;
  --accent:    #58a6ff;
  --accent2:   #3d8bcd;
  --green:     #3fb950;
  --tag-bg:    #1e2d3d;
  --tag-text:  #58a6ff;
  --code-bg:   #1e1e2e;
  --radius:    8px;
  --radius-sm: 4px;
  --font:      -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-mono: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  --max-w:     1100px;
  --post-w:    760px;
}

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.65;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; height: auto; display: block; }

/* ============================================================
   LAYOUT HELPERS
   ============================================================ */
.container {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 24px;
}

main { flex: 1; }

/* ============================================================
   HEADER
   ============================================================ */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
}

.site-title a {
  color: var(--heading);
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.site-title a:hover { text-decoration: none; color: var(--accent); }

.site-header nav {
  display: flex;
  gap: 8px;
}

.site-header nav a {
  color: var(--text-muted);
  font-size: 0.9rem;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  transition: color 0.15s, background 0.15s;
}

.site-header nav a:hover {
  color: var(--heading);
  background: var(--surface2);
  text-decoration: none;
}

/* ============================================================
   HERO
   ============================================================ */
.hero {
  padding: 64px 0 48px;
  border-bottom: 1px solid var(--border);
}

.hero-inner {
  display: flex;
  align-items: center;
  gap: 40px;
}

.hero-avatar-wrap {
  flex-shrink: 0;
}

.hero-avatar {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  border: 3px solid var(--border);
  object-fit: cover;
  background: var(--surface2);
}

.hero-text { flex: 1; }

.hero-name {
  font-size: 2rem;
  font-weight: 700;
  color: var(--heading);
  letter-spacing: -0.5px;
  margin-bottom: 6px;
}

.hero-tagline {
  font-size: 1.05rem;
  color: var(--accent);
  margin-bottom: 14px;
}

.hero-bio {
  color: var(--text);
  font-size: 0.97rem;
  max-width: 560px;
  margin-bottom: 20px;
}

.hero-links {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.hero-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  font-size: 0.9rem;
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: 20px;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.hero-link:hover {
  color: var(--heading);
  border-color: var(--accent);
  background: var(--tag-bg);
  text-decoration: none;
}

/* ============================================================
   SEARCH (HOME)
   ============================================================ */
.search-section {
  padding: 48px 0;
  border-bottom: 1px solid var(--border);
}

.search-wrap {
  position: relative;
  max-width: 620px;
  margin: 0 auto;
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 14px;
  color: var(--text-muted);
  pointer-events: none;
  flex-shrink: 0;
}

.search-input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--heading);
  font-size: 1rem;
  font-family: var(--font);
  padding: 13px 44px 13px 44px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.search-input::placeholder { color: var(--text-muted); }

.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(88,166,255,0.15);
}

.search-clear {
  position: absolute;
  right: 12px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.3rem;
  cursor: pointer;
  line-height: 1;
  padding: 4px;
}
.search-clear:hover { color: var(--heading); }

.search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  max-height: 400px;
  overflow-y: auto;
  z-index: 200;
}

.search-result-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  transition: background 0.1s;
}

.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: var(--surface2); text-decoration: none; }

.result-title {
  color: var(--heading);
  font-size: 0.95rem;
  font-weight: 500;
}

.result-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.search-empty {
  padding: 20px;
  color: var(--text-muted);
  text-align: center;
  font-size: 0.9rem;
}

/* ============================================================
   TAGS SECTION (HOME)
   ============================================================ */
.tags-section {
  padding: 56px 0 64px;
}

.section-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--heading);
  margin-bottom: 6px;
}

.section-subtitle {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 32px;
}

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

.tags-loading {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.tag-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  text-decoration: none;
  display: flex;
  flex-direction: column;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}

.tag-card:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 16px rgba(88,166,255,0.1);
  transform: translateY(-2px);
  text-decoration: none;
}

.tag-card-thumb {
  height: 130px;
  overflow: hidden;
  background: var(--surface2);
  display: flex;
  align-items: center;
  justify-content: center;
}

.tag-card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s;
}

.tag-card:hover .tag-card-thumb img {
  transform: scale(1.05);
}

.tag-card-info {
  padding: 14px 16px;
}

.tag-card-name {
  font-size: 1rem;
  font-weight: 600;
  color: var(--heading);
  margin-bottom: 4px;
}

.tag-card-desc {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.tag-card-count {
  font-size: 0.78rem;
  color: var(--accent);
  margin-top: 6px;
}

/* ============================================================
   PAGE LAYOUT (blog index, tag pages, about, etc.)
   ============================================================ */
.page-main {
  padding: 40px 0 64px;
}

.page-title {
  font-size: 1.7rem;
  font-weight: 700;
  color: var(--heading);
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

/* Page search (on blog/tag pages) */
.page-search-wrap {
  margin-bottom: 24px;
}

.page-search-wrap .search-box {
  max-width: 480px;
}

.page-search-wrap .search-input {
  font-size: 0.92rem;
  padding: 10px 16px 10px 40px;
  border-radius: var(--radius-sm);
}

.filter-count {
  margin-top: 8px;
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* Post list (generated by SSG on blog/tag index pages) */
.page-body article.post-preview {
  padding: 24px 0;
  border-bottom: 1px solid var(--border);
}

.page-body article.post-preview:last-child {
  border-bottom: none;
}

.page-body article.post-preview h2 {
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 6px;
}

.page-body article.post-preview h2 a {
  color: var(--heading);
  transition: color 0.15s;
}

.page-body article.post-preview h2 a:hover {
  color: var(--accent);
  text-decoration: none;
}

.page-body article.post-preview .post-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.page-body article.post-preview .post-meta time {
  font-variant-numeric: tabular-nums;
}

.page-body article.post-preview .excerpt {
  color: var(--text);
  font-size: 0.92rem;
  line-height: 1.55;
}

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 40px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.page-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.9rem;
  font-family: var(--font);
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.page-btn:hover:not(:disabled) {
  background: var(--surface2);
  border-color: var(--accent);
  color: var(--heading);
}

.page-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.page-info {
  font-size: 0.85rem;
  color: var(--text-muted);
  min-width: 80px;
  text-align: center;
}

/* ============================================================
   POST PAGE
   ============================================================ */
.post-main {
  padding: 40px 0 80px;
}

.post {
  max-width: var(--post-w);
  margin: 0 auto;
}

.post-header {
  margin-bottom: 28px;
}

.post-tags-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.post-title {
  font-size: 2rem;
  font-weight: 700;
  color: var(--heading);
  line-height: 1.3;
  letter-spacing: -0.4px;
  margin-bottom: 12px;
}

.post-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.post-date { font-variant-numeric: tabular-nums; }

.post-reading-time::before { content: '· '; }
.post-reading-time::after  { content: ' min read'; }

/* Hero image */
.post-hero-wrap {
  margin-bottom: 32px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}

.post-hero-img {
  width: 100%;
  max-height: 420px;
  object-fit: cover;
}

/* Post body content */
.post-body.content {
  font-size: 1.02rem;
  line-height: 1.75;
}

.content h1,
.content h2,
.content h3,
.content h4 {
  color: var(--heading);
  font-weight: 600;
  line-height: 1.3;
  margin-top: 2.2em;
  margin-bottom: 0.7em;
}

.content h1 { font-size: 1.8rem; }
.content h2 { font-size: 1.45rem; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.content h3 { font-size: 1.2rem; }
.content h4 { font-size: 1rem; }

.content p {
  margin-bottom: 1.1em;
}

.content ul,
.content ol {
  margin-bottom: 1.1em;
  padding-left: 1.6em;
}

.content li {
  margin-bottom: 0.35em;
}

.content li > ul,
.content li > ol {
  margin-top: 0.35em;
  margin-bottom: 0;
}

.content a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: rgba(88,166,255,0.4);
}

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

.content strong { color: var(--heading); font-weight: 600; }
.content em     { font-style: italic; }

/* Inline code */
.content code {
  background: var(--code-bg);
  color: #f8f8f2;
  font-family: var(--font-mono);
  font-size: 0.875em;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--border);
}

/* Code blocks */
.content pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  overflow-x: auto;
  margin-bottom: 1.5em;
  position: relative;
}

.content pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: 0.9rem;
  line-height: 1.6;
  color: #cdd6f4;
}

/* Blockquote */
.content blockquote {
  border-left: 3px solid var(--accent);
  padding: 4px 0 4px 20px;
  margin: 1.5em 0;
  color: var(--text-muted);
  font-style: italic;
}

/* Tables */
.content table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
  margin-bottom: 1.5em;
  overflow-x: auto;
  display: block;
}

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

.content th {
  background: var(--surface2);
  color: var(--heading);
  font-weight: 600;
}

.content tr:nth-child(even) td {
  background: rgba(255,255,255,0.02);
}

/* Images inside posts */
.content img {
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  margin: 1.5em auto;
}

/* Horizontal rule */
.content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2.5em 0;
}

/* Inline tags on post list */
.tag {
  display: inline-block;
  background: var(--tag-bg);
  color: var(--tag-text);
  font-size: 0.76rem;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 20px;
  border: 1px solid rgba(88,166,255,0.2);
  font-family: var(--font-mono);
}

/* Post footer */
.post-footer {
  margin-top: 56px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 16px;
}

.back-link {
  font-size: 0.88rem;
  color: var(--text-muted);
  transition: color 0.15s;
}

.back-link:hover { color: var(--accent); text-decoration: none; }

/* ============================================================
   FOOTER
   ============================================================ */
.site-footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 28px 0;
  margin-top: auto;
}

.site-footer .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.site-footer p {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.site-footer a {
  color: var(--text-muted);
  font-size: 0.85rem;
}

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

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 640px) {
  .hero { padding: 40px 0 32px; }

  .hero-inner {
    flex-direction: column;
    align-items: flex-start;
    gap: 24px;
  }

  .hero-avatar { width: 80px; height: 80px; }
  .hero-name   { font-size: 1.6rem; }

  .tags-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  }

  .post-title { font-size: 1.5rem; }

  .pagination {
    flex-direction: column;
    gap: 10px;
  }

  .site-header nav a {
    padding: 6px 8px;
    font-size: 0.85rem;
  }
}
