/* ===== Design Tokens ===== */
:root {
  --text: #ededef;
  --text-secondary: #9ca3af;
  --bg: #0a0a0c;
  --bg-card: #131316;
  --bg-card-hover: #1a1a1f;
  --accent: #60a5fa;
  --accent-soft: rgba(96, 165, 250, 0.12);
  --muted: #6b7280;
  --border: #1f1f24;
  --border-hover: #2d2d35;
  --code-bg: #141418;
  --highlight: #fbbf24;
  --radius: 10px;
  --transition: 0.2s ease;
}

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

/* ===== Body ===== */
body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.75;
  max-width: 860px;
  margin: 0 auto;
  padding: 0 1.5rem;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ===== Header ===== */
.site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem 0;
  margin-bottom: 2rem;
}

.site-brand {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.03em;
}
.site-brand:hover { color: var(--accent); opacity: 1; }

.nav-links {
  display: flex;
  align-items: center;
  gap: 0.1rem;
}

.nav-links a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0.4rem 0.75rem;
  border-radius: 8px;
  transition: color var(--transition), background var(--transition);
}

.nav-links a:hover {
  color: var(--text);
  background: var(--bg-card);
  opacity: 1;
}

/* ===== Hero (homepage) ===== */
.hero {
  padding: 0 0 2.5rem;
  margin-bottom: 2.5rem;
  border-bottom: 1px solid var(--border);
}

.hero p {
  color: var(--text-secondary);
  font-size: 1.2rem;
  font-weight: 400;
  line-height: 1.75;
}

/* ===== Typography ===== */
h1 { font-size: 1.8rem; font-weight: 700; margin-bottom: 1rem; letter-spacing: -0.03em; line-height: 1.2; }
h2 { font-size: 1.35rem; font-weight: 600; margin: 2rem 0 0.75rem; letter-spacing: -0.02em; }
h3 { font-size: 1.1rem; font-weight: 600; margin: 1.5rem 0 0.5rem; }

a { color: var(--accent); text-decoration: none; transition: opacity var(--transition); }
a:hover { opacity: 0.85; }

/* ===== Post Summary Cards ===== */
.post-summary {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  margin-bottom: 0.75rem;
  transition: border-color var(--transition), background var(--transition);
}

.post-summary:hover {
  border-color: var(--border-hover);
  background: var(--bg-card-hover);
}

.post-summary h3 {
  margin: 0 0 0.35rem;
  font-size: 1.1rem;
  font-weight: 600;
  line-height: 1.35;
}
.post-summary h3 a { color: var(--text); }
.post-summary h3 a:hover { color: var(--accent); opacity: 1; }

.post-meta {
  color: var(--muted);
  font-size: 0.8rem;
  margin-bottom: 0.5rem;
  font-variant-numeric: tabular-nums;
}

.reading-time { color: var(--muted); }

.post-excerpt {
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.6;
  margin: 0.35rem 0 0.5rem;
}

.external-badge {
  display: inline-block;
  font-size: 0.6rem;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 0.15rem 0.45rem;
  border-radius: 5px;
  margin-left: 0.4rem;
  vertical-align: middle;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ===== Tags ===== */
.tags { margin-top: 0.5rem; display: flex; flex-wrap: wrap; gap: 0.3rem; }
.tag {
  display: inline-block;
  background: var(--accent-soft);
  color: var(--accent);
  padding: 0.15rem 0.55rem;
  border-radius: 5px;
  font-size: 0.72rem;
  font-weight: 600;
  text-decoration: none;
  letter-spacing: 0.02em;
  transition: background var(--transition);
}
.tag:hover { background: rgba(96, 165, 250, 0.22); opacity: 1; }

/* ===== Post list (simple) ===== */
.post-list { list-style: none; }
.post-list li { display: flex; gap: 1rem; align-items: baseline; padding: 0.5rem 0; }
.post-list time { color: var(--muted); font-size: 0.85rem; white-space: nowrap; font-variant-numeric: tabular-nums; }

/* ===== Post Header ===== */
.post-header { margin-bottom: 2.5rem; }
.post-header h1 { margin-bottom: 0.6rem; }
.post-header time { color: var(--muted); font-size: 0.85rem; }

/* ===== Post Content ===== */
.post-content { font-size: 1.05rem; }
.post-content p { margin: 1.25rem 0; }
.post-content ul, .post-content ol { margin: 1.25rem 0; padding-left: 1.5rem; }
.post-content li { margin-bottom: 0.3rem; }
.post-content img { max-width: 100%; height: auto; border-radius: var(--radius); margin: 1rem 0; }
.post-content blockquote {
  border-left: 3px solid var(--accent);
  padding: 0.75rem 1rem;
  margin: 1.5rem 0;
  background: var(--bg-card);
  border-radius: 0 var(--radius) var(--radius) 0;
  color: var(--text-secondary);
}
.post-content h2 { padding-top: 0.5rem; border-top: 1px solid var(--border); }
.post-content a { text-decoration: underline; text-decoration-color: rgba(96, 165, 250, 0.3); text-underline-offset: 3px; }
.post-content a:hover { text-decoration-color: var(--accent); opacity: 1; }

/* ===== Post Footer (prev/next) ===== */
.post-footer {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

.post-nav {
  font-size: 0.875rem;
  color: var(--text-secondary);
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  transition: border-color var(--transition), color var(--transition);
}
.post-nav:hover { border-color: var(--accent); color: var(--accent); opacity: 1; }

/* ===== Code ===== */
code {
  background: var(--code-bg);
  color: var(--accent);
  padding: 0.15rem 0.4rem;
  border-radius: 5px;
  font-size: 0.85em;
  font-family: "JetBrains Mono", "Fira Code", "Cascadia Code", ui-monospace, monospace;
  border: 1px solid var(--border);
}

pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  padding: 1.25rem;
  border-radius: var(--radius);
  overflow-x: auto;
  margin: 1.5rem 0;
}

pre code {
  background: none;
  color: var(--text);
  padding: 0;
  border: none;
  border-radius: 0;
}

/* ===== About Page ===== */
.about-page { max-width: 100%; }

.about-photo {
  width: 130px;
  height: 130px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
  margin: 0 auto 1.5rem;
  border: 3px solid var(--border);
  transition: border-color var(--transition);
}
.about-photo:hover { border-color: var(--accent); }

.about-socials {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  margin-bottom: 2rem;
}

.about-social-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  color: var(--text-secondary);
  background: var(--bg-card);
  border: 1px solid var(--border);
  transition: color var(--transition), background var(--transition), border-color var(--transition);
}

.about-social-link:hover {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: rgba(96, 165, 250, 0.3);
  opacity: 1;
}

/* ===== Footer ===== */
footer {
  margin-top: 4rem;
  padding: 1.5rem 0;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.78rem;
}

/* ===== Homepage Two-Column ===== */
.home-layout {
  display: flex;
  gap: 2.5rem;
  align-items: flex-start;
}

.home-posts {
  flex: 1;
  min-width: 0;
}

.home-posts h2 {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-bottom: 1rem;
  margin-top: 0;
}

.home-sidebar {
  width: 200px;
  flex-shrink: 0;
  position: sticky;
  top: 2rem;
}

.home-sidebar h3 {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-bottom: 0.75rem;
}

.sidebar-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.sidebar-tag {
  display: inline-block;
  font-size: 0.78rem;
  color: var(--text-secondary);
  background: var(--bg-card);
  padding: 0.25rem 0.6rem;
  border-radius: 6px;
  text-decoration: none;
  border: 1px solid var(--border);
  transition: all var(--transition);
}

.sidebar-tag:hover {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: rgba(96, 165, 250, 0.3);
  opacity: 1;
}

.sidebar-tag-count {
  font-size: 0.65rem;
  color: var(--muted);
  margin-left: 0.2rem;
}

/* ===== Search Button ===== */
.search-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  padding: 0.4rem;
  margin-left: 0.15rem;
  display: inline-flex;
  align-items: center;
  border-radius: 8px;
  transition: color var(--transition), background var(--transition);
}
.search-btn:hover { color: var(--text); background: var(--bg-card); }

/* ===== Search Overlay ===== */
.search-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 1000;
  justify-content: center;
  align-items: flex-start;
  padding-top: 12vh;
}
.search-overlay.active { display: flex; }

.search-container {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  width: 90%;
  max-width: 560px;
  max-height: 65vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
}

.search-header {
  display: flex;
  align-items: center;
  padding: 1rem 1.25rem;
  gap: 0.75rem;
}

.search-input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 1rem;
  font-family: inherit;
  color: var(--text);
  background: transparent;
}
.search-input::placeholder { color: var(--muted); }

.search-close {
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--muted);
  line-height: 1;
  padding: 0.15rem 0.35rem;
  border-radius: 6px;
  transition: color var(--transition), background var(--transition);
}
.search-close:hover { color: var(--text); background: var(--bg-card-hover); }

.search-results {
  overflow-y: auto;
  padding: 0.5rem 1.25rem 1.25rem;
  border-top: 1px solid var(--border);
}
.search-results:empty { display: none; }

.search-msg {
  color: var(--muted);
  font-size: 0.9rem;
  padding: 1rem 0;
  text-align: center;
}

.search-result-list { list-style: none; }

.search-result-item {
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}
.search-result-item:last-child { border-bottom: none; }

.search-result-item a {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  text-decoration: none;
  gap: 0.75rem;
}
.search-result-item a:hover .search-result-title { color: var(--accent); }

.search-result-title {
  font-weight: 600;
  font-size: 1rem;
  color: var(--text);
}

.search-result-date {
  color: var(--muted);
  font-size: 0.78rem;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.search-result-snippet {
  color: var(--text-secondary);
  font-size: 0.82rem;
  margin: 0.3rem 0 0.2rem;
  line-height: 1.5;
}

.search-result-snippet mark {
  background: rgba(251, 191, 36, 0.15);
  color: var(--highlight);
  padding: 0 2px;
  border-radius: 3px;
}

.search-result-tags { margin-top: 0.3rem; }

/* ===== Responsive ===== */
@media (max-width: 768px) {
  body { padding: 0 1.25rem; }
  .hero { padding: 0 0 2.5rem; }
  .hero p { font-size: 1.05rem; }
  .home-layout { flex-direction: column; gap: 2rem; }
  .home-sidebar { width: 100%; position: static; }
  .post-summary { padding: 1rem 1.25rem; }
}

@media (max-width: 480px) {
  .hero p { font-size: 0.95rem; }
  .post-summary h3 { font-size: 1rem; }
  .post-footer { flex-direction: column; }
  .search-container { width: 96%; max-height: 80vh; border-radius: 12px; }
  .search-result-item a { flex-direction: column; gap: 0.15rem; }
  .nav-links a { padding: 0.35rem 0.5rem; font-size: 0.8rem; }
  .about-photo { width: 100px; height: 100px; }
}
