/* ============================================================
   Thanh Lam — personal site
   Vibe: a researcher's notebook that's having a good day.
   Dot-grid paper, warm coral + teal, highlighter marks,
   handwritten margin notes. Cheerful, but still rigorous.
   ============================================================ */

:root {
  --bg: #fbf6ee;
  --bg-tint: #f4ead9;
  --surface: #fffdf8;
  --text: #211d2e;
  --text-soft: #534f60;
  --text-faint: #8c8798;
  --border: #e7ddcb;

  --accent: #ef4f2b;        /* warm coral — the star */
  --accent-ink: #cf3c1c;
  --accent-soft: #fde4dc;
  --teal: #0d9488;          /* friendly secondary */
  --teal-soft: #cdeee9;
  --hl: #ffdf6b;            /* highlighter yellow */
  --dot: #d8cdb8;          /* graph-paper dots */

  --shadow: 0 1px 2px rgba(40, 30, 20, .04), 0 10px 30px rgba(60, 40, 20, .08);
  --shadow-lg: 0 16px 48px rgba(60, 40, 20, .16);
  --radius: 16px;
  --maxw: 900px;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-display: 'Fraunces', Georgia, serif;
  --font-hand: 'Caveat', 'Comic Sans MS', cursive;
}

html[data-theme='dark'] {
  --bg: #14131c;
  --bg-tint: #1b1925;
  --surface: #1d1b28;
  --text: #ece9f3;
  --text-soft: #b3aec0;
  --text-faint: #7c7689;
  --border: #2c2939;

  --accent: #ff6b4d;
  --accent-ink: #ff8568;
  --accent-soft: #34211d;
  --teal: #34d3c3;
  --teal-soft: #14302d;
  --hl: #c9a93a;
  --dot: #2a2738;

  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px rgba(0, 0, 0, .4);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, .55);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

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

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background .3s ease, color .3s ease;
  position: relative;
}

/* graph-paper dot grid behind everything */
body::before {
  content: ''; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background-image: radial-gradient(var(--dot) 1.1px, transparent 1.2px);
  background-size: 24px 24px;
  opacity: .55;
  transition: opacity .3s;
}

a { color: var(--accent); text-decoration: none; transition: color .2s; }
a:hover { color: var(--accent-ink); }

/* highlighter marker effect */
.hl {
  background-image: linear-gradient(120deg, var(--hl) 0%, var(--hl) 100%);
  background-repeat: no-repeat;
  background-size: 100% 42%;
  background-position: 0 82%;
  padding: 0 2px;
  font-weight: 600; color: var(--text);
}

/* waving hand */
@keyframes wave {
  0%,60%,100% { transform: rotate(0deg); }
  10%,30% { transform: rotate(16deg); }
  20% { transform: rotate(-10deg); }
  40% { transform: rotate(-5deg); }
  50% { transform: rotate(12deg); }
}
.wave { display: inline-block; transform-origin: 70% 70%; animation: wave 2.6s ease-in-out infinite; }

/* ===== Navigation ===== */
.nav {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid transparent;
  transition: border-color .3s, background .3s;
}
.nav.is-scrolled { border-bottom-color: var(--border); }
.nav__inner {
  max-width: var(--maxw); margin: 0 auto;
  padding: 14px 24px; display: flex; align-items: center; gap: 20px;
}
.nav__brand {
  font-family: var(--font-display); font-weight: 600; font-size: 1.2rem;
  color: var(--text); letter-spacing: .2px;
}
.nav__dot { color: var(--accent); }
.nav__links { display: flex; gap: 22px; margin-left: auto; font-size: .92rem; font-weight: 500; }
.nav__links a { color: var(--text-soft); position: relative; }
.nav__links a::after {
  content: ''; position: absolute; left: 0; right: 100%; bottom: -4px; height: 2px;
  background: var(--accent); border-radius: 2px; transition: right .25s ease;
}
.nav__links a:hover { color: var(--accent); }
.nav__links a:hover::after { right: 0; }
.theme-toggle {
  background: none; border: 1px solid var(--border); cursor: pointer;
  width: 38px; height: 38px; border-radius: 10px;
  display: grid; place-items: center; font-size: 1rem;
  transition: background .2s, transform .2s;
}
.theme-toggle:hover { background: var(--bg-tint); transform: rotate(-12deg) scale(1.05); }

/* ===== Hero ===== */
.hero { padding: 36px 24px 32px; position: relative; overflow: hidden; }
.hero__blob {
  position: absolute; top: -120px; right: -80px; width: 460px; height: 460px;
  background: radial-gradient(circle at 30% 30%, var(--accent-soft), transparent 62%),
              radial-gradient(circle at 70% 70%, var(--teal-soft), transparent 60%);
  filter: blur(10px); opacity: .8; z-index: 0; pointer-events: none;
}
.hero__inner {
  max-width: var(--maxw); margin: 0 auto; position: relative; z-index: 1;
  display: grid; grid-template-columns: 230px 1fr; gap: 44px; align-items: center;
}
.hero__photo { width: 230px; display: flex; flex-direction: column; gap: 10px; }
.hero__photo-frame { position: relative; width: 100%; aspect-ratio: 3 / 4; }
.hero__photo img {
  width: 100%; height: 100%; object-fit: cover;
  border-radius: 22px; box-shadow: var(--shadow-lg);
  border: 4px solid var(--surface);
}
.hero__caption {
  font-family: var(--font-hand); font-size: 1.1rem; font-weight: 600;
  color: var(--text-soft); text-align: center; line-height: 1.2;
}
.hero__photo-fallback {
  display: none; position: absolute; inset: 0;
  flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  border-radius: 22px; border: 2px dashed var(--accent);
  background: var(--accent-soft); color: var(--accent-ink); text-align: center;
}
.hero__photo-fallback span { font-family: var(--font-display); font-size: 3.4rem; font-weight: 600; }
.hero__photo-fallback small { font-family: var(--font-hand); font-size: 1.05rem; color: var(--accent-ink); line-height: 1.3; }
.hero__sticker {
  position: absolute; bottom: -14px; left: -18px;
  font-family: var(--font-hand); font-weight: 700; font-size: 1.25rem;
  background: var(--teal); color: #fff; padding: 4px 14px; border-radius: 20px;
  box-shadow: var(--shadow); transform: rotate(-8deg);
}

.hero__hello { font-family: var(--font-hand); font-size: 1.45rem; font-weight: 600; color: var(--accent); margin-bottom: 0; }
.hero__name {
  font-family: var(--font-display); font-weight: 600;
  font-size: clamp(2.4rem, 7vw, 3.6rem); line-height: .98; letter-spacing: -1px;
  margin-bottom: 6px;
}
.hero__role { font-weight: 600; font-size: .95rem; color: var(--teal); letter-spacing: .2px; margin-bottom: 12px; }
.hero__tagline { font-size: .95rem; color: var(--text-soft); max-width: 58ch; }
.hero__tagline p { margin-bottom: 7px; }
.hero__tagline p:last-child { margin-bottom: 0; }
.hero__tagline strong { color: var(--text); font-weight: 600; }

/* currently status */
.status {
  display: inline-flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-top: 22px; padding: 9px 16px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 999px; box-shadow: var(--shadow); font-size: .86rem;
}
.status__pulse {
  width: 9px; height: 9px; border-radius: 50%; background: var(--teal);
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--teal) 60%, transparent);
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--teal) 55%, transparent); }
  70% { box-shadow: 0 0 0 9px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}
.status__label { font-weight: 700; color: var(--teal); text-transform: uppercase; letter-spacing: 1px; font-size: .72rem; }
.status__text { color: var(--text-soft); }

.hero__actions { display: flex; gap: 14px; margin-top: 18px; flex-wrap: wrap; }
.hero__actions--center { justify-content: center; }
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 12px 24px; border-radius: 12px; font-weight: 600; font-size: .95rem; cursor: pointer;
  transition: transform .15s, box-shadow .2s, background .2s, border-color .2s;
}
.btn--primary { background: var(--accent); color: #fff; box-shadow: var(--shadow); }
.btn--primary:hover { color: #fff; transform: translateY(-3px) rotate(-1deg); box-shadow: var(--shadow-lg); }
.btn--ghost { border: 1px solid var(--border); color: var(--text); background: var(--surface); }
.btn--ghost:hover { color: var(--accent); border-color: var(--accent); transform: translateY(-3px) rotate(1deg); }

.hero__social { margin-top: 14px; display: flex; gap: 10px; align-items: center; font-size: .88rem; font-weight: 500; color: var(--text-faint); flex-wrap: wrap; }

/* ===== Sections ===== */
.section { padding: 30px 24px; position: relative; }
.section--tint { background: var(--bg-tint); }
.section__inner { max-width: var(--maxw); margin: 0 auto; }
.section__inner--center { text-align: center; }
.section__title {
  font-family: var(--font-display); font-size: clamp(1.35rem, 3vw, 1.7rem); font-weight: 600;
  letter-spacing: -.4px; margin-bottom: 14px; display: flex; align-items: baseline; gap: 12px;
}
.section__title--center { justify-content: center; }
.section__num {
  font-family: var(--font-hand); font-size: 1.15rem; font-weight: 700; color: #fff;
  background: var(--accent); width: 32px; height: 32px; flex: 0 0 32px;
  display: grid; place-items: center; border-radius: 50%; transform: rotate(-6deg);
  box-shadow: var(--shadow); align-self: center;
}
.section__lead { color: var(--text-soft); font-size: .9rem; margin-bottom: 14px; max-width: 62ch; }
.section__lead--center { margin: 0 auto 28px; }

.prose p { margin-bottom: 16px; color: var(--text-soft); font-size: 1.05rem; }
.prose strong { color: var(--text); font-weight: 600; }
.prose em { color: var(--accent); font-style: normal; font-weight: 600; }
.prose__kicker {
  border-left: 3px solid var(--accent); padding-left: 18px; margin-top: 22px;
  font-size: 1.08rem;
}

/* ===== Research cards ===== */
.cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow);
  transition: transform .2s, box-shadow .2s, border-color .2s;
}
.card:hover { transform: translateY(-5px) rotate(-1deg); box-shadow: var(--shadow-lg); border-color: var(--accent); }
.card__icon {
  font-size: 1.5rem; margin-bottom: 12px; width: 50px; height: 50px;
  display: grid; place-items: center; border-radius: 14px; background: var(--accent-soft);
}
.card h3 { font-size: 1.1rem; margin-bottom: 6px; letter-spacing: -.2px; }
.card p { color: var(--text-soft); font-size: .95rem; }

/* ===== Beliefs ===== */
.beliefs { margin-top: 42px; }
.beliefs__list { list-style: none; display: grid; grid-template-columns: 1fr 1fr; gap: 14px 28px; }
.beliefs__list li {
  display: flex; gap: 12px; align-items: baseline; color: var(--text-soft); font-size: 1rem;
  padding: 4px 0;
}
.beliefs__list strong { color: var(--text); }
.beliefs__num { font-family: var(--font-hand); font-size: 1.3rem; font-weight: 700; color: var(--teal); flex: 0 0 auto; }

/* ===== Publications ===== */
.pubs { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.pub {
  position: relative;
  display: grid; grid-template-columns: 95px 1fr; gap: 16px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 11px 18px; box-shadow: var(--shadow);
  transition: transform .2s, box-shadow .2s, border-color .2s;
}
.pub:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: var(--accent); }
.pub--fav { border-color: var(--accent); border-width: 1.5px; }
.pub__note-hand {
  position: absolute; top: -14px; right: 18px;
  font-family: var(--font-hand); font-weight: 700; font-size: 1.15rem; color: var(--accent);
  transform: rotate(-3deg); background: var(--bg); padding: 0 8px;
}
.pub__venue { padding-top: 2px; }
.pub__title { font-size: .96rem; line-height: 1.3; letter-spacing: -.2px; margin-bottom: 2px; }
.pub__authors { font-size: .85rem; color: var(--text-soft); }
.pub__authors strong { color: var(--accent); }
.pub__note { color: var(--text-faint); font-weight: 400; font-style: italic; }
.pub__meta { font-size: .92rem; color: var(--text-faint); }
.pub__links { margin-top: 10px; display: flex; gap: 14px; }
.pub__links a { font-size: .86rem; font-weight: 600; }

.tag {
  display: inline-block; font-size: .72rem; font-weight: 700; letter-spacing: .3px;
  padding: 5px 11px; border-radius: 7px; white-space: nowrap; color: #fff;
  transform: rotate(-2deg);
}
.tag--icml    { background: #e0552f; }
.tag--iclr    { background: #0d9488; }
.tag--neurips { background: #7b54c4; }
.tag--preprint{ background: #8c8798; }

/* ===== Timeline ===== */
.timeline { display: flex; flex-direction: column; gap: 4px; }
.timeline__item {
  display: grid; grid-template-columns: 150px 1fr; gap: 20px;
  padding: 9px 0; border-bottom: 1px dashed var(--border);
}
.timeline__item:last-child { border-bottom: none; }
.timeline__date { font-family: var(--font-hand); font-size: 1.05rem; font-weight: 700; color: var(--accent); padding-top: 1px; }
.timeline__content h3 { font-size: 1rem; letter-spacing: -.2px; }
.timeline__emoji { font-size: .9rem; }
.timeline__org { font-size: .88rem; color: var(--teal); font-weight: 600; margin: 1px 0 4px; }
.timeline__content p:last-child { color: var(--text-soft); font-size: .9rem; }
.timeline--compact .timeline__item { grid-template-columns: 110px 1fr; gap: 16px; }

/* ===== Grid 2 / lists ===== */
.grid2 { display: grid; grid-template-columns: 1.15fr 1fr; gap: 44px; }
.subhead {
  font-family: var(--font-display); font-size: 1.1rem; font-weight: 600;
  margin-bottom: 10px; padding-bottom: 6px; border-bottom: 2px solid var(--accent-soft);
}
.subhead--mt { margin-top: 20px; }
.list { list-style: none; display: flex; flex-direction: column; gap: 7px; }
.list li { font-size: .88rem; color: var(--text-soft); }
.list li strong { color: var(--text); }
.list__year { display: inline-block; min-width: 44px; font-family: var(--font-hand); font-size: 1.15rem; font-weight: 700; color: var(--teal); }

/* ===== Footer ===== */
.footer { padding: 36px 24px; border-top: 1px dashed var(--border); }
.footer__inner {
  max-width: var(--maxw); margin: 0 auto;
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  font-size: .9rem; color: var(--text-faint); flex-wrap: wrap;
}
.footer__links { display: flex; gap: 18px; }
.footer__links a { color: var(--text-soft); }

/* ===== Reveal-on-scroll ===== */
[data-reveal] { opacity: 0; transform: translateY(22px); transition: opacity .6s ease, transform .6s ease; }
[data-reveal].is-visible { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  [data-reveal] { opacity: 1; transform: none; transition: none; }
  .wave, .status__pulse { animation: none; }
}

/* ===== Responsive ===== */
@media (max-width: 740px) {
  .nav__links { display: none; }
  .hero { padding: 52px 22px 44px; }
  .hero__inner { grid-template-columns: 1fr; gap: 30px; text-align: center; justify-items: center; }
  .hero__tagline, .status { text-align: left; }
  .hero__hello, .hero__actions, .hero__social { justify-content: center; }
  .cards, .beliefs__list { grid-template-columns: 1fr; }
  .pub { grid-template-columns: 1fr; gap: 10px; }
  .pub__venue { padding-top: 0; }
  .pub__note-hand { position: static; display: inline-block; margin-bottom: 6px; background: none; }
  .timeline__item, .timeline--compact .timeline__item { grid-template-columns: 1fr; gap: 4px; }
  .grid2 { grid-template-columns: 1fr; gap: 32px; }
  .section { padding: 50px 22px; }
}
