/* ===== Theme tokens (warm off-white + blue links) ===== */
:root {
  --background: #fafaf8;
  --foreground: #1a1a18;
  --border: #dcdcd6;
  --card: #f3f3ee;
  --primary: #2563eb;
  --primary-foreground: #ffffff;
  --secondary: #ececea;
  --secondary-foreground: #1a1a18;
  --muted: #ececea;
  --muted-foreground: #74746c;

  --font-sans: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-serif: 'Lora', Georgia, serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;

  --radius: 0.375rem;
  --max-width: 700px;
}

* { box-sizing: border-box; }
*, *::before, *::after { border-color: var(--border); }

html, body {
  margin: 0;
  padding: 0;
  background: var(--background);
  color: var(--foreground);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  font-size: 16px;
  line-height: 1.55;
}

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

p { margin: 0 0 0.75rem; }

strong { font-weight: 600; }

/* ===== Layout ===== */
.main-container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 4rem 1rem 2.5rem;
  min-height: calc(100vh - 200px);
}
@media (min-width: 640px) {
  .main-container { padding: 5rem 1.5rem 2.5rem; }
}

.section { margin-bottom: 2.5rem; }

/* ===== Navbar ===== */
.navbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  background: var(--background);
  border-bottom: 1px solid var(--border);
  z-index: 40;
}
.navbar-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0.75rem 1rem;
}
@media (min-width: 640px) {
  .navbar-inner { padding: 1rem 1.5rem; }
}
.nav-main {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.nav-logo { color: inherit; text-decoration: none; }
.nav-title {
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: 1rem;
  margin: 0;
  color: var(--foreground);
  white-space: nowrap;
  transition: color 0.15s;
}
.nav-logo:hover .nav-title { color: var(--primary); }
@media (min-width: 640px) {
  .nav-title { font-size: 1.25rem; }
}
.nav-links {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.875rem;
}
.nav-link { color: var(--primary); }
.nav-sep { color: var(--muted-foreground); }

/* Hamburger toggle (mobile only) */
.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  width: 40px;
  height: 40px;
  padding: 8px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.nav-toggle-bar {
  display: block;
  width: 100%;
  height: 2px;
  background: var(--foreground);
  border-radius: 2px;
  transition: transform 0.2s, opacity 0.2s;
}
.nav-toggle:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* Mobile collapse: links hide behind hamburger and slide down when open */
@media (max-width: 639px) {
  .nav-toggle { display: flex; }
  .nav-links {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    background: var(--background);
    border-bottom: 1px solid var(--border);
    padding: 0.25rem 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.2s ease, padding 0.2s ease;
  }
  .nav-links[data-open="true"] {
    max-height: 60vh;
    padding: 0.5rem 0;
  }
  .nav-links .nav-link {
    padding: 0.75rem 1.25rem;
    font-size: 1rem;
  }
  .nav-links .nav-sep { display: none; }
  .navbar-inner { position: relative; }
}

/* ===== Footer ===== */
.site-footer {
  max-width: var(--max-width);
  margin: 4rem auto 0;
  padding: 2rem 1.5rem;
  border-top: 1px solid var(--border);
  font-size: 0.875rem;
  color: var(--muted-foreground);
}
.footer-inner {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
@media (min-width: 640px) {
  .footer-inner { flex-direction: row; justify-content: space-between; align-items: center; }
}
.footer-inner p { margin: 0; }
.footer-links { display: flex; gap: 1rem; }
.footer-link {
  color: var(--muted-foreground);
  transition: color 0.15s;
}
.footer-link:hover { color: var(--foreground); text-decoration: none; }

/* ===== Avatar ===== */
.avatar-img {
  width: 80px; height: 80px;
  border-radius: 9999px;
  object-fit: cover;
  border: 1px solid var(--border);
}
.avatar-fallback {
  width: 80px; height: 80px;
  border-radius: 9999px;
  border: 1px solid var(--border);
  background: var(--secondary);
  color: var(--foreground);
  font-family: var(--font-serif);
  font-size: 1.25rem;
  display: flex; align-items: center; justify-content: center;
}

/* ===== Headings & utilities ===== */
.h2-serif {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  font-weight: 500;
  margin: 0 0 1rem;
}
.kicker, .focus-kicker {
  font-size: 0.75rem;
  color: var(--muted-foreground);
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 0 0 0.25rem;
}
.focus-kicker {
  text-transform: uppercase;
  font-family: var(--font-sans);
  font-weight: 500;
  letter-spacing: 0.04em;
  font-size: 0.75rem;
}
.muted { color: var(--muted-foreground); }
.small { font-size: 0.875rem; }
.bold { font-weight: 500; }
.mb-3 { margin-bottom: 0.75rem; }
.mb-5 { margin-bottom: 1.25rem; }
.mb-6 { margin-bottom: 1.5rem; }
.mt-3 { margin-top: 0.75rem; }
.underline-link {
  font-size: 0.875rem;
  text-decoration: underline;
  text-underline-offset: 4px;
  color: var(--foreground);
  transition: color 0.15s;
}
.underline-link:hover { color: var(--muted-foreground); text-decoration: underline; }
.link { color: var(--primary); }
.link.bold { font-weight: 500; }

/* ===== Intro section ===== */
.intro-row { display: flex; align-items: flex-start; gap: 1.25rem; margin-bottom: 1rem; }
.intro-bio { margin-top: 0.5rem; }
.intro-bridge { margin-top: 0.75rem; }
.intro-links {
  margin-top: 1rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.75rem;
}

/* ===== Now ===== */
.now-stack { display: flex; flex-direction: column; gap: 0.75rem; }
.now-stack p { margin: 0; }

/* ===== Cards ===== */
.card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 0.75rem;
  background: var(--card);
  display: block;
  color: inherit;
}
.card-sub { margin: 0.25rem 0 0; font-size: 0.875rem; color: var(--muted-foreground); }
.linkedin-card {
  transition: border-color 0.15s;
  text-decoration: none;
}
.linkedin-card:hover { border-color: var(--primary); text-decoration: none; }
.li-excerpt {
  font-size: 0.875rem;
  color: var(--foreground);
  margin: 0.5rem 0 0;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.li-cta { margin-top: 0.75rem; font-size: 0.75rem; color: var(--primary); }
.linkedin-card:hover .li-cta { text-decoration: underline; }

/* ===== Recent focus ===== */
.focus-stack { display: flex; flex-direction: column; gap: 1rem; }
.focus-item {
  border-left: 2px solid var(--primary);
  padding-left: 1rem;
}
.focus-item p:last-child { margin: 0.25rem 0 0; }

/* ===== Section header layout ===== */
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 1rem;
}
.section-head .h2-serif { margin: 0; }

/* ===== Post lists ===== */
.post-stack { display: flex; flex-direction: column; gap: 1rem; }
.post-stack > div p, .post-stack > a p { margin: 0.25rem 0 0; }
.meta-mono {
  font-size: 0.75rem;
  color: var(--muted-foreground);
  font-family: var(--font-mono);
  margin: 0.25rem 0 0;
}

/* ===== Tags ===== */
.tag-row { display: flex; flex-wrap: wrap; gap: 0.25rem; margin-top: 0.5rem; }
.tag {
  font-size: 0.75rem;
  background: var(--secondary);
  color: var(--secondary-foreground);
  padding: 0.125rem 0.5rem;
  border-radius: 4px;
}

/* ===== Bullet list ===== */
.bullet-list {
  margin: 0.25rem 0 0;
  padding-left: 1.25rem;
  font-size: 0.875rem;
  list-style: disc;
}
.bullet-list li { margin: 0.125rem 0; }

/* ===== Blog index ===== */
.search-wrap { position: relative; margin-bottom: 2rem; }
.search-input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem 2rem 0.5rem 0.75rem;
  font-size: 0.875rem;
  background: var(--background);
  color: var(--foreground);
  font-family: inherit;
}
.search-input:focus { outline: none; box-shadow: 0 0 0 1px var(--primary); }
.search-input::placeholder { color: var(--muted-foreground); }
.search-clear {
  position: absolute;
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  font-size: 1.25rem;
  line-height: 1;
  color: var(--muted-foreground);
  cursor: pointer;
  padding: 0 0.25rem;
}
.search-clear:hover { color: var(--foreground); }

.article-stack { display: flex; flex-direction: column; gap: 2rem; }
.article-item p { margin: 0.25rem 0 0; }
.article-title { font-size: 1.125rem; line-height: 1.35; }
.meta-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.5rem;
  font-size: 0.75rem;
  color: var(--muted-foreground);
  font-family: var(--font-mono);
}

.back-row {
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

/* ===== Blog post ===== */
.post-header {
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}
.post-title {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  line-height: 1.3;
  font-weight: 500;
  margin: 0 0 0.75rem;
}

/* ===== Reading progress bar ===== */
.reading-progress {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 3px;
  z-index: 50;
  background: transparent;
}
.reading-progress-bar {
  height: 100%;
  width: 0%;
  background: var(--primary);
}

/* ===== Prose (markdown content) ===== */
.prose {
  color: var(--foreground);
  font-size: 0.95rem;
  line-height: 1.7;
}
.prose h1, .prose h2, .prose h3, .prose h4 {
  font-family: var(--font-serif);
  font-weight: 500;
  color: var(--foreground);
  line-height: 1.3;
}
.prose h2 { font-size: 1.4rem; margin: 2rem 0 0.75rem; }
.prose h3 { font-size: 1.15rem; margin: 1.5rem 0 0.5rem; }
.prose h4 { font-size: 1rem; margin: 1.25rem 0 0.5rem; }
.prose p { margin: 0 0 1rem; }
.prose ul, .prose ol { padding-left: 1.5rem; margin: 0 0 1rem; }
.prose li { margin: 0.25rem 0; }
.prose a { color: var(--primary); text-decoration: underline; text-underline-offset: 3px; }
.prose strong { font-weight: 600; }
.prose em { font-style: italic; }
.prose blockquote {
  border-left: 3px solid var(--border);
  margin: 1rem 0;
  padding: 0.25rem 0 0.25rem 1rem;
  color: var(--muted-foreground);
}
.prose hr { border: none; border-top: 1px solid var(--border); margin: 2rem 0; }
.prose img { border-radius: 6px; max-width: 100%; margin: 1.5rem 0; }
.prose video { width: 100%; border-radius: 6px; margin: 1.5rem 0; }
.prose iframe { width: 100%; aspect-ratio: 16/9; border-radius: 6px; margin: 1.5rem 0; border: none; }
.prose table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.875rem;
}
.prose th, .prose td {
  border: 1px solid var(--border);
  padding: 0.5rem 0.75rem;
  text-align: left;
}
.prose th { background: var(--card); font-weight: 600; }

/* Inline code */
.prose :not(pre) > code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: var(--secondary);
  padding: 0.1em 0.3em;
  border-radius: 3px;
}

/* Code block wrapper */
.prose .highlight, .prose pre {
  position: relative;
  background: var(--secondary);
  border-radius: var(--radius);
  margin: 1.5rem 0;
  overflow: hidden;
}
.prose .highlight pre, .prose pre {
  margin: 0;
  padding: 1rem;
  overflow-x: auto;
  background: transparent;
  font-family: var(--font-mono);
  font-size: 0.875rem;
  line-height: 1.5;
}
.prose pre code {
  background: transparent;
  padding: 0;
  font-size: inherit;
  font-family: var(--font-mono);
}
.copy-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  padding: 0.25rem 0.5rem;
  font-size: 0.7rem;
  font-family: var(--font-mono);
  background: var(--secondary);
  color: var(--muted-foreground);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s;
}
.prose .highlight:hover .copy-btn,
.prose pre:hover + .copy-btn,
.code-wrap:hover .copy-btn { opacity: 1; }
.copy-btn:hover { color: var(--foreground); }

/* ===== Pygments github-light theme (subset) ===== */
.highlight .c, .highlight .c1, .highlight .cm, .highlight .cs { color: #6a737d; font-style: italic; }
.highlight .k, .highlight .kn, .highlight .kd, .highlight .kr, .highlight .kt, .highlight .kc { color: #d73a49; }
.highlight .s, .highlight .s1, .highlight .s2, .highlight .sb, .highlight .sc, .highlight .sd, .highlight .se, .highlight .sh, .highlight .si, .highlight .sx, .highlight .sr, .highlight .ss { color: #032f62; }
.highlight .mi, .highlight .mf, .highlight .mh, .highlight .mo, .highlight .il { color: #005cc5; }
.highlight .nb, .highlight .bp { color: #005cc5; }
.highlight .nf, .highlight .fm { color: #6f42c1; }
.highlight .nc { color: #6f42c1; }
.highlight .o, .highlight .ow { color: #d73a49; }
.highlight .p { color: #24292e; }
.highlight .n, .highlight .na, .highlight .nv { color: #24292e; }
.highlight .nt { color: #22863a; }
.highlight .err { color: #b31d28; }

/* ===== Page fade transition ===== */
.page-fade { animation: pageFade 0.25s ease-in-out; }
@keyframes pageFade {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ===== Projects ===== */
.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
  margin-top: 1rem;
}
.project-grid-sparse {
  grid-template-columns: minmax(280px, 520px);
  justify-content: start;
}
.project-card {
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid #ececec;
  border-radius: 8px;
  overflow: hidden;
  transition: box-shadow 0.18s ease, transform 0.18s ease;
}
.project-card:hover {
  box-shadow: 0 4px 14px rgba(0,0,0,0.06);
  transform: translateY(-1px);
}
.project-thumb-link {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 8;
  background: #f4f4ef;
  overflow: hidden;
}
.project-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.project-thumb-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #eef2ff 0%, #faf5ff 100%);
}
.project-thumb-initial {
  font-family: 'Lora', serif;
  font-size: 3rem;
  color: #2563eb;
  font-weight: 500;
}
.project-body {
  padding: 1rem 1.1rem 1.1rem;
}
.project-title {
  margin: 0 0 0.4rem;
  font-size: 1.05rem;
  font-family: 'IBM Plex Sans', system-ui, sans-serif;
  font-weight: 500;
}
.project-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem;
  align-items: center;
  margin-top: 0.7rem;
  font-size: 0.82rem;
  color: #6a737d;
}
.project-lang { display: inline-flex; align-items: center; gap: 0.35rem; }
.lang-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  vertical-align: middle;
  margin-right: 0.25rem;
}
.project-stars { font-variant-numeric: tabular-nums; }

/* ===== Featured projects (home teaser) ===== */
.featured-projects {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.9rem;
  margin-top: 0.5rem;
}
.featured-project-card {
  display: block;
  padding: 0.9rem 1rem;
  background: #fff;
  border: 1px solid #ececec;
  border-radius: 8px;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.featured-project-card:hover {
  border-color: #d4d4cf;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}
.featured-project-card .meta-mono { margin-top: 0.5rem; font-size: 0.78rem; }
.mt-2 { margin-top: 0.5rem; }
