/* LIGHT: plain white card on a light-gray page, bold gray name, small gray text */
:root {
  --page: #e6e6e6;
  --card: #ffffff;
  --fg: #373737;
  --muted: #757575;
  --accent: #21759b;
  --strong: #515151;
  --rule: #ededed;
  --mark: #ffe6c2;
  --orange: #e8710a; --hot: 232, 113, 10;
  --shadow: 0 2px 8px rgba(0,0,0,.12);
  --font: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --name-weight: 700;
  --name-color: #515151;
  --h-weight: 600;
  --body-size: 15.5px;
}
/* DARK: slate navy, airy light type, pale-blue links */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --page: #21242f; --card: #2a2d3c; --fg: #f1f3f9; --muted: #a9afc2; --accent: #a9c7f2;
    --strong: #cfe0fb; --rule: #3a3e52; --mark: #4a3a2b; --orange: #ff9a3c; --hot: 255, 154, 60; --shadow: none;
    --font: "Roboto", "Helvetica Neue", Helvetica, Arial, sans-serif;
    --name-weight: 300; --name-color: #ffffff; --h-weight: 300; --body-size: 17px;
  }
}
:root[data-theme="dark"] {
  --page: #21242f; --card: #2a2d3c; --fg: #f1f3f9; --muted: #a9afc2; --accent: #a9c7f2;
  --strong: #cfe0fb; --rule: #3a3e52; --mark: #4a3a2b; --orange: #ff9a3c; --hot: 255, 154, 60; --shadow: none;
  --font: "Roboto", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --name-weight: 300; --name-color: #ffffff; --h-weight: 300; --body-size: 17px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; background-color: var(--page); color: var(--fg);
  background-image:
    radial-gradient(ellipse 65% 55% at 4% 6%,  rgba(160, 100, 220, .18) 0%, transparent 100%),
    radial-gradient(ellipse 55% 65% at 96% 94%, rgba(240, 190, 50,  .15) 0%, transparent 100%);
  font-family: var(--font); font-size: var(--body-size); line-height: 1.65;
  transition: background-color .3s, color .3s;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) body { background-image: none; }
}
:root[data-theme="dark"] body { background-image: none; }

main {
  position: relative; z-index: 1;
  max-width: 780px; margin: 36px auto; padding: 44px 48px 36px;
  background: var(--card); box-shadow: var(--shadow);
  transition: background .3s;
}

/* ---------- header ---------- */
header { display: flex; gap: 30px; align-items: center; flex-wrap: wrap; margin-bottom: 30px; }
.photo { position: relative; width: 160px; height: 160px; flex: none; }
.photo img, .photo .fallback {
  width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block;
  filter: grayscale(1) contrast(1.05);
  transition: filter .5s ease, transform .5s cubic-bezier(.2,.8,.2,1);
}
.photo .fallback {
  display: none; align-items: center; justify-content: center;
  background: var(--rule); color: var(--muted); font-size: 46px; font-weight: 300; letter-spacing: 2px;
}
.photo svg { position: absolute; inset: -10px; width: calc(100% + 20px); height: calc(100% + 20px); pointer-events: none; overflow: visible; }
.photo svg ellipse {
  fill: none; stroke: var(--orange); stroke-width: 2; stroke-linecap: round;
  stroke-dasharray: 420; stroke-dashoffset: 420; transition: stroke-dashoffset .8s ease;
}
.photo:hover img, .photo:hover .fallback { filter: grayscale(0); transform: rotate(-3deg) scale(1.04); }
.photo:hover svg ellipse { stroke-dashoffset: 0; }

h1 { margin: 0; font-size: 2rem; line-height: 1.15; font-weight: var(--name-weight); color: var(--name-color); letter-spacing: -.005em; }
h1 .word { display: inline-block; white-space: nowrap; }
h1 .ch { display: inline-block; transition: transform .25s cubic-bezier(.3,1.8,.5,1), color .25s; }
h1 .ch:hover { transform: translateY(-8px) rotate(-6deg); color: var(--orange); }
.tagline { margin: 8px 0 0; color: var(--muted); font-size: .95rem; }

/* ---------- text ---------- */
h2 {
  font-size: 1.45rem; font-weight: var(--h-weight); color: var(--name-color);
  margin: 44px 0 14px; padding-bottom: 8px; border-bottom: 1px solid var(--rule);
}
p { margin: 0 0 1em; }

/* orange underline sweep on hover, orange accent bar on section headings */
a:hover, a:focus-visible { background-image: linear-gradient(var(--orange), var(--orange)); }
h2 { position: relative; }
h2::after {
  content: ""; position: absolute; left: 0; bottom: -1px; height: 2px; width: 34px; background: var(--orange);
  transition: width .6s cubic-bezier(.2,.8,.2,1);
}
section:hover > h2::after { width: 100%; }
.entries li:hover .title { color: var(--orange); }

/* entrance: everything rises in, one after another */
.rise { animation: rise .8s cubic-bezier(.2,.8,.2,1) both; animation-delay: calc(var(--i, 0) * 90ms); }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.photo svg ellipse { animation: ring 1.6s .5s ease both; }
@keyframes ring { from { stroke-dashoffset: 420; } 60% { stroke-dashoffset: 0; } to { stroke-dashoffset: 420; } }
.photo:hover svg ellipse { animation: none; }
em { font-style: italic; }

a {
  color: var(--accent); text-decoration: none;
  background-image: linear-gradient(currentColor, currentColor);
  background-size: 0% 1.5px; background-position: 0 100%; background-repeat: no-repeat;
  transition: background-size .3s ease;
}
a:hover, a:focus-visible { background-size: 100% 1.5px; }

/* ---------- logo links ---------- */
.links { display: flex; flex-wrap: wrap; gap: 12px; margin: 22px 0 0; padding: 0; list-style: none; }
.icon-link {
  --brand: var(--accent); position: relative;
  display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%;
  border: 1px solid var(--rule); color: var(--muted); background-image: none;
  transition: color .25s, border-color .25s, transform .35s cubic-bezier(.3,1.8,.5,1), box-shadow .25s;
}
.icon-link svg { width: 20px; height: 20px; fill: currentColor; display: block; }
.icon-link:hover, .icon-link:focus-visible {
  background-image: none; color: var(--brand); border-color: var(--brand); transform: translateY(-4px) rotate(-8deg); box-shadow: 0 6px 14px -6px var(--brand);
}
.icon-link::after {
  content: attr(data-label); position: absolute; top: calc(100% + 8px); left: 50%; transform: translate(-50%, -4px);
  font: 600 .72rem/1 var(--font); letter-spacing: .02em; white-space: nowrap;
  color: var(--card); background: var(--fg); padding: 5px 8px; border-radius: 4px;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
}
.icon-link:hover::after, .icon-link:focus-visible::after { opacity: 1; transform: translate(-50%, 0); }
.icon-link.scholar  { --brand: #4285f4; }
.icon-link.linkedin { --brand: #0a66c2; }
.icon-link.github   { --brand: var(--fg); }
.icon-link.orcid    { --brand: #a6ce39; }
.icon-link.mail     { --brand: #d9534f; }
.icon-link.cv       { --brand: var(--accent); }
:root[data-theme="dark"] .icon-link.linkedin { --brand: #6ea8e8; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .icon-link.linkedin { --brand: #6ea8e8; } }

/* ---------- lists (projects) ---------- */
ul.entries { list-style: none; margin: 0; padding: 0; }
.entries li { position: relative; padding: 10px 12px; margin: 0 -12px; border-radius: 6px; isolation: isolate; }
.entries li::before {
  content: ""; position: absolute; inset: 0; z-index: -1; border-radius: 6px; background: var(--mark);
  transform: scaleX(0); transform-origin: left; transition: transform .35s cubic-bezier(.2,.8,.2,1);
}
.entries li:hover::before, .entries li:focus-within::before { transform: scaleX(1); }
.entries .title { font-weight: 700; color: var(--strong); }
.entries .title:hover { color: var(--accent); }
.entries .meta { color: var(--muted); font-size: .88rem; margin-left: 4px; }
.lang-dot { display: inline-block; width: .6em; height: .6em; border-radius: 50%; background: var(--orange); margin: 0 4px 0 6px; transition: transform .3s cubic-bezier(.3,1.8,.5,1); }
.entries li:hover .lang-dot { transform: scale(1.6); }
.entries .desc { margin: 2px 0 0; font-size: .95rem; color: var(--muted); }
.entries .aside {
  display: block; max-height: 0; overflow: hidden; opacity: 0; font-style: italic; font-size: .85rem; color: var(--fg);
  transition: max-height .35s ease, opacity .35s ease, margin .35s ease;
}
.entries li:hover .aside, .entries li:focus-within .aside { max-height: 3em; opacity: .8; margin-top: 4px; }

.more { margin-top: 10px; font-size: .92rem; }
.soon { color: var(--muted); font-style: italic; margin: 0; }
.soon::after { content: ""; display: inline-block; width: .5ch; height: 1.05em; margin-left: 4px; background: var(--orange); vertical-align: text-bottom; animation: blink 1.1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

footer { margin-top: 56px; padding-top: 16px; border-top: 1px solid var(--rule); font-size: .82rem; color: var(--muted); display: flex; justify-content: space-between; align-items: center; gap: 12px; }
#theme {
  font: inherit; background: none; border: 1px solid var(--rule); color: var(--muted);
  border-radius: 999px; padding: 2px 12px; cursor: pointer; transition: transform .3s, color .2s, border-color .2s;
}
#theme:hover { color: var(--accent); border-color: var(--accent); transform: rotate(12deg); }

::selection { background: var(--mark); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
@media (max-width: 820px) { main { margin: 0; padding: 32px 22px 28px; } }
@media (max-width: 520px) { h1 { font-size: 1.65rem; } .photo { width: 130px; height: 130px; } }

/* ======================= blog ======================= */
:root { --code-bg: #f5f5f5; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --code-bg: #20222e; } }
:root[data-theme="dark"] { --code-bg: #20222e; }

.topnav { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: .9rem; margin: -12px 0 30px; }
.topnav a, .topnav a:visited { color: var(--muted); }
.topnav a:hover { color: var(--accent); }
.topnav .sep { color: var(--rule); margin: 0 6px; }

.page-title { margin: 0 0 6px; font-size: 2rem; line-height: 1.2; font-weight: var(--name-weight); color: var(--name-color); }
.post-meta { color: var(--muted); font-size: .88rem; margin: 6px 0 0; }
.post-content { margin-top: 28px; }
.post-content h2 { margin-top: 38px; }
.post-content h3 { font-size: 1.15rem; font-weight: var(--h-weight); color: var(--name-color); margin: 28px 0 8px; }
.post-content img { max-width: 100%; height: auto; border-radius: 4px; }
.post-content figure { margin: 1.4em 0; }
.post-content figcaption { color: var(--muted); font-size: .85rem; text-align: center; margin-top: 6px; }
.post-content blockquote { margin: 1.2em 0; padding: 2px 0 2px 18px; border-left: 3px solid var(--orange); color: var(--muted); }
.post-content table { border-collapse: collapse; width: 100%; font-size: .92rem; margin: 1.2em 0; display: block; overflow-x: auto; }
.post-content th, .post-content td { padding: 6px 12px; border-bottom: 1px solid var(--rule); text-align: left; }
.post-content hr { border: 0; border-top: 1px solid var(--rule); margin: 2em 0; }
.post-content mjx-container[display="true"] { overflow-x: auto; overflow-y: hidden; }
.post-content code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .88em; background: var(--code-bg); padding: .12em .35em; border-radius: 4px; }
.post-content pre { background: var(--code-bg); padding: 14px 16px; border-radius: 6px; overflow-x: auto; line-height: 1.5; margin: 1.2em 0; }
.post-content pre code { background: none; padding: 0; font-size: .85rem; }
.highlight .c, .highlight .cm, .highlight .c1, .highlight .cs { color: var(--muted); font-style: italic; }
.highlight .k, .highlight .kd, .highlight .kn, .highlight .kr, .highlight .kc, .highlight .ow { color: var(--orange); }
.highlight .s, .highlight .s1, .highlight .s2, .highlight .sb, .highlight .si { color: var(--accent); }
.highlight .m, .highlight .mi, .highlight .mf, .highlight .mh { color: var(--orange); }
.highlight .nf, .highlight .nc, .highlight .nd { color: var(--strong); font-weight: 600; }

.post-nav { margin-top: 44px; padding-top: 16px; border-top: 1px solid var(--rule); font-size: .92rem; }

.entries .date { color: var(--muted); font-size: .85rem; font-variant-numeric: tabular-nums; margin-left: 6px; }
