/* Caveat (SIL Open Font License, fonts/OFL.txt), served from here: loading it from Google would
   send every visitor's address to Google. Latin subset, variable weight. */
@font-face {
  font-family: "Caveat"; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url("fonts/caveat-latin.woff2") format("woff2");
}

/* Tokens: GitHub-like neutrals. */
:root {
  color-scheme: light;
  --bg: #ffffff;
  --bg-subtle: #f6f8fa;
  --bg-inset: #eff2f5;
  --border: #d1d9e0;
  --border-muted: #e1e6eb;
  --fg: #1f2328;
  --muted: #59636e;
  --accent: #0969da;
  --accent-soft: #ddf4ff;
  --btn: #f6f8fa;
  --btn-hover: #eef1f4;
  --primary: #1f883d;
  --primary-fg: #ffffff;
  --star: #9a6700;
  --dot: rgba(31, 35, 40, 0.09);
  --shadow: 0 1px 0 rgba(31, 35, 40, 0.04), 0 8px 24px rgba(66, 74, 83, 0.12);
  --figure-bg: #ffffff;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --hand: "Caveat", "Comic Sans MS", cursive;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d1117; --bg-subtle: #151b23; --bg-inset: #010409; --border: #3d444d; --border-muted: #2a313a;
  --fg: #f0f6fc; --muted: #9198a1; --accent: #4493f8; --accent-soft: #121d2f; --btn: #212830; --btn-hover: #262c36;
  --primary: #238636; --primary-fg: #ffffff; --star: #d29922; --dot: rgba(240, 246, 252, 0.07);
  --shadow: 0 0 0 1px #3d444d, 0 8px 24px #010409;
  --figure-bg: #f6f8fa;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0d1117; --bg-subtle: #151b23; --bg-inset: #010409; --border: #3d444d; --border-muted: #2a313a;
    --fg: #f0f6fc; --muted: #9198a1; --accent: #4493f8; --accent-soft: #121d2f; --btn: #212830; --btn-hover: #262c36;
    --primary: #238636; --primary-fg: #ffffff; --star: #d29922; --dot: rgba(240, 246, 252, 0.07);
    --shadow: 0 0 0 1px #3d444d, 0 8px 24px #010409;
      --figure-bg: #f6f8fa;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 72px; }
body {
  margin: 0;
  background-color: var(--bg);
  /* graph paper / go board: the rabbit hole is a grid */
  background-image: radial-gradient(var(--dot) 1px, transparent 1.2px);
  background-size: 22px 22px;
  color: var(--fg);
  font: 14px/1.5 var(--sans);
  overflow-x: hidden;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img, video, iframe { max-width: 100%; }
code, kbd { font-family: var(--mono); font-size: 85%; background: var(--bg-inset); border-radius: 6px; padding: 0.15em 0.4em; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
[hidden] { display: none !important; }

/* ------------------------------------------------------------- top bar */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 24px;
  padding: 0 24px; height: 56px;
  background: var(--bg-subtle); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 8px; color: var(--fg); font-weight: 600; white-space: nowrap; }
.brand img { width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--border); }
.tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; flex: 1; align-self: stretch; }
.tabs a {
  display: flex; align-items: center; gap: 6px; padding: 0 10px; color: var(--fg); white-space: nowrap;
  border-bottom: 2px solid transparent;
}
.tabs a:hover { text-decoration: none; border-bottom-color: var(--border); }
.tabs a.active { border-bottom-color: #fd8c73; font-weight: 600; }
.counter { min-width: 20px; padding: 0 6px; border-radius: 2em; background: var(--btn); border: 1px solid var(--border-muted); font-size: 12px; line-height: 18px; text-align: center; }
.counter:empty { display: none; }
.theme-toggle {
  display: grid; place-items: center; width: 32px; height: 32px; border-radius: 6px;
  border: 1px solid var(--border); background: var(--btn); color: var(--fg); cursor: pointer;
}
.theme-toggle:hover { background: var(--btn-hover); }

/* ------------------------------------------------------------- layout */
.layout {
  max-width: 1440px; margin: 0 auto; padding: 32px 24px 0;
  display: grid; gap: 24px 32px; align-items: start;
  grid-template-columns: 280px minmax(0, 1fr) 340px;
  grid-template-areas: "profile main rail";
}
.profile { grid-area: profile; }
.main { grid-area: main; display: flex; flex-direction: column; gap: 32px; min-width: 0; }
.rail { grid-area: rail; display: flex; flex-direction: column; gap: 24px; min-width: 0; }
@media (max-width: 1239px) {
  .layout { grid-template-columns: 300px minmax(0, 1fr); grid-template-areas: "profile main" "rail main"; grid-template-rows: auto 1fr; }
}
@media (max-width: 860px) {
  .layout { grid-template-columns: minmax(0, 1fr); grid-template-areas: "profile" "main" "rail"; padding: 16px 16px 0; }
  .topbar { padding: 0 16px; gap: 12px; }
  .brand span { display: none; }
}

.box { background: var(--bg); border: 1px solid var(--border); border-radius: 6px; }
.section-title { font-size: 16px; font-weight: 600; margin-bottom: 8px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.section-head .section-title { margin: 0; }
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 16px; border-radius: 6px;
  border: 1px solid var(--border); background: var(--btn); color: var(--fg); font-weight: 500; font-size: 14px;
}
.btn:hover { background: var(--btn-hover); text-decoration: none; }
.btn.primary { background: var(--primary); border-color: rgba(31, 35, 40, 0.15); color: var(--primary-fg); }
.btn.primary:hover { filter: brightness(1.08); }
.icon { width: 16px; height: 16px; flex: none; fill: currentColor; vertical-align: text-bottom; }

/* ------------------------------------------------------------- profile */
.avatar-wrap { position: relative; }
.avatar { display: block; width: 100%; aspect-ratio: 1; border-radius: 50%; border: 1px solid var(--border); object-fit: cover; box-shadow: var(--shadow); }
/* The status bubble: a circle with an icon that opens into the full text on hover. A fixed-width
   text block keeps long truths from reflowing while the bubble grows. */
.status {
  position: absolute; left: 75%; bottom: 10%; z-index: 2;
  display: flex; align-items: flex-start; gap: 8px; padding: 8px; max-width: 38px; max-height: 38px; overflow: hidden;
  border-radius: 19px; border: 1px solid var(--border); background: var(--bg); color: var(--fg);
  box-shadow: var(--shadow); transition: max-width 0.3s ease, max-height 0.3s ease; cursor: default;
}
a.status { cursor: pointer; }
a.status:hover { text-decoration: none; border-color: var(--accent); }
.status:hover, .status:focus, .status:focus-within { max-width: 360px; max-height: 260px; padding-right: 14px; }
.status-icon { flex: none; display: grid; place-items: center; width: 20px; height: 20px; }
.status-icon svg { width: 20px; height: 20px; fill: currentColor; }
.status-text { flex: none; width: max-content; max-width: min(280px, calc(100vw - 150px)); line-height: 20px; font-size: 13px; }
.profile h1 { font-size: 26px; font-weight: 600; margin-top: 16px; }
.handles { font-size: 20px; font-weight: 300; color: var(--muted); line-height: 1.2; }
.bio { font-size: 16px; margin: 12px 0; }
.profile .btn.mail { width: 100%; justify-content: center; margin-bottom: 16px; }
.facts, .socials { list-style: none; margin: 0 0 16px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.facts li, .socials li { display: flex; gap: 8px; align-items: flex-start; }
.facts .icon, .socials .icon { margin-top: 2px; color: var(--muted); }
.socials a { color: var(--fg); }
.socials a:hover { color: var(--accent); }
.socials .stat { color: var(--muted); }
.profile-section { border-top: 1px solid var(--border-muted); padding-top: 16px; margin-top: 16px; }
.profile-section h2 { font-size: 16px; font-weight: 600; margin-bottom: 10px; }
@media (max-width: 860px) {
  .profile-top { display: flex; gap: 16px; align-items: center; }
  .avatar-wrap { width: 96px; flex: none; }
  .status { left: 70%; bottom: -4px; }
  .profile h1 { margin-top: 0; font-size: 22px; }
  .readme-body { padding: 16px; }
}

/* ------------------------------------------------------------- README */
.readme-head { display: flex; align-items: center; gap: 6px; padding: 10px 16px; border-bottom: 1px solid var(--border-muted); font-family: var(--mono); font-size: 12px; color: var(--muted); }
.readme-body { padding: 24px; }
.motto { margin: 0 0 16px; color: var(--muted); font-size: 13px; font-family: var(--mono); }
.readme-body h2 { font-size: 24px; padding-bottom: 6px; border-bottom: 1px solid var(--border-muted); margin-bottom: 12px; }
.readme-body ul { margin: 0 0 16px; padding-left: 24px; font-size: 15px; }
.readme-body li { margin: 4px 0; }
.here { display: inline-block; margin-left: 6px; padding: 0 8px; border-radius: 2em; background: #fd8c73; color: #fff; font-size: 11px; font-weight: 600; transform: rotate(-3deg); }
.snake { display: block; width: 100%; height: auto; }
.snake.dark { display: none; }
:root[data-theme="dark"] .snake.light { display: none; }
:root[data-theme="dark"] .snake.dark { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .snake.light { display: none; }
  :root:not([data-theme="light"]) .snake.dark { display: block; }
}

/* ------------------------------------------------------------- pinned repos */
.pinned-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 600px) { .pinned-grid { grid-template-columns: minmax(0, 1fr); } }
.repo { display: flex; flex-direction: column; gap: 8px; padding: 16px; }
.repo-name { display: flex; align-items: center; gap: 8px; font-weight: 600; min-width: 0; }
.repo-name a { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.repo-name .icon { color: var(--muted); }
.pill { padding: 0 7px; border: 1px solid var(--border); border-radius: 2em; font-size: 12px; font-weight: 500; color: var(--muted); line-height: 18px; }
.repo p { margin: 0; color: var(--muted); font-size: 12px; flex: 1; }
.repo-meta { display: flex; gap: 16px; color: var(--muted); font-size: 12px; align-items: center; }
.repo-meta a { color: var(--muted); display: inline-flex; gap: 4px; align-items: center; }
.repo-meta a:hover { color: var(--accent); text-decoration: none; }
.lang-dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; border: 1px solid rgba(127,127,127,0.2); }

/* ------------------------------------------------------------- publications */
.scholar-link { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.pubs { list-style: none; margin: 0; padding: 0; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); }
.pubs > li + li { border-top: 1px solid var(--border-muted); }
.pub summary {
  list-style: none; cursor: pointer; display: grid; gap: 4px 16px; padding: 16px;
  grid-template-columns: 44px minmax(0, 1fr) 132px; align-items: start;
}
.pub summary::-webkit-details-marker { display: none; }
.pub summary:hover { background: var(--bg-subtle); }
.pub-year { font-family: var(--mono); font-size: 12px; color: var(--muted); padding-top: 3px; }
.pub-title { font-size: 15px; font-weight: 600; color: var(--fg); }
.pub-title:hover { color: var(--accent); }
.pub-meta { margin-top: 4px; font-size: 12px; color: var(--muted); }
.pub-meta .me { color: var(--fg); font-weight: 600; }
.pub-venue { font-style: italic; }
.pub-tags { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; align-items: center; }
.pub-tags .pill.kind { border-color: var(--accent); color: var(--accent); }
.chevron { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); }
.chevron::before { content: "▸"; transition: transform 0.2s; display: inline-block; }
.pub[open] .chevron::before { transform: rotate(90deg); }
.pub-thumb {
  width: 132px; height: 84px; border-radius: 6px; border: 1px solid var(--border); background: var(--figure-bg);
  object-fit: contain; padding: 4px; transition: opacity 0.2s;
}
.pub[open] .pub-thumb { opacity: 0; }
.pub-body { padding: 0 16px 20px 76px; }
.pub-figure { margin: 0 0 12px; }
.pub-figure a { display: block; background: var(--figure-bg); border: 1px solid var(--border); border-radius: 6px; padding: 16px; }
.pub-figure img { display: block; width: 100%; max-height: 560px; object-fit: contain; margin: 0 auto; }
.pub-figure figcaption { margin-top: 6px; font-size: 12px; color: var(--muted); }
.pub-abstract { font-size: 14px; margin: 0 0 12px; max-width: 75ch; }
.pub-actions { display: flex; gap: 8px; flex-wrap: wrap; }
@media (max-width: 600px) {
  .pub summary { grid-template-columns: minmax(0, 1fr); }
  .pub-year { padding: 0; }
  .pub-thumb { display: none; }
  .pub-body { padding: 0 16px 20px; }
}

/* ------------------------------------------------------------- projects */
.project { border: 1px solid var(--border); border-radius: 6px; background: var(--bg); margin-bottom: 16px; overflow: hidden; }
.project summary { list-style: none; cursor: pointer; display: flex; gap: 16px; align-items: center; padding: 16px; }
.project summary::-webkit-details-marker { display: none; }
.project summary:hover { background: var(--bg-subtle); }
.project-head { flex: 1; min-width: 0; }
.project-head h3 { font-size: 18px; font-weight: 600; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.project-head h3::before { content: "▸"; color: var(--muted); font-size: 14px; transition: transform 0.2s; display: inline-block; }
.project[open] .project-head h3::before { transform: rotate(90deg); }
.host { font-family: var(--mono); font-size: 12px; font-weight: 400; color: var(--muted); }
.project-head p { margin: 6px 0 0; color: var(--muted); }
.project-thumb {
  width: 168px; height: 105px; object-fit: cover; flex: none; border-radius: 4px;
  border: 4px solid var(--bg); box-shadow: var(--shadow); transform: rotate(2deg); transition: transform 0.2s;
}
.project:nth-of-type(even) .project-thumb { transform: rotate(-2.5deg); }
.project summary:hover .project-thumb { transform: rotate(0) scale(1.04); }
.project[open] .project-thumb { display: none; }
.project-body { padding: 0 16px 20px; }
.shots { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; margin-bottom: 16px; }
.shots.single { grid-template-columns: minmax(0, 1fr); }
.shots img, .shots video { display: block; width: 100%; border-radius: 6px; border: 1px solid var(--border); }
.readme-text { max-width: 78ch; }
.readme-text p, .readme-text ul { margin: 0 0 10px; }
.readme-text h4 { font-size: 14px; margin: 16px 0 6px; }
.project-links { display: flex; gap: 8px; flex-wrap: wrap; margin: 16px 0 0; }
@media (max-width: 600px) {
  .project summary { flex-direction: column-reverse; align-items: stretch; }
  .project-thumb { width: 100%; height: 160px; transform: none !important; }
}
/* Polaroids thrown on a table */
.collage { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 18px 14px; padding: 8px 4px 20px; }
.polaroid {
  margin: 0; padding: 6px 6px 4px; background: #fff; color: #1f2328; border-radius: 2px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18), 0 10px 22px rgba(0, 0, 0, 0.12);
  transform: rotate(var(--tilt, 0deg)) translateY(var(--lift, 0)); transition: transform 0.2s; text-align: center;
}
.polaroid:hover { transform: rotate(0) scale(1.06); z-index: 1; position: relative; }
.polaroid img { display: block; width: 100%; aspect-ratio: 16 / 10; object-fit: cover; object-position: top; }
.polaroid figcaption { font-family: var(--hand); font-size: 19px; line-height: 1.3; padding-top: 2px; }
.polaroid a { color: inherit; }

/* ------------------------------------------------------------- right rail */
.rail .box { overflow: hidden; }
.card-head { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--border-muted); font-weight: 600; }
.card-head .muted { font-weight: 400; margin-left: auto; font-size: 12px; }
.card-body { padding: 14px; }
.lichess-board { position: relative; aspect-ratio: 7 / 10; background: var(--bg-subtle); }
.lichess-final { position: absolute; inset: 0 0 auto; display: block; width: 100%; height: auto; }
.lichess-frame { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; opacity: 0; transition: opacity 0.2s; }
.lichess-frame.loaded { opacity: 1; }
.game-info { font-size: 12px; color: var(--muted); }
.game-info strong { color: var(--fg); }
.game-info p { margin: 0 0 4px; }
.ratings { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.ratings span { padding: 1px 8px; border-radius: 2em; background: var(--bg-inset); font-size: 12px; }

.posts { display: flex; flex-direction: column; gap: 12px; }
.post { display: grid; grid-template-columns: 76px minmax(0, 1fr); gap: 12px; padding: 12px; color: var(--fg); }
.post:hover { text-decoration: none; border-color: var(--accent); }
.post:hover .post-title { color: var(--accent); }
.post img, .post .post-ph { width: 76px; height: 76px; border-radius: 6px; object-fit: cover; border: 1px solid var(--border-muted); }
.post .post-ph { display: grid; place-items: center; font-size: 30px; background: var(--accent-soft); }
.post-title { font-weight: 600; line-height: 1.3; }
.post-meta { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); margin: 2px 0 4px; }
.post-desc { font-size: 12px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.dice { margin-left: auto; font-size: 16px; line-height: 1; padding: 4px 8px; border-radius: 6px; border: 1px solid var(--border); background: var(--btn); cursor: pointer; }
.dice:hover { background: var(--btn-hover); }
.truth { margin: 0; padding: 2px 0 2px 12px; border-left: 3px solid var(--border); font-size: 15px; min-height: 2.6em; }
.truth.fade { animation: fade 0.3s ease; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.truths details { margin-top: 12px; }
.truths summary { cursor: pointer; color: var(--accent); font-size: 13px; }
.truth-list { list-style: none; margin: 8px 0 0; padding: 0; font-size: 13px; }
.truth-list li { padding: 7px 0; border-top: 1px solid var(--border-muted); }

.reddit-meta { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.reddit-meta .sub { color: var(--fg); font-weight: 600; }
.reddit h3 { font-size: 17px; margin: 6px 0 4px; }
.reddit h3 a { color: var(--fg); }
.reddit p { margin: 0 0 10px; }
.gallery { position: relative; border-radius: 8px; overflow: hidden; background: var(--bg-inset); }
.gallery img { display: block; width: 100%; max-height: 420px; object-fit: contain; }
.gallery button {
  position: absolute; top: 50%; transform: translateY(-50%); width: 30px; height: 30px; border-radius: 50%;
  border: 0; background: rgba(0, 0, 0, 0.55); color: #fff; cursor: pointer; font-size: 16px;
}
.gallery .prev { left: 8px; } .gallery .next { right: 8px; }
.gallery .count { position: absolute; top: 8px; right: 8px; padding: 0 8px; border-radius: 2em; background: rgba(0, 0, 0, 0.6); color: #fff; font-size: 12px; }
.votes { display: flex; gap: 8px; margin-top: 10px; }
.votes a { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: 2em; background: var(--bg-inset); color: var(--fg); font-weight: 600; font-size: 13px; }
.votes a:hover { text-decoration: none; background: var(--btn-hover); }
.votes .up { color: #ff4500; }

/* ------------------------------------------------------------- footer */
.footer { max-width: 1440px; margin: 48px auto 0; padding: 24px; border-top: 1px solid var(--border-muted); text-align: center; }
.footer-truth { font-size: 15px; font-style: italic; margin: 0 auto 10px; max-width: 70ch; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
  html { scroll-behavior: auto; }
}

/* research topics under the profile */
.topics { display: flex; flex-wrap: wrap; gap: 6px; }
.pill.topic { background: var(--accent-soft); border-color: transparent; color: var(--accent); line-height: 22px; padding: 0 10px; }
