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

:root {
  --bg-primary: #0d1117;
  --bg-secondary: #161b22;
  --bg-tertiary: #1c2128;
  --border: #30363d;
  --text-primary: #e6edf3;
  --text-secondary: #8b949e;
  --accent: #58a6ff;
  --accent-hover: #79b8ff;
  --accent-subtle: rgba(88, 166, 255, 0.1);
  --font-stack: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial,
    sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  --max-width: 800px;
  --header-height: 60px;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-height) + 1rem);
}

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

/* ─── Sticky Frosted-Glass Header ────────────────────── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-height);
  background: rgba(13, 17, 23, 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.site-title {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-primary);
  text-decoration: none;
  white-space: nowrap;
}

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

.site-nav {
  display: flex;
  gap: 0.25rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.site-nav a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.85rem;
  padding: 0.35rem 0.6rem;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
}

.site-nav a:hover {
  color: var(--text-primary);
  background: var(--bg-tertiary);
}

.site-nav a.active {
  color: var(--accent);
  background: var(--accent-subtle);
}

/* ─── Layout ─────────────────────────────────────────── */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1.5rem;
}

.main-content {
  flex: 1;
  padding: 2.5rem 0;
}

/* ─── Typography ─────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 {
  color: var(--text-primary);
  line-height: 1.3;
  margin-top: 2rem;
  margin-bottom: 0.75rem;
}

h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }

h1:first-child,
h2:first-child,
h3:first-child {
  margin-top: 0;
}

p {
  margin-bottom: 1rem;
}

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

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

strong {
  color: var(--text-primary);
  font-weight: 600;
}

/* ─── Lists ──────────────────────────────────────────── */
ul, ol {
  margin-bottom: 1rem;
  padding-left: 1.5rem;
}

li {
  margin-bottom: 0.35rem;
}

li::marker {
  color: var(--text-secondary);
}

/* ─── Tables ─────────────────────────────────────────── */
table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.5rem;
  font-size: 0.95rem;
}

th, td {
  padding: 0.6rem 0.85rem;
  text-align: left;
  border: 1px solid var(--border);
}

th {
  background: var(--bg-secondary);
  font-weight: 600;
  color: var(--text-primary);
}

td {
  color: var(--text-secondary);
}

tr:nth-child(even) td {
  background: var(--bg-secondary);
}

/* ─── Images ─────────────────────────────────────────── */
img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  margin: 1.5rem 0;
  border: 1px solid var(--border);
}

/* ─── Code Blocks ────────────────────────────────────── */
code {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  background: var(--bg-secondary);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  border: 1px solid var(--border);
}

pre {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  overflow-x: auto;
  margin-bottom: 1rem;
}

pre code {
  background: none;
  border: none;
  padding: 0;
}

/* ─── Blockquotes ────────────────────────────────────── */
blockquote {
  border-left: 3px solid var(--accent);
  padding: 0.5rem 1rem;
  margin: 0 0 1rem;
  color: var(--text-secondary);
  background: var(--bg-secondary);
  border-radius: 0 6px 6px 0;
}

blockquote p:last-child {
  margin-bottom: 0;
}

/* ─── Horizontal Rules ───────────────────────────────── */
hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2rem 0;
}

/* ─── Hero Section (Homepage) ────────────────────────── */
.hero {
  text-align: center;
  padding: 3rem 0 2rem;
}

.hero h1 {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
}

.hero .bio {
  font-size: 1.15rem;
  color: var(--text-secondary);
  max-width: 540px;
  margin: 0 auto 1rem;
}

/* ─── Project Cards ──────────────────────────────────── */
.projects-section {
  padding: 1rem 0 2rem;
}

.projects-section h2 {
  margin-bottom: 1.25rem;
}

.project-cards {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.project-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem 1.5rem;
  text-decoration: none;
  color: var(--text-primary);
  transition: border-color 0.2s, transform 0.2s;
  display: block;
}

.project-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  text-decoration: none;
  color: var(--text-primary);
}

.project-card h3 {
  margin: 0 0 0.5rem;
  font-size: 1.15rem;
  color: var(--accent);
}

.project-card p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.project-card .tag {
  display: inline-block;
  font-size: 0.75rem;
  background: var(--accent-subtle);
  color: var(--accent);
  padding: 0.15rem 0.5rem;
  border-radius: 12px;
  margin-top: 0.5rem;
}

/* ─── Footer ─────────────────────────────────────────── */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 1.5rem 0;
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.85rem;
}

/* ─── MathJax Overrides ──────────────────────────────── */
mjx-container {
  color: var(--text-primary) !important;
  overflow-x: auto;
}

mjx-container[jax="SVG"] svg {
  color: var(--text-primary);
}

/* ─── Responsive ─────────────────────────────────────── */
@media (max-width: 600px) {
  :root {
    --header-height: auto;
  }

  .site-header .container {
    flex-direction: column;
    gap: 0.5rem;
    padding-top: 0.75rem;
    padding-bottom: 0.75rem;
  }

  .site-nav {
    justify-content: center;
    gap: 0.15rem;
  }

  .site-nav a {
    font-size: 0.8rem;
    padding: 0.3rem 0.45rem;
  }

  .hero h1 {
    font-size: 1.8rem;
  }

  .main-content {
    padding: 1.5rem 0;
  }
}
