/* ─── Tokens ──────────────────────────────────────────────────────────────── */
:root {
  --cobalt:       #2563EB;
  --cobalt-dark:  #1D4ED8;
  --cobalt-faint: #DBEAFE;
  --tan:          #967856;
  --tan-dark:     #7A6045;
  --tan-faint:    #F7F0E8;
  --text:         #111827;
  --text-muted:   #4B5563;
  --border:       #E2DDD7;
  --bg:           #F8F7F4;
  --nav-bg:       #F8F7F4;
  --footer-bg:    #0F1117;
  --max-w:        900px;
  --font:         'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --serif:        'Playfair Display', Georgia, 'Times New Roman', serif;
  --mono:         'JetBrains Mono', 'Fira Code', 'Courier New', monospace;
}

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

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.65;
  color: var(--text);
  background:
    radial-gradient(900px circle at var(--mouse-x, 50%) var(--mouse-y, 40%), rgba(37,99,235,0.055) 0%, transparent 60%),
    var(--bg);
  min-height: 100vh;
}

/* ─── Nav ─────────────────────────────────────────────────────────────────── */
header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(248,247,244,0.88);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

nav {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 18px 24px 0;
  height: 54px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.brand {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: -0.01em;
  line-height: 1;
  color: var(--cobalt);
  text-decoration: none;
  flex-shrink: 0;
  transition: color 0.15s;
}

.brand:hover { color: var(--cobalt-dark); }

nav ul {
  list-style: none;
  display: flex;
  gap: 24px;
  align-items: center;
}

nav ul a {
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1;
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.15s;
  position: relative;
}

nav ul a::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 0;
  height: 1px;
  background: var(--cobalt);
  transition: width 0.22s ease;
}

nav ul a:hover,
nav ul a.active {
  color: var(--text);
}

nav ul a:hover::after,
nav ul a.active::after {
  width: 100%;
}

/* ─── Main ────────────────────────────────────────────────────────────────── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

main {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 56px 24px 96px;
  animation: fadeUp 0.4s ease both;
}

/* ─── Footer ──────────────────────────────────────────────────────────────── */
footer {
  background: var(--footer-bg);
  margin-top: 40px;
}

footer .inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 20px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  color: rgba(255,255,255,0.5);
}


footer a {
  color: rgba(255,255,255,0.5);
  text-decoration: none;
}

footer a:hover { color: #ffffff; }

/* ─── Typography ──────────────────────────────────────────────────────────── */
h1 {
  font-family: var(--serif);
  font-size: 2.5rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.15;
  color: var(--text);
}

h2 {
  font-family: var(--serif);
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: 0;
  color: var(--text);
  margin-top: 2.5rem;
  margin-bottom: 0.75rem;
}

h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.25rem;
}

p { margin-bottom: 1rem; }
p:last-child { margin-bottom: 0; }

a {
  color: var(--cobalt);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: rgba(37,99,235,0.3);
  transition: color 0.15s, text-decoration-color 0.15s;
}

a:hover {
  color: var(--cobalt-dark);
  text-decoration-color: var(--cobalt-dark);
}

ul, ol {
  padding-left: 1.5rem;
  margin-bottom: 1rem;
}

li { margin-bottom: 0.2rem; }

/* ─── Section label ───────────────────────────────────────────────────────── */
.label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--tan);
  margin-bottom: 8px;
}

.label::before {
  content: '';
  display: inline-block;
  width: 18px;
  height: 2px;
  background: var(--tan);
  flex-shrink: 0;
}

/* ─── Home ────────────────────────────────────────────────────────────────── */
.intro-eyebrow {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--cobalt);
  margin-bottom: 28px;
  opacity: 0.75;
}

.intro {
  padding: 88px 0 72px;
  margin-bottom: 72px;
  border-bottom: 1px solid var(--border);
}

.intro h1 {
  font-size: 5.5rem;
  letter-spacing: -0.045em;
  line-height: 0.92;
  color: var(--text);
  margin-bottom: 32px;
}

.intro h1 em {
  font-style: italic;
  color: var(--cobalt);
}

.intro p {
  font-size: 1.05rem;
  color: var(--text-muted);
  max-width: 460px;
  line-height: 1.8;
}

.home-section {
  margin-bottom: 64px;
}

/* ─── Post list ───────────────────────────────────────────────────────────── */
.post-list {
  list-style: none;
  padding: 0;
  counter-reset: post-counter;
}

.post-row {
  counter-increment: post-counter;
  display: flex;
  align-items: baseline;
  gap: 16px;
  padding: 18px 0;
  border-bottom: 1px solid var(--border);
  transition: opacity 0.15s;
}

.post-row::before {
  content: counter(post-counter, decimal-leading-zero);
  font-family: var(--mono);
  font-size: 0.65rem;
  color: var(--text-muted);
  opacity: 0.35;
  flex-shrink: 0;
  align-self: center;
  min-width: 20px;
}

.post-row:hover {
  opacity: 0.75;
}

.post-row:first-child {
  border-top: 1px solid var(--border);
}

.post-row:last-child {
  border-bottom: 1px solid var(--border);
}

.post-row a {
  font-size: 1rem;
  font-weight: 500;
  color: var(--text);
  text-decoration: none;
  flex: 1;
  min-width: 0;
  transition: color 0.15s;
}

.post-row a:hover { color: var(--cobalt); }

.post-row-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.tag {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--cobalt);
  background: var(--cobalt-faint);
  padding: 2px 8px;
  border-radius: 999px;
  text-decoration: none;
  border: 1px solid rgba(37,99,235,0.2);
}

.date {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-family: var(--mono);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* ─── Blog page ───────────────────────────────────────────────────────────── */
.blog-header {
  margin-bottom: 32px;
}

.blog-header h1 {
  margin-bottom: 8px;
}

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

/* ─── Post ────────────────────────────────────────────────────────────────── */
.post-header {
  margin-bottom: 40px;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--border);
}

.post-tag {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--tan);
  margin-bottom: 10px;
}

.post-header h1 {
  margin-bottom: 8px;
}

.post-meta {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-family: var(--mono);
}

.post-body {
  max-width: 65ch;
}

.post-body p {
  line-height: 1.8;
  margin-bottom: 1.25rem;
}

.post-body h2 {
  margin-top: 2.25rem;
  margin-bottom: 0.75rem;
}

.post-body h3 {
  margin-top: 1.75rem;
  margin-bottom: 0.5rem;
  font-size: 0.95rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

.post-body ul,
.post-body ol {
  margin-bottom: 1.25rem;
  line-height: 1.7;
}

.post-body img {
  max-width: 100%;
  border-radius: 8px;
  margin: 1.5rem 0;
  border: 1px solid var(--border);
}

.post-nav {
  margin-top: 56px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  font-size: 0.875rem;
}

.post-nav a {
  text-decoration: none;
  font-weight: 500;
}

.post-nav a:hover { text-decoration: underline; }

/* ─── Code ────────────────────────────────────────────────────────────────── */
pre[class*="language-"] {
  background: #0d1b2e;
  border-radius: 8px;
  padding: 20px 24px;
  overflow-x: auto;
  margin: 1.5rem 0;
  border: 1px solid #1a3a5c;
  font-size: 0;  /* reset to avoid whitespace issues */
}

pre[class*="language-"] code {
  font-family: var(--mono);
  font-size: 0.85rem;
  line-height: 1.65;
  color: #cbd5e1;
  background: none;
  padding: 0;
  border-radius: 0;
}

code {
  font-family: var(--mono);
  font-size: 0.875em;
}

:not(pre) > code {
  background: var(--cobalt-faint);
  color: var(--cobalt);
  padding: 2px 6px;
  border-radius: 4px;
}

/* Prism token colors (cobalt-dark theme) */
.token.comment,
.token.prolog,
.token.doctype,
.token.cdata          { color: #4a6880; }
.token.punctuation    { color: #8ba7c0; }
.token.keyword        { color: #93c5fd; }
.token.operator       { color: #94a3b8; }
.token.boolean,
.token.number         { color: #fca5a5; }
.token.string,
.token.char,
.token.attr-value     { color: #86efac; }
.token.function       { color: #c4b5fd; }
.token.class-name     { color: #7dd3fc; }
.token.builtin        { color: #67e8f9; }
.token.attr-name      { color: #fde68a; }
.token.tag            { color: #93c5fd; }
.token.regex,
.token.important      { color: #fca5a5; }

/* ─── KaTeX ───────────────────────────────────────────────────────────────── */
.katex-display {
  margin: 1.75rem 0;
  overflow-x: auto;
  padding: 4px 0;
}

/* ─── About ───────────────────────────────────────────────────────────────── */
.about-photo {
  width: 112px;
  height: 112px;
  border-radius: 50%;
  object-fit: cover;
  margin-bottom: 32px;
  border: 3px solid var(--cobalt-faint);
  display: block;
}

.about-body {
  max-width: 58ch;
}

.about-body p {
  line-height: 1.8;
  margin-bottom: 1.25rem;
  color: var(--text);
}

.about-links {
  display: flex;
  gap: 20px;
  margin-top: 32px;
  flex-wrap: wrap;
  list-style: none;
  padding: 0;
}

.about-links a {
  font-size: 0.875rem;
  font-weight: 500;
}

/* ─── Projects ────────────────────────────────────────────────────────────── */
.projects-header {
  margin-bottom: 32px;
}

.projects-header h1 {
  margin-bottom: 8px;
}

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

.project {
  padding: 20px 0;
  border-bottom: 1px solid var(--border);
}

.project:first-of-type {
  border-top: 1px solid var(--border);
}

.project-title-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}

.project-name {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text);
}

.project-stack {
  font-size: 0.75rem;
  font-family: var(--mono);
  color: var(--text-muted);
}

.project-links {
  display: flex;
  gap: 12px;
}

.project-links a {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--cobalt);
}

.project-links a:hover { text-decoration: underline; }

.project p {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.65;
  margin: 0;
}

/* ─── Resume ──────────────────────────────────────────────────────────────── */
.resume-header {
  margin-bottom: 40px;
}

.resume-header h1 {
  margin-bottom: 8px;
}

.resume-contact {
  font-size: 0.875rem;
  color: var(--text-muted);
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.resume-contact a {
  color: var(--text-muted);
  text-decoration: none;
}

.resume-contact a:hover { color: var(--cobalt); }

.resume-section {
  margin-bottom: 40px;
}

.resume-entry {
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}

.resume-entry:first-of-type {
  border-top: 1px solid var(--border);
}

.resume-entry-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 3px;
}

.resume-entry-title {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text);
}

.org-logo {
  width: 16px;
  height: 16px;
  border-radius: 3px;
  object-fit: contain;
  vertical-align: middle;
  margin-right: 6px;
  position: relative;
  top: -1px;
}

.resume-entry-date {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-family: var(--mono);
  white-space: nowrap;
  flex-shrink: 0;
}

.resume-entry-sub {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.resume-entry ul {
  padding-left: 1.25rem;
  font-size: 0.875rem;
  line-height: 1.65;
}

.resume-entry li {
  margin-bottom: 4px;
  color: var(--text);
}

.skills-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 16px 0;
  border-top: 1px solid var(--border);
}

.skill-tag {
  font-size: 0.78rem;
  font-family: var(--mono);
  background: var(--cobalt-faint);
  color: var(--cobalt);
  padding: 4px 10px;
  border-radius: 4px;
}

/* ─── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  h1 { font-size: 1.75rem; }

  main { padding: 40px 16px 72px; }

  nav {
    padding: 16px 16px 0;
    height: 50px;
  }

  nav ul { gap: 16px; }

  .brand { font-size: 0.875rem; }

  .intro { padding: 56px 0 40px; }

  .intro h1 { font-size: 3rem; letter-spacing: -0.03em; }

  .post-row {
    flex-wrap: wrap;
    gap: 6px;
  }

  .resume-entry-header {
    flex-direction: column;
    gap: 2px;
  }

  footer .inner {
    flex-direction: column;
    gap: 8px;
    text-align: center;
  }
}
