:root {
  --bg: #ffffff;
  --bg-subtle: #f6f8fa;
  --border: #d0d7de;
  --fg: #1f2328;
  --muted: #59636e;
  --accent: #0969da;
  --green: #1a7f37;
  --btn-primary: #1f883d;
  --btn-primary-hover: #1a7f37;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1117; --bg-subtle: #151b23; --border: #3d444d;
    --fg: #f0f6fc; --muted: #9198a1; --accent: #4493f8; --green: #3fb950;
    --btn-primary: #238636; --btn-primary-hover: #1a7f37;
  }
}
:root[data-theme="dark"] {
  --bg: #0d1117; --bg-subtle: #151b23; --border: #3d444d;
  --fg: #f0f6fc; --muted: #9198a1; --accent: #4493f8; --green: #3fb950;
    --btn-primary: #238636; --btn-primary-hover: #1a7f37;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 16px/1.6 var(--sans); -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.wrap { max-width: 760px; margin: 0 auto; padding: 0 16px; }

/* nav */
nav {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--border);
}
nav .wrap { display: flex; align-items: center; gap: 20px; height: 56px; }
nav .brand { font-family: var(--mono); font-weight: 600; color: var(--fg); margin-right: auto; }
nav .links a { color: var(--muted); font-size: 14px; margin-left: 18px; }
nav .links a:hover { color: var(--fg); text-decoration: none; }
#theme {
  background: none; border: 1px solid var(--border); color: var(--muted);
  border-radius: 6px; width: 32px; height: 32px; cursor: pointer; font-size: 15px;
}
#theme:hover { color: var(--fg); background: var(--bg-subtle); }
@media (max-width: 600px) { nav .links { display: none; } }

/* hero */
.hero { padding: 72px 0 48px; display: flex; gap: 28px; align-items: center; }
.hero img {
  width: 112px; height: 112px; border-radius: 50%; object-fit: cover;
  border: 1px solid var(--border); flex-shrink: 0;
}
.hero h1 { font-size: 32px; line-height: 1.2; margin: 0 0 4px; letter-spacing: -0.02em; }
.hero .role { font-family: var(--mono); color: var(--muted); font-size: 14px; margin: 0 0 12px; }
.hero .status {
  display: inline-flex; align-items: center; gap: 8px; font-size: 13px;
  border: 1px solid var(--border); border-radius: 14px; padding: 3px 12px; color: var(--muted);
}
.hero .status::before {
  content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--green);
}
@media (max-width: 600px) {
  .hero { flex-direction: column; align-items: flex-start; padding-top: 48px; }
  .hero img { width: 88px; height: 88px; }
}

/* optional cover photo behind the hero (set in Pages CMS → Profile & intro) */
body { overflow-x: clip; }
.hero.has-cover { position: relative; isolation: isolate; padding-top: 210px; }
.hero.has-cover::before, .hero.has-cover::after {
  content: ""; position: absolute; z-index: -1; top: 0; bottom: 0;
  left: 50%; width: 100vw; transform: translateX(-50%);
}
.hero.has-cover::before { background: var(--cover) var(--cover-pos, center) / cover no-repeat; }
.hero.has-cover::after {
  /* fades the photo into the page so the text stays readable in light and dark mode */
  background: linear-gradient(to bottom,
    color-mix(in srgb, var(--bg) 0%, transparent) 0%,
    color-mix(in srgb, var(--bg) 20%, transparent) 32%,
    color-mix(in srgb, var(--bg) 82%, transparent) 50%,
    color-mix(in srgb, var(--bg) 95%, transparent) 62%,
    var(--bg) 100%);
}
.hero.has-cover img { border: 3px solid var(--bg); box-shadow: 0 2px 12px rgb(0 0 0 / .25); }
.hero.has-cover .status { background: color-mix(in srgb, var(--bg) 80%, transparent); }
@media (max-width: 600px) { .hero.has-cover { padding-top: 140px; } }

.hero-actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }

section { padding: 40px 0; border-top: 1px solid var(--border); }
h2 {
  font-family: var(--mono); font-size: 14px; font-weight: 600; color: var(--muted);
  text-transform: lowercase; margin: 0 0 20px;
}
h2::before { content: "## "; color: var(--accent); }
p { margin: 0 0 12px; }
.lead { font-size: 17px; }

/* projects: GitHub repo-card style */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
@media (max-width: 400px) { .grid { grid-template-columns: 1fr; } }
.card {
  border: 1px solid var(--border); border-radius: 6px; padding: 16px;
  display: flex; flex-direction: column; background: var(--bg);
  transition: border-color .15s;
}
.card:hover { border-color: var(--muted); }
.card h3 { font-size: 15px; margin: 0 0 6px; display: flex; gap: 8px; align-items: center; }
.card h3 svg { fill: var(--muted); flex-shrink: 0; }
.card p { color: var(--muted); font-size: 14px; flex: 1; }
.card ul { color: var(--muted); font-size: 14px; padding-left: 18px; margin: 0 0 12px; flex: 1; }
.meta { font-size: 12px; color: var(--muted); display: flex; gap: 14px; flex-wrap: wrap; }
.lang::before {
  content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 50%;
  margin-right: 5px; vertical-align: -1px; background: var(--c);
}
.tag {
  font-size: 11px; font-family: var(--mono); padding: 1px 8px; border-radius: 999px;
  border: 1px solid var(--border); color: var(--muted);
}

.card.featured { grid-column: 1 / -1; border-color: var(--accent); background: var(--bg-subtle); padding: 20px; }
.card.featured h3 { font-size: 18px; margin-bottom: 10px; }
.card.featured p, .card.featured ul { color: var(--fg); font-size: 15px; flex: none; }
.feat-head { display: flex; gap: 8px; margin-bottom: 10px; }
.tag.live { color: var(--green); border-color: var(--green); }
.card.featured .note { font-size: 12px; color: var(--muted); margin: -6px 0 12px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin: 4px 0 14px; }

/* timeline */
.item { display: grid; grid-template-columns: 150px 1fr; gap: 16px; margin-bottom: 24px; }
.item:last-child { margin-bottom: 0; }
.item .when { font-family: var(--mono); font-size: 13px; color: var(--muted); padding-top: 2px; }
.item h3 { font-size: 16px; margin: 0; }
.item .where { color: var(--muted); font-size: 14px; margin-bottom: 6px; }
.item ul { margin: 0; padding-left: 18px; font-size: 15px; }
@media (max-width: 600px) { .item { grid-template-columns: 1fr; gap: 2px; } }

/* skills */
.skills { display: grid; grid-template-columns: 170px 1fr; gap: 10px 16px; font-size: 15px; }
.skills dt { color: var(--muted); font-family: var(--mono); font-size: 13px; padding-top: 3px; }
.skills dd { margin: 0; }
@media (max-width: 600px) { .skills { grid-template-columns: 1fr; gap: 2px; } .skills dd { margin-bottom: 10px; } }

.pubs { padding-left: 20px; margin: 0; }
.pubs li { margin-bottom: 12px; }
.pubs .venue { color: var(--muted); font-size: 14px; }

.contact { display: flex; gap: 12px; flex-wrap: wrap; }
.btn {
  display: inline-flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 500;
  border: 1px solid var(--border); border-radius: 6px; padding: 6px 14px;
  color: var(--fg); background: var(--bg-subtle);
}
.btn:hover { text-decoration: none; border-color: var(--muted); }
.btn svg { fill: currentColor; }
.btn.primary { background: var(--btn-primary); border-color: transparent; color: #fff; }
.btn.primary:hover { background: var(--btn-primary-hover); }

/* contact form */
.form { display: grid; gap: 12px; max-width: 520px; margin-bottom: 24px; }
.form .row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 480px) { .form .row { grid-template-columns: 1fr; } }
.form label { display: grid; gap: 5px; font-size: 13px; color: var(--muted); font-family: var(--mono); }
.form input, .form textarea {
  font: inherit; font-size: 15px; color: var(--fg); background: var(--bg);
  border: 1px solid var(--border); border-radius: 6px; padding: 9px 12px; width: 100%;
}
.form textarea { min-height: 120px; resize: vertical; }
.form input:focus, .form textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent);
}
.form button { align-self: start; cursor: pointer; }
.form button[disabled] { opacity: .6; cursor: default; }
.form-note { font-size: 13px; margin: 0; min-height: 1.4em; }
.form-note.ok { color: var(--green); }
.form-note.err { color: #cf222e; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .form-note.err { color: #ff7b72; } }
:root[data-theme="dark"] .form-note.err { color: #ff7b72; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

footer { border-top: 1px solid var(--border); padding: 24px 0 40px; color: var(--muted); font-size: 13px; font-family: var(--mono); }

/* ---------- blog ---------- */
:root {
  --code-bg: #f6f8fa;
  --hl-comment: #59636e; --hl-keyword: #cf222e; --hl-string: #0a3069;
  --hl-number: #0550ae; --hl-func: #8250df; --hl-name: #953800;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --code-bg: #151b23;
    --hl-comment: #9198a1; --hl-keyword: #ff7b72; --hl-string: #a5d6ff;
    --hl-number: #79c0ff; --hl-func: #d2a8ff; --hl-name: #ffa657;
  }
}
:root[data-theme="dark"] {
  --code-bg: #151b23;
  --hl-comment: #9198a1; --hl-keyword: #ff7b72; --hl-string: #a5d6ff;
  --hl-number: #79c0ff; --hl-func: #d2a8ff; --hl-name: #ffa657;
}

.page-head { padding: 56px 0 28px; }
.page-head h1 { font-size: 30px; line-height: 1.25; margin: 0 0 8px; letter-spacing: -0.02em; }
.page-head p { color: var(--muted); margin: 0; }
.page-head .meta { font-family: var(--mono); font-size: 13px; color: var(--muted); display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

.post-list { list-style: none; margin: 0; padding: 0; }
.post-list li { padding: 18px 0; border-top: 1px solid var(--border); }
.post-list li:first-child { border-top: 0; padding-top: 0; }
.post-list time { font-family: var(--mono); font-size: 13px; color: var(--muted); }
.post-list h3 { font-size: 18px; margin: 2px 0 4px; }
.post-list p { color: var(--muted); font-size: 15px; margin: 0 0 8px; }
.post-list .tags { display: flex; gap: 6px; flex-wrap: wrap; }
.empty { color: var(--muted); }

.prose { font-size: 17px; line-height: 1.7; padding-bottom: 40px; overflow-wrap: break-word; }
.prose h2, .prose h3, .prose h4 {
  font-family: var(--sans); color: var(--fg); text-transform: none;
  line-height: 1.3; margin: 1.8em 0 .6em; letter-spacing: -0.01em;
}
.prose h2 { font-size: 23px; font-weight: 600; }
.prose h3 { font-size: 19px; }
.prose h2::before { content: none; }
.prose p, .prose ul, .prose ol { margin: 0 0 1.1em; }
.prose li { margin-bottom: .3em; }
.prose img { max-width: 100%; height: auto; border-radius: 6px; border: 1px solid var(--border); }
.prose blockquote {
  margin: 0 0 1.1em; padding: 4px 16px; color: var(--muted);
  border-left: 3px solid var(--border);
}
.prose hr { border: 0; border-top: 1px solid var(--border); margin: 2em 0; }
.prose table { border-collapse: collapse; width: 100%; font-size: 15px; margin: 0 0 1.1em; display: block; overflow-x: auto; }
.prose th, .prose td { border: 1px solid var(--border); padding: 6px 12px; text-align: left; }
.prose th { background: var(--bg-subtle); }
.prose code {
  font-family: var(--mono); font-size: .86em; background: var(--code-bg);
  border: 1px solid var(--border); border-radius: 4px; padding: .1em .35em;
}
.prose pre {
  background: var(--code-bg); border: 1px solid var(--border); border-radius: 6px;
  padding: 14px 16px; overflow-x: auto; font-size: 14px; line-height: 1.55; margin: 0 0 1.2em;
}
.prose pre code { background: none; border: 0; padding: 0; font-size: inherit; }
.prose div.highlighter-rouge { margin: 0; }

/* syntax highlighting (Rouge) */
.highlight .c, .highlight .c1, .highlight .cm, .highlight .cs, .highlight .cp { color: var(--hl-comment); font-style: italic; }
.highlight .k, .highlight .kd, .highlight .kn, .highlight .kr, .highlight .kc, .highlight .kt, .highlight .ow { color: var(--hl-keyword); }
.highlight .s, .highlight .s1, .highlight .s2, .highlight .sb, .highlight .sd, .highlight .se, .highlight .si, .highlight .sx { color: var(--hl-string); }
.highlight .m, .highlight .mi, .highlight .mf, .highlight .mh, .highlight .il { color: var(--hl-number); }
.highlight .nf, .highlight .fm, .highlight .nc { color: var(--hl-func); }
.highlight .nb, .highlight .bp, .highlight .nd, .highlight .na, .highlight .nt { color: var(--hl-name); }

.post-foot { border-top: 1px solid var(--border); padding: 24px 0 8px; display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; font-size: 15px; }
.post-foot a { max-width: 48%; }
.post-foot .next { margin-left: auto; text-align: right; }
@media (max-width: 600px) { .post-foot a { max-width: 100%; } .post-foot .next { margin-left: 0; text-align: left; } }
.back { font-family: var(--mono); font-size: 13px; display: inline-block; margin-top: 32px; }

/* comments (giscus) */
.comments { border-top: 1px solid var(--border); padding: 32px 0 8px; margin-top: 24px; }
.comments .giscus { min-height: 120px; }

/* post cover images */
.post-cover {
  display: block; width: 100%; max-height: 420px; object-fit: cover;
  border-radius: 8px; border: 1px solid var(--border); margin: 0 0 32px;
}
.post-list .thumb {
  display: block; width: 100%; aspect-ratio: 1200 / 630; object-fit: cover;
  border-radius: 6px; border: 1px solid var(--border); margin: 0 0 12px;
}

/* clickable tags */
a.tag { color: var(--muted); text-decoration: none; }
a.tag:hover { color: var(--accent); border-color: var(--accent); text-decoration: none; }
.tag-cloud { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.tag-cloud .tag { font-size: 13px; padding: 3px 10px; }
.tag-cloud .count { opacity: .7; margin-left: 2px; }
.tag-group { padding-top: 32px; scroll-margin-top: 72px; }

/* table of contents */
.toc { border: 1px solid var(--border); border-radius: 8px; background: var(--bg-subtle); padding: 10px 16px; margin: 0 0 28px; font-size: 15px; }
.toc summary { cursor: pointer; font-family: var(--mono); font-size: 13px; color: var(--muted); }
.toc ol { margin: 8px 0 4px; padding-left: 20px; }
.toc li { margin: 3px 0; }
.toc li.sub { margin-left: 16px; list-style: circle; }
.prose h2, .prose h3 { scroll-margin-top: 72px; }

/* copy button on code blocks */
.has-copy { position: relative; }
.copy-btn {
  position: absolute; top: 8px; right: 8px; font: 12px var(--mono);
  color: var(--muted); background: var(--bg); border: 1px solid var(--border);
  border-radius: 6px; padding: 3px 8px; cursor: pointer; opacity: 0; transition: opacity .15s;
}
.has-copy:hover .copy-btn, .copy-btn:focus-visible { opacity: 1; }
.copy-btn:hover { color: var(--fg); border-color: var(--muted); }
@media (hover: none) { .copy-btn { opacity: 1; } }

/* project images */
.card-img { display: block; margin: -16px -16px 14px; border-bottom: 1px solid var(--border); overflow: hidden; border-radius: 6px 6px 0 0; }
.card-img img { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; }
.card.featured .card-img { margin: -20px -20px 16px; }
.card.featured .card-img img { aspect-ratio: 2 / 1; }
a.card-img:hover img { opacity: .92; }

/* links inside running text: underline so they don't rely on colour alone */
main p a:not(.btn):not(.tag), footer a, .prose li a, .prose td a {
  text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 2px;
  text-decoration-color: color-mix(in srgb, currentColor 45%, transparent);
}
main p a:not(.btn):not(.tag):hover, footer a:hover, .prose li a:hover, .prose td a:hover { text-decoration-color: currentColor; }
