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

:root {
  --bg:          #fafaf8;
  --surface:     #ffffff;
  --border:      #e5e5e0;
  --text:        #1a1a1a;
  --muted:       #6b6b6b;
  --accent:      #2563eb;
  --accent-hover:#1d4ed8;
  --sidebar-w:   240px;
  --radius:      6px;
  --font-sans:   "Inter", system-ui, -apple-system, sans-serif;
  --font-serif:  "Georgia", serif;
}

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

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

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

/* ── Main wrapper ──────────────────────────────────────────── */
main {
  flex: 1;
  max-width: 960px;
  width: 100%;
  margin: 0 auto;
  padding: 2.5rem 2rem;
}

/* ── Footer ────────────────────────────────────────────────── */
footer {
  border-top: 1px solid var(--border);
  text-align: center;
  padding: 1.25rem 2rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.footer-links {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 0.5rem;
}

.footer-links a {
  color: var(--muted);
}

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

/* ── Homepage layout ───────────────────────────────────────── */
.home-layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  gap: 3rem;
  align-items: start;
}

/* Sidebar */
.sidebar {
  position: sticky;
  top: 1.5rem;
}

.sidebar-bio h1 {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 0.4rem;
}

.sidebar-bio p {
  font-size: 0.875rem;
  color: var(--muted);
  margin-bottom: 1.5rem;
}

.sidebar-nav ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.sidebar-nav a {
  display: block;
  padding: 0.4rem 0.6rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
  transition: background 0.15s, color 0.15s;
}

.sidebar-nav a:hover {
  background: var(--border);
  text-decoration: none;
  color: var(--accent);
}

/* Page content (shared across all pages) */
.page-content section {
  margin-bottom: 2.5rem;
}

.page-content h2 {
  font-size: 1rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 1rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border);
}

.intro-lead {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  line-height: 1.7;
  color: var(--text);
  margin-bottom: 0.75rem;
}

.intro-body {
  font-size: 0.95rem;
  color: var(--muted);
  line-height: 1.7;
  margin-bottom: 1.25rem;
}

.intro-tags {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.intro-tags li {
  font-size: 0.8rem;
  background: var(--border);
  color: var(--muted);
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
}

.intro-tags li a {
  color: var(--muted);
}

.intro-tags li a:hover {
  color: var(--accent);
  text-decoration: none;
}

/* "What I'm building" list on homepage */
.services p {
  font-size: 0.95rem;
  color: var(--text);
  line-height: 1.7;
  margin-bottom: 0.85rem;
}

.services-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  margin-bottom: 0.85rem;
}

.services-list li {
  font-size: 0.95rem;
  line-height: 1.65;
  color: var(--text);
  padding-left: 0.85rem;
  border-left: 3px solid var(--border);
}

.services-list li strong {
  font-weight: 600;
}

.services-note {
  font-size: 0.875rem;
  color: var(--muted);
}

/* Recent posts list on homepage */
.recent-posts ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.recent-posts li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
}

.recent-posts .date {
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
}

/* ── Section (blog / research) list ───────────────────────── */
.section-layout {
  max-width: 680px;
}

.section-header {
  margin-bottom: 2rem;
}

.section-header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 0.4rem;
}

.section-header p {
  color: var(--muted);
  font-size: 0.95rem;
}

.post-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}

.post-item a {
  font-size: 1.05rem;
  font-weight: 600;
  display: block;
  margin-bottom: 0.15rem;
}

.post-item .date {
  font-size: 0.8rem;
  color: var(--muted);
  display: block;
  margin-bottom: 0.35rem;
}

.post-item .summary {
  font-size: 0.9rem;
  color: var(--muted);
  line-height: 1.55;
}

/* ── Individual page / post ────────────────────────────────── */
.post {
  max-width: 680px;
}

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

.post-header h1 {
  font-size: 1.9rem;
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: 0.5rem;
}

.post-header time {
  font-size: 0.85rem;
  color: var(--muted);
}

.tags {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.75rem;
}

.tags a {
  font-size: 0.78rem;
  background: var(--border);
  color: var(--muted);
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  transition: background 0.15s, color 0.15s;
}

.tags a:hover {
  background: var(--accent);
  color: #fff;
  text-decoration: none;
}

.post-content {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  line-height: 1.8;
}

.post-content h2,
.post-content h3,
.post-content h4 {
  font-family: var(--font-sans);
  margin: 2rem 0 0.75rem;
}

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

.post-content code {
  font-size: 0.875em;
  background: var(--border);
  padding: 0.15em 0.4em;
  border-radius: 3px;
}

.post-content pre {
  background: #1e1e1e;
  color: #d4d4d4;
  padding: 1.25rem;
  border-radius: var(--radius);
  overflow-x: auto;
  margin-bottom: 1.2rem;
}

.post-content pre code {
  background: none;
  padding: 0;
  color: inherit;
}

.post-content blockquote {
  border-left: 3px solid var(--accent);
  margin: 1.5rem 0;
  padding: 0.5rem 1.25rem;
  color: var(--muted);
  font-style: italic;
}

/* ── CV ────────────────────────────────────────────────────── */
.cv {
  max-width: 680px;
}

.cv hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2rem 0;
}

.cv h1 {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.cv h2 {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-top: 2rem;
  margin-bottom: 1rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border);
}

.cv h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-top: 1.25rem;
  margin-bottom: 0.25rem;
}

.cv p {
  margin-bottom: 0.5rem;
  line-height: 1.7;
  font-size: 0.95rem;
}

.cv p strong {
  font-weight: 600;
}

.cv ul {
  padding-left: 1.25rem;
  margin-bottom: 0.75rem;
}

.cv ul li {
  font-size: 0.95rem;
  line-height: 1.7;
  margin-bottom: 0.2rem;
  color: var(--text);
}

.post-footer {
  margin-top: 3rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
  font-size: 0.875rem;
}

/* ── Tag filter chips ──────────────────────────────────────── */
.tag-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 1rem;
}

.tag-chip {
  font-size: 0.78rem;
  background: var(--border);
  color: var(--text);
  border: 1px solid transparent;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  font-family: var(--font-sans);
}

.tag-chip:hover {
  background: var(--accent);
  color: #fff;
}

.tag-chip[aria-pressed="true"] {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.no-results {
  color: var(--muted);
  font-size: 0.9rem;
  margin-top: 1.5rem;
}

/* ── Night mode (Tokyo Night palette) ───────── */
@media (prefers-color-scheme: dark) {
  :root {
    --bg:          #1a1b26;
    --surface:     #16161e;
    --border:      #565f89;
    --text:        #a9b1d6;
    --muted:       #565f89;
    --accent:      #7aa2f7;
    --accent-hover:#7dcfff;
  }

  .post-content code {
    background: #24283b;
    color: #a9b1d6;
  }

  .intro-tags li {
    background: #24283b;
    color: var(--text);
  }

  .intro-tags li a {
    color: var(--text);
  }

  .tags a {
    background: #24283b;
    color: #a9b1d6;
  }

  .sidebar-nav a:hover {
    background: #24283b;
  }
}

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 680px) {
  .home-layout {
    grid-template-columns: 1fr;
    gap: 2rem;
  }

  .sidebar { position: static; }

  .sidebar-nav ul {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  main { padding: 1.5rem 1rem; }
}
