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

:root {
  --primary: #0d6efd;
  --primary-dark: #0a58ca;
  --bg: #f6f8fa;
  --surface: #ffffff;
  --surface-2: #f6f8fa;
  --border: #d0d7de;
  --text: #1f2328;
  --text-muted: #656d76;
  --nav-bg: #ffffff;
  --sidebar-bg: #ffffff;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,.10);
  --issue-open: #1a7f37;
  --issue-open-bg: #dafbe1;
  --issue-closed: #8250df;
  --issue-closed-bg: #f3eeff;
  --pr-open: #1a7f37;
  --pr-open-bg: #dafbe1;
  --pr-merged: #8250df;
  --pr-merged-bg: #f3eeff;
  --pr-closed: #d1242f;
  --pr-closed-bg: #ffebe9;
}

[data-theme="dark"] {
  --bg: #0d1117;
  --surface: #161b22;
  --surface-2: #21262d;
  --border: #30363d;
  --text: #e6edf3;
  --text-muted: #8b949e;
  --nav-bg: #161b22;
  --sidebar-bg: #161b22;
  --shadow: 0 1px 3px rgba(0,0,0,.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,.4);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

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

/* ===== Navbar ===== */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--nav-bg);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.nav-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.25rem;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.nav-brand {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  flex-shrink: 0;
}
.nav-brand:hover { text-decoration: none; color: var(--primary); }

.nav-links {
  display: flex;
  list-style: none;
  gap: .25rem;
  flex: 1;
}

.nav-link {
  display: block;
  padding: .35rem .75rem;
  border-radius: 6px;
  font-size: .9rem;
  color: var(--text-muted);
  text-decoration: none;
  transition: background .15s, color .15s;
}
.nav-link:hover, .nav-link.active {
  background: var(--surface-2);
  color: var(--text);
  text-decoration: none;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-shrink: 0;
}

.nav-search-wrap { position: relative; }

.nav-search {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: .35rem .75rem;
  font-size: .85rem;
  background: var(--surface-2);
  color: var(--text);
  width: 200px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.nav-search:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(13,110,253,.15);
}

.nav-search-results {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  width: 320px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  max-height: 360px;
  overflow-y: auto;
  display: none;
  z-index: 200;
}
.nav-search-results.open { display: block; }

.search-result-item {
  display: block;
  padding: .6rem 1rem;
  font-size: .85rem;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  cursor: pointer;
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: var(--surface-2); text-decoration: none; }
.search-result-item .result-type {
  font-size: .72rem;
  color: var(--text-muted);
  margin-bottom: .1rem;
}

.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: .35rem .5rem;
  cursor: pointer;
  color: var(--text-muted);
  font-size: .9rem;
  line-height: 1;
  transition: background .15s;
}
.theme-toggle:hover { background: var(--surface-2); }

[data-theme="light"] .icon-moon { display: none; }
[data-theme="dark"]  .icon-sun  { display: none; }

.nav-hamburger {
  display: none;
  flex-direction: column;
  gap: 4px;
  background: none;
  border: none;
  cursor: pointer;
  padding: .4rem;
  margin-left: auto;
}
.nav-hamburger span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: transform .2s, opacity .2s;
}

/* ===== Layout ===== */
.layout {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem;
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 1.5rem;
  align-items: start;
}

/* ===== Sidebar ===== */
.sidebar {
  position: sticky;
  top: 72px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.profile-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}

.avatar-placeholder {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary) 0%, #6610f2 100%);
  color: #fff;
  font-size: 1.8rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: .75rem;
}

.profile-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: cover;
  margin-bottom: .75rem;
  border: 2px solid var(--border);
}

.profile-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: .1rem;
}

.profile-handle {
  font-size: .82rem;
  color: var(--text-muted);
  margin-bottom: .6rem;
}

.profile-bio {
  font-size: .85rem;
  color: var(--text-muted);
  margin-bottom: .85rem;
  line-height: 1.5;
}

.profile-links {
  display: flex;
  flex-direction: column;
  gap: .35rem;
  margin-bottom: 1rem;
}

.profile-link {
  display: flex;
  align-items: center;
  gap: .4rem;
  font-size: .82rem;
  color: var(--text-muted);
  text-decoration: none;
  transition: color .15s;
}
.profile-link:hover { color: var(--primary); text-decoration: none; }
.profile-link svg { flex-shrink: 0; }

.sidebar-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .5rem;
  border-top: 1px solid var(--border);
  padding-top: .85rem;
}

.stat-item {
  text-align: center;
}

.stat-num {
  display: block;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
}

.stat-lbl {
  font-size: .72rem;
  color: var(--text-muted);
}

.sidebar-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  box-shadow: var(--shadow);
}

.sidebar-section-title {
  font-size: .78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  margin-bottom: .65rem;
}

.tech-tags {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
}

.tech-tag {
  font-size: .75rem;
  padding: .2rem .55rem;
  border-radius: 12px;
  font-weight: 500;
  border: 1px solid transparent;
}
.tech-tag.rust     { background: #fff3e0; color: #e65100; border-color: #ffcc80; }
.tech-tag.compiler { background: #e3f2fd; color: #1565c0; border-color: #90caf9; }
.tech-tag.ai       { background: #f3e5f5; color: #6a1b9a; border-color: #ce93d8; }
.tech-tag.os       { background: #e8f5e9; color: #2e7d32; border-color: #a5d6a7; }
.tech-tag.safety   { background: #fce4ec; color: #880e4f; border-color: #f48fb1; }
.tech-tag.miri     { background: #e8eaf6; color: #283593; border-color: #9fa8da; }
.tech-tag.llvm     { background: #fff8e1; color: #f57f17; border-color: #ffe082; }
.tech-tag.git      { background: #fbe9e7; color: #bf360c; border-color: #ffab91; }

[data-theme="dark"] .tech-tag.rust     { background: #3e2000; color: #ffb74d; border-color: #5d3000; }
[data-theme="dark"] .tech-tag.compiler { background: #0d2137; color: #64b5f6; border-color: #1a3a5c; }
[data-theme="dark"] .tech-tag.ai       { background: #2a0a3a; color: #ce93d8; border-color: #4a1060; }
[data-theme="dark"] .tech-tag.os       { background: #0a2a0a; color: #81c784; border-color: #1a4a1a; }
[data-theme="dark"] .tech-tag.safety   { background: #3a0a1a; color: #f48fb1; border-color: #5a1030; }
[data-theme="dark"] .tech-tag.miri     { background: #0d1040; color: #9fa8da; border-color: #1a2060; }
[data-theme="dark"] .tech-tag.llvm     { background: #3a2a00; color: #ffe082; border-color: #5a4000; }
[data-theme="dark"] .tech-tag.git      { background: #3a1000; color: #ffab91; border-color: #5a2000; }

.edu-item {
  display: flex;
  flex-direction: column;
  gap: .15rem;
}
.edu-school { font-size: .88rem; font-weight: 600; color: var(--text); }
.edu-degree { font-size: .82rem; color: var(--text-muted); }
.edu-year   { font-size: .78rem; color: var(--text-muted); }

/* ===== Main Content ===== */
.main-content { min-width: 0; }

.page { display: block; }
.page.hidden { display: none; }

.page-header {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-bottom: 1rem;
}

.page-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text);
}

.page-count {
  font-size: .78rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: .15rem .55rem;
  color: var(--text-muted);
}

/* ===== Filter Row ===== */
.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin-bottom: 1rem;
  align-items: center;
}

.filter-search {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: .4rem .75rem;
  font-size: .88rem;
  background: var(--surface);
  color: var(--text);
  outline: none;
  min-width: 200px;
  transition: border-color .15s, box-shadow .15s;
}
.filter-search:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(13,110,253,.12);
}

.filter-pills { display: flex; flex-wrap: wrap; gap: .35rem; }

.pill {
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: .25rem .75rem;
  font-size: .8rem;
  cursor: pointer;
  background: var(--surface);
  color: var(--text-muted);
  transition: all .15s;
}
.pill:hover { border-color: var(--primary); color: var(--primary); }
.pill.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ===== Post List ===== */
.post-list {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  list-style: none;
}

.blog-card {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  transition: background .15s;
}
.blog-card:last-child { border-bottom: none; }
.blog-card:hover { background: var(--surface-2); }

.blog-title {
  font-size: .95rem;
  font-weight: 600;
  margin-bottom: .3rem;
}
.blog-title a { color: var(--text); }
.blog-title a:hover { color: var(--primary); text-decoration: none; }

.blog-summary {
  font-size: .85rem;
  color: var(--text-muted);
  margin-bottom: .5rem;
  line-height: 1.5;
}

.blog-meta {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  align-items: center;
  font-size: .78rem;
  color: var(--text-muted);
}

.category-badge {
  background: rgba(13,110,253,.1);
  border: 1px solid rgba(13,110,253,.2);
  border-radius: 12px;
  padding: .1rem .5rem;
  font-size: .72rem;
  color: var(--primary);
}

/* ===== Categories Page ===== */
.categories-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
}

.category-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: box-shadow .15s, border-color .15s;
}
.category-card:hover { box-shadow: var(--shadow-md); border-color: var(--primary); }

.category-card-name {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: .25rem;
}
.category-card-count {
  font-size: .82rem;
  color: var(--text-muted);
}

/* ===== Tags Page ===== */
.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin-bottom: 1.5rem;
}

.tag-btn {
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: .3rem .85rem;
  font-size: .85rem;
  cursor: pointer;
  background: var(--surface);
  color: var(--text-muted);
  transition: all .15s;
}
.tag-btn:hover, .tag-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

/* ===== Contributions ===== */
.contrib-list {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.contrib-card {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  padding: .85rem 1.25rem;
  border-bottom: 1px solid var(--border);
  transition: background .15s;
}
.contrib-card:last-child { border-bottom: none; }
.contrib-card:hover { background: var(--surface-2); }

.contrib-icon {
  flex-shrink: 0;
  margin-top: .15rem;
  color: var(--text-muted);
}

.contrib-body { flex: 1; min-width: 0; }

.contrib-title {
  font-size: .9rem;
  font-weight: 500;
  color: var(--text);
  margin-bottom: .25rem;
  line-height: 1.4;
}
.contrib-title a { color: var(--text); }
.contrib-title a:hover { color: var(--primary); text-decoration: none; }

.contrib-meta {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  align-items: center;
  font-size: .75rem;
  color: var(--text-muted);
}

.repo-tag {
  background: rgba(13,110,253,.08);
  border: 1px solid rgba(13,110,253,.2);
  border-radius: 12px;
  padding: .1rem .45rem;
  font-size: .72rem;
  color: var(--primary);
}

.state-badge {
  border-radius: 12px;
  padding: .1rem .5rem;
  font-size: .72rem;
  font-weight: 500;
}
.state-open   { background: var(--issue-open-bg);   color: var(--issue-open); }
.state-closed { background: var(--issue-closed-bg); color: var(--issue-closed); }
.state-merged { background: var(--pr-merged-bg);    color: var(--pr-merged); }

/* ===== About Page ===== */
.about-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
}
.about-card:last-child { margin-bottom: 0; }

.about-section-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 1rem;
  padding-bottom: .5rem;
  border-bottom: 1px solid var(--border);
}

.about-card p {
  font-size: .9rem;
  color: var(--text-muted);
  margin-bottom: .75rem;
  line-height: 1.7;
}
.about-card p:last-child { margin-bottom: 0; }
.about-card p strong { color: var(--text); }

.skills-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
}

.skill-group h3 {
  font-size: .82rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: .5rem;
}

.skill-tags { display: flex; flex-wrap: wrap; gap: .35rem; }

.skill-tag {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: .2rem .55rem;
  font-size: .78rem;
  color: var(--text-muted);
}

/* ===== Timeline ===== */
.timeline { position: relative; padding-left: 1.5rem; }
.timeline::before {
  content: '';
  position: absolute;
  left: 6px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--border);
}

.timeline-item {
  position: relative;
  margin-bottom: 1.5rem;
}
.timeline-item:last-child { margin-bottom: 0; }

.timeline-dot {
  position: absolute;
  left: -1.5rem;
  top: .35rem;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid var(--surface);
  box-shadow: 0 0 0 2px var(--primary);
}

.timeline-content { padding-left: .25rem; }

.timeline-date {
  font-size: .75rem;
  color: var(--text-muted);
  font-weight: 500;
  display: block;
  margin-bottom: .2rem;
}

.timeline-content h3 {
  font-size: .9rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: .3rem;
}

.timeline-content p {
  font-size: .85rem;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 0;
}

/* ===== Talks List ===== */
.talks-list { list-style: none; display: flex; flex-direction: column; gap: .6rem; }

.talks-list li {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
}

.talks-list a { font-size: .88rem; }

.talk-channel {
  font-size: .72rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: .1rem .45rem;
  color: var(--text-muted);
}

/* ===== Empty / Loading states ===== */
.state-placeholder {
  padding: 2.5rem 1.25rem;
  text-align: center;
  color: var(--text-muted);
  font-size: .9rem;
}

.spinner {
  display: inline-block;
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  margin-bottom: .5rem;
}

@keyframes spin { to { transform: rotate(360deg); } }

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

/* ===== Responsive ===== */
@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: static;
  }
  .nav-links {
    display: none;
    position: absolute;
    top: 56px;
    left: 0;
    right: 0;
    background: var(--nav-bg);
    border-bottom: 1px solid var(--border);
    flex-direction: column;
    padding: .5rem 1.25rem;
    gap: .1rem;
    box-shadow: var(--shadow-md);
  }
  .nav-links.open { display: flex; }
  .nav-hamburger { display: flex; }
  .nav-search { width: 140px; }
}

@media (max-width: 600px) {
  .layout { padding: 1rem .75rem; }
  .skills-grid { grid-template-columns: 1fr; }
  .categories-grid { grid-template-columns: 1fr 1fr; }
  .nav-search { width: 110px; }
}
