/* Home page: blue-white academic theme */

:root {
  --ink: #14213d;
  --ink-soft: #46536b;
  --ink-faint: #74819a;
  --blue-900: #0f2a5c;
  --blue-700: #1d4ea3;
  --blue-600: #2a62c4;
  --blue-200: #c7d8f4;
  --blue-100: #e3ecfb;
  --blue-50:  #f4f7fd;
  --white: #ffffff;
  --line: #dde6f4;

  --mask: #dbe6f8;
  --mask-active: #a9c3ee;

  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  --radius: 12px;
  --shadow: 0 1px 2px rgba(15, 42, 92, .06), 0 8px 24px -12px rgba(15, 42, 92, .18);
}

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 72px; }

body {
  margin: 0;
  background: var(--white);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--blue-700); }

.wrap {
  width: 100%;
  max-width: 980px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ---------- Top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(255, 255, 255, .88);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}

.topbar__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 60px;
}

.topbar__name {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.08rem;
  color: var(--blue-900);
  text-decoration: none;
  white-space: nowrap;
}

.topbar__nav { display: flex; gap: 4px; }

.topbar__nav a {
  font-size: .9rem;
  font-weight: 500;
  color: var(--ink-soft);
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 8px;
  transition: color .2s, background-color .2s;
  white-space: nowrap;
}

.topbar__nav a:hover { color: var(--blue-700); background: var(--blue-50); }

/* ---------- Hero ---------- */

.hero {
  position: relative;
  overflow: hidden;
  background: linear-gradient(180deg, var(--blue-50) 0%, var(--white) 100%);
  border-bottom: 1px solid var(--line);
}

/* Faint lattice of tokens in the background */
.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(var(--blue-200) 1.2px, transparent 1.2px);
  background-size: 22px 22px;
  -webkit-mask-image: linear-gradient(100deg, transparent 35%, #000 100%);
          mask-image: linear-gradient(100deg, transparent 35%, #000 100%);
  opacity: .7;
  pointer-events: none;
}

.hero__inner {
  position: relative;
  display: flex;
  align-items: center;
  gap: 28px;
  padding-top: 36px;
  padding-bottom: 36px;
}

/* Monogram: the LaTeX letter \mathcal{A} in a circle, from KaTeX's Computer Modern fonts.
   For \mathbb{A} instead, change the font-family below to "KaTeX_AMS". */
@font-face {
  font-family: "KaTeX_Caligraphic";
  src: url("https://cdn.jsdelivr.net/npm/katex@0.16.11/dist/fonts/KaTeX_Caligraphic-Regular.woff2") format("woff2");
  font-display: block;
}

@font-face {
  font-family: "KaTeX_AMS";
  src: url("https://cdn.jsdelivr.net/npm/katex@0.16.11/dist/fonts/KaTeX_AMS-Regular.woff2") format("woff2");
  font-display: block;
}

.hero__mark {
  flex: none;
  display: grid;
  place-items: center;
  width: 168px;
  height: 168px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 25%, var(--white) 0%, var(--blue-50) 100%);
  border: 4px solid var(--white);
  box-shadow: 0 0 0 1px var(--blue-200), 0 12px 32px -12px rgba(15, 42, 92, .35);
  user-select: none;
}

.hero__glyph {
  /* Optical centring of the slanted calligraphic letter */
  transform: translate(-2%, -3%);
  padding: 0 .08em;
  font-family: "KaTeX_Caligraphic", var(--serif);
  font-weight: 400;
  font-size: 118px;
  line-height: 1;
  background: linear-gradient(160deg, var(--blue-900) 15%, var(--blue-600) 85%);
  -webkit-background-clip: text;
          background-clip: text;
  color: transparent;
}

.hero__name {
  margin: 0;
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(1.7rem, 3.6vw, 2.2rem);
  line-height: 1.1;
  letter-spacing: -.01em;
  color: var(--blue-900);
}

.hero__tagline {
  margin: 6px 0 0;
  font-size: 1rem;
  color: var(--ink-soft);
}

.hero__location {
  margin: 0;
  font-size: .9rem;
  color: var(--ink-faint);
}

.links {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0 0;
  padding: 0;
}

.link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 12px;
  font-size: .85rem;
  font-weight: 500;
  color: var(--blue-700);
  background: var(--white);
  border: 1px solid var(--blue-200);
  border-radius: 999px;
  text-decoration: none;
  transition: background-color .2s, color .2s, border-color .2s, transform .2s;
}

.link svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.link:hover,
.link:focus-visible {
  background: var(--blue-700);
  border-color: var(--blue-700);
  color: var(--white);
  transform: translateY(-1px);
}

/* ---------- Sections ---------- */

.section { padding: 72px 0; }
.section--tint { background: var(--blue-50); border-top: 1px solid var(--line); }

.section__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin-bottom: 28px;
}

.section__title {
  position: relative;
  margin: 0;
  padding-bottom: 10px;
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.75rem;
  line-height: 1.2;
  color: var(--blue-900);
}

.section__title::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 40px;
  height: 3px;
  border-radius: 2px;
  background: var(--blue-600);
}

/* ---------- About (prose) ---------- */

.prose { max-width: 760px; }
.prose p { margin: 0 0 1.1em; color: var(--ink); }
.prose p:last-child { margin-bottom: 0; }
.prose strong { font-weight: 600; color: var(--blue-900); }

.prose a {
  color: var(--blue-700);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  text-decoration-color: var(--blue-200);
  transition: text-decoration-color .3s, color .2s;
}

.prose a:hover { color: var(--blue-900); text-decoration-color: var(--blue-700); }

/* ---------- Block-diffusion decoding ---------- */

.decoder {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-family: var(--mono);
  font-size: .76rem;
  color: var(--ink-faint);
}

.decoder[hidden] { display: none; }

.decoder__status { white-space: nowrap; }

.decoder__replay {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  font: inherit;
  color: var(--blue-700);
  background: var(--white);
  border: 1px solid var(--blue-200);
  border-radius: 999px;
  cursor: pointer;
  transition: background-color .2s, border-color .2s;
}

.decoder__replay:hover { background: var(--blue-50); border-color: var(--blue-600); }

.decoder__replay svg {
  width: 12px;
  height: 12px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Hide the raw text until the script has masked it (failsafe: show after 2.5s) */
.js-diffuse [data-diffuse]:not(.is-ready) {
  visibility: hidden;
  animation: diffuse-failsafe 0s linear 2.5s forwards;
}

@keyframes diffuse-failsafe { to { visibility: visible; } }

.tok { transition: color .45s ease; }

/* A masked token: the word is hidden and a [MASK] token is shown instead */
.tok.is-masked { font-size: 0; }

.tok.is-masked::before {
  content: "[MASK]";
  display: inline-block;
  margin: 0 1px;
  padding: 0 .4em;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  font-style: normal;
  line-height: 1.75;
  letter-spacing: .02em;
  vertical-align: 1px;
  color: var(--blue-600);
  background-color: var(--mask);
  border-radius: 4px;
  transition: background-color .3s ease, color .3s ease;
}

/* Tokens in the paragraph currently being denoised */
.tok.is-masked.is-active::before {
  color: var(--blue-900);
  background-color: var(--mask-active);
}

/* A token that was just unmasked fades in blue, then settles */
.tok.is-fresh {
  color: var(--blue-600);
  animation: tok-in .35s ease;
}

@keyframes tok-in { from { opacity: 0; } }

/* Hide link underlines until the whole link is decoded */
.is-diffusing a:not(.is-decoded) { text-decoration-color: transparent; }

/* ---------- Research interest cards ---------- */

.cards {
  list-style: none;
  max-width: 760px;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.card {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 18px;
  padding: 16px 22px 16px 20px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: transform .25s ease, box-shadow .25s ease, border-color .25s ease;
}

.card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: linear-gradient(180deg, var(--blue-700), var(--blue-200));
}

.card:hover {
  transform: translateX(3px);
  border-color: var(--blue-200);
  box-shadow: 0 1px 2px rgba(15, 42, 92, .06), 0 16px 32px -14px rgba(15, 42, 92, .28);
}

.card__rank {
  flex: none;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.1rem;
  line-height: 1;
  color: var(--blue-700);
  background: var(--blue-100);
  border: 1px solid var(--blue-200);
}

/* The first preference stands out */
.card:first-child .card__rank {
  color: var(--white);
  background: var(--blue-700);
  border-color: var(--blue-700);
}

.card__title {
  margin: 0;
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.16rem;
  line-height: 1.3;
  color: var(--blue-900);
}

.card__desc {
  margin: 4px 0 0;
  font-size: .93rem;
  line-height: 1.55;
  color: var(--ink-soft);
}

/* ---------- Software ---------- */

.tools {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}

.tool {
  display: flex;
  flex-direction: column;
  padding: 22px 22px 20px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: transform .25s ease, box-shadow .25s ease, border-color .25s ease;
}

.tool:hover {
  transform: translateY(-3px);
  border-color: var(--blue-200);
  box-shadow: 0 1px 2px rgba(15, 42, 92, .06), 0 16px 32px -14px rgba(15, 42, 92, .28);
}

.tool__name {
  margin: 0;
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.16rem;
  line-height: 1.3;
  color: var(--blue-900);
}

.tool__desc {
  margin: 6px 0 0;
  font-size: .93rem;
  line-height: 1.6;
  color: var(--ink-soft);
}

.tool__links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: auto;
  padding-top: 16px;
}

.tool__link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  font-size: .82rem;
  font-weight: 500;
  color: var(--blue-700);
  text-decoration: none;
  background: var(--blue-50);
  border: 1px solid var(--blue-200);
  border-radius: 999px;
  transition: background-color .2s, color .2s, border-color .2s;
}

.tool__link:hover,
.tool__link:focus-visible {
  color: var(--white);
  background: var(--blue-700);
  border-color: var(--blue-700);
}

.tool__link svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

@media (max-width: 640px) {
  .tools { grid-template-columns: 1fr; }
}

/* ---------- Footer ---------- */

.footer {
  border-top: 1px solid var(--line);
  background: var(--white);
}

.footer__inner {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 24px;
  padding-top: 24px;
  padding-bottom: 24px;
  font-size: .85rem;
  color: var(--ink-faint);
}

/* ---------- Responsive ---------- */

@media (max-width: 640px) {
  body { font-size: 16px; }
  .wrap { padding: 0 16px; }
  .topbar__nav a { padding: 6px 8px; font-size: .85rem; }
  .hero__inner {
    align-items: flex-start;
    gap: 14px;
    padding-top: 26px;
    padding-bottom: 26px;
  }
  .hero__mark { width: 84px; height: 84px; border-width: 3px; }
  .hero__glyph { font-size: 58px; }
  .section { padding: 52px 0; }
  .card { gap: 14px; padding: 14px 16px 14px 16px; }
  .card__title { font-size: 1.05rem; }
}

@media (max-width: 480px) {
  .topbar__name { display: none; }
  .topbar__inner { justify-content: flex-end; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .tok, .card, .link { transition: none; }
}
