/* ---------- Tokens ---------- */
:root {
  --bg: #fbfbfa;
  --surface: #ffffff;
  --surface-2: #f3f3f1;
  --text: #1f2328;
  --text-2: #57606a;
  --text-3: #8b939c;
  --border: #e6e6e3;
  --accent: #2b5fd9;
  --accent-soft: rgba(43, 95, 217, 0.1);
  --code-bg: #f4f4f2;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 6px 24px rgba(0, 0, 0, 0.06);
  --radius: 10px;
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --measure: 720px;
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #0f1115;
  --surface: #161920;
  --surface-2: #1d212a;
  --text: #e6e8eb;
  --text-2: #a4acb7;
  --text-3: #6f7782;
  --border: #272b34;
  --accent: #7aa2ff;
  --accent-soft: rgba(122, 162, 255, 0.14);
  --code-bg: #0d1117;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 24px rgba(0, 0, 0, 0.35);
  color-scheme: dark;
}

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: 5rem;
}

body {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.2s, color 0.2s;
}

main {
  flex: 1;
}

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

a:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

img {
  max-width: 100%;
  height: auto;
}

::selection {
  background: var(--accent-soft);
}

.container {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 3rem 1.25rem 4rem;
}

.single-post {
  max-width: 780px;
}

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 0.75rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--text);
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-right: auto;
}

.brand:hover {
  text-decoration: none;
}

.brand img {
  border-radius: 50%;
}

.nav-list {
  display: flex;
  gap: 0.25rem;
  list-style: none;
}

.nav-list a {
  display: block;
  color: var(--text-2);
  font-size: 0.92rem;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  transition: background-color 0.15s, color 0.15s;
}

.nav-list a:hover {
  color: var(--text);
  background: var(--surface-2);
  text-decoration: none;
}

.nav-list a.active {
  color: var(--text);
  background: var(--surface-2);
  font-weight: 500;
}

.theme-toggle {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  color: var(--text-2);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.theme-toggle:hover {
  color: var(--text);
  border-color: var(--text-3);
}

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

[data-theme="dark"] .theme-toggle .icon-sun {
  display: block;
}

/* ---------- Typography ---------- */
h1,
h2,
h3,
h4 {
  color: var(--text);
  line-height: 1.25;
  letter-spacing: -0.02em;
  font-weight: 650;
}

.eyebrow {
  color: var(--text-3);
  font-size: 0.85rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.eyebrow a {
  color: inherit;
}

.page-header {
  margin-bottom: 2.5rem;
}

.page-header h1 {
  font-size: 2.25rem;
}

.page-lede {
  margin-top: 0.5rem;
  color: var(--text-2);
}

/* ---------- Prose (markdown content) ---------- */
.prose {
  font-size: 1.05rem;
  line-height: 1.75;
}

.prose > *:first-child {
  margin-top: 0;
}

.prose h1 {
  font-size: 1.75rem;
  margin: 2.5rem 0 1rem;
}

.prose h2 {
  font-size: 1.4rem;
  margin: 2.5rem 0 0.75rem;
}

.prose h3 {
  font-size: 1.15rem;
  margin: 2rem 0 0.5rem;
}

.prose p {
  margin: 1.1rem 0;
}

.prose ul,
.prose ol {
  margin: 1rem 0;
  padding-left: 1.4rem;
}

.prose li {
  margin: 0.35rem 0;
}

.prose li::marker {
  color: var(--text-3);
}

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

.prose blockquote {
  border-left: 3px solid var(--accent);
  background: var(--surface-2);
  padding: 0.75rem 1.25rem;
  margin: 1.75rem 0;
  border-radius: 0 var(--radius) var(--radius) 0;
  color: var(--text-2);
}

.prose blockquote p {
  margin: 0.4rem 0;
}

.prose hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 2.5rem 0;
}

.prose table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.95rem;
  display: block;
  overflow-x: auto;
}

.prose th,
.prose td {
  border-bottom: 1px solid var(--border);
  padding: 0.55rem 0.75rem;
  text-align: left;
}

.prose th {
  font-weight: 600;
  background: var(--surface-2);
}

code,
kbd,
pre {
  font-family: var(--font-mono);
}

.prose :not(pre) > code {
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 0.1em 0.35em;
  border-radius: 5px;
  font-size: 0.86em;
}

.prose pre,
.highlight pre {
  background: var(--code-bg) !important;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  overflow-x: auto;
  font-size: 0.85rem;
  line-height: 1.6;
  margin: 1.5rem 0;
}

.highlight {
  margin: 1.5rem 0;
}

.highlight pre {
  margin: 0;
}

.prose pre code {
  background: none;
  border: 0;
  padding: 0;
  font-size: inherit;
}

.chroma .lntd {
  vertical-align: top;
  padding: 0;
}

.chroma .lntable {
  border-spacing: 0;
  display: table;
  margin: 0;
  width: auto;
}

.chroma .lntable td {
  border: 0;
  padding: 0;
}

.chroma .ln,
.chroma .lnt {
  color: var(--text-3) !important;
  user-select: none;
}

.post-content img {
  display: block;
  margin: 2rem auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  cursor: zoom-in;
  transition: transform 0.2s ease;
}

.post-content img:hover {
  transform: translateY(-2px);
}

/* ---------- Buttons, tags, chips ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  padding: 0.55rem 1.1rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.92rem;
  font-weight: 500;
  transition: border-color 0.15s, background-color 0.15s, transform 0.15s;
}

.btn:hover {
  text-decoration: none;
  border-color: var(--text-3);
  transform: translateY(-1px);
}

.btn-primary {
  background: var(--text);
  border-color: var(--text);
  color: var(--bg);
}

.btn-primary:hover {
  border-color: var(--text);
  opacity: 0.9;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.78rem;
  color: var(--text-2);
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 0.1rem 0.55rem;
  border-radius: 999px;
  transition: color 0.15s, border-color 0.15s;
}

.tag:hover {
  color: var(--accent);
  border-color: var(--accent);
  text-decoration: none;
}

.tag-lg {
  font-size: 0.92rem;
  padding: 0.3rem 0.8rem;
}

.tag .count {
  color: var(--text-3);
  font-size: 0.8em;
}

.term-cloud {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.chip {
  display: inline-block;
  font-size: 0.82rem;
  padding: 0.12rem 0.6rem;
  margin: 0 0.35rem 0.4rem 0;
  border-radius: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
}

/* ---------- Home ---------- */
.hero {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
  padding: 1rem 0 2.5rem;
  margin-bottom: 2.5rem;
  border-bottom: 1px solid var(--border);
}

.hero-avatar {
  flex: none;
  border-radius: 50%;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.hero-title {
  font-size: 2.6rem;
  letter-spacing: -0.03em;
  margin: 0.1rem 0 0.6rem;
}

.hero-sub {
  color: var(--text-2);
  font-size: 1.1rem;
  max-width: 34em;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 1.4rem;
}

/* The about page markdown starts with its own "About Me" h1; keep it modest */
.home-content h1 {
  font-size: 1.5rem;
}

.recent {
  margin-top: 3.5rem;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.5rem;
}

.section-head h2 {
  font-size: 1.25rem;
}

.section-head a {
  font-size: 0.9rem;
}

/* ---------- Post lists ---------- */
.year-group {
  margin-bottom: 2.5rem;
}

.year-heading {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-3);
  letter-spacing: 0.04em;
  margin-bottom: 0.25rem;
}

.post-list {
  list-style: none;
}

.post-item {
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--border);
}

.post-item:last-child {
  border-bottom: 0;
}

.post-item-link {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  color: var(--text);
}

.post-item-link:hover {
  text-decoration: none;
}

.post-item-title {
  font-weight: 500;
  transition: color 0.15s;
}

.post-item-link:hover .post-item-title {
  color: var(--accent);
}

.post-item-date {
  flex: none;
  color: var(--text-3);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}

.post-item .tag-row {
  margin-top: 0.4rem;
}

/* ---------- Single post ---------- */
.post-header {
  margin-bottom: 2.5rem;
  padding-bottom: 1.75rem;
  border-bottom: 1px solid var(--border);
}

.back-link {
  display: inline-block;
  font-size: 0.88rem;
  color: var(--text-3);
  margin-bottom: 1.25rem;
}

.back-link:hover {
  color: var(--text);
  text-decoration: none;
}

.post-title {
  font-size: 2.4rem;
  letter-spacing: -0.03em;
  margin-bottom: 0.75rem;
}

.post-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  color: var(--text-3);
  font-size: 0.9rem;
  margin-bottom: 0.9rem;
}

.post-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 4rem;
}

.post-nav-link {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 1rem 1.2rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-weight: 500;
  transition: border-color 0.15s, transform 0.15s;
}

.post-nav-link:hover {
  text-decoration: none;
  border-color: var(--accent);
  transform: translateY(-1px);
}

.post-nav-link.prev {
  text-align: right;
  grid-column: 2;
}

.post-nav-label {
  font-size: 0.78rem;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 500;
}

/* ---------- Resume ---------- */
.resume-header {
  padding-bottom: 2rem;
  margin-bottom: 2.25rem;
  border-bottom: 1px solid var(--border);
}

.resume-header h1 {
  font-size: 2.6rem;
  letter-spacing: -0.03em;
}

.resume-title {
  color: var(--text-2);
  font-size: 1.1rem;
  margin-top: 0.25rem;
}

.resume-contact {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.25rem;
  margin-top: 1rem;
  font-size: 0.92rem;
  color: var(--text-2);
}

.resume-section {
  margin-bottom: 3rem;
}

.resume-section > h2 {
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-3);
  font-weight: 600;
  margin-bottom: 1.25rem;
}

.resume-summary {
  font-size: 1.08rem;
  line-height: 1.75;
}

.timeline {
  list-style: none;
  border-left: 2px solid var(--border);
  margin-left: 0.35rem;
}

.timeline-item {
  position: relative;
  padding: 0 0 2.25rem 1.5rem;
}

.timeline-item:last-child {
  padding-bottom: 0;
}

.timeline-item::before {
  content: "";
  position: absolute;
  left: -7px;
  top: 0.45rem;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--bg);
  border: 2px solid var(--accent);
}

.timeline-item:first-child::before {
  background: var(--accent);
}

.job-head,
.job-sub {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0 1rem;
}

.job-head h3 {
  font-size: 1.1rem;
}

.job-period {
  color: var(--text-3);
  font-size: 0.88rem;
  font-variant-numeric: tabular-nums;
}

.job-company {
  color: var(--text-2);
  font-weight: 500;
}

.job-location {
  color: var(--text-3);
  font-size: 0.88rem;
}

.job-context {
  margin-top: 0.4rem;
  font-size: 0.9rem;
  color: var(--text-2);
  font-style: italic;
}

.job-highlights {
  margin-top: 0.75rem;
  padding-left: 1.1rem;
}

.job-highlights li {
  margin: 0.4rem 0;
  line-height: 1.65;
}

.job-highlights li::marker {
  color: var(--text-3);
}

.skills {
  display: grid;
  gap: 0.75rem;
}

.skill-row {
  display: grid;
  grid-template-columns: 9rem 1fr;
  gap: 1rem;
}

.skill-row dt {
  font-weight: 600;
  font-size: 0.92rem;
  padding-top: 0.15rem;
}

.education {
  list-style: none;
  display: grid;
  gap: 1.25rem;
}

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--border);
}

.footer-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 1.75rem 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  font-size: 0.88rem;
}

.copyright {
  color: var(--text-3);
}

.social-list {
  display: flex;
  gap: 1.25rem;
}

.social-list a {
  color: var(--text-2);
}

.social-list a:hover {
  color: var(--text);
}

/* ---------- Image modal ---------- */
.image-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.88);
  cursor: zoom-out;
}

.image-modal.open {
  display: grid;
  place-items: center;
}

.image-modal img {
  max-width: 92vw;
  max-height: 90vh;
  border-radius: var(--radius);
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.5);
  cursor: default;
}

.image-modal .close {
  position: absolute;
  top: 1rem;
  right: 1.5rem;
  background: none;
  border: 0;
  color: #fff;
  font-size: 2.5rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0.8;
}

.image-modal .close:hover {
  opacity: 1;
}

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  .container {
    padding: 2rem 1rem 3rem;
  }

  .header-inner {
    flex-wrap: wrap;
    padding: 0.6rem 1rem;
    gap: 0.5rem;
  }

  .site-header nav {
    order: 3;
    width: 100%;
    overflow-x: auto;
  }

  .nav-list a {
    padding: 0.3rem 0.6rem;
  }

  .hero {
    flex-direction: column;
    gap: 1rem;
  }

  .hero-title,
  .resume-header h1 {
    font-size: 2rem;
  }

  .post-title,
  .page-header h1 {
    font-size: 1.8rem;
  }

  .post-item-link {
    flex-direction: column;
    gap: 0.1rem;
  }

  .post-nav {
    grid-template-columns: 1fr;
  }

  .post-nav-link.prev {
    grid-column: auto;
  }

  .skill-row {
    grid-template-columns: 1fr;
    gap: 0.25rem;
  }

  .footer-inner {
    justify-content: center;
    text-align: center;
  }
}

.nowrap {
  white-space: nowrap;
}
